diff --git a/src/org/olap4j/OlapExceptionHelper.java b/src/org/olap4j/OlapExceptionHelper.java index 19d6f87..b9a6bd1 100644 --- a/src/org/olap4j/OlapExceptionHelper.java +++ b/src/org/olap4j/OlapExceptionHelper.java @@ -1,55 +1,55 @@ -/* -// This software is subject to the terms of the Common Public License -// Agreement, available at the following URL: -// http://www.opensource.org/licenses/cpl.html. -// Copyright (C) 2007-2008 Julian Hyde -// All Rights Reserved. -// You must accept the terms of that agreement to use this software. -*/ -package org.olap4j; - -import java.sql.SQLException; - -/** - * Sugar class to help create OlapExceptions. - * @author Luc Boudreau - * @version $Id$ - */ -public class OlapExceptionHelper { - - public static OlapException createException(String msg) { - return new OlapException(msg); - } - - public static OlapException createException(Throwable cause) { - return new OlapException(cause.getMessage(), cause); - } - - public static OlapException createException(String msg, Throwable cause) { - return new OlapException(msg, cause); - } - - public static OlapException createException(Cell context, String msg) { - OlapException exception = new OlapException(msg); - exception.setContext(context); - return exception; - } - - public static OlapException createException( - Cell context, String msg, Throwable cause) - { - OlapException exception = new OlapException(msg, cause); - exception.setContext(context); - return exception; - } - - public static OlapException toOlapException(SQLException e) { - if (e instanceof OlapException) { - return (OlapException) e; - } else { - return new OlapException(null, e); - } - } -} - -//End ExceptionHelper.java \ No newline at end of file +/* +// This software is subject to the terms of the Common Public License +// Agreement, available at the following URL: +// http://www.opensource.org/licenses/cpl.html. +// Copyright (C) 2007-2008 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j; + +import java.sql.SQLException; + +/** + * Sugar class to help create OlapExceptions. + * @author Luc Boudreau + * @version $Id$ + */ +public class OlapExceptionHelper { + + public static OlapException createException(String msg) { + return new OlapException(msg); + } + + public static OlapException createException(Throwable cause) { + return new OlapException(cause.getMessage(), cause); + } + + public static OlapException createException(String msg, Throwable cause) { + return new OlapException(msg, cause); + } + + public static OlapException createException(Cell context, String msg) { + OlapException exception = new OlapException(msg); + exception.setContext(context); + return exception; + } + + public static OlapException createException( + Cell context, String msg, Throwable cause) + { + OlapException exception = new OlapException(msg, cause); + exception.setContext(context); + return exception; + } + + public static OlapException toOlapException(SQLException e) { + if (e instanceof OlapException) { + return (OlapException) e; + } else { + return new OlapException(null, e); + } + } +} + +// End OlapExceptionHelper.java \ No newline at end of file diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java b/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java index 7bb4afb..9daf330 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java @@ -368,7 +368,7 @@ public void setCatalog(String catalog) throws SQLException { public String getCatalog() throws OlapException { if (this.catalogName == null) { - // This means that no particular catalog name + // This means that no particular catalog name // was specified by the user. this.catalogName = this.getCatalogs().get(0).getName(); } else { @@ -378,7 +378,7 @@ public String getCatalog() throws OlapException { if (buf != null) { this.catalogName = buf.getName(); } else { - throw new OlapException("There is no catalog named " + + throw new OlapException("There is no catalog named " + this.catalogName + " available to query against."); } } @@ -1254,8 +1254,9 @@ static class CatalogSchemaHandler extends HandlerImpl { public CatalogSchemaHandler(String catalogName) { super(); - if (catalogName == null) + if (catalogName == null) { throw new RuntimeException("The CatalogSchemaHandler handler requires a catalog name."); + } this.catalogName = catalogName; } diff --git a/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jAbstractHttpProxy.java b/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jAbstractHttpProxy.java index 0dd9c4c..70e4cf8 100644 --- a/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jAbstractHttpProxy.java +++ b/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jAbstractHttpProxy.java @@ -82,7 +82,7 @@ abstract public Future getResponseViaSubmit( * @param urlConn The url connection to which we want the cookies * applied to. */ - protected void useCookies(URLConnection urlConn){ + protected void useCookies(URLConnection urlConn) { // Initializes the cookie manager this.initCookieManager(); // Saves the current cookies @@ -94,7 +94,7 @@ protected void useCookies(URLConnection urlConn){ * @param urlConn The url connection for which we want the cookies * saved for later use. */ - protected void saveCookies(URLConnection urlConn){ + protected void saveCookies(URLConnection urlConn) { // Initializes the cookie manager this.initCookieManager(); // Saves the current cookies diff --git a/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jCookieManager.java b/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jCookieManager.java index f58d74c..ae007f5 100644 --- a/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jCookieManager.java +++ b/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jCookieManager.java @@ -82,7 +82,7 @@ public XmlaOlap4jCookieManager() { * or IOException will be thrown * @throws java.io.IOException Thrown if conn is not open. */ - public void storeCookies(URLConnection conn){ + public void storeCookies(URLConnection conn) { // Determines the domain from where these cookies are being sent String domain = getDomainFromHost(conn.getURL().getHost()); @@ -158,7 +158,7 @@ public void storeCookies(URLConnection conn){ * @param conn a java.net.URLConnection - must NOT be open, or IOException will be thrown * @throws java.io.IOException Thrown if conn has already been opened. */ - public void setCookies(URLConnection conn){ + public void setCookies(URLConnection conn) { // Determines the domain and path to retrieve the appropriate cookies URL url = conn.getURL(); @@ -166,8 +166,9 @@ public void setCookies(URLConnection conn){ String path = url.getPath(); Map domainStore = (Map) store.get(domain); - if (domainStore == null) + if (domainStore == null) { return; + } StringBuffer cookieStringBuffer = new StringBuffer(); Iterator cookieNames = domainStore.keySet().iterator(); @@ -181,8 +182,9 @@ && isNotExpired((String) cookie.get(EXPIRES))) { cookieStringBuffer.append(cookieName); cookieStringBuffer.append("="); cookieStringBuffer.append((String) cookie.get(cookieName)); - if (cookieNames.hasNext()) + if (cookieNames.hasNext()) { cookieStringBuffer.append(SET_COOKIE_SEPARATOR); + } } } try { @@ -208,8 +210,9 @@ private String getDomainFromHost(String host) { } private boolean isNotExpired(String cookieExpires) { - if (cookieExpires == null) + if (cookieExpires == null) { return true; + } Date now = new Date(); try { return (now.compareTo(dateFormat.parse(cookieExpires))) <= 0; diff --git a/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jHttpProxy.java b/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jHttpProxy.java index a25084b..3f14566 100644 --- a/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jHttpProxy.java +++ b/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jHttpProxy.java @@ -88,11 +88,11 @@ public byte[] getResponse(URL url, String request) this.saveCookies(urlConnection); return baos.toByteArray(); - // All exceptions should be trapped here. + // All exceptions should be trapped here. // The response will only be available here anyways. } catch (Exception e) { throw new XmlaOlap4jProxyException( - "This proxy encountered an exception while processing the query.",e); + "This proxy encountered an exception while processing the query.", e); } } diff --git a/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jProxyException.java b/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jProxyException.java index 42518bd..6f91210 100644 --- a/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jProxyException.java +++ b/src/org/olap4j/driver/xmla/proxy/XmlaOlap4jProxyException.java @@ -1,25 +1,26 @@ -/* -// $Id:$ -// This software is subject to the terms of the Common Public License -// Agreement, available at the following URL: -// http://www.opensource.org/licenses/cpl.html. -// Copyright (C) 2007-2008 Julian Hyde -// All Rights Reserved. -// You must accept the terms of that agreement to use this software. -*/ -package org.olap4j.driver.xmla.proxy; - -/** - * Gets thrown whenever an exception is encountered during the querying - * of an XmlaOlap4jProxy subclass. - * - * @author Luc Boudreau - * @version $Id:$ - */ -public class XmlaOlap4jProxyException extends Exception { - private static final long serialVersionUID = 1729906649527317997L; - public XmlaOlap4jProxyException(String message, Throwable cause) { - super(message, cause); - } -} -//End XmlaOlap4jProxyException.java \ No newline at end of file +/* +// $Id$ +// This software is subject to the terms of the Common Public License +// Agreement, available at the following URL: +// http://www.opensource.org/licenses/cpl.html. +// Copyright (C) 2007-2008 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.driver.xmla.proxy; + +/** + * Gets thrown whenever an exception is encountered during the querying + * of an XmlaOlap4jProxy subclass. + * + * @author Luc Boudreau + * @version $Id$ + */ +public class XmlaOlap4jProxyException extends Exception { + private static final long serialVersionUID = 1729906649527317997L; + public XmlaOlap4jProxyException(String message, Throwable cause) { + super(message, cause); + } +} + +// End XmlaOlap4jProxyException.java \ No newline at end of file diff --git a/src/org/olap4j/impl/Olap4jUtilCompatibleJdk14.java b/src/org/olap4j/impl/Olap4jUtilCompatibleJdk14.java index dbc22f0..598f028 100644 --- a/src/org/olap4j/impl/Olap4jUtilCompatibleJdk14.java +++ b/src/org/olap4j/impl/Olap4jUtilCompatibleJdk14.java @@ -20,9 +20,9 @@ public class Olap4jUtilCompatibleJdk14 implements Olap4jUtilCompatible { public String quotePattern(String s) { int slashEIndex = s.indexOf("\\E"); - if (slashEIndex == -1) + if (slashEIndex == -1) { return "\\Q" + s + "\\E"; - + } StringBuilder sb = new StringBuilder(s.length() * 2); sb.append("\\Q"); int current = 0; diff --git a/src/org/olap4j/query/QueryDimension.java b/src/org/olap4j/query/QueryDimension.java index e5c149c..2fca802 100644 --- a/src/org/olap4j/query/QueryDimension.java +++ b/src/org/olap4j/query/QueryDimension.java @@ -89,26 +89,22 @@ public List resolve(Selection selection) throws OlapException final Member.TreeOp op; Member.TreeOp secondOp = null; switch (selection.getOperator()) { - case CHILDREN: - op = Member.TreeOp.CHILDREN; - break; - - case SIBLINGS: - op = Member.TreeOp.SIBLINGS; - break; - - case INCLUDE_CHILDREN: - op = Member.TreeOp.SELF; - secondOp = Member.TreeOp.CHILDREN; - break; - - case MEMBER: - op = Member.TreeOp.SELF; - break; - - default: - throw new OlapException("Operation not supported: " + selection.getOperator()); - + case CHILDREN: + op = Member.TreeOp.CHILDREN; + break; + case SIBLINGS: + op = Member.TreeOp.SIBLINGS; + break; + case INCLUDE_CHILDREN: + op = Member.TreeOp.SELF; + secondOp = Member.TreeOp.CHILDREN; + break; + case MEMBER: + op = Member.TreeOp.SELF; + break; + default: + throw new OlapException( + "Operation not supported: " + selection.getOperator()); } Set set = new TreeSet(); set.add(op); diff --git a/testsrc/org/olap4j/ConnectionTest.java b/testsrc/org/olap4j/ConnectionTest.java index c50cab0..7cf99f6 100644 --- a/testsrc/org/olap4j/ConnectionTest.java +++ b/testsrc/org/olap4j/ConnectionTest.java @@ -306,8 +306,7 @@ public void testConnectionUnwrap() throws SQLException { } public void testXmlaCatalogParameter() throws Exception { - if (tester.getFlavor() == TestContext.Tester.Flavor.XMLA) - { + if (tester.getFlavor() == TestContext.Tester.Flavor.XMLA) { // We won't use the tester itself since we want to test // creating a connection with and without a Catalog parameter. Properties info = new Properties(); @@ -859,8 +858,9 @@ public void testCell() throws Exception { // access method 1 Cell cell = cellSet.getCell(5); assertEquals(5, cell.getOrdinal()); - if (tester.getFlavor() != TestContext.Tester.Flavor.XMLA) // FIXME + if (tester.getFlavor() != TestContext.Tester.Flavor.XMLA) { // FIXME assertEquals(12935.16, cell.getValue()); + } assertEquals(12935.16, cell.getDoubleValue()); assertEquals("12,935.16", cell.getFormattedValue()); assertEquals(cellSet, cell.getCellSet());