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 attributesElement
" 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
Fields Modifier and Type Field Description protected E
root
static java.lang.String
STRING_ETHEREAL_SEPARATOR
-
Constructor Summary
Constructors Modifier Constructor Description protected
TypedDocument(TypedDTD dtd)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ElementDictionary<E,X>
createDictionary()
Create a dictionary which maps all Elements with id fields to the id values, and vice versa.protected abstract E
decode(DecodingInputStream in, X ext)
void
decode(java.io.InputStream in, X ext)
void
decodeEthereals(DecodingInputStream s)
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(java.io.OutputStream out, X ext)
protected void
encodeEthereals(EncodingOutputStream s)
Writes out the comments and pis.void
end(org.xml.sax.ContentHandler contentHandler, org.xml.sax.ext.LexicalHandler lexicalHandler)
Send the closing sax events to the two drains.TypedDTD
getDTD()
Returns the global DTD information compiled into this tdom model.TypedEtherealContainer
getEtherealContainer()
Gives access to the Comments and PIs after the opening tag and before the close tag.TypedElement<E,X>
getRootUntyped()
Returns the root element as an instance of TypedElement, so this method works for different tdom models.protected int
getTagIndex()
void
start(org.xml.sax.ContentHandler contentHandler, org.xml.sax.ext.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 Detail
-
root
protected E extends TypedElement<E,X> root
-
STRING_ETHEREAL_SEPARATOR
public static final java.lang.String STRING_ETHEREAL_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TypedDocument
protected TypedDocument(TypedDTD dtd)
-
-
Method Detail
-
getDTD
public final TypedDTD 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
public TypedEtherealContainer 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.
-
getTagIndex
protected int getTagIndex()
-
getRootUntyped
public TypedElement<E,X> getRootUntyped()
Returns the root element as an instance of TypedElement, so this method works for different tdom models.
-
encode
public void encode(java.io.OutputStream out, X ext) throws java.io.IOException
- Throws:
java.io.IOException
-
encode
public void encode(EncodingOutputStream out, X 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<X extends TypedExtension>
- Throws:
java.io.IOException
-
decode
public final void decode(java.io.InputStream in, X ext) throws java.io.IOException, TdomContentException, TdomAttributeException
- Throws:
java.io.IOException
TdomContentException
TdomAttributeException
-
decode
protected abstract E decode(DecodingInputStream in, X ext) throws java.io.IOException, TdomContentException, TdomAttributeException
- Throws:
java.io.IOException
TdomContentException
TdomAttributeException
-
start
public void start(org.xml.sax.ContentHandler contentHandler, org.xml.sax.ext.LexicalHandler lexicalHandler) throws org.xml.sax.SAXException
Send the opening sax events to the two drains. These are theContentHandler.startDocument()
event, followed by the leading comments fromgetEtherealContainer()
.- Throws:
org.xml.sax.SAXException
-
end
public void end(org.xml.sax.ContentHandler contentHandler, org.xml.sax.ext.LexicalHandler lexicalHandler) throws org.xml.sax.SAXException
Send the closing sax events to the two drains. These are the trailing comments fromgetEtherealContainer()
, followed byContentHandler.endDocument()
.- Throws:
org.xml.sax.SAXException
-
createDictionary
public ElementDictionary<E,X> 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
protected void encodeEthereals(EncodingOutputStream s)
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
public void decodeEthereals(DecodingInputStream s)
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](..)".)
-
-