com.lowagie.text.xml

Class XmlWriter

    • Field Detail

      • PROLOG

        public static final byte[] PROLOG
        This is the first line of the XML page.
      • DOCTYPE

        public static final byte[] DOCTYPE
        This is the reference to the DTD.
      • DTD

        public static final byte[] DTD
        This is the place where the DTD is located.
      • xmlCode

        private static final java.lang.String[] xmlCode
        This is an array containing character to XML translations.
      • itext

        private java.util.TreeMap itext
        This is the meta information of the document.
    • Constructor Detail

      • XmlWriter

        protected XmlWriter(Document doc,
                 java.io.OutputStream os)
        Constructs an XmlWriter.
        Parameters:
        doc - The Document that has to be written as XML
        os - The OutputStream the writer has to write to.
      • XmlWriter

        protected XmlWriter(Document doc,
                 java.io.OutputStream os,
                 java.lang.String dtd)
        Constructs an XmlWriter.
        Parameters:
        doc - The Document that has to be written as XML
        os - The OutputStream the writer has to write to.
        dtd - The DTD to use
    • Method Detail

      • getInstance

        public static XmlWriter getInstance(Document document,
                            java.io.OutputStream os)
        Gets an instance of the XmlWriter.
        Parameters:
        document - The Document that has to be written
        os - The OutputStream the writer has to write to.
        Returns:
        a new XmlWriter
      • getInstance

        public static XmlWriter getInstance(Document document,
                            java.io.OutputStream os,
                            java.lang.String dtd)
        Gets an instance of the XmlWriter.
        Parameters:
        document - The Document that has to be written
        os - The OutputStream the writer has to write to.
        dtd - The DTD to use
        Returns:
        a new XmlWriter
      • add

        public boolean add(Element element)
                    throws DocumentException
        Signals that an Element was added to the Document.
        Specified by:
        add in interface ElementListener
        Overrides:
        add in class DocWriter
        Parameters:
        element - A high level object that will be added to the XML
        Returns:
        true if the element was added, false if not.
        Throws:
        DocumentException - when a document isn't open yet, or has been closed
      • open

        public void open()
        Signals that the Document has been opened and that Elements can be added.
        Specified by:
        open in interface DocListener
        Overrides:
        open in class DocWriter
      • close

        public void close()
        Signals that the Document was closed and that no other Elements will be added.
        Specified by:
        close in interface DocListener
        Overrides:
        close in class DocWriter
      • write

        private void write(Element element,
                 int indent)
                    throws java.io.IOException
        Writes the XML representation of an element.
        Parameters:
        element - the element
        indent - the indentation
        Throws:
        java.io.IOException
      • writeSection

        private void writeSection(Section section,
                        int indent)
                           throws java.io.IOException
        Writes the XML representation of a section.
        Parameters:
        section - the section to write
        indent - the indentation
        Throws:
        java.io.IOException
      • write

        private void write(Rectangle rectangle)
                    throws java.io.IOException
        Writes the XML representation of this Rectangle.
        Parameters:
        rectangle - a Rectangle
        Throws:
        java.io.IOException
      • encode

        static final java.lang.String encode(java.lang.String string,
                              int indent)
        Encodes a String.
        Parameters:
        string - the String to encode
        indent - counter that keeps the number of tabs that has to be added for indentation
        Returns:
        the encoded String
      • addTabs

        static final void addTabs(java.lang.StringBuffer buf,
                   int indent)
        Adds a number of tabs to a StringBuffer.
        Parameters:
        buf - the stringbuffer
        indent - the number of tabs to add
      • write

        private void write(Font font)
                    throws java.io.IOException
        Writes the XML representation of a Font.
        Parameters:
        font - a Font
        Throws:
        java.io.IOException