From 6fdb5744f9e4f7df23960d52ab2e77332635b518 Mon Sep 17 00:00:00 2001 From: Julian Hyde Date: Mon, 22 Nov 2010 07:32:50 +0000 Subject: [PATCH] Add 'throws OlapException' to a few methods. git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@370 c6a108a4-781c-0410-a6c6-c2d559e19af0 --- src/org/olap4j/Cell.java | 5 +++- src/org/olap4j/OlapConnection.java | 16 +++++++++--- .../olap4j/driver/xmla/XmlaOlap4jMember.java | 10 ++++++-- .../driver/xmla/XmlaOlap4jPositionMember.java | 25 +++++++++++++------ src/org/olap4j/metadata/Level.java | 4 +++ src/org/olap4j/metadata/Member.java | 14 ++++++++--- 6 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/org/olap4j/Cell.java b/src/org/olap4j/Cell.java index 02a8079..020f198 100755 --- a/src/org/olap4j/Cell.java +++ b/src/org/olap4j/Cell.java @@ -185,11 +185,14 @@ public interface Cell { * @param value Cell value * @param allocationPolicy Allocation policy * @param allocationArgs Allocation policy arguments + * + * @throws OlapException if a database error occurs */ void setValue( Object value, AllocationPolicy allocationPolicy, - Object... allocationArgs); + Object... allocationArgs) + throws OlapException; } // End Cell.java diff --git a/src/org/olap4j/OlapConnection.java b/src/org/olap4j/OlapConnection.java index eb2fe37..656d16b 100644 --- a/src/org/olap4j/OlapConnection.java +++ b/src/org/olap4j/OlapConnection.java @@ -127,8 +127,10 @@ public interface OlapConnection extends Connection, OlapWrapper { * * @return a list of role names, or null if the available roles are not * known + * + * @throws OlapException if database error occurs */ - List getAvailableRoleNames(); + List getAvailableRoleNames() throws OlapException; /** * Creates a Scenario. @@ -139,8 +141,10 @@ public interface OlapConnection extends Connection, OlapWrapper { * @see #setScenario * * @return a new Scenario + * + * @throws OlapException if database error occurs */ - Scenario createScenario(); + Scenario createScenario() throws OlapException; /** * Sets the active Scenario of this connection. @@ -157,16 +161,20 @@ public interface OlapConnection extends Connection, OlapWrapper { *

