Skip to content

Commit

Permalink
MONDRIAN: move public interfaces related to customized parser
Browse files Browse the repository at this point in the history
to public class methods.

[git-p4: depot-paths = "//open/mondrian/": change = 11180]
  • Loading branch information
Rushan Chen committed Jun 16, 2008
1 parent b50ace8 commit 11d055f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
6 changes: 0 additions & 6 deletions src/main/mondrian/olap/Connection.java
Expand Up @@ -79,12 +79,6 @@ public interface Connection {
*/
Query parseQuery(String s);

/**
* Parses a query, with specified function table and the mode for strict
* validation(if true then invalid members are not ignored).
*/
Query parseQuery(String s, FunTable funTable, boolean strictValidation);

/**
* Sets the privileges for the this connection.
*
Expand Down
34 changes: 23 additions & 11 deletions src/main/mondrian/olap/ConnectionBase.java
Expand Up @@ -55,34 +55,46 @@ public String getFullConnectString() {
return s;
}

public Query parseQuery(String s) {
return parseQuery(s, null, false, false);
public Query parseQuery(String query) {
return parseQuery(query, null, false, false);
}

public Query parseQuery(String s, boolean load) {
return parseQuery(s, null, load, false);
public Query parseQuery(String query, boolean load) {
return parseQuery(query, null, load, false);
}

public Query parseQuery(String s, FunTable funTable, boolean strictValidation) {
return parseQuery(s, funTable, false, strictValidation);
/**
* Parses a query, with specified function table and the mode for strict
* validation(if true then invalid members are not ignored).
*
* This method is only used in testing and bu clients that need to support customized
* parser behavior. That is why this method is not part of the Connection interface.
*
* @param mdxQuery
* @param funTable
* @param strictValidation
* @return Query if parsing is successful
*/
public Query parseQuery(String query, FunTable funTable, boolean strictValidation) {
return parseQuery(query, funTable, false, strictValidation);
}

public Exp parseExpression(String s) {
public Exp parseExpression(String expr) {
boolean debug = false;
if (getLogger().isDebugEnabled()) {
//debug = true;
StringBuilder buf = new StringBuilder(256);
buf.append(Util.nl);
buf.append(s);
buf.append(expr);
getLogger().debug(buf.toString());
}
try {
Parser parser = new Parser();
final FunTable funTable = getSchema().getFunTable();
Exp q = parser.parseExpression(this, s, debug, funTable);
Exp q = parser.parseExpression(this, expr, debug, funTable);
return q;
} catch (Throwable e) {
throw MondrianResource.instance().FailedToParseQuery.ex(s, e);
} catch (Throwable exception) {
throw MondrianResource.instance().FailedToParseQuery.ex(expr, exception);
}
}

Expand Down
2 changes: 1 addition & 1 deletion testsrc/main/mondrian/olap/CustomizedParserTest.java
Expand Up @@ -55,7 +55,7 @@ private void checkErrorMsg(Throwable e, String expectedErrorMsg) {
private Query getParsedQueryForExpr(
CustomizedFunctionTable cftab, String expr, boolean strictValidation) {
String mdx = wrapExpr(expr);
Query q = getConnection().parseQuery(mdx, cftab, strictValidation);
Query q = ((ConnectionBase)getConnection()).parseQuery(mdx, cftab, strictValidation);
return q;
}

Expand Down

0 comments on commit 11d055f

Please sign in to comment.