public class MimeTypePropertyType extends PropertyType<MimeType>
javax.activation.MimeType
. aMimeType.match(bMimeType)
. Constructor Example | Comments | ||
---|---|---|---|
Property<MimeType> A_PROPERTY = |
Default value is null . |
||
Property<MimeType> A_PROPERTY = |
Default value is new MimeType("text/html") . |
||
Type of value(s) | Examples | Result | Comments |
Valid | text/html | ew MimeType("text/html") | Validate successfully. |
Invalid | cow | null |
Validate will throw an exception. The resulting value is null . |
Invalid | «only spaces» | null |
|
Invalid | null |
defaultValue OR null |
Validate will throw an exception. Return default value if set, otherwise null . |
ContentType
,
ContentType.getAsMimeType()
,
ContentType.parse(String)
,
ContentType.convert(MimeType)
,
Serialized FormModifier and Type | Field and Description |
---|---|
static String |
TYPE
The type name string constant of MimeTypePropertyType.
|
Constructor and Description |
---|
MimeTypePropertyType()
Default constructor, with null as default value.
|
MimeTypePropertyType(MimeType defaultValue)
Constructor.
|
MimeTypePropertyType(String defaultValue)
Constructor, using a string as default value.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
equalsMimeType(MimeType mt1,
MimeType mt2)
Since MimType do not implements a property Equals method.
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
MimeType |
validateValue(String propertyName,
String value)
Validates the MimeType using the new MimeType(rawvalue) method.
|
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 MimeTypePropertyType()
null as default value.
-
MimeTypePropertyType
public MimeTypePropertyType(MimeType defaultValue)
Constructor.
- Parameters:
defaultValue
- the default MimeType value.
-
MimeTypePropertyType
public MimeTypePropertyType(String defaultValue)
Constructor, using a string as default value.
- Parameters:
defaultValue
- the default value as String, if not valid an error is logged and null
used.
-
Method Detail
-
getRestrictions
public List<String> getRestrictions()
Description copied from class: PropertyType
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
This includes a description for the default value, if the default do not
it self parse the validation of the type, the exception is appended to
the description.
- Specified by:
getRestrictions
in class PropertyType<MimeType>
- Returns:
- the restrictions of the PropertyType as a list of strings.
-
validateValue
public MimeType validateValue(String propertyName,
String value)
throws PropertyException
Validates the MimeType using the new MimeType(rawvalue) method.
- Specified by:
validateValue
in class PropertyType<MimeType>
- Parameters:
propertyName
- the name of the property used for logging purposes. To uniquely identify the Property with validation issues.
value
- the string representation of the property
- Returns:
- the typed converted value.
- Throws:
PropertyException
- if the conversion failed.
- See Also:
MimeType.MimeType(String)
-
equalsMimeType
public static boolean equalsMimeType(MimeType mt1,
MimeType mt2)
Since MimType do not implements a property Equals method. Here is a method for it.
- Parameters:
mt1
-
mt2
-
- Returns:
true
if both mt1 and mt2 is null
, false
if either is null
, otherwise a match is returned.
- See Also:
MimeType.match(MimeType)