public class Query extends Object
Constructor and Description |
---|
Query(String name,
Cube cube)
Constructs a Query object.
|
Modifier and Type | Method and Description |
---|---|
void |
addQueryNodeListener(QueryNodeListener l)
Registers a new listener for a QueryNode.
|
CellSet |
execute()
Executes the query against the current OlapConnection and returns
a CellSet object representation of the data.
|
Map<Axis,QueryAxis> |
getAxes()
Returns a map of the current query's axis.
|
QueryAxis |
getAxis(Axis axis)
Returns the query axis for a given axis type.
|
Cube |
getCube()
Returns the underlying cube object that is used to query against.
|
QueryDimension |
getDimension(String name)
Returns the Olap4j's Dimension object according to the name
given as a parameter.
|
Locale |
getLocale()
Returns the current locale with which this query is expressed.
|
String |
getName()
Returns this query's name.
|
SelectNode |
getSelect()
Returns the MDX parse tree behind this Query.
|
QueryAxis |
getUnusedAxis()
Returns the fictional axis into which all unused dimensions are stored.
|
void |
removeQueryNodeListener(QueryNodeListener l)
De-registers a new listener for a QueryNode.
|
void |
setSelectDefaultMembers(boolean selectDefaultMembers)
Behavior setter for a query.
|
void |
swapAxes()
Swaps rows and columns axes.
|
void |
tearDown()
Safely disposes of all underlying objects of this
query and closes the underlying
OlapConnection . |
void |
tearDown(boolean closeConnection)
Safely disposes of all underlying objects of this
query.
|
void |
validate()
Validates the current query structure.
|
public Query(String name, Cube cube) throws SQLException
name
- Any arbitrary name to give to this query.cube
- A Cube object against which to build a query.SQLException
- If an error occurs while accessing the
cube's underlying connection.public SelectNode getSelect()
public Cube getCube()
public QueryDimension getDimension(String name)
name
- The name of the dimension you want the object for.public void swapAxes()
public QueryAxis getAxis(Axis axis)
If you pass axis=null, returns a special axis that is used to hold all unused hierarchies. (We may change this behavior in future.)
axis
- Axis typepublic Map<Axis,QueryAxis> getAxes()
Be aware that modifications to this list might have unpredictable consequences.
public QueryAxis getUnusedAxis()
public void tearDown(boolean closeConnection)
closeConnection
- Whether or not to call the
Connection.close()
method of the underlying
connection.public void tearDown()
OlapConnection
.
Equivalent of calling Query.tearDown(true).
public void validate() throws OlapException
setSelectDefaultMembers(boolean)
method.OlapException
- If the query is not valid, an exception
will be thrown and it's message will describe exactly what to fix.public CellSet execute() throws OlapException
OlapException
- If something goes sour, an OlapException will
be thrown to the caller. It could be caused by many things, like
a stale connection. Look at the root cause for more details.public String getName()
public Locale getLocale()
public void setSelectDefaultMembers(boolean selectDefaultMembers)
selectDefaultMembers
- Enables or disables the default
member and hierarchy selection upon validation.public void addQueryNodeListener(QueryNodeListener l)
l
- The new listener object, implementation of QueryNodeListenerQueryNodeListener
public void removeQueryNodeListener(QueryNodeListener l)
l
- The listener object to de-register.QueryNodeListener