Enterprise Information Portal APIs

com.ibm.mm.sdk.common
Class DKQExpr

java.lang.Object
  |
  +--com.ibm.mm.sdk.common.DKQExpr
All Implemented Interfaces:
java.io.Serializable

public class DKQExpr
extends java.lang.Object
implements java.io.Serializable

A query expression is used to specify a simple query. It is an alternate form of a query string. It may have one or more sub-query expressions (DKQSubExpr). Each sub-query expression has a query term (DKQTerm), an option list, and a parameter list. The query term specifies the query conditions The option list specifies options relevant to the query. An example of an option in DL could be the maximum result limit of this query. The parameter list specifies parameters to be used by or bound to the query. The query language type indicates if it is parametric, text, or image query. You can combine two query expressions with logical operator AND to form a query expression tree. Logical operator OR is not supported yet. A DKQExpr can represents either a query expression or expression tree. An expression tree has positive opCode(), and non-null left() and right() subtree. A DKQExpr is singular if opCode() is negative, and left() and right() are null. Currently, the expression tree can only contains a maximum of one parametric, one text, and one image query .

See Also:
Serialized Form

Constructor Summary
DKQExpr()
          Default constructor without a parameter.
DKQExpr(DKQExpr lhs, short logOpCode, DKQExpr rhs)
          Creates a query expression tree by applying a logical operator to a pair of query expressions.
 
Method Summary
 int addSubQuery(DKQSubExpr subQE)
          Adds a sub-query to this expression.
 DKQExpr and(DKQExpr rhs)
          Apply logical AND operator between this query expression and another one.
 java.lang.String getAssociatedEntityName()
          Gets the associated entity name associated with this query This entity will support text and parametric query
 java.lang.String getAssociatedMapping()
          Gets the associated mapping for this query expression.
 java.lang.String getDatastoreName()
          Gets the target datastore name for executing this query.
 java.lang.String getDatastoreType()
          Gets the target datastore type for executing this query.
 java.lang.String[] getEntityNames()
          Gets the mapped entity names in this query expression.
 java.lang.String[] getMappingNames()
          Gets the optional schema mapping names for executing this query.
 int[] getMappingTypes()
          Gets the optional schema mapping types for executing this query.
 DKNVPair getOption(int position)
          Gets an option at the given position.
 DKNVPair getOption(java.lang.String name)
          Gets an option with a given name.
 DKNVPair[] getOptionList()
          Gets the option list.
 DKNVPair getParameter(int position)
          Gets a parameter at a given position.
 DKNVPair getParameter(java.lang.String name)
          Gets a parameter with a given name.
 DKNVPair[] getParameterList()
          Gets the parameter list.
 short getQLType()
          Gets the query language type, which could be a parametric, text, image query, etc.
 DKQSubExpr getSubQuery(int position)
          Gets the sub-query at the given position.
 boolean isLeaf()
          Check if this expression is a leaf.
 boolean isTranslation()
          Check if this query requires a translation using schema mapping.
 DKQExpr left()
          Gets the query in left hand side.
 short opCode()
          Gets the operator code in this expression tree.
 int optionCount()
          Gets the number of defined options.
 DKQExpr or(DKQExpr rhs)
          Apply logical OR operator between this query and another one.
 int parameterCount()
          Gets the number of defined parameters.
 void removeOption(int position)
          Removes the option at the given position.
 int removeOption(java.lang.String name)
          Removes the option with the given name.
 void removeParameter(int position)
          Removes the parameter at the given position.
 int removeParameter(java.lang.String name)
          Removes the parameter with the given name.
 int removeSubQuery(DKQSubExpr subQE)
          Removes a given sub-query form this expression.
 void removeSubQuery(int position)
          Removes a sub-query at the given position form this expression.
 DKQExpr right()
          Gets the query in right hand side.
 void setAssociatedMapping(java.lang.String associatedMapping)
          Sets the associated mapping for this query expression.
 void setDatastoreName(java.lang.String dsName)
          Sets the target datastore name for executing this query.
 void setDatastoreType(java.lang.String dsType)
          Sets the target datastore type for executing this query.
 void setOption(int position, DKNVPair optionPair)
          Sets the option at the given position.
 int setOption(java.lang.String name, java.lang.Object value)
          Sets the option with the given name.
 void setOptionList(DKNVPair[] optionList)
          Sets the option list.
 void setParameter(int position, DKNVPair parmPair)
          Sets the parameter at the given position.
 int setParameter(java.lang.String name, java.lang.Object value)
          Sets a parameter with a given name.
 void setParameterList(DKNVPair[] parameterList)
          Sets the parameter list.
 void setQLType(short qlType)
          Sets the query language type, which could be a parametric, text, image query, etc.
 int subQueryCount()
          Gets the number of sub-queries in this expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DKQExpr

