com.sas.storage.olap.embedded
Class ResultSetMetadata

com.sas.storage.olap.embedded.ResultSetMetadata
All Implemented Interfaces:
ResultSetMetadataInterface

public class ResultSetMetadata
implements ResultSetMetadataInterface

Used for building embedded multidimensional ResultSetMetadata, which defines the structure and contents of the resultset. This metadata is specific to the ResultSet, and it is not the same as the metadata defining a Cube. In the embedded version the Metadata for a Cube is not available. The topmost level of metadata is represented by the AxisInterface, and this information can be accessed via get/setAxis() method for the result set. A typical query contains two axes, although queries can contain any number of axes. More detailed metadata information can be acquired through the getTuples and getTupleElements methods. The methods are defined in two places. Both are defined directly on the ResultSetMetadataInterface, and they are also available on the AxisInterface and TupleInterface, respectively.

See Also:
ResultSetMetadataInterface, ResultSetInterface

Constructor Summary
ResultSetMetadata()
          Create an empty ResultSetMetadata
ResultSetMetadata(AxisInterface[] axes)
          Create a resultSetMetadata with the axes.
 
Method Summary
 void addAxis(AxisInterface axis)
          Add an axis to this resultset.
 AxisInterface[] getAxes(int index, int count)
          Return all the axes including slicer axis set for this restultset metadata.
 AxisInterface getAxis(int index)
          Return axis at the given index
 TupleElementInterface[] getElements(int axisIndex, int tupleCoordinate, int index, int count)
          Return the elements associated with a given tuple coordinate and axis starting from index upto count.
 ResultSetInterface getResultSet()
          Return the resultSet set for this resultSet metadata.
 TupleInterface[] getTuples(int axisIndex, int index, int count)
          Return the number of tuples associated with the axis starting with index upto count.
 AxisInterface removeAxis(int axisNumber)
          Remove an axis on this result set.
 void setAxes(AxisInterface[] axes)
          Replace the axes associated with this ResultSet.
 void setResultSet(ResultSetInterface resultSet)
          Sets the ResultSet that is defined by this metadata.
 void setSlicerAxis(AxisInterface slicerAxis)
          Set the SlicerAxis on this resultset metadata.
 

Constructor Detail

ResultSetMetadata

public ResultSetMetadata()
                  throws OLAPException
Create an empty ResultSetMetadata

Throws:
OLAPException

ResultSetMetadata

public ResultSetMetadata(AxisInterface[] axes)
                  throws OLAPException
Create a resultSetMetadata with the axes.

Parameters:
axes - an array of axes ordered from lowest to highest i.e. axis at index 0 of the array is ColumnAxis, 1 is RowAxis, 2 is PageAxis... and the last is SlicerAxis. The Axis are non null and should not be skipped i.e. cannot have RowAxis without a ColumnAxis.
Throws:
OLAPException - if an axis is skipped other than Slicer axis
Method Detail

setSlicerAxis

public void setSlicerAxis(AxisInterface slicerAxis)
                   throws OLAPException
Set the SlicerAxis on this resultset metadata. This method will set the resultmetadata for the slicer axis.

Parameters:
slicerAxis - slicer axis which is the last axis for the result set metadata.
Throws:
OLAPException - if the slicer axis cannot be set

setResultSet

public void setResultSet(ResultSetInterface resultSet)
                  throws OLAPException
Sets the ResultSet that is defined by this metadata. This resultset metadata is also set for the resultset object.

Parameters:
resultSet - The ResultSet that is defined by this metadata.
Throws:
OLAPException - if cannot set the resultset

addAxis

public void addAxis(AxisInterface axis)
             throws OLAPException
Add an axis to this resultset. Use setSlicerAxis to add a slicer axis.

Parameters:
axis - add the non null axis to this result set. Axis should be one of the axis defined in AxisInterface. The axis has to be added in order e.g. ColumnAxis then RowAxis etc.
Throws:
OLAPException - if the axis cannot be added

setAxes

public void setAxes(AxisInterface[] axes)
             throws OLAPException
Replace the axes associated with this ResultSet. An array of AxisInterfaces describing the axes. These axes are 0 based, beginning with the AxisInterface.COLUMNS_AXIS axis, followed by AxisInterface.ROWS_AXIS, then AxisInterface.PAGES_AXIS, etc. Each axis is non-null, that is no axis is skipped. It's not possible to have a PAGESAXIS axis without a COLUMNS_AXIS and ROWS_AXIS axis.

Parameters:
axes - an array of axes to be set.
Throws:
OLAPException - if a database error occurs

removeAxis

public AxisInterface removeAxis(int axisNumber)
                         throws OLAPException
Remove an axis on this result set. The axis are removed at the end. If an axis is removed from the middle, all other axis will move up.

Parameters:
axisNumber - axis to be removed AxisInterface.ROWS_AXIS, AxisInterface.COLUMNS_AXIS etc...
Throws:
OLAPException - if cannot remove an axis

getAxes

public AxisInterface[] getAxes(int index,
                               int count)
                        throws OLAPException
Return all the axes including slicer axis set for this restultset metadata. If there are not axes set yet, an empty array will be returned.

Specified by:
getAxes in interface ResultSetMetadataInterface
Parameters:
index - beginning index for the number of axes. -1 indicates SlicersAxis.
count - number of axis to return. -1 indicates all the remaining axes
Returns:
an array of Axes that is as big as positive count value passed in.
Throws:
OLAPException - if elements cannot be returned

getAxis

public AxisInterface getAxis(int index)
                      throws OLAPException
Return axis at the given index

Specified by:
getAxis in interface ResultSetMetadataInterface
Parameters:
index - axis number of the aixs to be returned
Returns:
aixs at the specified axis number
Throws:
OLAPException
See Also:
ResultSetMetadataInterface.getAxis(int)

getResultSet

public final ResultSetInterface getResultSet()
                                      throws OLAPException
Return the resultSet set for this resultSet metadata.

Specified by:
getResultSet in interface ResultSetMetadataInterface
Returns:
resultSet the resultSet for this metadata
Throws:
OLAPException - if the result set cannot be returned

getTuples

public TupleInterface[] getTuples(int axisIndex,
                                  int index,
                                  int count)
                           throws OLAPException
Return the number of tuples associated with the axis starting with index upto count. This is a convenience method for getAxis(axisNumber).getTuples(index, count).

Specified by:
getTuples in interface ResultSetMetadataInterface
Parameters:
axisIndex - Axis where the tuples are located
index - to begin the count
count - number of requested tuples
Returns:
an array of requested tuples, an empty array if the axis is null.
Throws:
OLAPException - if elements cannot be returned

getElements

public TupleElementInterface[] getElements(int axisIndex,
                                           int tupleCoordinate,
                                           int index,
                                           int count)
                                    throws OLAPException
Return the elements associated with a given tuple coordinate and axis starting from index upto count. A convenience method for getAxis.getTuple.getElements.

Specified by:
getElements in interface ResultSetMetadataInterface
Parameters:
axisIndex - axis number for the tuple elments
tupleCoordinate - the tuple ordinal on the axis
index - starting index
count - number of requested elements
Returns:
an array of TupleElements, length of count. An empty array is returned if axis is not set.
Throws:
OLAPException - if elements cannot be returned



Copyright © 2009 SAS Institute Inc. All Rights Reserved.