Class NmTokenAttribute
- Direct Known Subclasses:
Attr_hreflang
,Attr_lang
,Attr_xml_lang
,Element_a.Attr_name
,Element_bool.Attr_default
,Element_comment.Attr_name
,Element_entry.Attr_lang
,Element_enum.Attr_default
,Element_enum.Attr_name
,Element_enumeration.Attr_name
,Element_enumitem.Attr_compilable
,Element_enumset.Attr_name
,Element_enumSetContains.Attr_number
,Element_enumSetContains.Attr_option
,Element_enumSetContains.Attr_value
,Element_float.Attr_default
,Element_int.Attr_default
,Element_map.Attr_name
,Element_object.Attr_name
,Element_optarg.Attr_number
,Element_optarg.Attr_option
,Element_option.Attr_abbrev
,Element_option.Attr_name
,Element_text.Attr_lang
,Element_text.Attr_lang
,IdAttribute
,IdRefAttribute
NMTOKEN
" type.
Offers additionally static methods for checking several flavours of
Token definitions from XML, which can be used explicitly by user code, and
are used by this and other attribute base classes.-
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected static boolean
_checkToken
(@Opt String token, boolean mustBeName) Checks whether the argument fits the rules for Nmtoken and Name in XML1.0.static void
checkNameToken
(@Opt String token) Check whether the argument is a legal value for a "Name" token, according to [XML 1.0].static void
checkNCName
(@Opt String token) Check whether the argument is a legal value for a "Name" token and does not contain a colon ":".static void
checkNmToken
(@Opt String token) Check whether the argument is a legal value for "Nmtoken".static void
checkPITarget
(@Opt String token) Check whether the argument is a legal value for a "Name" token and does not start with the three characters "XML" in any combination of upper/lower case.protected void
checkValue
(@Opt String value) Check routine for the validity of the attributes' intended value.(package private) final void
decode
(DecodingInputStream in, TypedExtension ext) DOCUMENT MEfinal void
encode
(EncodingOutputStream out, TypedExtension ext) Abstract fall-back method which MUST be overridden and always throws an Exception.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.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, 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 Details
-
NmTokenAttribute
protected NmTokenAttribute() -
NmTokenAttribute
- Throws:
TdomAttributeSyntaxException
-
-
Method Details
-
checkValue
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 theTypedAttribute.setValue(V)
method. The valuenull
means "absent" for#IMPLIED
attributes and passes the test.- Specified by:
checkValue
in classTypedAttribute<String>
- Parameters:
value
- the value to test; maybe null.- Throws:
TdomAttributeSyntaxException
- iff the value does not match the type of the XML attribute, including a forbidden Null.
-
getTypeString
Description copied from class:TypedAttribute
The definition text for the "type" of the attribute in the original DTD.- Specified by:
getTypeString
in classTypedAttribute<String>
-
_checkToken
Checks whether the argument fits the rules for Nmtoken and Name in XML1.0. For details seecheckNmToken(java.lang.String)
.- Parameters:
token
- the string to check.mustBeName
- true if the stricter rules for name are checked, not onnly those for NmTokenAttribute.- Returns:
- true on success. Null and empty string fail the test.
-
checkNmToken
Check whether the argument is a legal value for "Nmtoken". This check method throws an IllegalArgumentException, or returns silently.The flavours of XML names and their relations
The rules for a correct xml Nmtoken or xml Name are crucial and complicated, see [XML 1.0], grammar rules [5] and [7].
Grammar rule [7] defines NmToken as a non-empty string from letters, digits and few punctation characters. XML spec lists about HUNDRED of ranges which can serve as "Letter", either defined as "BaseChar" or "Ideographic". [XML 1.0:rules 84-86].
FIXME CHECK XML 1.1 !!
Instead of "Letter" we useCharacter.isJavaIdentifierStart(char)
as an APPROXIMATION, and for "Letter or Digit" we useCharacter.isJavaIdentifierPart(char)
. But both after excluding the "dollar" sign.
Names are defined by rule [5]. The difference between Nmtokens and Names is, that the very first character of a name must be a "letter" or "_" or ":".
Names are checked bycheckNameToken(String)
.
The Name production must be adhered to by the value of all attributes of type Id, IdRef, IdRefs, Entity, Entities and Notation. (The value for "notation" must be defined somewhere else as a "NOTATION"; this is a further *global* consistency condition currently not checked by tdom)
The weaker Nmtoken can be used for NmToken, NmTokens and Enumeration values.
Further there is NCName (="No-Colon-Name") [NSinXML 1.0:rule 4], which is a Name not containing a colon ":".
NCNames are checked bycheckNCName(String)
.
Further there is PiTarget, which is a Name token which does not start with "(X|x)(M|m)(L|l)" in any combination.
PiTargets are checked bycheckPITarget(String)
.
Further there are the un-reserved namespace prefixes, which are NCNames and do not start with "(X|x)(M|m)(L|l)" in any combination. [NSinXML: NSC:Reserved Prefixes and Namespace Names].- Parameters:
token
- The token to check, Null passes the test.- Throws:
IllegalArgumentException
-
checkNameToken
Check whether the argument is a legal value for a "Name" token, according to [XML 1.0].
SeecheckNmToken(String)
for details.- Parameters:
token
- The token to check, Null passes the test.- Throws:
IllegalArgumentException
-
checkNCName
Check whether the argument is a legal value for a "Name" token and does not contain a colon ":".
(This is currently not used by us, but defined by [NSinXML 1.0:rule 4], and addtionally REQUIRED FOR ALL Attribute Values of type Id/IdRef/IdRefs/Entity/Entities/Notation for a "namespace-valid" document, see [NSinXML 1.0:section 7, last sentence],
SeecheckNmToken(String)
for further details of all check methods in this class.- Parameters:
token
- The token to check, Null passes the test.- Throws:
IllegalArgumentException
-
checkPITarget
Check whether the argument is a legal value for a "Name" token and does not start with the three characters "XML" in any combination of upper/lower case. These can be used as "PI targets" and are allowed as prefices in namespace declarations. See [XML1.0:section 2.6] and [NSinXML 1.0:section 3, last sentence].
SeecheckNmToken(String)
for further details of all check methods in this class.- Parameters:
token
- The token to check, Null and empty string pass the test.- Throws:
IllegalArgumentException
- when test fails
-
encode
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:
IOException
-
decode
final void decode(DecodingInputStream in, TypedExtension ext) throws TdomAttributeSyntaxException, IOException Description copied from class:TypedAttribute
DOCUMENT ME- Specified by:
decode
in classTypedAttribute<String>
- Throws:
TdomAttributeSyntaxException
IOException
-
getStringValue
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<String>
- Returns:
- (never null) the textual representation of this attribute value, as it would be contained literally in a possible XML text representation.
-