Skip to content

Commit

Permalink
Change code to comply with code-formatting standard.
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@90 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Apr 13, 2008
1 parent 8a3e97d commit c0fa333
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 197 deletions.
73 changes: 27 additions & 46 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
* @version $Id$
* @since May 24, 2007
*/
abstract class XmlaOlap4jCellSet implements CellSet
{

abstract class XmlaOlap4jCellSet implements CellSet {
final XmlaOlap4jStatement olap4jStatement;
protected boolean closed;
private XmlaOlap4jCellSetMetaData metaData;
Expand Down Expand Up @@ -272,13 +270,9 @@ void populate() throws OlapException {
propertyValues.clear();
final int cellOrdinal =
Integer.valueOf(cell.getAttribute("CellOrdinal"));

// Get the value casted correctly.
final Object value = this.getTypedValue(cell);

final Object value = getTypedValue(cell);
final String formattedValue = stringElement(cell, "FmtValue");
final String formatString = stringElement(cell, "FormatString");

Olap4jUtil.discard(formatString);
for (Element element : childElements(cell)) {
String tag = element.getLocalName();
Expand All @@ -299,66 +293,53 @@ void populate() throws OlapException {
}
}




/**
* Returns the value of a cell, cast to the appropriate Java object type
* corresponding to the XML schema (XSD) type of the value.
*
* <p>The value type has to conform to XSD definitions of
* the XML element. See http://books.xmlschemata.org/relaxng/relax-CHP-19.html
* for a full list of possible data types.
*
* <p>Not all types are supported for now. Those not supported fall back
* to Strings. Most numeric types are. No dates yet are supported.
*
* <p>The value type must conform to XSD definitions of the XML element. See
* <a href="http://books.xmlschemata.org/relaxng/relax-CHP-19.html">RELAX
* NG, Chapter 19</a> for a full list of possible data types.
*
* <p>This method does not currently support all types; must numeric types
* are supported, but no dates are yet supported. Those not supported
* fall back to Strings.
*
* <p>If any exception is encountered, it returns null.
*
* @param cell The cell of which we want the casted object.
* @return The object with a correct value.
*/
private Object getTypedValue(Element cell)
{
try
{
private Object getTypedValue(Element cell) {
try {
Element elm = findChild(cell, MDDATASET_NS, "Value");

// The object type is contained in xsi:type attribute.
String type = elm.getAttribute("xsi:type");

if ( type.equals( "xsd:int" ) )
if (type.equals( "xsd:int")) {
return XmlaOlap4jUtil.intElement(cell, "Value");

else if ( type.equals( "xsd:integer" ) )
} else if (type.equals( "xsd:integer")) {
return XmlaOlap4jUtil.integerElement(cell, "Value");

else if ( type.equals( "xsd:double" ) )
} else if (type.equals( "xsd:double")) {
return XmlaOlap4jUtil.doubleElement(cell, "Value");

else if ( type.equals( "xsd:float" ) )
} else if (type.equals( "xsd:float")) {
return XmlaOlap4jUtil.floatElement(cell, "Value");

else if ( type.equals( "xsd:long" ) )
} else if (type.equals( "xsd:long")) {
return XmlaOlap4jUtil.longElement(cell, "Value");

else if ( type.equals( "xsd:boolean" ) )
} else if (type.equals( "xsd:boolean")) {
return XmlaOlap4jUtil.booleanElement(cell, "Value");

else
} else {
return XmlaOlap4jUtil.stringElement(cell, "Value");
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
} catch (Exception e) {
// REVIEW: Use standard error-handling. Wrap the error in some
// contextual information and re-throw.
System.out.println(e.getMessage());
e.printStackTrace();
return null;
}
}





/**
* Creates metadata for a cell set, given the DOM of the XMLA result.
*
Expand Down
Loading

0 comments on commit c0fa333

Please sign in to comment.