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