Skip to content

Commit

Permalink
MONDRIAN: Intrinsic properties (RFE #1208403).
Browse files Browse the repository at this point in the history
  Also, update eigenbase-properties.jar.

[git-p4: depot-paths = "//open/mondrian/": change = 3816]
  • Loading branch information
julianhyde committed Jul 15, 2005
1 parent 9e0a26e commit 928430f
Show file tree
Hide file tree
Showing 34 changed files with 917 additions and 231 deletions.
Binary file modified lib/eigenbase-properties.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/mondrian/olap/AxisOrdinal.java
Expand Up @@ -37,7 +37,7 @@ public static AxisOrdinal get(int ordinal) {
* not found.
*/
public static AxisOrdinal get(String name) {
return (AxisOrdinal) enumeration.getValue(name);
return (AxisOrdinal) enumeration.getValue(name, true);
}

public static final int NoneOrdinal = -2;
Expand Down
35 changes: 19 additions & 16 deletions src/main/mondrian/olap/EnumeratedValues.java
Expand Up @@ -223,17 +223,20 @@ public final String getDescription(int ordinal)
* @throws Error if the name is not a member of the enumeration
*/
public final int getOrdinal(String name) {
return getValue(name).getOrdinal();
return getValue(name, true).getOrdinal();
}

/**
* Returns the value associated with a name.
*
* @throws Error if the name is not a member of the enumeration
* @param name Name of enumerated value
* @param fail Whether to throw if not found
* @throws Error if the name is not a member of the enumeration and
* <code>fail</code> is true
*/
public Value getValue(String name) {
public Value getValue(String name, final boolean fail) {
final Value value = (Value) valuesByName.get(name);
if (value == null) {
if (value == null && fail) {
throw new Error("Unknown enum name: "+name);
}
return value;
Expand All @@ -255,7 +258,7 @@ public List getValuesSortedByName() {
Arrays.sort(names);
for (int i = 0; i < names.length; i++) {
String name = names[i];
list.add(getValue(name));
list.add(getValue(name, true));
}
return list;
}
Expand Down Expand Up @@ -295,37 +298,37 @@ public interface Value {
* <code>BasicValue</code> is an obvious implementation of {@link Value}.
*/
public static class BasicValue implements Value {
public final String name_;
public final int ordinal_;
public final String description_;
public final String name;
public final int ordinal;
public final String description;

/**
* @pre name != null
*/
public BasicValue(String name, int ordinal, String description) {
Util.assertPrecondition(name != null, "name != null");
this.name_ = name;
this.ordinal_ = ordinal;
this.description_ = description;
this.name = name;
this.ordinal = ordinal;
this.description = description;
}

public String getName() {
return name_;
return name;
}

public int getOrdinal() {
return ordinal_;
return ordinal;
}

public String getDescription() {
return description_;
return description;
}

/**
* Returns the value's name.
*/
public String toString() {
return name_;
return name;
}

/**
Expand Down Expand Up @@ -355,7 +358,7 @@ public boolean equals(String s) {
* }</pre></blockquote>
*/
public RuntimeException unexpected() {
return Util.newInternal("Value " + name_ + " of class " +
return Util.newInternal("Value " + name + " of class " +
getClass() + " unexpected here");
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/mondrian/olap/Evaluator.java
Expand Up @@ -79,8 +79,10 @@ public interface Evaluator {
* Retrieves the value of property <code>name</code>. If more than one
* member in the current context defines that property, the one with the
* highest solve order has precedence.
*
* <p>If the property is not defined, default value is returned.
*/
Object getProperty(String name);
Object getProperty(String name, Object defaultValue);

/**
* Returns a {@link SchemaReader} appropriate for the current access-control
Expand Down
6 changes: 3 additions & 3 deletions src/main/mondrian/olap/Formula.java
Expand Up @@ -104,7 +104,7 @@ void accept(Validator resolver) {
if (isMember) {
Exp formatExp = getFormatExp();
if (formatExp != null) {
mdxMember.setProperty(Property.PROPERTY_FORMAT_EXP, formatExp);
mdxMember.setProperty(Property.FORMAT_EXP.name, formatExp);
}
}
}
Expand Down Expand Up @@ -268,7 +268,7 @@ public Member getMdxMember() {
* @post return != null
*/
public int getSolveOrder() {
Exp exp = getMemberProperty(Property.PROPERTY_SOLVE_ORDER);
Exp exp = getMemberProperty(Property.SOLVE_ORDER.name);
if (exp != null) {
final Type type = exp.getTypeX();
if (type instanceof NumericType) {
Expand Down Expand Up @@ -315,7 +315,7 @@ private Exp getFormatExp() {
final Object o = walker.nextElement();
if (o instanceof Member) {
Exp formatExp = (Exp) ((Member) o).getPropertyValue(
Property.PROPERTY_FORMAT_EXP);
Property.FORMAT_EXP.name);
if (formatExp != null) {
return formatExp;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/mondrian/olap/LevelType.java
Expand Up @@ -68,10 +68,10 @@ private LevelType(String name, int ordinal) {
}
);
public static LevelType lookup(String s) {
return (LevelType) enumeration.getValue(s);
return (LevelType) enumeration.getValue(s, true);
}
public boolean isTime() {
return ordinal_ >= TimeYearsORDINAL && ordinal_ <= TimeDaysORDINAL;
return ordinal >= TimeYearsORDINAL && ordinal <= TimeDaysORDINAL;
}
}

Expand Down

0 comments on commit 928430f

Please sign in to comment.