public DKQExpr()
Default constructor without a parameter.

DKQExpr

public DKQExpr(DKQExpr lhs,
               short logOpCode,
               DKQExpr rhs)
Creates a query expression tree by applying a logical operator to a pair of query expressions.
Parameters:
lhs - left query
logOpCode - logical operator code
rhs - right query
Method Detail

getQLType

public short getQLType()
Gets the query language type, which could be a parametric, text, image query, etc.
Returns:
the query language type

setQLType

public void setQLType(short qlType)
Sets the query language type, which could be a parametric, text, image query, etc.
Parameters:
qlType - the query language type

getDatastoreType

public java.lang.String getDatastoreType()
Gets the target datastore type for executing this query.
Returns:
target datastore type

setDatastoreType

public void setDatastoreType(java.lang.String dsType)
Sets the target datastore type for executing this query.
Parameters:
dsName - target datastore type

getDatastoreName

public java.lang.String getDatastoreName()
Gets the target datastore name for executing this query.
Returns:
target datastore name

setDatastoreName

public void setDatastoreName(java.lang.String dsName)
Sets the target datastore name for executing this query.
Parameters:
dsName - target datastore name

isTranslation

public boolean isTranslation()
Check if this query requires a translation using schema mapping.
Returns:
true if schema translation is required.

getMappingNames

public java.lang.String[] getMappingNames()
Gets the optional schema mapping names for executing this query. The default value is null, which means mapping is not required.
Returns:
the array of mapping names.

getMappingTypes

public int[] getMappingTypes()
Gets the optional schema mapping types for executing this query. The default value is 0, which means mapping is not required. Valid types are: DK_FED_MAPPED_ENTITY, DK_FED_MAPPED_TEXT_ENTITY, etc
Returns:
the array of mapping types.

getAssociatedMapping

public java.lang.String getAssociatedMapping()
Gets the associated mapping for this query expression. Only applicable for text query.
Returns:
the associated mapping

setAssociatedMapping

public void setAssociatedMapping(java.lang.String associatedMapping)
Sets the associated mapping for this query expression. Only applicable for text query.
Parameters:
the - associated mapping

getEntityNames

public java.lang.String[] getEntityNames()
Gets the mapped entity names in this query expression.
Returns:
the array of mapped entity names.

getAssociatedEntityName

public java.lang.String getAssociatedEntityName()
Gets the associated entity name associated with this query This entity will support text and parametric query
Returns:
name of associated entity name

subQueryCount

public int subQueryCount()
Gets the number of sub-queries in this expression.
Returns:
the number of sub-queries.

addSubQuery

public int addSubQuery(DKQSubExpr subQE)
Adds a sub-query to this expression.
Returns:
number of sub-queries in this expression.

removeSubQuery

public int removeSubQuery(DKQSubExpr subQE)
Removes a given sub-query form this expression.
Returns:
the position of removed sub-query.

removeSubQuery

public void removeSubQuery(int position)
Removes a sub-query at the given position form this expression.

