com.caucho.vfs
Class XmlWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by com.caucho.vfs.XmlWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class XmlWriter
extends java.io.PrintWriter


Nested Class Summary
static class XmlWriter.Html
           
static class XmlWriter.Strategy
           
static class XmlWriter.Xhtml
          If content model is empty,
static class XmlWriter.Xml
           
 
Field Summary
static XmlWriter.Strategy HTML
           
static XmlWriter.Strategy XHTML
           
static XmlWriter.Strategy XML
           
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
XmlWriter(java.io.Writer out)
           
 
Method Summary
 void endBlockElement(java.lang.String name)
          End an element where the opening tag is on it's own line, the content is on it's own line, and the closing tag is on it's own line.
 void endElement(java.lang.String name)
          End an element.
 void endLineElement(java.lang.String name)
          End an element where the opening tag, content, and closing tags are on a single line of their own.
 void flush()
          Close an open element (if any), then flush the underlying writer.
 java.lang.String getCharacterEncoding()
           
 java.lang.String getContentType()
           
 boolean isIndenting()
           
 boolean isNewLine()
           
 void println()
           
 void setCharacterEncoding(java.lang.String characterEncoding)
          Default is "UTF-8".
 void setContentType(java.lang.String contentType)
          Default is "text/xml".
 void setIndenting(boolean isIndenting)
           
 void setStrategy(XmlWriter.Strategy strategy)
           
 boolean softPrintln()
           
 void startBlockElement(java.lang.String name)
          Start an element where the opening tag is on it's own line, the content is on it's own line, and the closing tag is on it's own line.
 void startElement(java.lang.String name)
          Start an element.
 void startLineElement(java.lang.String name)
          Start an element where the opening tag, content, and closing tags are on a single line of their own.
 void write(char[] buf)
           
 void write(char[] buf, int off, int len)
           
 void write(int ch)
           
 void write(java.lang.String s)
           
 void write(java.lang.String s, int off, int len)
           
 void writeAttribute(java.lang.String name, java.lang.Object... values)
          Write an attribute with multiple values, separated by space, if a value is null nothing is written.
 void writeAttribute(java.lang.String name, java.lang.Object value)
          Write an attribute with a value, if value is null nothing is written.
 void writeBlockElement(java.lang.String name)
          Convenience method, same as doing a startBlockElement() and then immediately doing an endBlockElement().
 void writeBlockElement(java.lang.String name, java.lang.Object text)
          Convenience method, same as doing a startBlockElement(), writeText(text), endBlockElement().
 void writeComment(java.lang.String comment)
          Close an open element (if any), then write with escaping as needed.
 void writeElement(java.lang.String name)
          Convenience method, same as doing a startElement() and then immediately doing an endElement().
 void writeElement(java.lang.String name, java.lang.Object text)
          Convenience method, same as doing a startElement(), writeText(text), endElement().
 void writeLineElement(java.lang.String name)
          Convenience method, same as doing a startLineElement() and then immediately doing an endLineElement().
 void writeLineElement(java.lang.String name, java.lang.Object text)
          Convenience method, same as doing a startLineElement(), writeText(text), endLineElement().
 void writeText(char ch)
          Close an open element (if any), then write with escaping as needed.
 void writeText(char[] buf)
          Close an open element (if any), then write with escaping as needed.
 void writeText(char[] buf, int offset, int length)
          Close an open element (if any), then write with escaping as needed.
 void writeText(java.lang.Object obj)
          Close an open element (if any), then write object.toString(), with escaping as needed.
 
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, clearError, close, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, setError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML

public static final XmlWriter.Strategy XML

XHTML

public static final XmlWriter.Strategy XHTML

HTML

public static final XmlWriter.Strategy HTML
Constructor Detail

XmlWriter

public XmlWriter(java.io.Writer out)
Method Detail

getContentType

public java.lang.String getContentType()

setContentType

public void setContentType(java.lang.String contentType)
Default is "text/xml".


setStrategy

public void setStrategy(XmlWriter.Strategy strategy)

setIndenting

public void setIndenting(boolean isIndenting)

isIndenting

public boolean isIndenting()

setCharacterEncoding

public void setCharacterEncoding(java.lang.String characterEncoding)
Default is "UTF-8".


getCharacterEncoding

public java.lang.String getCharacterEncoding()

startElement

public void startElement(java.lang.String name)
Start an element.


endElement

public void endElement(java.lang.String name)
End an element.


startBlockElement

public void startBlockElement(java.lang.String name)
Start an element where the opening tag is on it's own line, the content is on it's own line, and the closing tag is on it's own line.


endBlockElement

public void endBlockElement(java.lang.String name)
End an element where the opening tag is on it's own line, the content is on it's own line, and the closing tag is on it's own line.


startLineElement

public void startLineElement(java.lang.String name)
Start an element where the opening tag, content, and closing tags are on a single line of their own.


endLineElement

public void endLineElement(java.lang.String name)
End an element where the opening tag, content, and closing tags are on a single line of their own.


writeElement

public void writeElement(java.lang.String name)
Convenience method, same as doing a startElement() and then immediately doing an endElement().


writeLineElement

public void writeLineElement(java.lang.String name)
Convenience method, same as doing a startLineElement() and then immediately doing an endLineElement().


writeBlockElement

public void writeBlockElement(java.lang.String name)
Convenience method, same as doing a startBlockElement() and then immediately doing an endBlockElement().


writeElement

public void writeElement(java.lang.String name,
                         java.lang.Object text)
Convenience method, same as doing a startElement(), writeText(text), endElement().


writeLineElement

public void writeLineElement(java.lang.String name,
                             java.lang.Object text)
Convenience method, same as doing a startLineElement(), writeText(text), endLineElement().


writeBlockElement

public void writeBlockElement(java.lang.String name,
                              java.lang.Object text)
Convenience method, same as doing a startBlockElement(), writeText(text), endBlockElement().


writeAttribute

public void writeAttribute(java.lang.String name,
                           java.lang.Object value)
Write an attribute with a value, if value is null nothing is written.

Throws:
java.lang.IllegalStateException - if the is no element is open

writeAttribute

public void writeAttribute(java.lang.String name,
                           java.lang.Object... values)
Write an attribute with multiple values, separated by space, if a value is null nothing is written.

Throws:
java.lang.IllegalStateException - if the is no element is open

writeText

public void writeText(char ch)
Close an open element (if any), then write with escaping as needed.


writeText

public void writeText(char[] buf)
Close an open element (if any), then write with escaping as needed.


writeText

public void writeText(char[] buf,
                      int offset,
                      int length)
Close an open element (if any), then write with escaping as needed.


writeText

public void writeText(java.lang.Object obj)
Close an open element (if any), then write object.toString(), with escaping as needed.


writeComment

public void writeComment(java.lang.String comment)
Close an open element (if any), then write with escaping as needed.


flush

public void flush()
Close an open element (if any), then flush the underlying writer.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.PrintWriter

println

public void println()
Overrides:
println in class java.io.PrintWriter

isNewLine

public boolean isNewLine()

softPrintln

public boolean softPrintln()

write

public void write(int ch)
Overrides:
write in class java.io.PrintWriter

write

public void write(char[] buf,
                  int off,
                  int len)
Overrides:
write in class java.io.PrintWriter

write

public void write(char[] buf)
Overrides:
write in class java.io.PrintWriter

write

public void write(java.lang.String s,
                  int off,
                  int len)
Overrides:
write in class java.io.PrintWriter

write

public void write(java.lang.String s)
Overrides:
write in class java.io.PrintWriter