Remap field names and data values in a predicate string.


Namespace: NetricsServerInterface
Assembly: NetricsServerInterface (in NetricsServerInterface.dll)

Syntax

Visual Basic (Declaration)
Public Class NetricsPredicateMapper
C#
public class NetricsPredicateMapper
C++
ref class NetricsPredicateMapper
J#
public class NetricsPredicateMapper
JScript
public class NetricsPredicateMapper

Remarks

This class is used to map values that appear in a predicate string expression. It allows field names and data values to be changed in the string. This class is intended to be used in association with the ANetricsQueryBuilder class. To support predicate queries the class must have a means of updating the field names used, and substituting data values into the query at run time.

The ANetricsQueryBuilder class tracks two sets of names:

  1. Output Field Names. These are the names sent to the Patterns server to reference a record field value. Within a Predicate String Expression it takes the form: $"field-name". Field name expressions cannot appear in string constants or other field name expressions. They appear only at the top level of the Predicate String Expression.
  2. Input Data Names. These are the names of the input data items used to generate the query text. A standard Predicate String Expression has no representation for intput data items. This class extends the standard expression to add a means of specifying an input data item. It takes the form: ${data-item-name}. All text between the curly braces is the name of the input data field. Input data items can appear both at the top level and within string constants.

To allow the character sequence ${ to be expressed in a string constant (or elsewhere) the sequence $\ can be used to represent a single dollar sign that has no special meaning. This sequence is translated to a single dollar sign character by this class.

The ANetricsQueryBuilder class allows both the input and output field names to be updated at run time. This class must support these operations. It does so through the setFieldNames and setDataNames methods.

The class must also allow the data values to be inserted into the expression. The getMappedExpr method is used to retrieve the fully mapped Predicate String Expression.

When a data value is inserted into a predicate expression string constant the mapper will encode the value before inserting it. The value should not be encoded before passing it to the predicate expression mapper.

Some Things To Note:

This class does not validate the predicate expression syntax. If given an invalid predicate expression, it will quietly generate an invalid predicate expression.

A data item name may contain any character except a closing curly brace. This includes double quotes. So expressions of the form $"first" = "${"data-item-1"}" are valid. Beware of: $"first" = "${data-item-1"} : this is an unterminated string constant.

* Unterminated field names expressions or data item expressions are treated as fixed values. For example: "George" = $"first and "George" = "${first" are both output exactly as is, as neither has a substitution section. The unterminated Field Name and Data sections are treated as if they were fixed text.

Inheritance Hierarchy

System.Object
   NetricsServerInterface.NetricsPredicateMapper

Thread Safety

Public static (Shared in Visual Basic)staticShared members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

See Also