Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.openspml.util
Class XmlBuffer

    java.lang.Object
      |
      +--org.openspml.util.XmlBuffer

Direct Known Subclasses:
  SpmlBuffer

public class XmlBuffer
extends java.lang.Object

A utility class used to format XML strings.

It wraps a StringBuffer and provides methods with awareness of XML syntax.

Field Summary
`static java.lang.String` | `XML_HEADER`

Constructor Summary
`XmlBuffer()`
`XmlBuffer(int length)`

Method Summary
`void` | `addAttribute(java.lang.String name, boolean value)` Adds a boolean attribute to the buffer.
`void` | `addAttribute(java.lang.String name, int value)` Adds an integer attribute to the buffer.
`void` | `addAttribute(java.lang.String name, java.lang.Object obj)` Add an an attribute value using an arbitrary object, by calling its toString method.
`void` | `addAttribute(java.lang.String name, java.lang.String value)`
`void` | `addAttribute(java.lang.String name, java.lang.String prefix, java.lang.String value)` Adds an attribute name and value to the buffer.
`void` | `addContent(java.lang.String s)` Adds a string of element content to the buffer.
`void` | `addElement(java.lang.String element, java.lang.String content)` Adds an element with content to the buffer, being careful to escape content.
`void` | `addElement(java.lang.String namespace, java.lang.String element, java.lang.String content)`
`void` | `addEndTag(java.lang.String name)` Adds an element end tag.
`void` | `addEndTag(java.lang.String name, boolean indent)` Adds an element end tag, with control over indentation.
`void` | `addEndTag(java.lang.String namespace, java.lang.String name)`
`void` | `addEndTag(java.lang.String namespace, java.lang.String name, boolean indent)`
`void` | `addIndent(int indent)` Add indentation to the buffer.
`void` | `addNamespace(java.lang.String name, java.lang.String url)`
`void` | `addOpenStartTag(java.lang.String name)` Adds an open element start tag.
`void` | `addOpenStartTag(java.lang.String namespace, java.lang.String name)`
`void` | `addStartTag(java.lang.String name)` Adds a closed element start tag followed by a newline.
`void` | `addStartTag(java.lang.String name, boolean newline)` Adds a closed element start tag with control over the trailing newline.
`void` | `addStartTag(java.lang.String namespace, java.lang.String name)`
`void` | `addStartTag(java.lang.String namespace, java.lang.String name, boolean newline)`
`void` | `append(char c)`
`void` | `append(int i)`
`void` | `append(java.lang.Integer i)`
`void` | `append(java.lang.String s)`
`char` | `charAt(int index)`
`void` | `closeEmptyElement()` Close an empty open start tag.
`void` | `closeStartTag()` Close an open start tag.
`void` | `closeStartTag(boolean newline)` Close an element with control over trailing newline.
`void` | `decIndent()`
`void` | `decIndent(int i)` Decrement the indentation level.
`void` | `incIndent()`
`void` | `incIndent(int i)` Increment the indentation level.
`int` | `length()`
`void` | `setLength(int len)`
`void` | `setNamespace(java.lang.String s)`
`void` | `setPrefix(java.lang.String s)`
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### XML_HEADER

    public static final java.lang.String XML_HEADER

Constructor Detail

### XmlBuffer

    public XmlBuffer()

### XmlBuffer

    public XmlBuffer(int length)

Method Detail

### setPrefix

    public void setPrefix(java.lang.String s)

### setNamespace

    public void setNamespace(java.lang.String s)

### addNamespace

    public void addNamespace(java.lang.String name,
                             java.lang.String url)

### append

    public void append(java.lang.String s)

### append

    public void append(java.lang.Integer i)

### append

    public void append(char c)

### append

    public void append(int i)

### charAt

    public char charAt(int index)

### toString

    public java.lang.String toString()

  Overrides:
    toString in class java.lang.Object

### length

    public int length()

### setLength

    public void setLength(int len)

### incIndent

    public void incIndent(int i)

  Increment the indentation level.

### incIndent

    public void incIndent()

### decIndent

    public void decIndent(int i)

  Decrement the indentation level.

### decIndent

    public void decIndent()

### addAttribute

    public void addAttribute(java.lang.String name,
                             java.lang.String prefix,
                             java.lang.String value)

  Adds an attribute name and value to the buffer.

  Performs any necessary escaping on the value. This should be used when you're building the XML for something, and its possible for an attribute value to have any of the characters &, ', or "

### addAttribute

    public void addAttribute(java.lang.String name,
                             java.lang.String value)

### addAttribute

    public void addAttribute(java.lang.String name,
                             java.lang.Object obj)

  Add an an attribute value using an arbitrary object, by calling its toString method.

### addAttribute

    public void addAttribute(java.lang.String name,
                             boolean value)

  Adds a boolean attribute to the buffer.

  If the value is false, the attribute is suppressed.

### addAttribute

    public void addAttribute(java.lang.String name,
                             int value)

  Adds an integer attribute to the buffer.

### addContent

    public void addContent(java.lang.String s)

  Adds a string of element content to the buffer.

  Replaces special characters in a string with XML character entities. The characters replaced are '&' and '<'. This should be when building strings intended to be the values of XML attributes or XML element content.

### addIndent

    public void addIndent(int indent)

  Add indentation to the buffer.

### addOpenStartTag

    public void addOpenStartTag(java.lang.String name)

  Adds an open element start tag.

### addOpenStartTag

    public void addOpenStartTag(java.lang.String namespace,
                                java.lang.String name)

### closeStartTag

    public void closeStartTag()

  Close an open start tag.

### closeStartTag

    public void closeStartTag(boolean newline)

  Close an element with control over trailing newline.

### closeEmptyElement

    public void closeEmptyElement()

  Close an empty open start tag.

### addStartTag

    public void addStartTag(java.lang.String name)

  Adds a closed element start tag followed by a newline.

### addStartTag

    public void addStartTag(java.lang.String namespace,
                            java.lang.String name)

### addStartTag

    public void addStartTag(java.lang.String name,
                            boolean newline)

  Adds a closed element start tag with control over the trailing newline.

### addStartTag

    public void addStartTag(java.lang.String namespace,
                            java.lang.String name,
                            boolean newline)

### addEndTag

    public void addEndTag(java.lang.String name)

  Adds an element end tag.

### addEndTag

    public void addEndTag(java.lang.String namespace,
                          java.lang.String name)

### addEndTag

    public void addEndTag(java.lang.String name,
                          boolean indent)

  Adds an element end tag, with control over indentation.

### addEndTag

    public void addEndTag(java.lang.String namespace,
                          java.lang.String name,
                          boolean indent)

### addElement

    public void addElement(java.lang.String element,
                           java.lang.String content)

  Adds an element with content to the buffer, being careful to escape content.

### addElement

    public void addElement(java.lang.String namespace,
                           java.lang.String element,
                           java.lang.String content)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD