Package eu.bandm.tools.tdom.runtime
Class TypedDocument<E extends TypedElement<E,X>,X extends TypedExtension>
java.lang.Object
eu.bandm.tools.tdom.runtime.TypedNode<X>
eu.bandm.tools.tdom.runtime.TypedDocument<E,X>
public abstract class TypedDocument<E extends TypedElement<E,X>,X extends TypedExtension>
extends TypedNode<X>
Fundamental base class for all Elements which can serve as a "document element"
/ "root element".
One(1) immediate subclass of this class with the name "
Document
"
will be generated in each tdom model.
Then for every element declaration (e.g. "EL") which is declared as
"public
" by a PI in the underlying DTD, a subclass of this class
is generated called "Document_EL
".
This class will provide the factory methods for converting sources into
complete document instances and other global methods. Since these rely on the
generated classes, they cannot be found here, but only in the generated code.
They will look aprox. like ...
Document_EL (Element_EL) {..} // = bottom-up explicit constructor Document_EL ((Reminder: "SAXEventStream
,TypedExtension
) {..} // = for parsing a complete document from the sax input Document_EL (org.w3c.dom.Document, Extension) {..} // = for converting one complete DOM model into a tdom model ElementDictionary<Element> createDictionary() {..} // = for linking all id and idref attributes
Element
" is the name of the generated class serving as
common base class of all element classes.)-
Nested Class Summary
Nested classes/interfaces inherited from class eu.bandm.tools.tdom.runtime.TypedNode
TypedNode.ParseListener<E extends TypedElement<?,
?>> -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate a dictionary which maps all Elements with id fields to the id values, and vice versa.protected abstract E
decode
(DecodingInputStream in, X ext) final void
decode
(InputStream in, X ext) void
Must be called explicitly by the user, after he/she has created the document object.void
encode
(EncodingOutputStream out, X ext) Abstract fall-back method which MUST be overridden and always throws an Exception.void
encode
(OutputStream out, X ext) protected void
Writes out the comments and pis.void
end
(ContentHandler contentHandler, LexicalHandler lexicalHandler) Send the closing sax events to the two drains.final TypedDTD
getDTD()
Returns the global DTD information compiled into this tdom model.Gives access to the Comments and PIs after the opening tag and before the close tag.Returns the root element as an instance of TypedElement, so this method works for different tdom models.protected int
void
setGenerationComment
(@Opt String generationComment) Will be emitted when this document is dumped to any SAX handler.void
start
(ContentHandler contentHandler, LexicalHandler lexicalHandler) Send the opening sax events to the two drains.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
-
Field Details
-
root
-
generationComment
-
STRING_ETHEREAL_SEPARATOR
- See Also:
-
-
Constructor Details
-
TypedDocument
-
-
Method Details
-
getDTD
Returns the global DTD information compiled into this tdom model. This includes reflexive data about the generated base classes.- Returns:
- the global DTD information compiled into this tdom model.
-
getEtherealContainer
Gives access to the Comments and PIs after the opening tag and before the close tag.- Returns:
- (never null) access to the Comments and PIs before the very first element's opening tag, and after its closing tag.
-
setGenerationComment
Will be emitted when this document is dumped to any SAX handler. -
getGenerationComment
-
getTagIndex
protected int getTagIndex() -
getRootUntyped
Returns the root element as an instance of TypedElement, so this method works for different tdom models. -
encode
- Throws:
IOException
-
encode
Description copied from class:TypedNode
Abstract fall-back method which MUST be overridden and always throws an Exception.- Specified by:
encode
in classTypedNode<X extends TypedExtension>
- Throws:
IOException
-
decode
public final void decode(InputStream in, X ext) throws IOException, TdomContentException, TdomAttributeException -
decode
protected abstract E decode(DecodingInputStream in, X ext) throws IOException, TdomContentException, TdomAttributeException -
start
Send the opening sax events to the two drains. The events are theContentHandler.startDocument()
event, followed by the optional generationComment, followed by the leading comments fromgetEtherealContainer()
.- Throws:
SAXException
-
end
Send the closing sax events to the two drains. These are the trailing comments fromgetEtherealContainer()
, followed byContentHandler.endDocument()
.- Throws:
SAXException
-
createDictionary
Create a dictionary which maps all Elements with id fields to the id values, and vice versa. These Elements are identified by implementingIdentifiable
. The data are collected usingElementDictionary.addIfIdentifiable(TypedElement)
. See there for the exception conditions.- Throws:
HomonymousIdException
- seeElementDictionary
-
encodeEthereals
Writes out the comments and pis. Is called automatically when writing out a TypedDocument. (The decode part must be applied explicitly by the user.) -
decodeEthereals
Must be called explicitly by the user, after he/she has created the document object. (The invocation of the document creation method is via the generated "TypedDTD.createDocument_[XX](..)".)
-