Index

DKQExpr

Purpose:

DKQExpr is a query expression used to specify a simple query. It is an alternate form of a query string. It has a query term, an option list, and a parameter list. The query term specifies the query condition and the type of the query, for example, it could be a parametric, text, or image query. The option list specifies options relevant to the query. An example of option list could be the maximum result limit of this query, index-class name, and so forth. The parameter list specifies parameters to be used by or bound to the query.

Class summary:

class DKQExpr
{
  public:
    DKQExpr();
    DKQExpr(DKQExpr* lhs, short logOpCode, DKQExpr* rhs);
    virtual ~DKQExpr();
 
    virtual short getQLType();
    virtual void setQLType(short qlType);
    virtual DKString getDatastoreType();
    virtual void setDatastoreType(const char* dsType);
    virtual DKString getDatastoreName();
    virtual void setDatastoreName(const char* dsName);
    virtual DKBoolean isTranslation(); 
    virtual DKString* getMappingNames(long& arraySize);
    virtual int* getMappingTypes(long& arraySize);
    virtual DKString getAssociatedMapping();
    virtual void setAssociatedMapping(const char* associatedMapping);
    virtual DKString* getEntityNames(long& arraySize);
    virtual long subQueryCount();
    virtual long addSubQuery(DKQSubExpr* subQE);
    virtual long removeSubQuery(DKQSubExpr* subQE);
    virtual void removeSubQuery(long position);
    virtual DKQSubExpr* getSubQuery(long position);
    virtual long optionCount();
    virtual DKNVPair* getOptionList(long& arraySize);
    virtual void setOptionList(const DKNVPair* optionList, long arraySize);
    virtual DKNVPair* getOption(long position);
    virtual DKNVPair* getOption(const char* name);
    virtual void setOption(long position, const DKNVPair& optionPair);
    virtual void setOption(const char* name, const DKAny& value);
    virtual void removeOption(long position);
    virtual long removeOption(const char* name);
    virtual long parameterCount();
    virtual DKNVPair* getParameterList(long& arraySize);
    virtual void setParameterList(const DKNVPair* parameterList, long arraySize);
    virtual DKNVPair* getParameter(long position);
    virtual DKNVPair* getParameter(const char* name);
    virtual void setParameter(long position, const DKNVPair& parmPair);
    virtual void setParameter(const char* name, const DKAny& value);
    virtual void removeParameter(long position);
    virtual long removeParameter(const char* name);
    virtual short opCode();
    virtual DKQExpr* left();
    virtual DKQExpr* right();
    virtual DKBoolean isLeaf();
    virtual DKQExpr* and(DKQExpr* rhs);
    virtual DKQExpr* or(DKQExpr* rhs);
    virtual void setLeft(DKQExpr* qexpr);
    virtual void setRight(DKQExpr* qexpr);
};

Members:

Constructors and destructor
The first constructor of query expression takes three parameters, a query term, query options, and query parameters. Alternatively, you can create an empty DKQExpr and set each individual term, options and parameters separately.

Parameters

lhs
Left query.

logOpCode
A logical operator code.

rhs
Right query.
    DKQExpr();
    DKQExpr(DKQExpr* lhs, short logOpCode, DKQExpr* rhs);
    virtual ~DKQExpr();
 

Member functions

getQLType
Gets the query language type, which could be a parametric query, a text query, or an image query.
virtual short getQLType();

setQLType
Sets the query language type, which could be a parametric query, a text query, or an image query.
virtual void setQLType(short qlType);

getDatastoreType
Gets the target datastore type for executing this query.
virtual DKString getDatastoreType();

setDatastoreType
Sets the target datastore type for executing this query.
virtual void setDatastoreType(const char* dsType);

getDatastoreName
Gets the target datastore name for executing this query.
virtual DKString getDatastoreName();

setDatastoreName
Sets the target datastore name for executing this query.
virtual void setDatastoreName(const char* dsName);

