Class ParameterRefTools
- java.lang.Object
-
- de.aristaflow.adept2.model.common.paramref.ParameterRefTools
-
public final class ParameterRefTools extends Object
This utility class provides methods to deal withParameterRefparameter references in all kinds of strings, used in different places likeSystemDataConsumer-annotated methods.
-
-
Field Summary
Fields Modifier and Type Field Description static StringEVEN_BSThe regular expression for an even number of backslashes.static intINPUT_PARAMETER_GRPThe index of the matcher group for input parameter name in the parameter ref pattern.static PatternIO_PARAMETER_REF_PATTERNPattern to match IO parameter references with a user-defined type parsing the UDT-name.static intLEADING_BACKSLASH_GRPThe index of the matcher group for the leading backslashes in the parameter ref pattern.static intOUTPUT_PARAMETER_GRPThe index of the matcher group for optional output parameter name in the parameter ref pattern.static PatternPARAMETER_REF_PATTERNPattern to match simple parameter references.static intTYPE_CHAR_GRPThe index of the matcher group for the type character in the parameter ref pattern.static intUDT_NAME_GRPThe index of the matcher group for the optional UDT name in the parameter ref pattern.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.static ProcessConstants.AdeptDataTypefromTypeKey(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 StringunescapeIdentifier(String s)Unescapes the designated identifier name, that is\are removed where appropriate.
-
-
-
Field Detail
-
EVEN_BS
public static final String 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:
- Constant Field Values
-
LEADING_BACKSLASH_GRP
public static final int LEADING_BACKSLASH_GRP
The index of the matcher group for the leading backslashes in the parameter ref pattern.- See Also:
- Constant Field Values
-
TYPE_CHAR_GRP
public static final int TYPE_CHAR_GRP
The index of the matcher group for the type character in the parameter ref pattern.- See Also:
- Constant Field Values
-
UDT_NAME_GRP
public static final int UDT_NAME_GRP
The index of the matcher group for the optional UDT name in the parameter ref pattern.- See Also:
- Constant Field Values
-
INPUT_PARAMETER_GRP
public static final int INPUT_PARAMETER_GRP
The index of the matcher group for input parameter name in the parameter ref pattern.- See Also:
- Constant Field Values
-
OUTPUT_PARAMETER_GRP
public static final int OUTPUT_PARAMETER_GRP
The index of the matcher group for optional output parameter name in the parameter ref pattern.- See Also:
- Constant Field Values
-
PARAMETER_REF_PATTERN
public static final Pattern 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
public static final Pattern 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 Detail
-
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
public static String toTypeKey(ProcessConstants.AdeptDataType dataType)
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
public static ProcessConstants.AdeptDataType fromTypeKey(String typeKey)
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
public static String unescapeIdentifier(String s)
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
\.
-
-