Skip to content

Commit

Permalink
Ensure that all Java files comply with checkFile coding standard.
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@126 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Nov 2, 2008
1 parent 610aa2a commit dfcb158
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 117 deletions.
110 changes: 55 additions & 55 deletions src/org/olap4j/OlapExceptionHelper.java
Original file line number Diff line number Diff line change
@@ -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
/*
// 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
7 changes: 4 additions & 3 deletions src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.");
}
}
Expand Down Expand Up @@ -1254,8 +1254,9 @@ static class CatalogSchemaHandler extends HandlerImpl<XmlaOlap4jSchema> {

public CatalogSchemaHandler(String catalogName) {
super();
if (catalogName == null)
if (catalogName == null) {
throw new RuntimeException("The CatalogSchemaHandler handler requires a catalog name.");
}
this.catalogName = catalogName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ abstract public Future<byte[]> 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
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions src/org/olap4j/driver/xmla/proxy/XmlaOlap4jCookieManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public XmlaOlap4jCookieManager() {
* or IOException will be thrown
* @throws java.io.IOException Thrown if <i>conn</i> 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());
Expand Down Expand Up @@ -158,16 +158,17 @@ 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 <i>conn</i> 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();
String domain = getDomainFromHost(url.getHost());
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();
Expand All @@ -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 {
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/org/olap4j/driver/xmla/proxy/XmlaOlap4jHttpProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
51 changes: 26 additions & 25 deletions src/org/olap4j/driver/xmla/proxy/XmlaOlap4jProxyException.java
Original file line number Diff line number Diff line change
@@ -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
/*
// $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
4 changes: 2 additions & 2 deletions src/org/olap4j/impl/Olap4jUtilCompatibleJdk14.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 16 additions & 20 deletions src/org/olap4j/query/QueryDimension.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,22 @@ public List<Member> 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<Member.TreeOp> set = new TreeSet<Member.TreeOp>();
set.add(op);
Expand Down
6 changes: 3 additions & 3 deletions testsrc/org/olap4j/ConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit dfcb158

Please sign in to comment.