com.sas.storage.olap
Class OLAPUtil

com.sas.storage.olap.OLAPUtil

public class OLAPUtil

OLAPUtil is a utility class which provides methods that perform some common functions that may be useful in conjunction with the various com.sas.storage.olap interfaces.


Field Summary
static boolean[] EMPTY_BOOLEAN_ARRAY
           
static java.lang.Object[] EMPTY_OBJECT_ARRAY
           
static java.lang.String[] EMPTY_STRING_ARRAY
           
static TupleInterface[] EMPTY_TUPLE_ARRAY
           
 
Method Summary
static int calculateCellOrdinal(ResultSetMetadataInterface resultSetMetadata, int[] coordinates)
          Calculates a cell ordinal based on a set of tuple coordinates.
static void calculateMinMaxCoordinates(TupleInterface[] tuples)
          Calculate the minimum and maximum coordinate of each element in the list of given tuples.
static void calculateSpan(TupleInterface[] tuples)
          Calculate the Span and span depth value for an element in a array of tuples.
static int[] calculateTupleCoordinates(ResultSetMetadataInterface resultSetMetadata, int cellOrdinal)
          Calculates tuple coordinates based on a cell ordinal.
static TupleElementInterface[] getTupleElementsForLevel(int level, TupleInterface[] tuples, boolean includeDuplicates, int count)
          This method will return all of the tupleElements that map to a given level.
 

Field Detail

EMPTY_STRING_ARRAY

public static final java.lang.String[] EMPTY_STRING_ARRAY

EMPTY_OBJECT_ARRAY

public static final java.lang.Object[] EMPTY_OBJECT_ARRAY

EMPTY_BOOLEAN_ARRAY

public static final boolean[] EMPTY_BOOLEAN_ARRAY

EMPTY_TUPLE_ARRAY

public static final TupleInterface[] EMPTY_TUPLE_ARRAY
Method Detail

calculateCellOrdinal

public static int calculateCellOrdinal(ResultSetMetadataInterface resultSetMetadata,
                                       int[] coordinates)
                                throws OLAPException
Calculates a cell ordinal based on a set of tuple coordinates. The coordinates should be specified in the same order as the axes (Columns, Rows, Pages, etc).

Parameters:
resultSetMetadata - The ResultSetMetadataInterface object that should be used when calculating the cell ordinal.
coordinates - An array of tuple coordinates marking the cell. These coordinates should be supplied in the same order as the axes.
Returns:
The ordinal which identifies the cell at the specified coordinates.
Throws:
OLAPException

calculateTupleCoordinates

public static int[] calculateTupleCoordinates(ResultSetMetadataInterface resultSetMetadata,
                                              int cellOrdinal)
                                       throws OLAPException
Calculates tuple coordinates based on a cell ordinal. The coordinates will be returned in the same order as the axes (Columns, Rows, Pages, etc).

Parameters:
resultSetMetadata - The ResultSetMetadataInterface object that should be used when calculating the tuple coordinates.
cellOrdinal - The ordinal which identifies the cell at the specified coordinates.
Returns:
An array of tuple coordinates marking the cell. These coordinates should be supplied in the same order as the axes.
Throws:
OLAPException

calculateMinMaxCoordinates

public static void calculateMinMaxCoordinates(TupleInterface[] tuples)
                                       throws OLAPException
Calculate the minimum and maximum coordinate of each element in the list of given tuples. The minimum and maximum coordinate is how many rows or columns an element spans. The minimum coordinate is the beginning row or column and maximum coordinate is the ending row or column. If it only spans one row or column then minimum and maximum coordinate is the same. For example, 1993 1994 1995 1 1995 2 1995 3 1995 4 1996 All the elements above except 1995 will have the same minimum maximum coordiante. 1993 will have 0, 1994 is 1, 1995 minimum coordiante is 2 and maximum coordinate is 5 and 1996 is 6.

Parameters:
tuples - Calculate the min/max coordinate based on the tuples passed in
Throws:
OLAPException

getTupleElementsForLevel

public static TupleElementInterface[] getTupleElementsForLevel(int level,
                                                               TupleInterface[] tuples,
                                                               boolean includeDuplicates,
                                                               int count)
                                                        throws OLAPException
This method will return all of the tupleElements that map to a given level. For example, Year Quarter Country 1999 USA 1999 CAN 1999 GER 2000 Q1 USA 2000 Q1 CAN 2000 Q1 GER 2001 USA 2001 CAN 2001 GER Where the list of tupleElements belonging to Quarter is tuples {4, 5, 6} index 2 Or where the list of tupleElements belonging to Country is tuples {1,2,3,7,8,9} index 2 and {4,5,6} index 3

Parameters:
level - An integer which identifies the level to be scanned
tuples - An array of tuples on which to apply the search
includeDuplicates - Determines whether a tupleElement with the same name as the previous element should be returned as a separate entry in the array
count - The maximum number of tupleElements to return. A value of -1 will return all of the tupleElements for the specified level.
Returns:
An array of TupleElements for a given level
Throws:
OLAPException

calculateSpan

public static void calculateSpan(TupleInterface[] tuples)
                          throws OLAPException
Calculate the Span and span depth value for an element in a array of tuples. Span is how many rows/column an element should take up when displayed in a table. For example, 1993 1994 ->1 1994 ->2 1994 ->3 1994 ->4 The element 1993 will have a span of 2 and all other elements will have a span of 1. The span depth value is always 1 except in case of ragged hierarchy, where children are from different levels (depths). So the sapn value is used to position the child in the spanned children list. For example, Country->State Country->Province Country->City The number of elements on Header will be 4 with Country elment spanning 1 and State/Province/City elements spanning 3 with span depth of State will be 1, spanDepth of Province 2 and SpanDepth of City to be 3.

Parameters:
tuples - TupleElements of the tuples to calculate the span for.
Throws:
OLAPException



Copyright © 2009 SAS Institute Inc. All Rights Reserved.