001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.dynamicdatamapping.storage;
016    
017    import com.liferay.portal.kernel.util.GetterUtil;
018    
019    import java.io.Serializable;
020    
021    import java.util.Date;
022    
023    /**
024     * @author Marcellus Tavares
025     */
026    public class FieldConstants {
027    
028            public static final String BOOLEAN = "boolean";
029    
030            public static final String DATA_TYPE = "dataType";
031    
032            public static final String DATE = "date";
033    
034            public static final String DOCUMENT_LIBRARY = "document-library";
035    
036            public static final String DOUBLE = "double";
037    
038            public static final String EDITABLE = "editable";
039    
040            public static final String FILE_UPLOAD = "file-upload";
041    
042            public static final String FLOAT = "float";
043    
044            public static final String INTEGER = "integer";
045    
046            public static final String LABEL = "label";
047    
048            public static final String LONG = "long";
049    
050            public static final String NAME = "name";
051    
052            public static final String PREDIFINED_VALUE = "predefinedValue";
053    
054            public static final String REQUIRED = "required";
055    
056            public static final String SHORT = "short";
057    
058            public static final String SHOW = "showLabel";
059    
060            public static final String SORTABLE = "sortable";
061    
062            public static final String STRING = "string";
063    
064            public static final String TYPE = "type";
065    
066            public static final String VALUE  = "value";
067    
068            public static final Serializable getSerializable(
069                    String type, String value) {
070    
071                    if (type.equals(BOOLEAN)) {
072                            return GetterUtil.getBoolean(value);
073                    }
074                    else if (type.equals(DATE)) {
075                            return new Date(GetterUtil.getLong(value));
076                    }
077                    else if (type.equals(DOUBLE)) {
078                            return GetterUtil.getDouble(value);
079                    }
080                    else if (type.equals(FLOAT)) {
081                            return GetterUtil.getFloat(value);
082                    }
083                    else if (type.equals(INTEGER)) {
084                            return GetterUtil.getInteger(value);
085                    }
086                    else if (type.equals(LONG)) {
087                            return GetterUtil.getLong(value);
088                    }
089                    else if (type.equals(SHORT)) {
090                            return GetterUtil.getShort(value);
091                    }
092                    else {
093                            return value;
094                    }
095            }
096    
097    }