bibliothek.util.xml
Class XIO

java.lang.Object
  extended by bibliothek.util.xml.XIO

public class XIO
extends Object

Class used to read and write xml-files. Clients should use writeUTF(XElement, OutputStream) and readUTF(InputStream) to guarantee maximal independence from the underlying file system.

Author:
Benjamin Sigg

Constructor Summary
XIO()
           
 
Method Summary
static XElement read(CharSequence text)
          Interprets text as a xml-file and reads it.
static XElement read(InputSource source)
          Reads a xml-file from source.
static XElement read(InputStream in, String encoding)
          Reads a xml file provided from in using encoding as encoding.
static XElement read(Reader reader)
          Reads a xml file provided from reader.
static XElement readUTF(InputStream in)
          Reads a xml file provided from in using UTF-8 as encoding.
static void write(XElement element, Appendable out)
          Writes the contents of element into out.
static void write(XElement element, OutputStream out, String encoding)
          Writes the contents of element into out.
static void writeUTF(XElement element, OutputStream out)
          Writes the contents of element into out using the UTF-8 encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XIO

public XIO()
Method Detail

write

public static void write(XElement element,
                         Appendable out)
                  throws IOException
Writes the contents of element into out.

Parameters:
element - the element to write
out - the stream to write into
Throws:
IOException - if an I/O-error occurs

writeUTF

public static void writeUTF(XElement element,
                            OutputStream out)
                     throws IOException
Writes the contents of element into out using the UTF-8 encoding.

Parameters:
element - the element to write
out - the stream to write into
Throws:
IOException - if an I/O-error occurs

write

public static void write(XElement element,
                         OutputStream out,
                         String encoding)
                  throws IOException
Writes the contents of element into out.

Parameters:
element - the element to write
out - the stream to write into
encoding - the encoding for the characters
Throws:
IOException - if an I/O-error occurs

readUTF

public static XElement readUTF(InputStream in)
                        throws IOException
Reads a xml file provided from in using UTF-8 as encoding.

Parameters:
in - the stream to read from
Returns:
the root element
Throws:
IOException - if an I/O-error occurs

read

public static XElement read(InputStream in,
                            String encoding)
                     throws IOException
Reads a xml file provided from in using encoding as encoding.

Parameters:
in - the stream to read from
encoding - the encoding used to decode characters
Returns:
the root element
Throws:
IOException - if an I/O-error occurs

read

public static XElement read(CharSequence text)
                     throws IOException
Interprets text as a xml-file and reads it.

Parameters:
text - the content to read, in xml format
Returns:
the root element of text
Throws:
IOException - if an I/O-error occurs

read

public static XElement read(InputSource source)
                     throws IOException
Reads a xml-file from source.

Parameters:
source - the xml-file
Returns:
the root element of the file.
Throws:
IOException - if an I/O-error occurs

read

public static XElement read(Reader reader)
                     throws IOException
Reads a xml file provided from reader.

Parameters:
reader - the reader from which characters will be read
Returns:
the root element
Throws:
IOException - if an I/O-error occurs