public class URLPropertyType extends PropertyType<URL> implements MarkerProxyDependent
java.net.URL
. new URL(string)
and make a regular expression check.URLUtils.construct
, which hides the cheched exception from URL constructor.
Constructor Example | Comments | ||
---|---|---|---|
Property<URL> A_PROPERTY = |
Creates URLPropertyType with no default value,no protocol restrictions, and using DefaultURLValidator. | ||
Property<URL> A_PROPERTY = |
Creates URLPropertyType with no default value, the protocol must be "http", and using DefaultURLValidator. | ||
Property<URL> A_PROPERTY = |
Creates URLPropertyType with default value "http://www.jp.dk" and the protocol must be "http"; and using DefaultURLValidator | ||
Property<URL> A_PROPERTY = |
Creates URLPropertyType with no default value and the protocol must be either "http" or "ftp", and using DefaultURLValidator | ||
Property<URL> A_PROPERTY = |
|||
Type of value(s) | Examples | Result | Comments |
Valid | http://www.cnn.com | new URL("http://www.cnn.com") | 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 . |
URL.URL(String)
,
DefaultURLValidator
,
URLValidator
,
URLUtils.construct(String)
,
Serialized FormModifier and Type | Field and Description |
---|---|
static URLValidator |
NO_URL_VALIDATOR
Static menber instance of NoURLValidator, where no URL validation is performed.
|
static String |
REGEX_URL
The regular expression use to validate the URL with.
|
static String |
TYPE
The type name string constant of URLPropertyType.
|
Constructor and Description |
---|
URLPropertyType()
Default constructor, no default value and no protocol constraints and DefaultURLValidator used.
|
URLPropertyType(String protocol)
Constructor with protocol constraint and DefaultURLValidator used.
|
URLPropertyType(String[] protocols)
Constructor with DefaultURLValidator used.
|
URLPropertyType(String[] protocols,
URLValidator urlValidator)
Constructor.
|
URLPropertyType(String defaultValue,
String[] protocols)
Constructor, using
URLUtils.construct(String) to construct default URL and using DefaultURLValidator. |
URLPropertyType(String defaultValue,
String[] protocols,
URLValidator urlValidator)
Constructor, using
URLUtils.construct(String) to construct default URL. |
URLPropertyType(String defaultValue,
String protocol,
URLValidator urlValidator)
Constructor, using
URLUtils.construct(String) to construct default URL. |
URLPropertyType(String protocol,
URLValidator urlValidator)
Constructor with protocol constraint.
|
URLPropertyType(URL defaultValue)
Constructor.
|
URLPropertyType(URL defaultValue,
String protocol)
Constructor with DefaultURLValidator used.
|
URLPropertyType(URL defaultValue,
String[] protocols)
Constructor with DefaultURLValidator used.
|
URLPropertyType(URL defaultValue,
String[] protocols,
URLValidator urlValidator)
Constructor.
|
URLPropertyType(URL defaultValue,
String protocol,
URLValidator urlValidator)
Constructor.
|
URLPropertyType(URL defaultValue,
URLValidator urlValidator)
Constructor.
|
URLPropertyType(URLValidator urlValidator)
Constructor with validation connection constraint.
|
Modifier and Type | Method and Description |
---|---|
String[] |
getProtocols()
Gets the valid protocols.
|
Proxy |
getProxy()
Gets the proxy setup for this URL, default is null.
|
protected Proxy |
getProxyToUse()
Determines what proxy to use in the validation URL Connection.
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
URLValidator |
getURLValidator()
Gets the implementation of the URLValidator, if
null no connection validation is performed. |
void |
setProtocol(String protocol)
Set valid protocol
|
void |
setProtocols(String[] protocols)
Set valid protocols.
|
void |
setProxy(Proxy proxy)
Set a specific proxy setup for this URL.
|
void |
setURLValidator(URLValidator urlValidator)
Sets the implementation of the URLValidator, if
null no connection validation is performed. |
URL |
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_URL
public static final URLValidator NO_URL_VALIDATOR
NoURLValidator
public URLPropertyType()
public URLPropertyType(URLValidator urlValidator)
urlValidator
- implementation of the URLVaildator. If null
no validation is performed.DefaultURLValidator
,
NoURLValidator
,
URLValidator
public URLPropertyType(String protocol)
protocol
- the protocol which the URL must start with, not case sensitive.public URLPropertyType(String protocol, URLValidator urlValidator)
protocol
- the protocol which the URL must start with, not case sensitive.urlValidator
- implementation of the URLValidator. If null
no validation is performed.DefaultURLValidator
,
NoURLValidator
,
URLValidator
public URLPropertyType(URL defaultValue)
defaultValue
- default value returned if property value is undefined.public URLPropertyType(URL defaultValue, URLValidator urlValidator)
defaultValue
- default value returned if property value is undefined.urlValidator
- implementation of the URLValidator. If null
no validation is performed.DefaultURLValidator
,
NoURLValidator
,
URLValidator
public URLPropertyType(URL defaultValue, String protocol, URLValidator urlValidator)
defaultValue
- default value returned if property value is undefined.protocol
- the protocol which the URL must start with, not case sensitive.urlValidator
- implementation of the URLValidator. If null
no validation is performed.DefaultURLValidator
,
NoURLValidator
,
URLValidator
public URLPropertyType(String[] protocols)
protocols
- the protocols which the URL must start with one of them, not case sensitive.public URLPropertyType(String[] protocols, URLValidator urlValidator)
protocols
- the protocols which the URL must start with one of them, not case sensitive.urlValidator
- implementation of the URLValidator. If null
no validation is performed.DefaultURLValidator
,
NoURLValidator
,
URLValidator
public URLPropertyType(URL defaultValue, String[] protocols)
defaultValue
- default value returned if property value is undefined, and connection validation is performed.protocols
- the protocols which the URL must start with one of them, not case sensitive.public URLPropertyType(URL defaultValue, String protocol)
defaultValue
- default value returned if property value is undefined, and connection validation is performed.protocol
- the protocol which the URL must start with, not case sensitive.public URLPropertyType(URL defaultValue, String[] protocols, URLValidator urlValidator)
defaultValue
- default value returned if property value is undefined.protocols
- the protocols which the URL must start with one of them, not case sensitive.urlValidator
- implementation of the URLValidator. If null
no validation is performed.DefaultURLValidator
,
NoURLValidator
,
URLValidator
public URLPropertyType(String defaultValue, String[] protocols, URLValidator urlValidator)
URLUtils.construct(String)
to construct default URL.defaultValue
- the URL as a string using URLUtils.construct(String)
which incapsulate the MalformedURLException
protocols
- the protocols which the URL must start with one of them, not case sensitive.urlValidator
- implementation of the URLValidator. If null
no validation is performed.URLUtils.construct(String)
,
DefaultURLValidator
,
NoURLValidator
,
URLValidator
public URLPropertyType(String defaultValue, String[] protocols)
URLUtils.construct(String)
to construct default URL and using DefaultURLValidator.defaultValue
- the URL as a string using URLUtils.construct(String)
which incapsulate the MalformedURLException
protocols
- the protocols which the URL must start with one of them, not case sensitive.URLUtils.construct(String)
public URLPropertyType(String defaultValue, String protocol, URLValidator urlValidator)
URLUtils.construct(String)
to construct default URL.defaultValue
- the URL as a string using URLUtils.construct(String)
which incapsulate the MalformedURLException
protocol
- the protocol which the URL must start with, not case sensitive.urlValidator
- implementation of the URLValidator. If null
no validation is performed.URLUtils.construct(String)
,
DefaultURLValidator
,
NoURLValidator
,
URLValidator
public String[] getProtocols()
public void setProtocols(String[] protocols)
protocols
- the protocols which the URL must start with one of them, not case sensitive. If null or empty, protocols will not be used in the validation.public void setProtocol(String protocol)
protocol
- the protocol which the URL must start with, not case sensitive. If null or empty, protocol will not be used in the validation.public URLValidator getURLValidator()
null
no connection validation is performed.public void setURLValidator(URLValidator urlValidator)
null
no connection validation is performed.urlValidator
- the URLValidator implementation.public Proxy getProxy()
getProxy
in interface MarkerProxyDependent
public void setProxy(Proxy proxy)
proxy
- public URL validateValue(String propertyName, String value) throws PropertyException
PropertyType
validateValue
in class PropertyType<URL>
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<URL>
protected Proxy getProxyToUse()
Proxy.NO_PROXY
is used.getProxy()
,
PropertyFrameworkGlobals.getDefaultProxy()
,
Proxy.NO_PROXY