public class XML extends Type
| Modifier and Type | Field and Description |
|---|---|
static XML |
SINGLETON
The only instance of this class.
|
| Modifier | Constructor and Description |
|---|---|
protected |
XML(String name)
Constructs a new
XML instance. |
| Modifier and Type | Method and Description |
|---|---|
static Element |
fromStringForOptional(String string)
Constructs an
Element from the specified string. |
static Element |
fromStringForRequired(String string)
Constructs an
Element from the specified
non-null string. |
protected Object |
fromStringImpl(String string)
Converts from a
String to an instance of the value class
for this type (implementation method). |
String |
getDescription()
Retrieves the description of this type.
|
protected boolean |
isValidValueImpl(String value)
Determines if the specified
String value is considered
valid for this type (implementation method). |
static String |
toString(Element element)
Converts the specified
Element to a string. |
String |
toString(Object value)
Generates a string representation of the specified value for this type.
|
checkValue, fromString, getName, getValueClass, isValidValue, toStringpublic static final XML SINGLETON
null.protected XML(String name)
XML instance.
This constructor is protected to be used by XMLType.public static Element fromStringForRequired(String string) throws IllegalArgumentException, TypeValueException
Element from the specified
non-null string.string - the string to convert, cannot be null.Element object, never null.IllegalArgumentException - if string == null.TypeValueException - if the specified string does not represent a valid value for this
type.public static Element fromStringForOptional(String string) throws TypeValueException
Element from the specified string.string - the string to convert, can be null.Element, or null if
string == null.TypeValueException - if the specified string does not represent a valid value for this
type.protected boolean isValidValueImpl(String value)
TypeString value is considered
valid for this type (implementation method).
This method is called from Type.isValidValue(String). When
called from that method, it is guaranteed that the argument is not
null.
Type returns
true.isValidValueImpl in class Typevalue - the String value that should be checked for validity,
never null.true if and only if the specified String
value is valid, false otherwise.protected final Object fromStringImpl(String string) throws TypeValueException
TypeString to an instance of the value class
for this type (implementation method).
This method is not required to check the validity of the specified
value (since Type.isValidValueImpl(String) should have been called
before) but if it does, then it may throw a TypeValueException.
fromStringImpl in class Typestring - the string to convert to an instance of the value class, guaranteed
to be not null and guaranteed to have been passed to
Type.isValidValueImpl(String) without getting an exception.null.TypeValueException - if string is considered to be an invalid value for this
type.public final String toString(Object value) throws IllegalArgumentException, ClassCastException, TypeValueException
TypeType.getValueClass()). Also, it may have to fall within a
certain range of valid values, depending on the type.
The default implementation of this method in class Type does
the following:
value == null then it throws an
IllegalArgumentException;
getValueClass().isInstance(value) == false then
it throws a ClassCastException;
value.Object.toString().
toString in class Typevalue - the value, cannot be null.null.IllegalArgumentException - if value == null.ClassCastException - if getValueClass().isInstance(value) == false.TypeValueException - if the specified value is not in the allowed range.public static String toString(Element element)
Element to a string.element - the XML fragment to convert, can be null.null if and only if value == null.public String getDescription()
TypegetDescription in class Typenull.See http://www.xins.org/.