com.sas.storage.olap.embedded
Class Tuple

com.sas.storage.olap.embedded.Tuple
All Implemented Interfaces:
TupleInterface

public class Tuple
implements TupleInterface

Used for building the Tuples of an in memory multidimensional ResultSet This implementation is designed for the simple definition of a tuple in a multidimensional ResultSet. The tuples are stored in memory within the model.

The tuple concept is a core element of the result set metadata. It combines members from each dimension that is projected onto the axis. Each axis contains a set of tuples with each one representing a single point on the axis. The tuple Index uniquely identifies the position of the tuple on the axis.

{(2000, Chairs)} is an example of a tuple where the Time and Products dimensions are projected onto the axis. While this example displays a set of two labels, "2000" and "Chairs", each element of a tuple may contain more information than just the displayable text. This information is found in the tuple elements which are returned from the getTupleElements() method.

See Also:
TupleInterface, AxisInterface, ResultSetMetadata

Constructor Summary
Tuple()
          Default tuple with no elements
Tuple(TupleElementInterface[] tupleElements)
          Create a tuple with the elements
 
Method Summary
 void addElement(int index, TupleElementInterface element)
          Add a tupleElement at the specfied index.
 void addElement(TupleElementInterface element)
          Append a tupleElement.
 AxisInterface getAxis()
          Returns the axis for the tuple.
 TupleElementInterface getElement(int index)
          Returns TupleElement for this tuple
 TupleElementInterface[] getElements(int index, int count)
          Returns TupleElements for this tuple
 int getTupleDepth()
          Return the number of elements in this tuple.
 int getTupleIndex()
          Returns the tuple ordinal if set.
 TupleElementInterface removeElement(int index)
          Remove a tuple element from this tuple.
 void setAxis(AxisInterface axis)
          Set the axis for this tuple.
 void setElements(int index, int endIndex, TupleElementInterface[] tupleElements)
          Sets TupleElements for this tuple
 

Constructor Detail

Tuple

public Tuple()
      throws OLAPException
Default tuple with no elements

Throws:
OLAPException

Tuple

public Tuple(TupleElementInterface[] tupleElements)
      throws OLAPException
Create a tuple with the elements

Parameters:
tupleElements - the elements that makes this tuple. The outer most element on the row/column has index zero and the inner most element has index element count -1.
Throws:
OLAPException - if the tuple cannot be created
Method Detail

getTupleIndex

public int getTupleIndex()
                  throws OLAPException
Returns the tuple ordinal if set. The default index is the index of this tuple added on to an axis.

Specified by:
getTupleIndex in interface TupleInterface
Returns:
The tuple ordinal of this tuple if set, -1 otherwise
Throws:
OLAPException - if cannot get the coordinate

getElement

public TupleElementInterface getElement(int index)
                                 throws OLAPException
Returns TupleElement for this tuple

Specified by:
getElement in interface TupleInterface
Parameters:
index - index of the element in this tuple. index should in the range of zero to current element count.
Returns:
A tuple element for this tuple.
Throws:
OLAPException - if the elements cannot be retrieved

getElements

public TupleElementInterface[] getElements(int index,
                                           int count)
                                    throws OLAPException
Returns TupleElements for this tuple

Specified by:
getElements in interface TupleInterface
Parameters:
index - index of the element in this tuple. index should in the range of zero to current element count.
count - number of elements to be returned.
Returns:
An array of tuple elements for this tuple. The length of this array should be equal to the tuple depth for the axis associated with this tuple. The labels are ordered from least to most specific. For example, [North America, USA, North Carolina, Cary]. where North America being the outermost label and Cary being the inner most label.
Throws:
OLAPException - if the elements cannot be retrieved

addElement

public void addElement(TupleElementInterface element)
                throws OLAPException
Append a tupleElement.

Parameters:
tupleElement - to insert
Throws:
OLAPException - if the tuple element cannot be added

addElement

public void addElement(int index,
                       TupleElementInterface element)
                throws OLAPException
Add a tupleElement at the specfied index.

Parameters:
index - to insert the tupleElement
tupleElement - to insert
Throws:
OLAPException - if the tuple element cannot be added

setElements

public void setElements(int index,
                        int endIndex,
                        TupleElementInterface[] tupleElements)
                 throws OLAPException
Sets TupleElements for this tuple

Parameters:
index - beginning index for setting the elements
endIndex - exclusive ending index
tupleElements - An array of tuple labels for this tuple. The length of this array should be equal to the tuple depth for the axis associated with this tuple. The labels are ordered from least to most specific. For example, [North America, USA, North Carolina, Cary].
Throws:
OLAPException

removeElement

public TupleElementInterface removeElement(int index)
                                    throws OLAPException
Remove a tuple element from this tuple.

Parameters:
index - element index in the tuple. index should be greater than zero and less than current element count.
Returns:
the element that was removed, null otherwise.
Throws:
OLAPException - if the element cannot be removed

getAxis

public AxisInterface getAxis()
                      throws OLAPException
Returns the axis for the tuple.

Specified by:
getAxis in interface TupleInterface
Returns:
Axis that is set for this tuple, null if not set.
Throws:
OLAPException - if the axis cannot be returned

setAxis

public void setAxis(AxisInterface axis)
             throws OLAPException
Set the axis for this tuple. This method will simply set the axis property for this tuple and will not add this tuple to the specified axis. Use axis.addTuple() method to add it to the axis.

Parameters:
axis - for the tuple
Throws:
OLAPException - if the axis cannot be set

getTupleDepth

public int getTupleDepth()
                  throws OLAPException
Return the number of elements in this tuple.

Specified by:
getTupleDepth in interface TupleInterface
Returns:
tuple element count
Throws:
OLAPException - if cannot get the tupledepth



Copyright © 2009 SAS Institute Inc. All Rights Reserved.