public class URIPropertyType extends PropertyType<URI>
java.net.URI
. new URI(string)
and make a regular expression check.Constructor Example | Comments | ||
---|---|---|---|
Property<URI> A_PROPERTY = |
Creates URIPropertyType with no default value and no protocol restrictions. | ||
Property<URI> A_PROPERTY = |
Creates URIPropertyType with no default value and the protocol must be "http". | ||
Property<URI> A_PROPERTY = |
Creates URIPropertyType with default value "http://www.jp.dk" and the protocol must be "http". | ||
Property<URI> A_PROPERTY = |
Creates URIPropertyType with no default value and the protocol must be either "ldap" or "ldaps". | ||
Property<URI> A_PROPERTY = |
Creates URIPropertyType with default value "http://www.jp.dk" and the protocol must be either "http" or "ftp". | ||
Type of value(s) | Examples | Result | Comments |
Valid | http://www.cnn.com | new URI("http://www.cnn.com") | Validate successfully. |
Valid | ldaps://aserver.test.det.rm.com:636 | new URI("ldaps://aserver.test.det.rm.com:636") | Validate successfully. |
Invalid | cow | null |
Validate will throw an exception. The resulting value is null . |
Invalid | «empty string» | null |
|
Invalid | «empty string after trim» | null |
|
Invalid | 10.0.0.1 | null |
Validate will throw an exception. The resulting value is null . No Protocol. |
Invalid | null |
defaultValue OR null |
Validate will throw an exception. Return default value if set, otherwise null . |
URI
,
Serialized FormModifier and Type | Field and Description |
---|---|
static String |
REGEX_URI
The regular expression use to validate the URI with.
|
static String |
TYPE
The type name string constant of URIPropertyType.
|
Constructor and Description |
---|
URIPropertyType()
Default constructor, no default value and no schemes constraints.
|
URIPropertyType(String scheme)
Constructor with scheme constraint.
|
URIPropertyType(String[] schemes)
Constructor.
|
URIPropertyType(URI defaultValue)
Constructor.
|
URIPropertyType(URI defaultValue,
String scheme)
Constructor.
|
URIPropertyType(URI defaultValue,
String[] schemes)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
String[] |
getSchemes()
Gets the valid schemas
|
void |
setSchema(String schema)
Sets the valid schema.
|
void |
setSchemes(String[] schemes)
Sets the valid schemas.
|
URI |
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, validateConstraints, validateNullType
public static final String TYPE
public static final String REGEX_URI
public URIPropertyType()
public URIPropertyType(String scheme)
scheme
- the scheme the URI must start with, not case sensitive.public URIPropertyType(URI defaultValue)
defaultValue
- default value returned if property value is undefined.public URIPropertyType(URI defaultValue, String scheme)
defaultValue
- default value returned if property value is undefined.scheme
- the scheme the URI must start with, not case sensitive.public URIPropertyType(String[] schemes)
schemes
- the schemes the URI must start with, not case sensitive.public String[] getSchemes()
public void setSchemes(String[] schemes)
schemes
- the schemas which the URL must start with one of them, not case sensitive. If null or empty, schemas will not be used in the validation.public void setSchema(String schema)
schema
- the schema which the URL must start with, not case sensitive. If null or empty, schema will not be used in the validation.public URI validateValue(String propertyName, String value) throws PropertyException
PropertyType
validateValue
in class PropertyType<URI>
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 List<String> getRestrictions()
PropertyType
getRestrictions
in class PropertyType<URI>