001    /*
002    // $Id: //open/mondrian/src/main/mondrian/xmla/Enumeration.java#15 $
003    // This software is subject to the terms of the Common Public License
004    // Agreement, available at the following URL:
005    // http://www.opensource.org/licenses/cpl.html.
006    // Copyright (C) 2003-2008 Julian Hyde
007    // All Rights Reserved.
008    // You must accept the terms of that agreement to use this software.
009    //
010    // jhyde, May 2, 2003
011    */
012    package mondrian.xmla;
013    
014    import java.util.List;
015    import java.util.ArrayList;
016    
017    /**
018     * Contains inner classes which define enumerations used in XML for Analysis.
019     *
020     * @author jhyde
021     * @since May 2, 2003
022     * @version $Id: //open/mondrian/src/main/mondrian/xmla/Enumeration.java#15 $
023     */
024    class Enumeration {
025        public final String name;
026        public final String description;
027        public final RowsetDefinition.Type type;
028        private final Class<? extends Enum> clazz;
029    
030        public Enumeration(
031            String name,
032            String description,
033            RowsetDefinition.Type type,
034            Class<? extends Enum> clazz)
035        {
036            this.name = name;
037            this.description = description;
038            this.type = type;
039            this.clazz = clazz;
040        }
041    
042        public String getName() {
043            return name;
044        }
045    
046        public String[] getNames() {
047            List<String> names = new ArrayList<String>();
048            for (Enum anEnum : clazz.getEnumConstants()) {
049                names.add(anEnum.name());
050            }
051            return names.toArray(new String[names.size()]);
052        }
053    
054        public Enum<?> getValue(String valueName, boolean b) {
055            return Enum.valueOf(clazz, valueName);
056        }
057    
058        public enum Methods {
059            discover,
060            execute,
061            discoverAndExecute;
062    
063            public static final Enumeration enumeration = new Enumeration(
064                "Methods",
065                "Set of methods for which a property is applicable",
066                RowsetDefinition.Type.Enumeration,
067                Methods.class);
068        }
069    
070        public enum Access implements EnumWithOrdinal {
071            Read(1),
072            Write(2),
073            ReadWrite(3);
074            private final int userOrdinal;
075    
076            Access(int userOrdinal) {
077                this.userOrdinal = userOrdinal;
078            }
079    
080            public static final Enumeration enumeration =
081                new Enumeration(
082                    "Access",
083                    "The read/write behavior of a property",
084                    RowsetDefinition.Type.Enumeration,
085                    Access.class);
086    
087            public int userOrdinal() {
088                return userOrdinal;
089            }
090        }
091    
092        public enum Format implements EnumWithDesc {
093            Tabular("a flat or hierarchical rowset. Similar to the XML RAW format in SQL. The Format property should be set to Tabular for OLE DB for Data Mining commands."),
094            Multidimensional("Indicates that the result set will use the MDDataSet format (Execute method only)."),
095            Native("The client does not request a specific format, so the provider may return the format  appropriate to the query. (The actual result type is identified by namespace of the result.)");
096            private final String description;
097    
098            Format(String description) {
099                this.description = description;
100            }
101    
102            public String getDescription() {
103                return description;
104            }
105        }
106    
107        public enum AxisFormat implements EnumWithDesc {
108            TupleFormat("The MDDataSet axis is made up of one or more CrossProduct elements."),
109            ClusterFormat("Analysis Services uses the TupleFormat format for this setting."),
110            CustomFormat("The MDDataSet axis contains one or more Tuple elements.");
111            private final String description;
112    
113            AxisFormat(String description) {
114                this.description = description;
115            }
116    
117            public String getDescription() {
118                return description;
119            }
120        }
121    
122        public enum Content {
123            None,
124            Schema,
125            Data,
126            SchemaData;
127        }
128    
129        enum MDXSupport {
130            Core
131        }
132    
133        enum StateSupport {
134            None,
135            Sessions
136        }
137    
138        enum AuthenticationMode implements EnumWithDesc {
139            Unauthenticated("no user ID or password needs to be sent."),
140            Authenticated("User ID and Password must be included in the information required for the connection."),
141            Integrated("the data source uses the underlying security to determine authorization, such as Integrated Security provided by Microsoft Internet Information Services (IIS).");
142            private final String description;
143    
144            AuthenticationMode(String description) {
145                this.description = description;
146            }
147    
148            public static final Enumeration enumeration = new Enumeration(
149                    "AuthenticationMode",
150                    "Specification of what type of security mode the data source uses.",
151                    RowsetDefinition.Type.EnumString,
152                    AuthenticationMode.class);
153    
154            public String getDescription() {
155                return description;
156            }
157        }
158    
159        enum ProviderType implements EnumWithDesc {
160            TDP("tabular data provider."),
161            MDP("multidimensional data provider."),
162            DMP("data mining provider. A DMP provider implements the OLE DB for Data Mining specification.");
163            private final String description;
164    
165            private ProviderType(String description) {
166                this.description = description;
167            }
168    
169            public static final Enumeration enumeration = new Enumeration(
170                    "ProviderType",
171                    "The types of data supported by the provider.",
172                    RowsetDefinition.Type.Array,
173                    ProviderType.class);
174    
175            public String getDescription() {
176                return description;
177            }
178        }
179    
180        enum Literal implements EnumWithDesc {
181            DBLITERAL_CATALOG_NAME(2, null, 24, ".", "0123456789", "A catalog name in a text command."),
182            DBLITERAL_CATALOG_SEPARATOR(3, ".", 0, null, null, null),
183            DBLITERAL_COLUMN_ALIAS(5, null, -1, "'\"[]", "0123456789", null),
184            DBLITERAL_COLUMN_NAME(6, null, -1, ".", "0123456789", null),
185            DBLITERAL_CORRELATION_NAME(7, null, -1, "'\"[]", "0123456789", null),
186            DBLITERAL_CUBE_NAME(21, null, -1, ".", "0123456789", null),
187            DBLITERAL_DIMENSION_NAME(22, null, -1, ".", "0123456789", null),
188            DBLITERAL_HIERARCHY_NAME(23, null, -1, ".", "0123456789", null),
189            DBLITERAL_LEVEL_NAME(24, null, -1, ".", "0123456789", null),
190            DBLITERAL_MEMBER_NAME(25, null, -1, ".", "0123456789", null),
191            DBLITERAL_PROCEDURE_NAME(14, null, -1, ".", "0123456789", null),
192            DBLITERAL_PROPERTY_NAME(26, null, -1, ".", "0123456789", null),
193            DBLITERAL_QUOTE(15, "[", -1, null, null, "The character used in a text command as the opening quote for quoting identifiers that contain special characters."),
194            DBLITERAL_QUOTE_SUFFIX(28, "]", -1, null, null, "The character used in a text command as the closing quote for quoting identifiers that contain special characters. 1.x providers that use the same character as the prefix and suffix may not return this literal value and can set the lt member of the DBLITERAL structure to DBLITERAL_INVALID if requested."),
195            DBLITERAL_TABLE_NAME(17, null, -1, ".", "0123456789", null),
196            DBLITERAL_TEXT_COMMAND(18, null, -1, null, null, "A text command, such as an SQL statement."),
197            DBLITERAL_USER_NAME(19, null, 0, null, null, null);
198            private final String literalValue;
199            private final int literalMaxLength;
200            private final String literalInvalidChars;
201            private final String literalInvalidStartingChars;
202            private final String description;
203    
204            /*
205            // Enum DBLITERALENUM and DBLITERALENUM20, OLEDB.H.
206            public static final int DBLITERAL_INVALID   = 0,
207            DBLITERAL_BINARY_LITERAL    = 1,
208            DBLITERAL_CATALOG_NAME  = 2,
209            DBLITERAL_CATALOG_SEPARATOR = 3,
210            DBLITERAL_CHAR_LITERAL  = 4,
211            DBLITERAL_COLUMN_ALIAS  = 5,
212            DBLITERAL_COLUMN_NAME   = 6,
213            DBLITERAL_CORRELATION_NAME  = 7,
214            DBLITERAL_CURSOR_NAME   = 8,
215            DBLITERAL_ESCAPE_PERCENT    = 9,
216            DBLITERAL_ESCAPE_UNDERSCORE = 10,
217            DBLITERAL_INDEX_NAME    = 11,
218            DBLITERAL_LIKE_PERCENT  = 12,
219            DBLITERAL_LIKE_UNDERSCORE   = 13,
220            DBLITERAL_PROCEDURE_NAME    = 14,
221            DBLITERAL_QUOTE = 15,
222            DBLITERAL_QUOTE_PREFIX = DBLITERAL_QUOTE,
223            DBLITERAL_SCHEMA_NAME   = 16,
224            DBLITERAL_TABLE_NAME    = 17,
225            DBLITERAL_TEXT_COMMAND  = 18,
226            DBLITERAL_USER_NAME = 19,
227            DBLITERAL_VIEW_NAME = 20,
228            DBLITERAL_CUBE_NAME = 21,
229            DBLITERAL_DIMENSION_NAME    = 22,
230            DBLITERAL_HIERARCHY_NAME    = 23,
231            DBLITERAL_LEVEL_NAME    = 24,
232            DBLITERAL_MEMBER_NAME   = 25,
233            DBLITERAL_PROPERTY_NAME = 26,
234            DBLITERAL_SCHEMA_SEPARATOR  = 27,
235            DBLITERAL_QUOTE_SUFFIX  = 28;
236    */
237    
238            Literal(int ordinal, String literalValue, int literalMaxLength, String literalInvalidChars, String literalInvalidStartingChars, String description) {
239                this.literalValue = literalValue;
240                this.literalMaxLength = literalMaxLength;
241                this.literalInvalidChars = literalInvalidChars;
242                this.literalInvalidStartingChars = literalInvalidStartingChars;
243                this.description = description;
244            }
245    
246            public String getLiteralName() {
247                return name();
248            }
249    
250            public String getLiteralValue() {
251                return literalValue;
252            }
253    
254            public String getLiteralInvalidChars() {
255                return literalInvalidChars;
256            }
257    
258            public String getLiteralInvalidStartingChars() {
259                return literalInvalidStartingChars;
260            }
261    
262            public int getLiteralMaxLength() {
263                return literalMaxLength;
264            }
265    
266            public String getDescription() {
267                return description;
268            }
269        }
270    
271        enum TreeOp implements EnumWithDesc, EnumWithOrdinal, EnumWithName {
272            Children("MDTREEOP_CHILDREN", 1, "Returns only the immediate children"),
273            Siblings("MDTREEOP_SIBLINGS", 2, "Returns members on the same level"),
274            Parent("MDTREEOP_PARENT", 4, "Returns only the immediate parent"),
275            Self("MDTREEOP_SELF", 8, "Returns the immediate member in the list of returned rows"),
276            Descendants("MDTREEOP_DESCENDANTS", 16, "Returns all descendants"),
277            Ancestors("MDTREEOP_ANCESTORS", 32, "Returns all ancestors");
278            private final String userName;
279            private final int userOrdinal;
280            private final String description;
281    
282            TreeOp(String userName, int userOrdinal, String description) {
283                this.userName = userName;
284                this.userOrdinal = userOrdinal;
285                this.description = description;
286            }
287    
288            static final Enumeration enumeration =
289                new Enumeration(
290                    "TREE_OP",
291                    "Bitmap which controls which relatives of a member are returned",
292                    RowsetDefinition.Type.Integer,
293                    TreeOp.class);
294    
295            public int userOrdinal() {
296                return userOrdinal;
297            }
298    
299            public String userName() {
300                return userName;
301            }
302    
303            public String getDescription() {
304                return description;
305            }
306        }
307    
308        enum VisualMode {
309            Default("DBPROPVAL_VISUAL_MODE_DEFAULT", 0, "Provider-dependent. In Microsoft SQL Server 2000 Analysis Services, this is equivalent to DBPROPVAL_VISUAL_MODE_ORIGINAL."),
310            Visual("DBPROPVAL_VISUAL_MODE_VISUAL", 1, "Visual totals are enabled."),
311            Original("DBPROPVAL_VISUAL_MODE_ORIGINAL", 2, "Visual totals are not enabled.");
312    
313            VisualMode(String name2, int ordinal2, String description) {
314            }
315    
316            static final Enumeration enumeration =
317                new Enumeration(
318                    "VisualMode",
319                    "This property determines the default behavior for visual totals.",
320                    RowsetDefinition.Type.Integer,
321                    VisualMode.class);
322        }
323    
324        interface EnumWithDesc {
325            String getDescription();
326        }
327    
328        interface EnumWithOrdinal {
329            int userOrdinal();
330        }
331    
332        interface EnumWithName {
333            String userName();
334        }
335    }
336    
337    // End Enumeration.java