Class SimpleDocument

    • Constructor Detail

      • SimpleDocument

        public SimpleDocument()
        Construct an empty SimpleDocument. Note: this constructor is needed only to comply with the requirements for the Externalizable and ExternalizableLite interfaces.
      • SimpleDocument

        public SimpleDocument​(String sName)
        Construct a SimpleDocument.
        Parameters:
        sName - the name of the root element
      • SimpleDocument

        public SimpleDocument​(String sName,
                              String sDtdUri,
                              String sDtdName)
        Construct a SimpleDocument.
        Parameters:
        sName - the name of the root element
        sDtdUri - the URI of the DTD (system identifier)
        sDtdName - the name of the DTD (public identifier); may be null
    • Method Detail

      • getDtdUri

        public String getDtdUri()
        Get the URI of the DTD (DOCTYPE) for the document. This is referred to as the System Identifier by the XML specification. For example: http://java.sun.com/j2ee/dtds/web-app_2_2.dtd
        Specified by:
        getDtdUri in interface XmlDocument
        Returns:
        the document type URI
      • setDtdUri

        public void setDtdUri​(String sUri)
        Set the URI of the DTD (DOCTYPE) for the document. This is referred to as the System Identifier by the XML specification.
        Specified by:
        setDtdUri in interface XmlDocument
        Parameters:
        sUri - the document type URI
      • getDtdName

        public String getDtdName()
        Get the public identifier of the DTD (DOCTYPE) for the document. For example: -//Sun Microsystems, Inc.//DTD Web Application 1.2//EN
        Specified by:
        getDtdName in interface XmlDocument
        Returns:
        the DTD public identifier
      • setDtdName

        public void setDtdName​(String sName)
        Set the public identifier of the DTD (DOCTYPE) for the document.
        Specified by:
        setDtdName in interface XmlDocument
        Parameters:
        sName - the DTD public identifier
      • getEncoding

        public String getEncoding()
        Get the encoding string for the XML document. Documents that are parsed may or may not have the encoding string from the persistent form of the document.
        Specified by:
        getEncoding in interface XmlDocument
        Returns:
        the encoding set for the document
      • setEncoding

        public void setEncoding​(String sEncoding)
        Set the encoding string for the XML document.
        Specified by:
        setEncoding in interface XmlDocument
        Parameters:
        sEncoding - the encoding that the document will use
      • getDocumentComment

        public String getDocumentComment()
        Get the XML comment that appears outside of the root element. This differs from the Comment property of this object, which refers to the comment within the root element.
        Specified by:
        getDocumentComment in interface XmlDocument
        Returns:
        the document comment
      • setDocumentComment

        public void setDocumentComment​(String sComment)
        Set the XML comment that appears outside of the root element. This differs from the Comment property of this object, which refers to the comment within the root element.
        Specified by:
        setDocumentComment in interface XmlDocument
        Parameters:
        sComment - the document comment
      • writeXml

        public void writeXml​(PrintWriter out,
                             boolean fPretty)
        Write the XML document, including an XML header and DOCTYPE if one exists. This overrides the contract of the XmlElement super interface.
        Specified by:
        writeXml in interface XmlDocument
        Specified by:
        writeXml in interface XmlElement
        Overrides:
        writeXml in class SimpleElement
        Parameters:
        out - a PrintWriter object to use to write to
        fPretty - true to specify that the output is intended to be as human readable as possible
      • hashCode

        public int hashCode()
        Provide a hash value for this XML document and all of its contained information. Note that this overrides the contract of the hashCode method in the super interface XmlElement. The hash value is defined as a xor of the following:
        1. the hashCode from the root element
        2. the hashCode from the document type (uri and optional name)
        Specified by:
        hashCode in interface XmlDocument
        Specified by:
        hashCode in interface XmlElement
        Specified by:
        hashCode in interface XmlValue
        Overrides:
        hashCode in class SimpleElement
        Returns:
        the hash value for this XML document
      • equals

        public boolean equals​(Object o)
        Compare this XML document and all of its contained information with another XML document for equality. Note that this overrides the contract of the equals method in the super interface XmlElement.
        Specified by:
        equals in interface XmlDocument
        Specified by:
        equals in interface XmlElement
        Specified by:
        equals in interface XmlValue
        Overrides:
        equals in class SimpleElement
        Returns:
        true if the documents are equal, false otherwise
      • writeExternal

        public void writeExternal​(ObjectOutput out)
                           throws IOException
        The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
        Specified by:
        writeExternal in interface Externalizable
        Parameters:
        out - the stream to write the object to
        Throws:
        IOException - Includes any I/O exceptions that may occur
      • readExternal

        public void readExternal​(ObjectInput in)
                          throws IOException,
                                 ClassNotFoundException
        The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
        Specified by:
        readExternal in interface Externalizable
        Parameters:
        in - the stream to read data from in order to restore the object
        Throws:
        IOException - if I/O errors occur
        ClassNotFoundException - If the class for an object being restored cannot be found.
      • readExternal

        public void readExternal​(DataInput in)
                          throws IOException
        Restore the contents of this object by loading the object's state from the passed DataInput object.
        Specified by:
        readExternal in interface ExternalizableLite
        Overrides:
        readExternal in class SimpleElement
        Parameters:
        in - the DataInput stream to read data from in order to restore the state of this object
        Throws:
        IOException - if an I/O exception occurs
        NotActiveException - if the object is not in its initial state, and therefore cannot be deserialized into
      • toXml

        public XmlElement toXml()
        Serialize the object into an XmlElement.
        Specified by:
        toXml in interface XmlSerializable
        Overrides:
        toXml in class SimpleElement
        Returns:
        an XmlElement that contains the serialized form of the object