Scenarios are created using {@link #createScenario()}. * * @param scenario Scenario + * + * @throws OlapException if database error occurs */ - void setScenario(Scenario scenario); + void setScenario(Scenario scenario) throws OlapException; /** * Returns this connection's active Scenario, or null if there is no * active Scenario. * * @return Active scenario, or null + * + * @throws OlapException if database error occurs */ - Scenario getScenario(); + Scenario getScenario() throws OlapException; } // End OlapConnection.java diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jMember.java b/src/org/olap4j/driver/xmla/XmlaOlap4jMember.java index 1ae5955..dc05e94 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jMember.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jMember.java @@ -175,7 +175,7 @@ public boolean isCalculatedInQuery() { throw new UnsupportedOperationException(); } - public Object getPropertyValue(Property property) { + public Object getPropertyValue(Property property) throws OlapException { return getPropertyValue( property, this, @@ -189,11 +189,15 @@ public Object getPropertyValue(Property property) { * @param member Member * @param propertyValueMap Map of property-value pairs * @return Property value + * + * @throws OlapException if database error occurs while evaluating + * CHILDREN_CARDINALITY; no other property throws */ static Object getPropertyValue( Property property, XmlaOlap4jMemberBase member, Map propertyValueMap) + throws OlapException { // If property map contains a value for this property (even if that // value is null), that overrides. @@ -282,7 +286,9 @@ public Map getPropertyValueMap() { return propertyValueMap; } - public String getPropertyFormattedValue(Property property) { + public String getPropertyFormattedValue(Property property) + throws OlapException + { // FIXME: need to use a format string; but what format string; and how // to format the property on the client side? return String.valueOf(getPropertyValue(property)); diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jPositionMember.java b/src/org/olap4j/driver/xmla/XmlaOlap4jPositionMember.java index 8a886fc..972be3c 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jPositionMember.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jPositionMember.java @@ -93,7 +93,7 @@ public NamedList getChildMembers() throws OlapException { return member.getChildMembers(); } - public int getChildMemberCount() { + public int getChildMemberCount() throws OlapException { return member.getChildMemberCount(); } @@ -145,14 +145,16 @@ public boolean isCalculatedInQuery() { return member.isCalculatedInQuery(); } - public Object getPropertyValue(Property property) { + public Object getPropertyValue(Property property) throws OlapException { if (propertyValues.containsKey(property)) { return propertyValues.get(property); } return member.getPropertyValue(property); } - public String getPropertyFormattedValue(Property property) { + public String getPropertyFormattedValue(Property property) + throws OlapException + { // REVIEW: Formatted value is not available for properties which // come back as part of axis tuple. Unformatted property is best we // can do. @@ -183,11 +185,18 @@ public boolean isHidden() { } public int getDepth() { - return XmlaOlap4jMember.toInteger( - XmlaOlap4jMember.getPropertyValue( - Property.StandardMemberProperty.DEPTH, - member, - getPropertyValueMap())); + try { + final Object value = + XmlaOlap4jMember.getPropertyValue( + Property.StandardMemberProperty.DEPTH, + member, + getPropertyValueMap()); + return XmlaOlap4jMember.toInteger(value); + } catch (OlapException e) { + // should not happen; only CHILDREN_CARDINALITY can potentially + // give an error + throw new RuntimeException(e); + } } public Member getDataMember() { diff --git a/src/org/olap4j/metadata/Level.java b/src/org/olap4j/metadata/Level.java index d8247b2..9681378 100644 --- a/src/org/olap4j/metadata/Level.java +++ b/src/org/olap4j/metadata/Level.java @@ -59,6 +59,8 @@ public interface Level extends MetadataElement { /** * Returns whether the level is calculated. + * + * @return Whether this level is calculated */ boolean isCalculated(); @@ -87,6 +89,8 @@ public interface Level extends MetadataElement { * is a {@link List} not a {@link NamedList}. * * @return List of members in this Level + * + * @throws OlapException if database error occurs */ List getMembers() throws OlapException; diff --git a/src/org/olap4j/metadata/Member.java b/src/org/olap4j/metadata/Member.java index 0aba722..cdd83b2 100644 --- a/src/org/olap4j/metadata/Member.java +++ b/src/org/olap4j/metadata/Member.java @@ -37,6 +37,8 @@ public interface Member extends MetadataElement { * @see org.olap4j.OlapDatabaseMetaData#getMembers * * @return children of this member + * + * @throws OlapException if database error occurs */ NamedList getChildMembers() throws OlapException; @@ -47,8 +49,10 @@ public interface Member extends MetadataElement { * getChildMembers().size(), but is typically less expensive. * * @return number of children + * + * @throws OlapException if database error occurs */ - int getChildMemberCount(); + int getChildMemberCount() throws OlapException; /** * Returns the parent of this Member, or null if it has no parent. @@ -212,8 +216,10 @@ private Type(int ordinal) { * @return formatted value of the given property * * @see #getPropertyFormattedValue(Property) + * + * @throws OlapException if database error occurs */ - Object getPropertyValue(Property property); + Object getPropertyValue(Property property) throws OlapException; /** * Returns the formatted value of a given property. @@ -231,8 +237,10 @@ private Type(int ordinal) { * @return formatted value of the given property * * @see #getPropertyValue(Property) + * + * @throws OlapException if database error occurs */ - String getPropertyFormattedValue(Property property); + String getPropertyFormattedValue(Property property) throws OlapException; /** * Sets a property of this member to a given value.