getSubQuery

public DKQSubExpr getSubQuery(int position)
Gets the sub-query at the given position.
Returns:
the sub-query object

optionCount

public int optionCount()
Gets the number of defined options.
Returns:
integer number of options

getOptionList

public DKNVPair[] getOptionList()
Gets the option list.
Returns:
an NVPair array of options.

setOptionList

public void setOptionList(DKNVPair[] optionList)
Sets the option list.
Parameters:
an - NVPair array of options.

getOption

public DKNVPair getOption(int position)
Gets an option at the given position.
Throws:
java.lang.IndexOutOfBoundsException - if position is invalid.

getOption

public DKNVPair getOption(java.lang.String name)
Gets an option with a given name.
Returns:
the option with the given name; or null if it is not found.

setOption

public void setOption(int position,
                      DKNVPair optionPair)
Sets the option at the given position.
Parameters:
optionPair - the new option
Throws:
java.lang.IndexOutOfBoundsException - if position is invalid.

setOption

public int setOption(java.lang.String name,
                     java.lang.Object value)
Sets the option with the given name. The option will be added, if it does not exist yet.
Returns:
the position of the option

removeOption

public void removeOption(int position)
Removes the option at the given position.
Parameters:
the - position.
Throws:
java.lang.IndexOutOfBoundsException - if position is invalid.

removeOption

public int removeOption(java.lang.String name)
Removes the option with the given name.
Parameters:
name - the option name.
Returns:
the position; -1 if not found.
Throws:
java.lang.IndexOutOfBoundsException - if position is invalid.

parameterCount

public int parameterCount()
Gets the number of defined parameters.
Returns:
integer number of parameters

getParameterList

public DKNVPair[] getParameterList()
Gets the parameter list.
Returns:
an NVPair array of parameters.

setParameterList

public void setParameterList(DKNVPair[] parameterList)
Sets the parameter list.
Parameters:
an - NVPair array of parameters.

getParameter

public DKNVPair getParameter(int position)
Gets a parameter at a given position.
Throws:
java.lang.IndexOutOfBoundsException - if position is invalid.

getParameter

public DKNVPair getParameter(java.lang.String name)
Gets a parameter with a given name.
Returns:
the option with the given name; or null if it is not found.

setParameter

public void setParameter(int position,
                         DKNVPair parmPair)
Sets the parameter at the given position.
Parameters:
parmPair - the new parameter
Throws:
java.lang.IndexOutOfBoundsException - if position is invalid.

setParameter

public int setParameter(java.lang.String name,
                        java.lang.Object value)
Sets a parameter with a given name. The parameter will be added, if it does not exist yet.
Returns:
the position of the parameter

removeParameter

public void removeParameter(int position)
Removes the parameter at the given position.
Parameters:
the - position.
Throws:
java.lang.IndexOutOfBoundsException - if position is invalid.

removeParameter

public int removeParameter(java.lang.String name)
Removes the parameter with the given name.
Parameters:
name - the parameter name.
Returns:
the position; -1 if not found.
Throws:
java.lang.IndexOutOfBoundsException - if position is invalid.

opCode

public short opCode()
Gets the operator code in this expression tree.
Returns:
the operator code

left

public DKQExpr left()
Gets the query in left hand side.
Returns:
left query

right

public DKQExpr right()
Gets the query in right hand side.
Returns:
right query

isLeaf

public boolean isLeaf()
Check if this expression is a leaf.
Returns:
true if this is a leaf.

and

public DKQExpr and(DKQExpr rhs)
Apply logical AND operator between this query expression and another one.
Parameters:
rhs - the query to be AND-ed at the right hand side
Returns:
a new resulting query

or

public DKQExpr or(DKQExpr rhs)
Apply logical OR operator between this query and another one.
Parameters:
rhs - the query to be OR-ed at the right hand side
Returns:
a new resulting query

EIP Java APIs

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.