Class TypedDocument<E extends TypedElement<E,​X>,​X extends TypedExtension>

  • Direct Known Subclasses:
    Document, Document, Document, Document

    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 (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
      
    (Reminder: "Element" is the name of the generated class serving as common base class of all element classes.)
    • 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 class TypedNode<X extends TypedExtension>
        Throws:
        java.io.IOException
      • 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 the ContentHandler.startDocument() event, followed by the leading comments from getEtherealContainer().
        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 from getEtherealContainer(), followed by ContentHandler.endDocument().
        Throws:
        org.xml.sax.SAXException
      • 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](..)".)