Enterprise Information Portal APIs

com.ibm.mm.sdk.common
Class DKQTerm

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

public class DKQTerm
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Query terms are used to represent a predicate logic expression in a query. A basic query term can be as simple as a text string (as part of a text query) or a pair of attribute name and value separated by a comparison operator : ==, >, >=, <, <=, <>, BETWEEN, LIKE, IN . Query terms can be combined together with logical operators : AND, OR, NOT. This class does not support operators: NOTIN, NOTLIKE, NOTBETWEEN, however, you can create an equivalent expression using NOT logical operator.

See Also:
Serialized Form

Constructor Summary
DKQTerm()
          Default constructor.
DKQTerm(DKQTerm leftTerm, short logOpCode, DKQTerm rightTerm)
          Creates a term specifying a query condition to be met.
DKQTerm(java.lang.String stringTerm)
          Create a query term based on the string input.
DKQTerm(java.lang.String stringTerm, DKNVPair[] options)
           
DKQTerm(java.lang.String attrName, short cmpOpCode, java.lang.String attrValue)
          Creates a term specifying a query condition to be met.
DKQTerm(java.lang.String attrName, short cmpOpCode, java.lang.String[] attrValues)
          Creates a term specifying a query condition to be met.
 
Method Summary
 DKQTerm and(DKQTerm rhs)
          Apply logical AND operator between this term and another given term.
 java.lang.Object clone()
           
 DKQTerm getLeft()
          Gets the left hand side part of this term.
 java.lang.String getName()
          Gets the attribute name in this term.
 short getOpCode()
          Gets the operator code in this term.
 DKNVPair[] getOptions()
          Gets options defined in this term.
 DKQTerm getRight()
          Gets the right hand side part of this term.
 java.lang.String getStringTerm()
          Gets the string part of this term.
 java.lang.String getValue()
          Gets the value part of this term.
 java.lang.String[] getValues()
          Gets the value part of this term; there are more than one values.
 boolean hasMultiValues()
          Check if this term has multi-values.
 boolean isLeaf()
          Check if this term is a leaf.
 boolean isNotTerm()
          Check if this term is negated.
 DKQTerm not()
          Apply logical NOT operator to this term, that is, negate this term.
 DKQTerm or(DKQTerm rhs)
          Apply logical OR operator between this term and another given term.
 void setLeft(DKQTerm left)
          Sets the left hand side part of this term.
 void setName(java.lang.String attrName)
          Sets the attribute name part of this term.
 void setOpCode(short opCode)
          Sets the operator code in this term.
 void setOptions(DKNVPair[] options)
          Sets options for this term.
 void setRight(DKQTerm right)
          Sets the right hand side part of this term.
 void setStringTerm(java.lang.String stringTerm)
          Sets the string part of this term.
 void setValue(java.lang.String value)
          Sets the value part of this term.
 void setValues(java.lang.String[] values)
          Sets the value part of this term; there are more than one values.
 java.lang.String toString()
          Re-constructs the string form of this query expression with the correct levels of required parentheses.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DKQTerm

public DKQTerm()
Default constructor.

DKQTerm

public DKQTerm(java.lang.String stringTerm)
Create a query term based on the string input.
Parameters:
stringTerm - a text query string term.

DKQTerm

public DKQTerm(java.lang.String stringTerm,
               DKNVPair[] options)
Parameters:
stringTerm - a text query string term.
options - options applicable to this term, for example in the test string the options could be CCSID, wildcard char, etc.

DKQTerm

public DKQTerm(java.lang.String attrName,
               short cmpOpCode,
               java.lang.String attrValue)
Creates a term specifying a query condition to be met.
Parameters:
attrName - attribute name in this conditional expression
cmpOpCode - comparison operator code, that is, >, <, ==, etc.
attrValue - attribute value

DKQTerm

public DKQTerm(java.lang.String attrName,
               short cmpOpCode,
               java.lang.String[] attrValues)
