Package eu.bandm.tools.tdom.runtime
Class EnumerationAttribute<V extends java.lang.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 java.lang.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 aTdomAttributeSyntaxException
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 aEnumerationValue.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.SafeValues
-
Nested 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
Constructors Modifier Constructor Description protected
EnumerationAttribute()
protected
EnumerationAttribute(@Opt java.lang.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)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkValue(V value)
Check routine for the validity of the attributes' intended value.(package private) void
decode(DecodingInputStream in, TypedExtension ext)
DOCUMENT MEvoid
encode(EncodingOutputStream out, TypedExtension ext)
Abstract fall-back method which MUST be overridden and always throws an Exception.protected <V extends java.lang.Enum<V>>
Vfind(java.util.Map<java.lang.String,? extends V> items, org.xml.sax.Attributes attrs, NamespaceName name)
java.lang.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.java.lang.String
getTypeString()
The definition text for the "type" of the attribute in the original DTD.protected abstract java.lang.Class<V>
getValueClass()
Will be overridden in the generated code by a method which returns the dedicated value class.protected abstract java.util.Map<java.lang.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(java.lang.String value)
void
setValue(V newValue, TypedAttribute.SafeValues flag)
Internal use only.-
Methods inherited from class eu.bandm.tools.tdom.runtime.TypedAttribute
assertSetAttrValid, checkRequired, clearValue, find, find, getDefaultValue, getLocalName, getNamespaceName, getNamespaceURI, getStringValue, getTagName, getValue, isFixed, isOptional, isRequired, isSpecified, makeUnspecified, put, setValue
-
Methods 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 Detail
-
EnumerationAttribute
protected EnumerationAttribute()
-
EnumerationAttribute
protected EnumerationAttribute(@Opt @Opt java.lang.String value) throws TdomAttributeSyntaxException
- Throws:
TdomAttributeSyntaxException
-
EnumerationAttribute
protected EnumerationAttribute(@Opt V value) throws TdomAttributeSyntaxException
- Throws:
TdomAttributeSyntaxException
-
EnumerationAttribute
protected EnumerationAttribute(TypedAttribute.SafeValues flag, @Opt V value)
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 Detail
-
checkValue
protected void checkValue(@Opt V value)
Description copied from class:TypedAttribute
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 the#set_value(V)
method. The valuenull
means "absent" for#IMPLIED
attributes and passes the test.- Specified by:
checkValue
in classTypedAttribute<V extends java.lang.Enum<V> & EnumerationValue>
- Parameters:
value
- the value to test; maybe null.
-
setValue
public void setValue(java.lang.String value) throws TdomAttributeSyntaxException
- Throws:
TdomAttributeSyntaxException
-
setValue
public void setValue(@Opt V newValue, TypedAttribute.SafeValues flag)
Internal use only. Is called by the generated code iff attribute is #IMPLIED, because then never aTdomAttributeSyntaxException
will be thrown.
-
getTypeString
public java.lang.String getTypeString()
Description copied from class:TypedAttribute
The definition text for the "type" of the attribute in the original DTD.- Specified by:
getTypeString
in classTypedAttribute<V extends java.lang.Enum<V> & EnumerationValue>
-
getValueClass
protected abstract java.lang.Class<V> 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
protected abstract java.util.Map<java.lang.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. Will be overridden by the generated code.
-
getStringValue
public final java.lang.String getStringValue(V v)
Description copied from class:TypedAttribute
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:
getStringValue
in classTypedAttribute<V extends java.lang.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
public final void encode(EncodingOutputStream out, TypedExtension ext) throws java.io.IOException
Description copied from class:TypedNode
Abstract fall-back method which MUST be overridden and always throws an Exception.- Specified by:
encode
in classTypedNode<TypedExtension>
- Throws:
java.io.IOException
-
decode
final void decode(DecodingInputStream in, TypedExtension ext) throws java.io.IOException, TdomAttributeSyntaxException
Description copied from class:TypedAttribute
DOCUMENT ME- Specified by:
decode
in classTypedAttribute<V extends java.lang.Enum<V> & EnumerationValue>
- Throws:
java.io.IOException
TdomAttributeSyntaxException
-
find
protected <V extends java.lang.Enum<V>> V find(java.util.Map<java.lang.String,? extends V> items, org.xml.sax.Attributes attrs, NamespaceName name) throws TdomAttributeSyntaxException
- Throws:
TdomAttributeSyntaxException
-
-