Class XmlPrintStream

    • Constructor Detail

      • XmlPrintStream

        public XmlPrintStream​(OutputStream outputStream)
        Constructor.
        Parameters:
        outputStream - An OutputStream to which the formatted output will be sent.
    • Method Detail

      • openElement

        public void openElement​(String name)
        Open an XML element with the given name. A call to closeElement() will output the appropriate XML closing tag. This class remembers the tag names.
        Parameters:
        name - Name of the XML element to open.
      • openElement

        public void openElement​(String name,
                                Map<String,​String> attributes)
        Open an XML element with the given name, and attributes. A call to closeElement() will output the appropriate XML closing tag. This class remembers the tag names.
        Parameters:
        name - Name of the XML element to open.
        attributes - A map of name value pairs which will be used to add attributes to the element.
      • openElement

        public void openElement​(String name,
                                String... attributes)
        Open an XML element with the given name, and attributes. A call to closeElement() will output the appropriate XML closing tag. This class remembers the tag names. The String parameters are taken to be alternatively names and values. Any odd value at the end of the list is added as a valueless attribute.
        Parameters:
        name - Name of the element.
        attributes - Attributes in name value pairs.
      • closeElement

        public void closeElement()
        Close an element previously created with openElement().
      • printElement

        public void printElement​(String elementName,
                                 Object value)
        Output a complete element with the given content.
        Parameters:
        elementName - Name of element.
        value - Content of element.
      • printElement

        public void printElement​(String name,
                                 String value,
                                 String... attributes)
        Output an element with the given content (value). The opening and closing tags are output in a single operation.
        Parameters:
        name - Name of the element.
        value - Contents of the element.
        attributes - Alternate names and values of attributes for the element.
      • printElement

        public void printElement​(String elementName,
                                 String value,
                                 Map<String,​String> attributes)
        Output a complete element with the given content and attributes.
        Parameters:
        elementName - Name of element.
        value - Content of element.
        attributes - A map of name value pairs which will be used to add attributes to the element.
      • printElement

        public void printElement​(String name)
        Output a complete empty element.
        Parameters:
        name - Name of element.
      • printComment

        public void printComment​(String comment)
        Output a comment.
        Parameters:
        comment - Comment text.
      • escape

        public String escape​(String in)
        Translate reserved XML characters to XML entities.
        Parameters:
        in - Input string.
      • removeNewLines

        public static String removeNewLines​(String textContent)
        Replace multiple newline characters with a single space.
        Parameters:
        textContent - input String