MacroExpression

Overview

The MacroExpression class is the implementation of MacroExpression.

Instances of this class can be used to represent direct calls to the SQL function of the underlying database server.

For example: this SQL expression

DATEADD(DAY, 1, CURRENT_TIMESTAMP)

can be represented as

new MacroExpression("DATEADD",
  new WhereExpression[] { 
    new MacroExpression("DAY"), 
    new ConstantExpression(1), 
    new MacroExpression("CURRENT_TIMESTAMP") });

Please note that a WhereExpression containing a MacroExpression cannot be used to perform Dynamic Where clauses due to security restrictions (allowing it would enable SQL injection attacks via Dynamic Where).

Instead, you can provide a custom DataService method that accepts the WhereExpression parameter and converts it into SQL using the ToSqlString method.

Location

 

constructor

Creates a new instance of the MacroExpression class.

 

constructor

 

MacroExpression()

constructor (String)

Creates a new instance of the MacroExpression class with the given name.

 

constructor(aName: String)

 

MacroExpression(String aName)

Parameters:

  • aName: The name of the macro expression.

constructor (String, WhereExpression[])

Creates a new instance of the MacroExpression class with the given name and macro parameters.

 

constructor(aName: String; params aValues: array of WhereExpression)

 

MacroExpression(String aName, WhereExpression[]... aValues)

Parameters:

  • aName: The name of the macro expression.
  • aValues: The parameters of the macro expression.

add (Integer, WhereExpression)

Adds the provided WhereExpression instance to the list of macro parameters at a specified position.

 

method add(anIndex: Integer; aValue: WhereExpression)

 

void add(Integer anIndex, WhereExpression aValue)

Parameters:

  • anIndex: The position to put the parameter.
  • aValue: The macro parameter to be added.

Adds the provided WhereExpression instance to the list of macro parameters.

 

method add(aValue: WhereExpression)

 

void add(WhereExpression aValue)

Parameters:

  • aValue: The macro parameter to be added.

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.

Count

 

property Count: Integer read;

 

Integer Count { __get; }

fromString    (declared in WhereExpression)

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    (declared in WhereExpression)

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    (declared in WhereExpression)

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.

Item

 

property Item[anIndex: Integer]: WhereExpression read write;

 

WhereExpression Item[Integer anIndex] { __get; __set; }

Kind

 

property Kind: WhereKind read;

 

WhereKind Kind { __get; }

Name

 

property Name: String read write;

 

String Name { __get; __set; }

parseExpression    (declared in WhereExpression)

 

class method parseExpression(node: Node): WhereExpression

 

static WhereExpression parseExpression(Node node)

Parameters:

  • node:

readFromXml (Node)    (declared in WhereExpression)

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.

readFromXml (Node)

Initializes the current MacroExpression from the given XML node. Fills ParameterExpression with data from the given xml node, that should be in the correct Dynamic Where XML Format.

 

method readFromXml(node: Node)

 

void readFromXml(Node node)

Parameters:

  • node: The node that contains the serialized expression.

remove (Integer)

Removes the macro parameter at the specified position from the parameters list .

 

method remove(anIndex: Integer)

 

void remove(Integer anIndex)

Parameters:

  • anIndex: The position of the parameter that is to be removed.

remove (WhereExpression)

Removes the provided WhereExpression instance from the macro parameters list.

 

method remove(aValue: WhereExpression)

 

void remove(WhereExpression aValue)

Parameters:

  • aValue: The expression to be removed.

toSqlString    (declared in WhereExpression)

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 macro expression and appends it to the provided StringBuilder.

 

method toSqlString(aDestination: StringBuilder)

 

void toSqlString(StringBuilder aDestination)

Parameters:

  • aDestination: The destination string builder that will contain the string representation of the expression.

toString    (declared in WhereExpression)

Returns a SQL string representation of the current expression.

 

method toString: String

 

String toString()

toXmlNode    (declared in WhereExpression)

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

 

method toXmlNode: Node

 