Creates a term specifying a query condition to be met. It takes an array of values as input for handling operators requiring more than one value, like BETWEEN, IN, etc.
Parameters:
attrName - attribute name in this conditional expression
cmpOpCode - comparison operator code which takes more than one values.
attrValues - attribute value array

DKQTerm

public DKQTerm(DKQTerm leftTerm,
               short logOpCode,
               DKQTerm rightTerm)
Creates a term specifying a query condition to be met. It takes two terms, left and right term with a logical operator. Old terms will be absorbed by the new term.
Parameters:
leftTerm - left term
logOpCode - logical operator code
rightTerm - right term
Method Detail

getOpCode

public short getOpCode()
Gets the operator code in this term.
Returns:
the operator code in this term

setOpCode

public void setOpCode(short opCode)
Sets the operator code in this term. The caller is responsible to make sure that the operator is appropriate for this term.
Parameters:
opCode - the operator code for this term

getLeft

public DKQTerm getLeft()
Gets the left hand side part of this term.
Returns:
left term.

setLeft

public void setLeft(DKQTerm left)
Sets the left hand side part of this term. The caller is responsible to make sure that the lhs term is appropriate for this term.
Parameters:
left - the left term.

getRight

public DKQTerm getRight()
Gets the right hand side part of this term.
Returns:
right term.

setRight

public void setRight(DKQTerm right)
Sets the right hand side part of this term. The caller is responsible to make sure that the rhs term is appropriate for this term.
Returns:
right term.

and

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

or

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

not

public DKQTerm not()
Apply logical NOT operator to this term, that is, negate this term. This term will be the rhs of the resulting term.
Returns:
a new resulting term

isNotTerm

public boolean isNotTerm()
Check if this term is negated.
Returns:
true if this term is negated.

isLeaf

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

getStringTerm

public java.lang.String getStringTerm()
Gets the string part of this term.
Returns:
the string part

setStringTerm

public void setStringTerm(java.lang.String stringTerm)
Sets the string part of this term.
Parameters:
stringTerm - the string part

getName

public java.lang.String getName()
Gets the attribute name in this term.
Returns:
the attribute name

setName

public void setName(java.lang.String attrName)
Sets the attribute name part of this term. Attribute names containing blanks or quotes are assumed to have the correct pair of quotes, for example, 'First Name', \"Social Security Number\", \"Employee's Address\". Normal identifiers do not require quotes.
Parameters:
attrName - the attribute name

getValue

public java.lang.String getValue()
Gets the value part of this term. Assumes that there is only one value. String attribute values are assumed to have the correct pair of quotes, for example, 'Anonymous', \"John Smith\", \"Mary's Lamb\".
Returns:
the value part of this term; or null if the value is not initialized.

setValue

public void setValue(java.lang.String value)
Sets the value part of this term. Assumes that the new value is one value.
Parameters:
the - new value of this term
See Also:
getValue()

getValues

public java.lang.String[] getValues()
Gets the value part of this term; there are more than one values.
Returns:
a string array of values; or null if the attribute value is not initialized.

setValues

public void setValues(java.lang.String[] values)
Sets the value part of this term; there are more than one values.
Parameters:
values - a string array of values.

hasMultiValues

public boolean hasMultiValues()
Check if this term has multi-values.
Returns:
true if term has multi values

getOptions

public DKNVPair[] getOptions()
Gets options defined in this term. Options only applicable to text query term.
Returns:
an array of DKNVPair object each indicating option name and value.

setOptions

public void setOptions(DKNVPair[] options)
Sets options for this term.
Parameters:
options - an array of DKNVPair object each indicating option name and value.
See Also:
getOptions()

toString

public java.lang.String toString()
Re-constructs the string form of this query expression with the correct levels of required parentheses. String attribute values are assumed to have the correct pair of quotes, for example, 'Anonymous', \"John Smith\", \"Mary's Lamb\".
Overrides:
toString in class java.lang.Object
Returns:
the string form of this query expression

clone

public java.lang.Object clone()

EIP Java APIs

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