Class ParameterRefTools
java.lang.Object
de.aristaflow.adept2.model.common.paramref.ParameterRefTools
This utility class provides methods to deal with
ParameterRef
parameter references in all kinds of strings, used in different places like
SystemDataConsumer-annotated
methods.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe regular expression for an even number of backslashes.static final intThe index of the matcher group for input parameter name in the parameter ref pattern.static final PatternPattern to match IO parameter references with a user-defined type parsing the UDT-name.static final intThe index of the matcher group for the leading backslashes in the parameter ref pattern.static final intThe index of the matcher group for optional output parameter name in the parameter ref pattern.static final PatternPattern to match simple parameter references.static final intThe index of the matcher group for the type character in the parameter ref pattern.static final intThe index of the matcher group for the optional UDT name in the parameter ref pattern. -
Method Summary
Modifier and TypeMethodDescriptionstatic IOParameterRef[]findIOParameterReferences(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Finds all IO parameter references in the given string and returns them.static ParameterRef[]findParameterReferences(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Finds all simple parameter references (seeSystemDataConsumer) in the given string and returns them.fromTypeKey(String typeKey) Returns the data type associated to the given type key ornullif the type key is not recognised.static IOParameterRefParsergetIOParser(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Returns a parser for the specified parameterised string (for IO parameter references).static IOParameterRefReplacergetIOReplacer(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Returns a replacer for the specified parameterised string (for IO parameter references) to replace parameter references with actual values.static ParameterRefParsergetParser(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Returns a parser for the specified parameterised string (for simple parameter references).static ParameterRefReplacergetReplacer(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Returns a replacer for the specified parameterised string (for simple parameter references) to replace parameter references with actual values.static IOParameterRef[]listIOParameterReferences(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Finds all IO parameter references in the given string and returns them in the encountered order.static ParameterRef[]listParameterReferences(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Lists all simple parameter references (seeSystemDataConsumer) in the given string and returns them in the encountered order.static IOParameterRefparseIOParameterReference(String parameterReference, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Parses the specified string representation of a IO parameter reference (IO_PARAMETER_REF_PATTERN) (including the enclosing '%'s) and returns it as aIOParameterRefobject (ornullif the reference is in any way illegal).static ParameterRefparseParameterReference(String parameterReference, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Parses the specified string representation of a simple parameter reference (PARAMETER_REF_PATTERN) (including the enclosing '%'s) and returns it as aParameterRefobject (ornullif the reference is in any way illegal).static StringtoTypeKey(ProcessConstants.AdeptDataType dataType) Returns the type key (i.e.static StringUnescapes the designated identifier name, that is\are removed where appropriate.
-
Field Details
-
EVEN_BS
The regular expression for an even number of backslashes. In this case the following character is not escaped and has to be interpreted as syntax.- See Also:
-
LEADING_BACKSLASH_GRP
public static final int LEADING_BACKSLASH_GRPThe index of the matcher group for the leading backslashes in the parameter ref pattern.- See Also:
-
TYPE_CHAR_GRP
public static final int TYPE_CHAR_GRPThe index of the matcher group for the type character in the parameter ref pattern.- See Also:
-
UDT_NAME_GRP
public static final int UDT_NAME_GRPThe index of the matcher group for the optional UDT name in the parameter ref pattern.- See Also:
-
INPUT_PARAMETER_GRP
public static final int INPUT_PARAMETER_GRPThe index of the matcher group for input parameter name in the parameter ref pattern.- See Also:
-
OUTPUT_PARAMETER_GRP
public static final int OUTPUT_PARAMETER_GRPThe index of the matcher group for optional output parameter name in the parameter ref pattern.- See Also:
-
PARAMETER_REF_PATTERN
Pattern to match simple parameter references. Syntax characters like%and:have to be escaped appropriately with\. group(2) is the type char, group(3) is the (optional) UDT name (may benullor the empty string) and group(4) is the input parameter name. The caller has to validate whether the UDT name is makes sense or is required, the pattern does not check this.
Do not forget tounescapethe found parameter and data type names.
If you want to use this, have a look atParameterRefParserandParameterRefReplacer. They might be more suitable for you. -
IO_PARAMETER_REF_PATTERN
Pattern to match IO parameter references with a user-defined type parsing the UDT-name. This also allows for escaping syntax characters like%and:with\. group(2) is the type char, group(3) is the (optional) UDT name (may benullor the empty string), group(4) is the input parameter name and group(5) the optional output parameter name (may benullor the empty string). The caller has to validate whether the UDT name is makes sense or is required, the pattern does not check this.
Do not forget tounescapethe found parameter and data type names.
If you want to use this, have a look atParameterRefParserandParameterRefReplacer. They might be more suitable for you.
-
-
Method Details
-
findParameterReferences
public static ParameterRef[] findParameterReferences(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Finds all simple parameter references (seeSystemDataConsumer) in the given string and returns them. This method will avoid returning duplicates (i.e. two parameter references that exactly match in name and type).- Parameters:
parameterisedString- a string, potentially containing variables / parameter references. This may benull.consideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- all simple parameter references found in the string
-
findIOParameterReferences
public static IOParameterRef[] findIOParameterReferences(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Finds all IO parameter references in the given string and returns them. This method will avoid returning duplicates (i.e. two parameter references that exactly match in type and parameter names).- Parameters:
parameterisedString- a string, potentially containing variables / parameter referencesconsideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- all IO parameter references found in the string
-
listParameterReferences
public static ParameterRef[] listParameterReferences(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Lists all simple parameter references (seeSystemDataConsumer) in the given string and returns them in the encountered order. This method will NOT avoid returning duplicates.- Parameters:
parameterisedString- a string, potentially containing variables / parameter referencesconsideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- all simple parameter references found in the string
-
listIOParameterReferences
public static IOParameterRef[] listIOParameterReferences(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Finds all IO parameter references in the given string and returns them in the encountered order. This method will NOT avoid returning duplicates.- Parameters:
parameterisedString- a string, potentially containing variables / parameter referencesconsideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- all IO parameter references found in the string
-
parseParameterReference
public static ParameterRef parseParameterReference(String parameterReference, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Parses the specified string representation of a simple parameter reference (PARAMETER_REF_PATTERN) (including the enclosing '%'s) and returns it as aParameterRefobject (ornullif the reference is in any way illegal).- Parameters:
parameterReference- string representation of a simple parameter referenceconsideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- a parsed
ParameterRefobject ornullif the reference is in any way illegal
-
parseIOParameterReference
public static IOParameterRef parseIOParameterReference(String parameterReference, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Parses the specified string representation of a IO parameter reference (IO_PARAMETER_REF_PATTERN) (including the enclosing '%'s) and returns it as aIOParameterRefobject (ornullif the reference is in any way illegal).- Parameters:
parameterReference- string representation of a simple parameter referenceconsideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- a parsed
IOParameterRefobject ornullif the reference is in any way illegal
-
getParser
public static ParameterRefParser getParser(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Returns a parser for the specified parameterised string (for simple parameter references). The advantage compared tofindParameterReferences(String, EnumSet)is that the parser provides position information (start and end index of parameter reference).- Parameters:
parameterisedString- the parameterised string to be formattedconsideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- a formatter for the specified parameterised string
-
getReplacer
public static ParameterRefReplacer getReplacer(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Returns a replacer for the specified parameterised string (for simple parameter references) to replace parameter references with actual values.- Parameters:
parameterisedString- the parameterised string to be processedconsideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- a replacer for the specified parameterised string
-
getIOParser
public static IOParameterRefParser getIOParser(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Returns a parser for the specified parameterised string (for IO parameter references). The advantage compared tofindParameterReferences(String, EnumSet)is that the parser provides position information (start and end index of parameter reference).- Parameters:
parameterisedString- the parameterised string to be formattedconsideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- a formatter for the specified parameterised string
-
getIOReplacer
public static IOParameterRefReplacer getIOReplacer(String parameterisedString, EnumSet<ProcessConstants.AdeptDataType> consideredDataTypes) Returns a replacer for the specified parameterised string (for IO parameter references) to replace parameter references with actual values.- Parameters:
parameterisedString- the parameterised string to be processedconsideredDataTypes- the set of data types considered by this parser; all others will be ignored; usenullto consider all data types- Returns:
- a replacer for the specified parameterised string
-
toTypeKey
Returns the type key (i.e. the identifying character in parameter references) for the specified data type.- Parameters:
dataType- the data type for which to return the type key- Returns:
- the type key (i.e. the identifying character in parameter references) for the specified data type
-
fromTypeKey
Returns the data type associated to the given type key ornullif the type key is not recognised.- Parameters:
typeKey- the type key for which to return the associated data type- Returns:
- the data type associated to the given type key or
nullif the type key is not recognised
-
unescapeIdentifier
Unescapes the designated identifier name, that is\are removed where appropriate.- Parameters:
s- The identifier name (parameter or data type name) as retrieved from the matching the regular expression.- Returns:
- The identifier name name with appropriately removed
\.
-