WhereExpression

Overview

The base abstract class for classes that represent WHERE expression tree nodes:

  • BinaryExpression combines two other expressions with a binary operator (such as equality or binary logical operators);
  • UnaryExpression represents expressions, based in the application of a unary operator (like the change of sign or logical negation) to another, inner expression;
  • BetweenExpression represents expression that checks belonging to a range of values;
  • ConstantExpression - the constant values that appear in an expression are represented through objects of this class;
  • ListExpression is a complex expression, represented by a list of expressions;
  • ParameterExpression - the parameters (variables) of an expression are represented through objects of this class;
  • FieldExpression represents the part of expression containing table field names;
  • NullExpression represents NULL values used in the expression;
  • MacroExpression represents a call to a macro function, which will be processed by Macro Processor.

This class is used to dynamically build WHERE statements from code (Dynamic Where feature of Data Abstract).

For example, a WHERE part of this query

SELECT * FROM Employees WHERE ((Position = 'Sales Manager') 
OR (Zip IS NULL)) AND (City IN ('Atlanta GA', 'Seattle WA', 'New York CA'))

will be presented as:

WhereExpression lResult;
lResult = new BinaryExpression(new BinaryExpression(
            new BinaryExpression(
              new FieldExpression("Position"),
              new ConstantExpression("Sales Manager", DataType.String),BinaryOperator.Equal),
              new BinaryExpression(
              new FieldExpression("Zip"),
              new NullExpression(),BinaryOperator.Equal),BinaryOperator.Or),

              new BinaryExpression(
                new FieldExpression("City"),
                new ListExpression(
                new WhereExpression[]{ new ConstantExpression("Atlanta GA",DataType.String),
                                   new ConstantExpression("Seattle WA", DataType.String),
                                   new ConstantExpression("New York CA", DataType.String) }),
             BinaryOperator.In),

           BinaryOperator.And);

Location


 

Creates a new BinaryExpression from the given aLeft and aRight operands using BinaryOperator.

 

class method combine(aLeft: WhereExpression; aRight: WhereExpression): WhereExpression

 

static WhereExpression combine(WhereExpression aLeft, WhereExpression aRight)

Parameters:

  • aLeft: The left operand to be combined.
  • aRight: The right operand to be combined.

Creates a new BinaryExpression from the given aLeft and aRight operands using the given operator.

 

class method combine(aLeft: WhereExpression; aRight: WhereExpression; anOperator: BinaryOperator): WhereExpression

 

static WhereExpression combine(WhereExpression aLeft, WhereExpression aRight, BinaryOperator anOperator)

Parameters:

  • aLeft: The left operand to be combined.
  • aRight: The right operand to be combined.
  • anOperator: The operator to be used in combining.

fromString

Creates a new WhereExpression from the specified string, which should contain XML node in the correct Dynamic Where XML Format.

 

class method fromString(anXml: String): WhereExpression

 

static WhereExpression fromString(String anXml)

Parameters:

  • anXml: The given XML string.

fromStringToSql

A helper method to convert a XML string into SQL string.

 

class method fromStringToSql(anXml: String): String

 

static String fromStringToSql(String anXml)

Parameters:

  • anXml: The XML string to be converted.

fromXmlNode

Creates a new WhereExpression from the given XML node, which should be in the correct Dynamic Where XML Format.

 

class method fromXmlNode(aNode: Node): WhereExpression

 

static WhereExpression fromXmlNode(Node aNode)

Parameters:

  • aNode: The XML node to be parsed.

Kind

 

property Kind: WhereKind read;

 

WhereKind Kind { __get; }

parseExpression

 

class method parseExpression(node: Node): WhereExpression

 

static WhereExpression parseExpression(Node node)

Parameters:

  • node:

readFromXml

Abstract method that should fill the descendants of WhereExpression from the given xml node, that should be in the correct Dynamic Where XML Format.

 

method readFromXml(aNode: Node)

 

void readFromXml(Node aNode)

Parameters:

  • aNode: The XML node to be parsed.

toSqlString

A helper method that wraps the similar one with the string builder and returns a SQL string.

 

method toSqlString: String

 

String toSqlString()

toSqlString (StringBuilder)

Creates an SQL representation of thу current where expression instance and appends it to the provided StringBuilder.

 

method toSqlString(aDestination: StringBuilder)

 

void toSqlString(StringBuilder aDestination)

Parameters:

  • aDestination: The destination string builder to be appended.

toString

Returns a SQL string representation of the current expression.

 

method toString: String

 

String toString()

toXmlNode

Creates a query node (in the Dynamic Where XML Format) from the current expression.

 

method toXmlNode: Node

 

Node toXmlNode()

toXmlString

Creates the query node (in the Dynamic Where XML Format) from current expression and returns it in the string format.

 

