Skip to content

Commit

Permalink
Add 'throws OlapException' to a few methods.
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@370 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Nov 22, 2010
1 parent cae3a13 commit 6fdb574
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 18 deletions.
5 changes: 4 additions & 1 deletion src/org/olap4j/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 12 additions & 4 deletions src/org/olap4j/OlapConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getAvailableRoleNames();
List<String> getAvailableRoleNames() throws OlapException;

/**
* Creates a Scenario.
Expand All @@ -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.
Expand All @@ -157,16 +161,20 @@ public interface OlapConnection extends Connection, OlapWrapper {
* <p>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
10 changes: 8 additions & 2 deletions src/org/olap4j/driver/xmla/XmlaOlap4jMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<Property, Object> propertyValueMap)
throws OlapException
{
// If property map contains a value for this property (even if that
// value is null), that overrides.
Expand Down Expand Up @@ -282,7 +286,9 @@ public Map<Property, Object> 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));
Expand Down
25 changes: 17 additions & 8 deletions src/org/olap4j/driver/xmla/XmlaOlap4jPositionMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public NamedList<? extends Member> getChildMembers() throws OlapException {
return member.getChildMembers();
}

public int getChildMemberCount() {
public int getChildMemberCount() throws OlapException {
return member.getChildMemberCount();
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions src/org/olap4j/metadata/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public interface Level extends MetadataElement {

/**
* Returns whether the level is calculated.
*
* @return Whether this level is calculated
*/
boolean isCalculated();

Expand Down Expand Up @@ -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<Member> getMembers() throws OlapException;

Expand Down
14 changes: 11 additions & 3 deletions src/org/olap4j/metadata/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Member> getChildMembers() throws OlapException;

Expand All @@ -47,8 +49,10 @@ public interface Member extends MetadataElement {
* <code>getChildMembers().size()</code>, 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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 6fdb574

Please sign in to comment.