Node toXmlNode()

toXmlString    (declared in WhereExpression)

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    (declared in WhereExpression)

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    (declared in WhereExpression)

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

Creates Xml node (in the Dynamic Where XML Format) from the current MacroExpression and appends it to the given parent node.

 

method writeToXml(aNode: Node)

 

void writeToXml(Node aNode)

Parameters:

  • aNode: The parent XML node.

 

Count

 

property Count: Integer read;

 

Integer Count { __get; }

Item

 

property Item[anIndex: Integer]: WhereExpression read write;

 

WhereExpression Item[Integer anIndex] { __get; __set; }

Kind

 

property Kind: WhereKind read;

 

WhereKind Kind { __get; }

Name

 

property Name: String read write;

 

String Name { __get; __set; }

 

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    (declared in WhereExpression)

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    (declared in WhereExpression)

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    (declared in WhereExpression)

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    (declared in WhereExpression)

 

class method parseExpression(node: Node): WhereExpression

 

static WhereExpression parseExpression(Node node)

Parameters:

  • node:

validate (WhereExpression): Boolean    (declared in WhereExpression)

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.

 

constructor

Creates a new instance of the MacroExpression class.

 

constructor

 

MacroExpression()

constructor (String)

Creates a new instance of the MacroExpression class with the given name.

 

constructor(aName: String)

 

MacroExpression(String aName)

Parameters:

  • aName: The name of the macro expression.

constructor (String, WhereExpression[])

Creates a new instance of the MacroExpression class with the given name and macro parameters.

 

constructor(aName: String; params aValues: array of WhereExpression)

 

MacroExpression(String aName, WhereExpression[]... aValues)

Parameters:

  • aName: The name of the macro expression.
  • aValues: The parameters of the macro expression.

add (Integer, WhereExpression)

Adds the provided WhereExpression instance to the list of macro parameters at a specified position.

 

method add(anIndex: Integer; aValue: WhereExpression)

 

void add(Integer anIndex, WhereExpression aValue)

Parameters:

  • anIndex: The position to put the parameter.
  • aValue: The macro parameter to be added.

Adds the provided WhereExpression instance to the list of macro parameters.

 

method add(aValue: WhereExpression)

 

void add(WhereExpression aValue)

Parameters:

  • aValue: The macro parameter to be added.

readFromXml (Node)    (declared in WhereExpression)

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.

readFromXml (Node)

Initializes the current MacroExpression from the given XML node. Fills ParameterExpression with data from the given xml node, that should be in the correct Dynamic Where XML Format.

 

method readFromXml(node: Node)

 

void readFromXml(Node node)

Parameters:

  • node: The node that contains the serialized expression.

remove (Integer)

Removes the macro parameter at the specified position from the parameters list .

 

method remove(anIndex: Integer)

 

void remove(Integer anIndex)

Parameters:

  • anIndex: The position of the parameter that is to be removed.

remove (WhereExpression)

Removes the provided WhereExpression instance from the macro parameters list.

 

method remove(aValue: WhereExpression)

 

void remove(WhereExpression aValue)

Parameters:

  • aValue: The expression to be removed.

toSqlString    (declared in WhereExpression)

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 macro expression and appends it to the provided StringBuilder.

 

method toSqlString(aDestination: StringBuilder)

 

void toSqlString(StringBuilder aDestination)

Parameters:

  • aDestination: The destination string builder that will contain the string representation of the expression.

toString    (declared in WhereExpression)

Returns a SQL string representation of the current expression.

 

method toString: String

 

String toString()

toXmlNode    (declared in WhereExpression)

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

 

method toXmlNode: Node

 

Node toXmlNode()

toXmlString    (declared in WhereExpression)

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    (declared in WhereExpression)

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

Creates Xml node (in the Dynamic Where XML Format) from the current MacroExpression and appends it to the given parent node.

 

method writeToXml(aNode: Node)

 

void writeToXml(Node aNode)

Parameters:

  • aNode: The parent XML node.