Skip to content

Commit

Permalink
MONDRIAN: Use enum types rather than EnumeratedValues class.
Browse files Browse the repository at this point in the history
	Set version to 2.3-dev.

[git-p4: depot-paths = "//open/mondrian/": change = 8324]
  • Loading branch information
julianhyde committed Dec 12, 2006
1 parent d51e2fe commit 7153942
Show file tree
Hide file tree
Showing 88 changed files with 3,182 additions and 3,588 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<property name="project.build.debug" value="on"/>
<property name="Name" value="Mondrian"/>
<property name="name" value="mondrian"/>
<property name="version" value="2.2.1"/>
<property name="version" value="2.3-dev"/>

<!--
===================================================================
Expand Down
15 changes: 5 additions & 10 deletions src/main/mondrian/calc/ExpCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,35 +148,30 @@ public interface ExpCompiler {
* <p>In future, we may have an "ITERABLE" result style, which allows us
* to handle large lists without holding them in memory.
*/
class ResultStyle extends EnumeratedValues.BasicValue {

private ResultStyle(String name, int ordinal) {
super(name, ordinal, null);
}

enum ResultStyle {
/**
* Indicates that caller will accept any applicable style.
*/
public static final ResultStyle ANY = new ResultStyle("ANY", 0);
ANY,

/**
* Indicates that the expression returns its result as a list which may
* safely be modified by the caller.
*/
public static final ResultStyle MUTABLE_LIST = new ResultStyle("MUTABLE_LIST", 1);
MUTABLE_LIST,

/**
* Indicates that the expression returns its result as a list which must
* not be modified by the caller.
*/
public static final ResultStyle LIST = new ResultStyle("LIST", 2);
LIST,

/**
* Indicates that the expression results its result as an immutable
* value. This is typical for expressions which return string and
* numeric values.
*/
public static final ResultStyle VALUE = new ResultStyle("VALUE", 3);
VALUE
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/mondrian/jolap/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ private QueryAxis convert(MondrianEdgeView edgeView, int axisIndex) throws OLAPE
}
}
}
return new QueryAxis(false, exp, AxisOrdinal.get(axisIndex),
AxisOrdinal axisOrdinal = AxisOrdinal.forOrdinal2(axisIndex);
return new QueryAxis(false, exp, axisOrdinal,
QueryAxis.SubtotalVisibility.Undefined, new Id[0]);
}