isTranslation
Checks if this query requires a translation (using schema mapping).

virtual DKBoolean isTranslation();

getMappingNames
Gets the optional schema-mapping names for executing this query. The default value is null, which means mapping is not required.
virtual DKString* getMappingNames(long& arraySize);

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

virtual int* getMappingTypes(long& arraySize);

getAssociatedMapping
Gets the associated mapping for this query expression. This is only applicable for a text query.
virtual DKString getAssociatedMapping();

setAssociatedMapping
Sets the associated mapping for this query expression. This is only applicable for a text query.
virtual void setAssociatedMapping(const char* associatedMapping);

getEntityNames
Gets the mapped entity names in this query expression.
virtual DKString* getEntityNames(long& arraySize);

subQueryCount
Gets the number of sub-queries in this expression.
virtual long subQueryCount();

addSubQuery
Adds a sub-query to this expression.
virtual long addSubQuery(DKQSubExpr* subQE);

removeSubQuery
The first one removes a given sub-query form this expression. The second method removes a sub-query at the given position from this expression.
virtual long removeSubQuery(DKQSubExpr* subQE);
virtual void removeSubQuery(long position);

getSubQuery
Gets the sub-query at the given position.
virtual DKQSubExpr* getSubQuery(long position);

optionCount
Returns the number of options in this query expression.
virtual long optionCount();

getOptionList
Returns an array of DKNVPair containing the option list.
virtual DKNVPair* getOptionList(long& arraySize);

setOptionList
Sets the option list of this query expression.
virtual void setOptionList(const DKNVPair* optionList, long arraySize);

getOption
Returns a DKNVPair containing the option name and value given the option name or position. The first position is 1.
virtual DKNVPair* getOption(long position);
virtual DKNVPair* getOption(const char* name);

setOption
The first form sets the option indicated by its position or its name. The second form returns the position of the option set. If the named option does not exist yet, it will be added.
virtual void setOption(long position, const DKNVPair& optionPair);
virtual void setOption(const char* name, const DKAny& value);

removeOption
The first form removes the option in the given position. The second form removes the option with the given name.
virtual void removeOption(long position);
virtual long removeOption(const char* name);

parameterCount
Returns the number of parameters in this query expression.
virtual long parameterCount();

getParameterList
Returns an array of DKNVPair containing the parameter list.
virtual DKNVPair* getParameterList(long& arraySize);

setParameterList
Sets the parameter list of this query expression.
virtual void setParameterList(const DKNVPair* parameterList, long arraySize);

getParameter
Returns a DKNVPair containing the parameter name and value given the parameter name or position. The first position is 1.
virtual DKNVPair* getParameter(long position);
virtual DKNVPair* getParameter(const char* name);

setParameter
The first form sets the parameter at the given position. The second form sets a parameter with a given name. If the named parameter does not exist yet, it will be added.
virtual void setParameter(long position, const DKNVPair& parmPair);
virtual void setParameter(const char* name, const DKAny& value);

removeParameter
The first form removes the parameter in the given position. The second form removes the parameter with the given name.
virtual void removeParameter(long position);
virtual long removeParameter(const char* name);

opCode
Gets the operator code in this expression tree.
virtual short opCode();

left
Gets the query in the left-hand side.
virtual DKQExpr* left();

right
Gets the query in the right-hand side.
virtual DKQExpr* right();

isLeaf
Checks if this expression is a leaf.
virtual DKBoolean isLeaf();

and
Applies a logical AND operator between this query expression and another one.
virtual DKQExpr* and(DKQExpr* rhs);

or
Applies a logical OR operator between this query and another one.
virtual DKQExpr* or(DKQExpr* rhs);

setLeft
Sets the query in the left-hand side.
virtual void setLeft(DKQExpr* qexpr);

setRight
Sets the query in the right-hand side.
virtual void setRight(DKQExpr* qexpr);

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