method toXmlString: String

 

String toXmlString()

validate

Validates the current expression with the WhereValidator and returns TRUE if it contains no errors. The main purpose of the validation is to scan all objects of WhereExpession tree and make sure that they contain correct field names.

 

method validate: Boolean

 

Boolean validate()

validate (WhereExpression): Boolean

Validates the provided WhereExpression with the WhereValidator and returns TRUE if it contains no errors. The main purpose of the validation is to scan all objects of WhereExpession tree and make sure that it contains correct field names.

 

class method validate(anExpression: WhereExpression): Boolean

 

static Boolean validate(WhereExpression anExpression)

Parameters:

  • anExpression: The expression to be validated.

writeToXml

Abstract method. In descendants creates where node (in the Dynamic Where XML Format) from WhereExpression.

 

method writeToXml(aNode: Node)

 

void writeToXml(Node aNode)

Parameters:

  • aNode: The given parent XML node.

 

Kind

 

property Kind: WhereKind read;

 

WhereKind Kind { __get; }

 

Creates a new BinaryExpression from the given aLeft and aRight operands using BinaryOperator.

 

class method combine(aLeft: WhereExpression; aRight: WhereExpression): WhereExpression

 

static WhereExpression combine(WhereExpression aLeft, WhereExpression aRight)

Parameters:

  • aLeft: The left operand to be combined.
  • aRight: The right operand to be combined.

Creates a new BinaryExpression from the given aLeft and aRight operands using the given operator.

 

class method combine(aLeft: WhereExpression; aRight: WhereExpression; anOperator: BinaryOperator): WhereExpression

 

static WhereExpression combine(WhereExpression aLeft, WhereExpression aRight, BinaryOperator anOperator)

Parameters:

  • aLeft: The left operand to be combined.
  • aRight: The right operand to be combined.
  • anOperator: The operator to be used in combining.

fromString

Creates a new WhereExpression from the specified string, which should contain XML node in the correct Dynamic Where XML Format.

 

class method fromString(anXml: String): WhereExpression

 

static WhereExpression fromString(String anXml)

Parameters:

  • anXml: The given XML string.

fromStringToSql

A helper method to convert a XML string into SQL string.

 

class method fromStringToSql(anXml: String): String

 

static String fromStringToSql(String anXml)

Parameters:

  • anXml: The XML string to be converted.

fromXmlNode

Creates a new WhereExpression from the given XML node, which should be in the correct Dynamic Where XML Format.

 

class method fromXmlNode(aNode: Node): WhereExpression

 

static WhereExpression fromXmlNode(Node aNode)

Parameters:

  • aNode: The XML node to be parsed.

parseExpression

 

class method parseExpression(node: Node): WhereExpression

 

static WhereExpression parseExpression(Node node)

Parameters:

  • node:

validate (WhereExpression): Boolean

Validates the provided WhereExpression with the WhereValidator and returns TRUE if it contains no errors. The main purpose of the validation is to scan all objects of WhereExpession tree and make sure that it contains correct field names.

 

class method validate(anExpression: WhereExpression): Boolean

 

static Boolean validate(WhereExpression anExpression)

Parameters:

  • anExpression: The expression to be validated.

 

readFromXml

Abstract method that should fill the descendants of WhereExpression from the given xml node, that should be in the correct Dynamic Where XML Format.

 

method readFromXml(aNode: Node)

 

void readFromXml(Node aNode)

Parameters:

  • aNode: The XML node to be parsed.

toSqlString

A helper method that wraps the similar one with the string builder and returns a SQL string.

 

method toSqlString: String

 

String toSqlString()

toSqlString (StringBuilder)

Creates an SQL representation of thу current where expression instance and appends it to the provided StringBuilder.

 

method toSqlString(aDestination: StringBuilder)

 

void toSqlString(StringBuilder aDestination)

Parameters:

  • aDestination: The destination string builder to be appended.

toString

Returns a SQL string representation of the current expression.

 

method toString: String

 

String toString()

toXmlNode

Creates a query node (in the Dynamic Where XML Format) from the current expression.

 

method toXmlNode: Node

 

Node toXmlNode()

toXmlString

Creates the query node (in the Dynamic Where XML Format) from current expression and returns it in the string format.

 

method toXmlString: String

 

String toXmlString()

validate

Validates the current expression with the WhereValidator and returns TRUE if it contains no errors. The main purpose of the validation is to scan all objects of WhereExpession tree and make sure that they contain correct field names.

 

method validate: Boolean

 

Boolean validate()

writeToXml

Abstract method. In descendants creates where node (in the Dynamic Where XML Format) from WhereExpression.

 

method writeToXml(aNode: Node)

 

void writeToXml(Node aNode)

Parameters:

  • aNode: The given parent XML node.