Skip to content

Commit

Permalink
MONDRIAN: Misc.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 12751]
  • Loading branch information
julianhyde committed May 19, 2009
1 parent bdcae04 commit 3cab7ba
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 36 deletions.
30 changes: 18 additions & 12 deletions src/main/mondrian/olap/ConnectionBase.java
Expand Up @@ -71,15 +71,19 @@ public Query parseQuery(String query, boolean load) {
* support customized parser behavior. That is why this method is not part
* of the Connection interface.
*
* <p>See test case mondrian.olap.CustomizedParserTest.
*
* @param query MDX query that requires special parsing
* @param funTable Customized function table to use in parsing
* @param strictValidation If true, do not ignore invalid members
* @return Query the corresponding Query object if parsing is successful
* @throws MondrianException if parsing fails
* @see mondrian.olap.CustomizedParserTest
*/
public Query parseQuery(String query, FunTable funTable,
boolean strictValidation) {
public Query parseQuery(
String query,
FunTable funTable,
boolean strictValidation)
{
return parseQuery(query, funTable, false, strictValidation);
}

Expand All @@ -95,8 +99,7 @@ public Exp parseExpression(String expr) {
try {
Parser parser = new Parser();
final FunTable funTable = getSchema().getFunTable();
Exp q = parser.parseExpression(this, expr, debug, funTable);
return q;
return parser.parseExpression(this, expr, debug, funTable);
} catch (Throwable exception) {
throw
MondrianResource.instance().FailedToParseQuery.ex(
Expand All @@ -105,8 +108,12 @@ public Exp parseExpression(String expr) {
}
}

private Query parseQuery(String query, FunTable cftab, boolean load,
boolean strictValidation) {
private Query parseQuery(
String query,
FunTable cftab,
boolean load,
boolean strictValidation)
{
Parser parser = new Parser();
boolean debug = false;
final FunTable funTable;
Expand All @@ -126,11 +133,10 @@ private Query parseQuery(String query, FunTable cftab, boolean load,
}

try {
Query q =
parser.parseInternal(this, query, debug, funTable, load,
strictValidation);
return q;
} catch (Throwable e) {
return
parser.parseInternal(
this, query, debug, funTable, load, strictValidation);
} catch (Exception e) {
throw MondrianResource.instance().FailedToParseQuery.ex(query, e);
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/main/mondrian/olap4j/MondrianOlap4jCellSet.java
Expand Up @@ -44,6 +44,12 @@ abstract class MondrianOlap4jCellSet implements CellSet {
new ArrayList<CellSetAxis>();
private CellSetAxis filterAxis;

/**
* Creates a MondrianOlap4jCellSet.
*
* @param olap4jStatement Statement
* @param query Mondrian query
*/
public MondrianOlap4jCellSet(
MondrianOlap4jStatement olap4jStatement,
Query query)
Expand Down Expand Up @@ -155,14 +161,18 @@ private Cell getCellInternal(int[] pos) {
cell = result.getCell(pos);
} catch (MondrianException e) {
if (e.getMessage().indexOf("coordinates out of range") >= 0) {
int[] dimensions = new int[getAxes().size()];
for (int i = 0; i < axisList.size(); i++) {
dimensions[i] = axisList.get(i).getPositions().size();
}
throw new IndexOutOfBoundsException(
"Cell coordinates (" + getCoordsAsString(pos)
+ ") fall outside CellSet bounds ("
+ getCoordsAsString(pos) + ")");
+ getCoordsAsString(dimensions) + ")");
} else if (e.getMessage().indexOf("coordinates should have dimension") >= 0) {
throw new IllegalArgumentException(
"Cell coordinates should have dimension "
+ axisList.size() + ")");
+ axisList.size());
} else {
throw e;
}
Expand Down
22 changes: 0 additions & 22 deletions testsrc/main/mondrian/olap/UtilTestCase.java
Expand Up @@ -503,28 +503,6 @@ public void testServiceDiscovery() {
}
assertTrue(expectedClassNames.toString(), expectedClassNames.isEmpty());
}

/**
* Asserts that two integer arrays have equal length and contents.
*
* @param expected Expected integer array
* @param actual Actual integer array
*/
public void assertEqualsArray(int[] expected, int[] actual) {
if (expected == null) {
assertEquals(expected, actual);
} else {
List<Integer> expectedList = new ArrayList<Integer>();
for (int i : expected) {
expectedList.add(i);
}
List<Integer> actualList = new ArrayList<Integer>();
for (int i : actual) {
actualList.add(i);
}
assertEquals(expectedList, actualList);
}
}
}

// End UtilTestCase.java

0 comments on commit 3cab7ba

Please sign in to comment.