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