1
22
23 package com.liferay.portlet.expando.model.impl;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.kernel.util.UnicodeProperties;
28 import com.liferay.portlet.expando.model.ExpandoColumn;
29 import com.liferay.portlet.expando.model.ExpandoColumnConstants;
30 import com.liferay.portlet.expando.model.ExpandoValue;
31
32 import java.io.IOException;
33 import java.io.Serializable;
34
35
42 public class ExpandoColumnImpl
43 extends ExpandoColumnModelImpl implements ExpandoColumn {
44
45 public ExpandoColumnImpl() {
46 }
47
48 public Serializable getDefaultValue() {
49 try {
50 ExpandoValue value = new ExpandoValueImpl();
51
52 value.setColumnId(getColumnId());
53 value.setData(getDefaultData());
54
55 int type = getType();
56
57 if (type == ExpandoColumnConstants.BOOLEAN) {
58 return value.getBoolean();
59 }
60 else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) {
61 return value.getBooleanArray();
62 }
63 else if (type == ExpandoColumnConstants.DATE) {
64 return value.getDate();
65 }
66 else if (type == ExpandoColumnConstants.DATE_ARRAY) {
67 return value.getDateArray();
68 }
69 else if (type == ExpandoColumnConstants.DOUBLE) {
70 return value.getDouble();
71 }
72 else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) {
73 return value.getDoubleArray();
74 }
75 else if (type == ExpandoColumnConstants.FLOAT) {
76 return value.getFloat();
77 }
78 else if (type == ExpandoColumnConstants.FLOAT_ARRAY) {
79 return value.getFloatArray();
80 }
81 else if (type == ExpandoColumnConstants.INTEGER) {
82 return value.getInteger();
83 }
84 else if (type == ExpandoColumnConstants.INTEGER_ARRAY) {
85 return value.getIntegerArray();
86 }
87 else if (type == ExpandoColumnConstants.LONG) {
88 return value.getLong();
89 }
90 else if (type == ExpandoColumnConstants.LONG_ARRAY) {
91 return value.getLongArray();
92 }
93 else if (type == ExpandoColumnConstants.SHORT) {
94 return value.getShort();
95 }
96 else if (type == ExpandoColumnConstants.SHORT_ARRAY) {
97 return value.getShortArray();
98 }
99 else if (type == ExpandoColumnConstants.STRING_ARRAY) {
100 return value.getStringArray();
101 }
102 else {
103 return value.getString();
104 }
105 }
106 catch (Exception e) {
107 return null;
108 }
109 }
110
111 public String getTypeSettings() {
112 if (_typeSettingsProperties == null) {
113 return super.getTypeSettings();
114 }
115 else {
116 return _typeSettingsProperties.toString();
117 }
118 }
119
120 public UnicodeProperties getTypeSettingsProperties() {
121 if (_typeSettingsProperties == null) {
122 _typeSettingsProperties = new UnicodeProperties(true);
123
124 try {
125 _typeSettingsProperties.load(super.getTypeSettings());
126 }
127 catch (IOException ioe) {
128 _log.error(ioe, ioe);
129 }
130 }
131
132 return _typeSettingsProperties;
133 }
134
135 public void setTypeSettings(String typeSettings) {
136 _typeSettingsProperties = null;
137
138 super.setTypeSettings(typeSettings);
139 }
140
141 public void setTypeSettingsProperties(
142 UnicodeProperties typeSettingsProperties) {
143
144 _typeSettingsProperties = typeSettingsProperties;
145
146 super.setTypeSettings(_typeSettingsProperties.toString());
147 }
148
149 private static Log _log = LogFactoryUtil.getLog(ExpandoColumnImpl.class);
150
151 private UnicodeProperties _typeSettingsProperties = null;
152
153 }