public class RegularExpressionPropertyType extends PropertyType<String>
| Constructor Example | Comments | ||
|---|---|---|---|
Property<Date> A_PROPERTY = |
Creates RegularExpressionPropertyType with which validates the pattern "[bcr]at". No default value. | ||
Property<Date> A_PROPERTY = |
Creates RegularExpressionPropertyType with which validates the pattern "[bcr]at". With default value "cow". | ||
| Type of value(s) | Examples | Result | Comments |
| Valid | bat | bat | Validate successfully. With pattern "[bcr]at". |
| Valid | rat | rat | Validate successfully. With pattern "[bcr]at". |
| Invalid | horse | null |
Validate will throw an exception. The resulting value is null. |
| Invalid | «empty string» | null |
Validate will throw an exception. The resulting value is null. |
| Invalid | null |
defaultValue OR null |
Validate will throw an exception. Return default value if set, otherwise null. |
Pattern,
StringPropertyType,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static String |
TYPE
Type name of the propertytype 'RegularExpression'.
|
| Constructor and Description |
|---|
RegularExpressionPropertyType(String pattern)
Creates a property that parses a regular expression.
|
RegularExpressionPropertyType(String pattern,
String defaultValue)
Creates a property that parses a regular expression.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getPattern()
The regular expression pattern to be compiled
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
void |
setPattern(String pattern) |
void |
validateConstraints(String propertyName)
A PropertyType can have some constraints here is where they are
validated.
|
String |
validateValue(String propertyName,
String value)
Converts the string representation of to a typed value.
|
equals, getDefaultValue, getDefaultValueAsString, getDefaultValueDescription, getDescription, getDescription, getInitializationPriority, getIo, getLogger, getTypeName, hasDefaultValue, isDefaultValueValid, postGetValueProcessing, setDefaultValue, setInitializationPriority, setIo, setTypedValue, setTypeName, toString, toType, validate, validateNullTypepublic static final String TYPE
public RegularExpressionPropertyType(String pattern)
null.pattern - The expression to be compiledPattern.compile(String)public RegularExpressionPropertyType(String pattern, String defaultValue)
pattern - The expression to be compileddefaultValue - default value returned if property value is undefined.Pattern.compile(String)public String getPattern()
public void setPattern(String pattern)
public List<String> getRestrictions()
PropertyTypegetRestrictions in class PropertyType<String>public String validateValue(String propertyName, String value) throws PropertyException
PropertyTypevalidateValue in class PropertyType<String>propertyName - the name of the property used for logging purposes. To uniquely identify the Property with validation issues.value - the string representation of the propertyPropertyException - if the conversion failed.public void validateConstraints(String propertyName) throws PropertyException
PropertyTypevalidateConstraints in class PropertyType<String>propertyName - the name of the property used for logging purposes, to
identify the unique property which PropertyType has constraint
issues.PropertyException - if the constraints have invalid/conflicting values.Property.validate()