org.olap4j.query
Class QueryAxis

java.lang.Object
  extended by org.olap4j.query.QueryAxis

public class QueryAxis
extends java.lang.Object

An axis within an OLAP Query.

An axis has a location (columns, rows, etc) and has zero or more dimensions that are placed on it.

Since:
May 29, 2007
Version:
$Id: QueryAxis.java 277 2009-08-18 18:50:30Z lucboudreau $
Author:
jdixon, Luc Boudreau

Constructor Summary
QueryAxis(Query query, Axis location)
          Creates a QueryAxis.
 
Method Summary
 void addDimension(int index, QueryDimension dimension)
          Places a QueryDimension object on this axis at a specific index.
 void addDimension(QueryDimension dimension)
          Places a QueryDimension object on this axis.
 void addQueryNodeListener(QueryNodeListener l)
          Registers a new listener for a QueryNode.
 void clearSort()
          Clears the sort parameters from this axis.
 java.util.List<QueryDimension> getDimensions()
          Returns a list of the dimensions placed on this QueryAxis.
 Axis getLocation()
          Returns the location of this QueryAxis in the query; null if unused.
 java.lang.String getName()
          Returns the name of this QueryAxis.
 java.lang.String getSortIdentifierNodeName()
          Returns the current sort evaluation expression, or null if none are currently defined.
 SortOrder getSortOrder()
          Returns the current sort order in which this axis will be sorted.
 boolean isNonEmpty()
          Returns whether this QueryAxis filters out empty rows.
 void pullUp(int index)
          Places a QueryDimension object one position before in the list of current dimensions.
 void pushDown(int index)
          Places a QueryDimension object one position lower in the list of current dimensions.
 void removeDimension(QueryDimension dimension)
          Removes a QueryDimension object on this axis.
 void removeQueryNodeListener(QueryNodeListener l)
          De-registers a new listener for a QueryNode.
 void setNonEmpty(boolean nonEmpty)
          Sets whether this QueryAxis filters out empty rows.
 void sort(SortOrder order)
          Sorts the axis according to the supplied order.
 void sort(SortOrder order, Member member)
          Sorts the axis according to the supplied order and member.
 void sort(SortOrder order, java.lang.String... nameParts)
          Sorts the axis according to the supplied order and member unique name.
 void sort(SortOrder order, java.lang.String sortEvaluationLiteral)
          Sorts the axis according to the supplied order and evaluation expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryAxis

public QueryAxis(Query query,
                 Axis location)
Creates a QueryAxis.

Parameters:
query - Query that the axis belongs to
location - Location of axis (e.g. ROWS, COLUMNS)
Method Detail

getLocation

public Axis getLocation()
Returns the location of this QueryAxis in the query; null if unused.

Returns:
location of this axis in the query

getDimensions

public java.util.List<QueryDimension> getDimensions()
Returns a list of the dimensions placed on this QueryAxis.

Be aware that modifications to this list might have unpredictable consequences.

Returns:
list of dimensions

getName

public java.lang.String getName()
Returns the name of this QueryAxis.

Returns:
the name of this axis, for example "ROWS", "COLUMNS".

pullUp

public void pullUp(int index)
Places a QueryDimension object one position before in the list of current dimensions. Uses a 0 based index. For example, to place the 5th dimension on the current axis one position before, one would need to call pullUp(4), so the dimension would then use axis index 4 and the previous dimension at that position gets pushed down one position.

Parameters:
index - The index of the dimension to move up one notch. It uses a zero based index.

pushDown

public void pushDown(int index)
Places a QueryDimension object one position lower in the list of current dimensions. Uses a 0 based index. For example, to place the 4th dimension on the current axis one position lower, one would need to call pushDown(3), so the dimension would then use axis index 4 and the previous dimension at that position gets pulled up one position.

Parameters:
index - The index of the dimension to move down one notch. It uses a zero based index.

addDimension

public void addDimension(QueryDimension dimension)
Places a QueryDimension object on this axis.

Parameters:
dimension - The QueryDimension object to add to this axis.

addDimension

public void addDimension(int index,
                         QueryDimension dimension)
Places a QueryDimension object on this axis at a specific index.

Parameters:
dimension - The QueryDimension object to add to this axis.
index - The position (0 based) onto which to place the QueryDimension

removeDimension

public void removeDimension(QueryDimension dimension)
Removes a QueryDimension object on this axis.

Parameters:
dimension - The QueryDimension object to remove from this axis.

isNonEmpty

public boolean isNonEmpty()
Returns whether this QueryAxis filters out empty rows. If true, axis filters out empty rows, and the MDX to evaluate the axis will be generated with the "NON EMPTY" expression.

Returns:
Whether this axis should filter out empty rows
See Also:
setNonEmpty(boolean)

setNonEmpty

public void setNonEmpty(boolean nonEmpty)
Sets whether this QueryAxis filters out empty rows.

Parameters:
nonEmpty - Whether this axis should filter out empty rows
See Also:
isNonEmpty()

sort

public void sort(SortOrder order)
          throws OlapException

Sorts the axis according to the supplied order. The sort evaluation expression will be the default member of the default hierarchy of the dimension named "Measures".

Parameters:
order - The SortOrder to apply
Throws:
OlapException - If an error occurs while resolving the default measure of the underlying cube.

sort

public void sort(SortOrder order,
                 java.lang.String... nameParts)
          throws OlapException

Sorts the axis according to the supplied order and member unique name.

Using this method will try to resolve the supplied name parts from the underlying cube and find the corresponding member. This member will then be passed as a sort evaluation expression.

Parameters:
order - The SortOrder in which to sort the axis.
nameParts - The unique name parts of the sort evaluation expression.
Throws:
OlapException - If the supplied member cannot be resolved with Cube.lookupMember(String...)

sort

public void sort(SortOrder order,
                 Member member)

Sorts the axis according to the supplied order and member.

This method is most commonly called by passing it a Measure.

Parameters:
order - The SortOrder in which to sort the axis.
member - The member that will be used as a sort evaluation expression.

sort

public void sort(SortOrder order,
                 java.lang.String sortEvaluationLiteral)

Sorts the axis according to the supplied order and evaluation expression.

The string value passed as the sortIdentifierNodeName parameter willb e used literally as a sort evaluator.

Parameters:
order - The SortOrder in which to sort the axis.
sortEvaluationLiteral - The literal expression that will be used to sort against.

clearSort

public void clearSort()
Clears the sort parameters from this axis.


getSortOrder

public SortOrder getSortOrder()
Returns the current sort order in which this axis will be sorted. Might return null of none is currently specified.

Returns:
The SortOrder

getSortIdentifierNodeName

public java.lang.String getSortIdentifierNodeName()
Returns the current sort evaluation expression, or null if none are currently defined.

Returns:
The string literal that will be used in the MDX Order() function.

addQueryNodeListener

public void addQueryNodeListener(QueryNodeListener l)
Registers a new listener for a QueryNode.

Parameters:
l - The new listener object, implementation of QueryNodeListener
See Also:
QueryNodeListener

removeQueryNodeListener

public void removeQueryNodeListener(QueryNodeListener l)
De-registers a new listener for a QueryNode. If the listener object passed as a parameter was not registered, the method will return silently.

Parameters:
l - The listener object to de-register.
See Also:
QueryNodeListener

SourceForge.net_Logo