001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.expando.model;
016    
017    /**
018     * @author Raymond Augé
019     */
020    public class ExpandoColumnConstants {
021    
022            public static final int BOOLEAN = 1;
023    
024            public static final int BOOLEAN_ARRAY = 2;
025    
026            public static final String BOOLEAN_ARRAY_LABEL =
027                    "custom.field.boolean.array";
028    
029            public static final String BOOLEAN_LABEL = "custom.field.boolean";
030    
031            public static final int DATE = 3;
032    
033            public static final int DATE_ARRAY = 4;
034    
035            public static final String DATE_ARRAY_LABEL =
036                    "custom.field.java.util.Date.array";
037    
038            public static final String DATE_LABEL = "custom.field.java.util.Date";
039    
040            public static final int DOUBLE = 5;
041    
042            public static final int DOUBLE_ARRAY = 6;
043    
044            public static final String DOUBLE_ARRAY_LABEL = "custom.field.double.array";
045    
046            public static final String DOUBLE_LABEL = "custom.field.double";
047    
048            public static final int FLOAT = 7;
049    
050            public static final int FLOAT_ARRAY = 8;
051    
052            public static final String FLOAT_ARRAY_LABEL = "custom.field.float.array";
053    
054            public static final String FLOAT_LABEL = "custom.field.float";
055    
056            public static final int INTEGER = 9;
057    
058            public static final int INTEGER_ARRAY = 10;
059    
060            public static final String INTEGER_ARRAY_LABEL = "custom.field.int.array";
061    
062            public static final String INTEGER_LABEL = "custom.field.int";
063    
064            public static final int LONG = 11;
065    
066            public static final int LONG_ARRAY = 12;
067    
068            public static final String LONG_ARRAY_LABEL = "custom.field.long.array";
069    
070            public static final String LONG_LABEL = "custom.field.long";
071    
072            public static final String PROPERTY_HEIGHT = "height";
073    
074            public static final String PROPERTY_HIDDEN = "hidden";
075    
076            public static final String PROPERTY_SECRET = "secret";
077    
078            public static final String PROPERTY_SELECTION = "selection";
079    
080            public static final String PROPERTY_VISIBLE_WITH_UPDATE_PERMISSION =
081                    "visible-with-update-permission";
082    
083            public static final String PROPERTY_WIDTH = "width";
084    
085            public static final int SHORT = 13;
086    
087            public static final int SHORT_ARRAY = 14;
088    
089            public static final String SHORT_ARRAY_LABEL = "custom.field.short.array";
090    
091            public static final String SHORT_LABEL = "custom.field.short";
092    
093            public static final int STRING = 15;
094    
095            public static final int STRING_ARRAY = 16;
096    
097            public static final String STRING_ARRAY_LABEL =
098                    "custom.field.java.lang.String.array";
099    
100            public static final String STRING_LABEL = "custom.field.java.lang.String";
101    
102            public static final int[] TYPES = new int[] {
103                    BOOLEAN, BOOLEAN_ARRAY, DATE, DATE_ARRAY, DOUBLE, DOUBLE_ARRAY, FLOAT,
104                    FLOAT_ARRAY, INTEGER, INTEGER_ARRAY, LONG, LONG_ARRAY, SHORT,
105                    SHORT_ARRAY, STRING, STRING_ARRAY
106            };
107    
108            public static final String UNKNOWN_LABEL = "Unknown";
109    
110            public static final String getTypeLabel(int type) {
111                    if (type == BOOLEAN) {
112                            return BOOLEAN_LABEL;
113                    }
114                    else if (type == BOOLEAN_ARRAY) {
115                            return BOOLEAN_ARRAY_LABEL;
116                    }
117                    else if (type == DATE) {
118                            return DATE_LABEL;
119                    }
120                    else if (type == DATE_ARRAY) {
121                            return DATE_ARRAY_LABEL;
122                    }
123                    else if (type == DOUBLE) {
124                            return DOUBLE_LABEL;
125                    }
126                    else if (type == DOUBLE_ARRAY) {
127                            return DOUBLE_ARRAY_LABEL;
128                    }
129                    else if (type == FLOAT) {
130                            return FLOAT_LABEL;
131                    }
132                    else if (type == FLOAT_ARRAY) {
133                            return FLOAT_ARRAY_LABEL;
134                    }
135                    else if (type == INTEGER) {
136                            return INTEGER_LABEL;
137                    }
138                    else if (type == INTEGER_ARRAY) {
139                            return INTEGER_ARRAY_LABEL;
140                    }
141                    else if (type == LONG) {
142                            return LONG_LABEL;
143                    }
144                    else if (type == LONG_ARRAY) {
145                            return LONG_ARRAY_LABEL;
146                    }
147                    else if (type == SHORT) {
148                            return SHORT_LABEL;
149                    }
150                    else if (type == SHORT_ARRAY) {
151                            return SHORT_ARRAY_LABEL;
152                    }
153                    else if (type == STRING) {
154                            return STRING_LABEL;
155                    }
156                    else if (type == STRING_ARRAY) {
157                            return STRING_ARRAY_LABEL;
158                    }
159    
160                    return UNKNOWN_LABEL;
161            }
162    
163    }