@User public abstract class EnumerationAttribute<V extends Enum<V> & EnumerationValue> extends TypedAttribute<V>
<!ATTLIST e
f (a | b | ..c:d | e-_0123) #IMPLIED
>
For each such attribute a new enumeration type will be defined, as static inner
class of the attribute's class. This class is called "Value".
It will be used as the type parameter for the generated Attribute's class.
The methods are type-safe, as a TdomAttributeSyntaxException is only thrown
when an attribute is absent (null) and not #IMPLIED.
According to
[XML 1.0],
grammar rule [59], an Enumeration type consists of a set of "Nmtoken".
These are words made of letters, digits and few punctation characters.
But the items of the enumeration must be valid Java identifiers.
They are of the form
"Value_" + makeJavaName(s)
while that method replaces "." ":" and "-" by underscores.
The generated enumeration type will get a EnumerationValue.getStringValue() method
to re-translate any value into its original external representation.
The String arguments of the following methods but use this original wording
of the enumeration values.
TypedAttribute.__PreAtts, TypedAttribute.SafeValuesTypedNode.ParseListener<E extends TypedElement<?,?>>__preAtts, emptyAttributes, mutable, safeValues, specified, value| Modifier | Constructor and Description |
|---|---|
protected |
EnumerationAttribute() |
protected |
EnumerationAttribute(@Opt String value) |
protected |
EnumerationAttribute(TypedAttribute.SafeValues flag,
V value)
This variant may only be invoked by generated code if attribute is #IMPLIED
and not #FIXED.
|
protected |
EnumerationAttribute(V value) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkValue(V value)
Check routine for the validity of the attributes' intended value.
|
void |
encode(EncodingOutputStream out,
TypedExtension ext)
Abstract fall-back method which MUST be overridden and always throws an Exception.
|
protected <V extends Enum<V>> |
find(Map<String,? extends V> items,
Attributes attrs,
NamespaceName name) |
String |
getStringValue(V v)
Returns the textual representation of a possible attribute value (not null),
as it would be contained literally in a possible XML text representation.
|
String |
getTypeString()
The definition text for the "type" of the attribute in the original DTD.
|
protected abstract Class<V> |
getValueClass()
Will be overridden in the generated code by a method which
returns the dedicated value class.
|
protected abstract Map<String,? extends V> |
getValueMap()
Returns a map from the external representations as appearing in the DTD to
the enumeration items of the value's type.
|
void |
setValue(String value) |
void |
setValue(V newValue,
TypedAttribute.SafeValues flag)
Internal use only.
|
assertSetAttrValid, checkRequired, clearValue, find, find, getDefaultValue, getLocalName, getNamespaceName, getNamespaceURI, getStringValue, getTagName, getValue, isFixed, isOptional, isRequired, isSpecified, makeUnspecified, put, setValueasBigDecimal, asBigDecimal, asBigDecimal, asBigDecimal, asBigInteger, asBigInteger, asBigInteger, asBigInteger, asBoolean, asBoolean, asDouble, asDouble, asDouble, asDouble, asFloat, asFloat, asFloat, asFloat, asHexInt, asHexInt, asHexInt, asHexInt, asInt, asInt, asInt, asInt, asLong, asLong, asLong, asLong, asTrimmedString, asTrimmedString, asTrimmedString, asTrimmedString, checkPlus, checkPlus, checkStar, checkStar, checkStrict, encode, encodeOptional, encodePlus, encodePlus, encodeStar, encodeStar, extractEthereals, getLocation, getPCData, setLocation, setLocation, setLocationprotected EnumerationAttribute()
protected EnumerationAttribute(@Opt @Opt String value) throws TdomAttributeSyntaxException
TdomAttributeSyntaxExceptionprotected EnumerationAttribute(@Opt V value) throws TdomAttributeSyntaxException
TdomAttributeSyntaxExceptionprotected EnumerationAttribute(TypedAttribute.SafeValues flag, @Opt V value)
protected void checkValue(@Opt V value)
TypedAttribute#set_value(V) method.
The value null means "absent" for #IMPLIED attributes and passes the test.checkValue in class TypedAttribute<V extends Enum<V> & EnumerationValue>value - the value to test; maybe null.public void setValue(String value) throws TdomAttributeSyntaxException
TdomAttributeSyntaxExceptionpublic void setValue(@Opt V newValue, TypedAttribute.SafeValues flag)
TdomAttributeSyntaxException will be thrown.public String getTypeString()
TypedAttributegetTypeString in class TypedAttribute<V extends Enum<V> & EnumerationValue>protected abstract Class<V> getValueClass()
protected abstract Map<String,? extends V> getValueMap()
@User public final String getStringValue(V v)
TypedAttributegetStringValue in class TypedAttribute<V extends Enum<V> & EnumerationValue>public final void encode(EncodingOutputStream out, TypedExtension ext) throws IOException
TypedNodeencode in class TypedNode<TypedExtension>IOExceptionprotected <V extends Enum<V>> V find(Map<String,? extends V> items, Attributes attrs, NamespaceName name) throws TdomAttributeSyntaxException
TdomAttributeSyntaxExceptionsee also the complete user documentation .