001    /*
002    // $Id: Datatype.java 322 2010-06-29 00:49:51Z lucboudreau $
003    // This software is subject to the terms of the Eclipse Public License v1.0
004    // Agreement, available at the following URL:
005    // http://www.eclipse.org/legal/epl-v10.html.
006    // Copyright (C) 2006-2010 Julian Hyde
007    // All Rights Reserved.
008    // You must accept the terms of that agreement to use this software.
009    */
010    package org.olap4j.metadata;
011    
012    /**
013     * Enumeration of the allowable data types of a Property or Measure.
014     *
015     * <p>The values derive from the OLE DB specification, specifically a
016     * subset of the OLE DB Types Indicators returned by SQL Server.
017     *
018     * @author jhyde
019     * @version $Id: Datatype.java 322 2010-06-29 00:49:51Z lucboudreau $
020     * @since Aug 23, 2006
021     */
022    public enum Datatype implements XmlaConstant {
023        /*
024        * The following values exactly match VARENUM
025        * in Automation and may be used in VARIANT.
026        */
027        INTEGER(3, "DBTYPE_I4", "A four-byte, signed integer: INTEGER"),
028    
029        DOUBLE(5, "DBTYPE_R8", "A double-precision floating-point value: Double"),
030    
031        CURRENCY(
032            6,
033            "DBTYPE_CY",
034            "A currency value: LARGE_INTEGER, Currency is a fixed-point number with "
035            + "four digits to the right of the decimal point. It is stored in an "
036            + "eight-byte signed integer, scaled by 10,000."),
037    
038        BOOLEAN(
039            11,
040            "DBTYPE_BOOL",
041            "A Boolean value stored in the same way as in Automation: VARIANT_BOOL; "
042            + "0 means false and ~0 (bitwise, the value is not 0; that is, all bits "
043            + "are set to 1) means true."),
044    
045        /**
046         * Used by SQL Server for value.
047         */
048        VARIANT(12, "DBTYPE_VARIANT", "An Automation VARIANT"),
049    
050        /**
051         * Used by SQL Server for font size.
052         */
053        UNSIGNED_SHORT(18, "DBTYPE_UI2", "A two-byte, unsigned integer"),
054    
055        /**
056         * Used by SQL Server for colors, font flags and cell ordinal.
057         */
058        UNSIGNED_INTEGER(19, "DBTYPE_UI4", "A four-byte, unsigned integer"),
059    
060        /*
061        * The following values exactly match VARENUM
062        * in Automation but cannot be used in VARIANT.
063        */
064        LARGE_INTEGER(
065            20,
066            "DBTYPE_I8",
067            "An eight-byte, signed integer: LARGE_INTEGER"),
068    
069        /*
070        * The following values are not in VARENUM in OLE.
071        */
072        STRING(
073            130,
074            "DBTYPE_WSTR",
075            "A null-terminated Unicode character string: wchar_t[length]; If "
076            + "DBTYPE_WSTR is used by itself, the number of bytes allocated "
077            + "for the string, including the null-termination character, is "
078            + "specified by cbMaxLen in the DBBINDING structure. If "
079            + "DBTYPE_WSTR is combined with DBTYPE_BYREF, the number of bytes "
080            + "allocated for the string, including the null-termination character, "
081            + "is at least the length of the string plus two. In either case, the "
082            + "actual length of the string is determined from the bound length "
083            + "value. The maximum length of the string is the number of allocated "
084            + "bytes divided by sizeof(wchar_t) and truncated to the nearest "
085            + "integer."),
086    
087        /**
088         * Used by SAP BW. Represents a Character
089         */
090        ACCP(1000, "ACCP", "SAP BW Character"),
091    
092        /**
093         * Used by SAP BW. Represents a CHAR
094         */
095        CHAR(1001, "CHAR", "SAP BW CHAR"),
096    
097        /**
098         * Used by SAP BW. Represents a CHAR
099         */
100        CUKY(1002, "CUKY", "SAP BW CHAR"),
101    
102        /**
103         * Used by SAP BW. Represents a Currency - Packed decimal, Integer
104         */
105        CURR(1003, "CURR", "SAP BW Currency - Packed decimal, Integer"),
106    
107        /**
108         * Used by SAP BW. Represents a Date
109         */
110        DATS(1004, "DATS", "SAP BW Date"),
111    
112        /**
113         * Used by SAP BW. Represents a Decimal
114         */
115        DEC(1005, "DEC", "SAP BW Decimal"),
116    
117        /**
118         * Used by SAP BW. Represents a Point
119         */
120        FLTP(1006, "FLTP", "SAP BW Floating Point"),
121    
122        /**
123         * Used by SAP BW. Represents a Byte
124         */
125        INT1(1007, "INT1", "SAP BW Byte"),
126    
127        /**
128         * Used by SAP BW. Represents a Small integer
129         */
130        INT2(1008, "INT2", "SAP BW Small integer"),
131    
132        /**
133         * Used by SAP BW. Represents an Integer
134         */
135        INT4(1009, "INT4", "SAP BW Integer"),
136    
137        /**
138         * Used by SAP BW. Represents a Text
139         */
140        LCHR(1010, "LCHR", "SAP BW Text"),
141    
142        /**
143         * Used by SAP BW. Represents a Numeric
144         */
145        NUMC(1011, "NUMC", "SAP BW Numeric"),
146    
147        /**
148         * Used by SAP BW. Represents a Tiny Int
149         */
150        PREC(1012, "PREC", "SAP BW Tiny Int"),
151    
152        /**
153         * Used by SAP BW. Represents a QUAN Integer
154         */
155        QUAN(1013, "QUAN", "SAP BW QUAN Integer"),
156    
157        /**
158         * Used by SAP BW. Represents a String
159         */
160        SSTR(1014, "SSTR", "SAP BW String"),
161    
162        /**
163         * Used by SAP BW. Represents a Long String
164         */
165        STRG(1015, "STRG", "SAP BW Long String"),
166    
167        /**
168         * Used by SAP BW. Represents a Time
169         */
170        TIMS(1016, "TIMS", "SAP BW Time"),
171    
172        /**
173         * Used by SAP BW. Represents a Varchar
174         */
175        VARC(1017, "VARC", "SAP BW Varchar"),
176    
177        /**
178         * Used by SAP BW. Represents a Long String for Units
179         */
180        UNIT(1018, "UNIT", "SAP BW Long String for Units");
181    
182        private final int xmlaOrdinal;
183        private String dbTypeIndicator;
184        private String description;
185    
186        private static final DictionaryImpl<Datatype> DICTIONARY =
187            DictionaryImpl.forClass(Datatype.class);
188    
189        Datatype(
190            int xmlaOrdinal,
191            String dbTypeIndicator,
192            String description)
193        {
194            this.xmlaOrdinal = xmlaOrdinal;
195            this.dbTypeIndicator = dbTypeIndicator;
196            this.description = description;
197        }
198    
199        /**
200         * The internal name of this Datatype.
201         * Might not be unique across Datatype instances.
202         */
203        public String xmlaName() {
204            return dbTypeIndicator;
205        }
206    
207        /**
208         * Human readable description of a Datatype instance.
209         */
210        public String getDescription() {
211            return description;
212        }
213    
214        /**
215         * Unique identifier of a Datatype instance.
216         */
217        public int xmlaOrdinal() {
218            return xmlaOrdinal;
219        }
220    
221        /**
222         * Per {@link org.olap4j.metadata.XmlaConstant}, returns a dictionary
223         * of all values of this enumeration.
224         *
225         * @return Dictionary of all values
226         */
227        public static Dictionary<Datatype> getDictionary() {
228            return DICTIONARY;
229        }
230    }
231    
232    // End Datatype.java