Expand Down
28 changes: 5 additions & 23 deletions src/main/mondrian/olap/Access.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,15 @@
* @since Feb 21, 2003
* @version $Id$
*/
public class Access extends EnumeratedValues {
/** The singleton instance of <code>Access</code>. */
public static final Access instance = new Access();

private Access() {
super(
new String[] {
"none", "custom", "all_dimensions", "all",
},
new int[] {
NONE, CUSTOM, ALL_DIMENSIONS, ALL,
}
);
}

/** Returns the singleton instance of <code>Access</code>. */
public static final Access instance() {
return instance;
}
public enum Access {
/** No access to an object. */
public static final int NONE = 1;
NONE,
/** Custom access to an object (described by other parameters). */
public static final int CUSTOM = 2;
CUSTOM,
/** Access to all shared dimensions (applies to schema grant). */
public static final int ALL_DIMENSIONS = 3;
ALL_DIMENSIONS,
/** All access to an object. */
public static final int ALL = 4;
ALL;
}

// End Access.java
81 changes: 29 additions & 52 deletions src/main/mondrian/olap/AxisOrdinal.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,43 @@
* @since Feb 21, 2003
* @version $Id$
*/
public class AxisOrdinal extends EnumeratedValues.BasicValue {
public enum AxisOrdinal {

private AxisOrdinal(String name, int ordinal) {
super(name, ordinal, null);
}
/** No axis.*/
NONE,

/**
* Converts an ordinal value into an {@link AxisOrdinal}. Returns null if
* not found.
*/
public static AxisOrdinal get(int ordinal) {
return (AxisOrdinal) enumeration.getValue(ordinal);
/** Slicer axis (which JOLAP calls the Page axis, not to be confused with
* our {@link #PAGES} axis). */
SLICER,

/** Columns axis (also known as X axis), logical ordinal = 0. */
COLUMNS,

/** Rows axis (also known as Y axis), logical ordinal = 1. */
ROWS,

/** Pages axis, logical ordinal = 2. */
PAGES,

/** Chapters axis, logical ordinal = 3. */
CHAPTERS,

/** Sections axis, logical ordinal = 4. */
SECTIONS;

public static AxisOrdinal forOrdinal2(int ordinal) {
return values()[ordinal + 2];
}

/**
* Converts a name into an {@link AxisOrdinal}. Returns null if
* not found.
* Returns the ordinal of this axis with {@link #COLUMNS} = 0,
* {@link #ROWS} = 1, etc.
*/
public static AxisOrdinal get(String name) {
return (AxisOrdinal) enumeration.getValue(name, true);
public int logicalOrdinal() {
return ordinal() - 2;
}

public static final int NoneOrdinal = -2;
public static final int SlicerOrdinal = -1;
public static final int ColumnsOrdinal = 0;
public static final int RowsOrdinal = 1;
public static final int PagesOrdinal = 2;
public static final int ChaptersOrdinal = 3;
public static final int SectionsOrdinal = 4;
public static final int MaxOrdinal = SectionsOrdinal;
public static final int MinOrdinal = NoneOrdinal;

/** No axis.*/
public static final AxisOrdinal None =
new AxisOrdinal("NONE", NoneOrdinal);
/** Slicer axis (which JOLAP calls the Page axis, not to be confused with
* our {@link #PagesOrdinal} axis). */
public static final AxisOrdinal Slicer =
new AxisOrdinal("SLICER", SlicerOrdinal);
/** Columns axis (also known as X axis). */
public static final AxisOrdinal Columns =
new AxisOrdinal("COLUMNS", ColumnsOrdinal);
/** Rows axis (also known as Y axis). */
public static final AxisOrdinal Rows =
new AxisOrdinal("ROWS", RowsOrdinal);
/** Pages axis. */
public static final AxisOrdinal Pages =
new AxisOrdinal("PAGES", PagesOrdinal);
/** Chapters axis. */
public static final AxisOrdinal Chapters =
new AxisOrdinal("CHAPTERS", ChaptersOrdinal);
/** Sections axis. */
public static final AxisOrdinal Sections =
new AxisOrdinal("SECTIONS", SectionsOrdinal);
/** Enumerates the valid values {@link AxisOrdinal}. */
public static final EnumeratedValues enumeration = new EnumeratedValues(
new AxisOrdinal[] {
None, Slicer, Columns, Rows, Pages, Chapters, Sections,
}
);
public static final int MaxLogicalOrdinal = SECTIONS.logicalOrdinal() + 1;
}

// End AxisOrdinal.java
2 changes: 1 addition & 1 deletion src/main/mondrian/olap/CubeBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public OlapElement lookupChild(SchemaReader schemaReader, String s)
}

public OlapElement lookupChild(
SchemaReader schemaReader, String s, int matchType)
SchemaReader schemaReader, String s, MatchType matchType)
{
Dimension mdxDimension = (Dimension)lookupDimension(s);
if (mdxDimension != null) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/mondrian/olap/DelegatingSchemaReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Member getMemberByUniqueName(
public Member getMemberByUniqueName(
String[] uniqueNameParts,
boolean failIfNotFound,
int matchType)
MatchType matchType)
{
return schemaReader.getMemberByUniqueName(
uniqueNameParts, failIfNotFound, matchType);
Expand All @@ -86,7 +86,7 @@ public OlapElement lookupCompound(

public OlapElement lookupCompound(
OlapElement parent, String[] names,
boolean failIfNotFound, int category, int matchType) {
boolean failIfNotFound, int category, MatchType matchType) {
return schemaReader.lookupCompound(
parent, names, failIfNotFound, category, matchType);
}
Expand All @@ -103,7 +103,7 @@ public void getMemberRange(
Level level,
Member startMember,
Member endMember,
List list) {
List<Member> list) {
schemaReader.getMemberRange(level, startMember, endMember, list);
}

Expand All @@ -120,7 +120,7 @@ public OlapElement getElementChild(OlapElement parent, String name) {
}

public OlapElement getElementChild(
OlapElement parent, String name, int matchType)
OlapElement parent, String name, MatchType matchType)
{
return schemaReader.getElementChild(parent, name, matchType);
}
Expand Down Expand Up @@ -189,7 +189,7 @@ public Member lookupMemberChildByName(Member member, String memberName) {
}

public Member lookupMemberChildByName(
Member member, String memberName, int matchType)
Member member, String memberName, MatchType matchType)
{
return schemaReader.lookupMemberChildByName(
member, memberName, matchType);
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/olap/DimensionBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public OlapElement lookupChild(SchemaReader schemaReader, String s)
}

public OlapElement lookupChild(
SchemaReader schemaReader, String s, int matchType)
SchemaReader schemaReader, String s, MatchType matchType)
{
OlapElement oe = lookupHierarchy(s);

Expand Down
50 changes: 4 additions & 46 deletions src/main/mondrian/olap/DimensionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,16 @@
* @since 5 April, 2004
* @version $Id$
*/
public class DimensionType extends EnumeratedValues.BasicValue {
/**
* The constructor is private so that no spurious instances of DimensionType can
* be created.
* @param name The name of the new enumerated value.
* @param ordinal The ordinal value of the enumerated value.
*/
private DimensionType(String name, int ordinal) {
super(name, ordinal, null);
}

public static final int StandardDimensionORDINAL = 0;

public enum DimensionType {
/**
* Indicates that the dimension is not related to time.
*/
public static final DimensionType StandardDimension =
new DimensionType("StandardDimension", StandardDimensionORDINAL);

public static final int TimeDimensionORDINAL = 1;
StandardDimension,

/**
* Indicates that a dimension is a time deimsnsion.
* Indicates that a dimension is a time dimension.
*/
public static final DimensionType TimeDimension =
new DimensionType("TimeDimension", TimeDimensionORDINAL);

/**
* Contains all of the valid values for {@link DimensionType}.
*/
public static final EnumeratedValues enumeration =
new EnumeratedValues(
new DimensionType[] {
StandardDimension, TimeDimension,
}
);

/**
* Looks up a DimensionType with a given ordinal.
* Returns null if not found.
*/
public static DimensionType lookup(int ordinal) {
return (DimensionType) enumeration.getValue(ordinal);
}

/**
* Looks up a DimensionType with a given name.
* Returns null if not found.
*/
public static DimensionType lookup(String name) {
return (DimensionType) enumeration.getValue(name, false);
}
TimeDimension
}

// End LevelType.java
8 changes: 5 additions & 3 deletions src/main/mondrian/olap/DriverManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ public static Connection getConnection(
throw Util.newError("Provider not recognized: " + provider);
}
if (locator != null) {
String catalog = properties.get(RolapConnectionProperties.Catalog);
properties.put(RolapConnectionProperties.Catalog,
locator.locate(catalog));
String catalog = properties.get(
RolapConnectionProperties.Catalog.name());
properties.put(
RolapConnectionProperties.Catalog.name(),
locator.locate(catalog));
}
return new RolapConnection(properties, dataSource);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/mondrian/olap/EnumeratedValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

package mondrian.olap;

import java.util.*;

/**
Expand Down Expand Up @@ -92,6 +93,10 @@ public EnumeratedValues(String[] names, int[] codes, String[] descriptions) {
makeImmutable();
}

public EnumeratedValues(Class<? extends Enum> clazz) {
throw new UnsupportedOperationException();
}

public EnumeratedValues<V> clone() {
EnumeratedValues clone;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/olap/HierarchyBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public OlapElement lookupChild(SchemaReader schemaReader, String s) {
}

public OlapElement lookupChild(
SchemaReader schemaReader, String s, int matchType)
SchemaReader schemaReader, String s, MatchType matchType)
{
OlapElement oe = Util.lookupHierarchyLevel(this, s);
if (oe == null) {
Expand Down
Loading

0 comments on commit 7153942

Please sign in to comment.