com.tensegrity.generic.persistence
Class XMLIOUtilities

java.lang.Object
  extended bycom.tensegrity.generic.persistence.XMLIOUtilities

public final class XMLIOUtilities
extends java.lang.Object

Static convenience methods to load/store xml files in the context of the persistence framework.

Version:
$Id: XMLIOUtilities.java,v 1.30 2005/04/19 12:01:52 MichaelKegel Exp $
Author:
Stepan Rutz, Gilles Iachelini

Method Summary
static java.lang.String quoteString(java.lang.String strVal)
          Quotes all linefeeds in a string to be saved to XML
static AttributeList readXML(java.io.InputStream in)
          This method reads an AttributeList from an given InputStream.
static AttributeList readXMLFile(java.io.File file)
          Convenience method that builds an InputStream with the given File-parameter and then calls readXML().
static AttributeList readXMLFile(java.lang.String filename, java.lang.Class resourceClass)
          This method uses the XMLReader to create an AttributeList from the XML-file specified by the filename parameter.
static java.lang.String strReplace(java.lang.String string, java.lang.String token, java.lang.String replaceString)
          String replace function, replaces all occurrances of the token in the string with another string (Only neccessary, because replaceAll is not implemented in jdk1.3)
static java.lang.String unquoteString(java.lang.String strVal)
          Quotes all linefeeds in a string to be saved to XML
static void writeXML(java.io.OutputStream outputstream, java.lang.String header, AttributeList list)
          Writes the given list to the outputstream and prepends the header to the output.
static void writeXMLFile(java.lang.String filename, AttributeList list)
          Does the same as writeXMLFile, but you do not have to specify a XML-header.
static void writeXMLFile(java.lang.String filename, java.lang.String header, AttributeList list)
          Method writeXMLFile writes the parameter AttributeList to the File specified by filename using the given header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readXML

public static final AttributeList readXML(java.io.InputStream in)
                                   throws ReadException
This method reads an AttributeList from an given InputStream.

Parameters:
in - the InputStream to read from.
Returns:
the generated AttributeList.
Throws:
ReadException - thrown if reading from the InputStream fails

writeXML

public static final void writeXML(java.io.OutputStream outputstream,
                                  java.lang.String header,
                                  AttributeList list)
                           throws WriteException
Writes the given list to the outputstream and prepends the header to the output. The header is optional and can be null.

Parameters:
outputstream - the OutputStream to write to.
header - the optional header (for example a DTD)
list - the AttributeList to write.
Throws:
WriteException - thrown if writing to the OutputStream fails

readXMLFile

public static final AttributeList readXMLFile(java.io.File file)
                                       throws ReadException
Convenience method that builds an InputStream with the given File-parameter and then calls readXML().

Parameters:
file - the XML-file to be read.
Returns:
the built AttributeList.
Throws:
ReadException - thrown if reading from the File fails
See Also:
readXML(InputStream)

readXMLFile

public static final AttributeList readXMLFile(java.lang.String filename,
                                              java.lang.Class resourceClass)
                                       throws ReadException
This method uses the XMLReader to create an AttributeList from the XML-file specified by the filename parameter. The file-path must be specified relative to the given resourceClass parameter.

Parameters:
filename - name of the XML-file to be read.
resourceClass - the ResourceClass.
Returns:
AttributeList the AttributeList created by the XMLReader.
Throws:
ReadException - thrown if reading from the File fails

writeXMLFile

public static final void writeXMLFile(java.lang.String filename,
                                      java.lang.String header,
                                      AttributeList list)
                               throws WriteException
Method writeXMLFile writes the parameter AttributeList to the File specified by filename using the given header. If header is null, a default XML-header will be written.

Parameters:
filename - the file to write to.
header - header to be used as the XML-header.
list - the AttributeList to write out.
Throws:
WriteException - thrown if writing to the file given through filename fails

writeXMLFile

public static final void writeXMLFile(java.lang.String filename,
                                      AttributeList list)
                               throws WriteException
Does the same as writeXMLFile, but you do not have to specify a XML-header.

Parameters:
filename - the file to write to.
list - the AttributeList to write out.
Throws:
WriteException - thrown if writing to the file given through filename fails
See Also:
writeXMLFile(String, String, AttributeList)

quoteString

public static final java.lang.String quoteString(java.lang.String strVal)
Quotes all linefeeds in a string to be saved to XML

Parameters:
strVal - The string to quote
Returns:
The quoted string without linefeeds

unquoteString

public static final java.lang.String unquoteString(java.lang.String strVal)
Quotes all linefeeds in a string to be saved to XML

Parameters:
strVal - The string to quote
Returns:
The quoted string without linefeeds

strReplace

public static java.lang.String strReplace(java.lang.String string,
                                          java.lang.String token,
                                          java.lang.String replaceString)
String replace function, replaces all occurrances of the token in the string with another string (Only neccessary, because replaceAll is not implemented in jdk1.3)

Parameters:
string - The original string
token - The substring to look for
replaceString - The string to replace the token with
Returns:
The changed string


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.