Package eu.bandm.tools.tdom.runtime
Class EnumerationAttribute<V extends Enum<V> & EnumerationValue>
java.lang.Object
eu.bandm.tools.tdom.runtime.TypedNode<TypedExtension>
eu.bandm.tools.tdom.runtime.TypedAttribute<V>
eu.bandm.tools.tdom.runtime.EnumerationAttribute<V>
- Direct Known Subclasses:
Attr_align,Attr_checked,Attr_dir,Attr_disabled,Attr_multiple,Attr_readonly,Attr_selected,Attr_valign,Element_a.Attr_shape,Element_area.Attr_nohref,Element_area.Attr_shape,Element_bdo.Attr_dir,Element_button.Attr_type,Element_form.Attr_method,Element_img.Attr_ismap,Element_input.Attr_type,Element_int.Attr_format,Element_object.Attr_declare,Element_option.Attr_required,Element_optionlist.Attr_defaultSorting,Element_optionlist.Attr_fragmentedLists,Element_optionlist.Attr_setterFunctions,Element_param.Attr_valuetype,Element_pre.Attr_xml_space,Element_rep.Attr_kind,Element_script.Attr_defer,Element_script.Attr_xml_space,Element_style.Attr_xml_space,Element_table.Attr_frame,Element_table.Attr_rules,Element_td.Attr_scope,Element_th.Attr_scope
public abstract class EnumerationAttribute<V extends Enum<V> & EnumerationValue>
extends TypedAttribute<V>
Base class for all generated classes which realize an Attribute with an
"enumeration type", like
<!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.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.bandm.tools.tdom.runtime.TypedAttribute
TypedAttribute.__PreAtts, TypedAttribute.SafeValuesNested classes/interfaces inherited from class eu.bandm.tools.tdom.runtime.TypedNode
TypedNode.ParseListener<E extends TypedElement<?,?>> -
Field Summary
Fields inherited from class eu.bandm.tools.tdom.runtime.TypedAttribute
__preAtts, emptyAttributes, mutable, safeValues, specified, value -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedEnumerationAttribute(TypedAttribute.SafeValues flag, V value) This variant may only be invoked by generated code if attribute is #IMPLIED and not #FIXED.protectedEnumerationAttribute(@Opt String value) protectedEnumerationAttribute(V value) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckValue(V value) Check routine for the validity of the attributes' intended value.(package private) final voiddecode(DecodingInputStream in, TypedExtension ext) DOCUMENT MEfinal voidencode(EncodingOutputStream out, TypedExtension ext) Abstract fall-back method which MUST be overridden and always throws an Exception.protected <V extends Enum<V>>
Vfind(Map<String, ? extends V> items, Attributes attrs, NamespaceName name) final StringgetStringValue(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.The definition text for the "type" of the attribute in the original DTD.Will be overridden in the generated code by a method which returns the dedicated value class.Returns a map from the external representations as appearing in the DTD to the enumeration items of the value's type.voidvoidsetValue(V newValue, TypedAttribute.SafeValues flag) Internal use only.Methods inherited from class eu.bandm.tools.tdom.runtime.TypedAttribute
assertSetAttrValid, assertSetAttrValid, checkRequired, clearValue, find, find, getDefaultValue, getLocalName, getNamespaceName, getNamespaceURI, getStringValue, getTagName, getValue, isFixed, isOptional, isRequired, isSpecified, makeUnspecified, put, setValueMethods inherited from class eu.bandm.tools.tdom.runtime.TypedNode
asBigDecimal, 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, setLocation
-
Constructor Details
-
EnumerationAttribute
protected EnumerationAttribute() -
EnumerationAttribute
- Throws:
TdomAttributeSyntaxException
-
EnumerationAttribute
- Throws:
TdomAttributeSyntaxException
-
EnumerationAttribute
This variant may only be invoked by generated code if attribute is #IMPLIED and not #FIXED. In this case no TdomAttributeSyntaxException can be thrown, because all Enumeration values and null are permitted.
-
-
Method Details
-
checkValue
Check routine for the validity of the attributes' intended value. Is a call-back, implemented by the sub-classes. Is called only here, by two constructors and theTypedAttribute.setValue(V)method. The valuenullmeans "absent" for#IMPLIEDattributes and passes the test.- Specified by:
checkValuein classTypedAttribute<V extends Enum<V> & EnumerationValue>- Parameters:
value- the value to test; maybe null.
-
setValue
- Throws:
TdomAttributeSyntaxException
-
setValue
Internal use only. Is called by the generated code iff attribute is #IMPLIED, because then never aTdomAttributeSyntaxExceptionwill be thrown. -
getTypeString
The definition text for the "type" of the attribute in the original DTD.- Specified by:
getTypeStringin classTypedAttribute<V extends Enum<V> & EnumerationValue>
-
getValueClass
Will be overridden in the generated code by a method which returns the dedicated value class.- Returns:
- the Class object for the values of this attribute.
-
getValueMap
Returns a map from the external representations as appearing in the DTD to the enumeration items of the value's type. Will be overridden by the generated code. -
getStringValue
Returns the textual representation of a possible attribute value (not null), as it would be contained literally in a possible XML text representation. Since the textual representation of a String is the string itself, this method is relevant for enumeration types only (Later: also for "entity" types, but these are not yet supported.)- Specified by:
getStringValuein classTypedAttribute<V extends Enum<V> & EnumerationValue>- Returns:
- (never null) the textual representation of this attribute value, as it would be contained literally in a possible XML text representation.
-
encode
Description copied from class:TypedNodeAbstract fall-back method which MUST be overridden and always throws an Exception.- Specified by:
encodein classTypedNode<TypedExtension>- Throws:
IOException
-
decode
final void decode(DecodingInputStream in, TypedExtension ext) throws IOException, TdomAttributeSyntaxException Description copied from class:TypedAttributeDOCUMENT ME- Specified by:
decodein classTypedAttribute<V extends Enum<V> & EnumerationValue>- Throws:
IOExceptionTdomAttributeSyntaxException
-
find
protected <V extends Enum<V>> V find(Map<String, ? extends V> items, Attributes attrs, NamespaceName name) throws TdomAttributeSyntaxException- Throws:
TdomAttributeSyntaxException
-