JIDE 3.5.15

com.jidesoft.swing
Class PersistenceUtils

java.lang.Object
  extended by com.jidesoft.swing.PersistenceUtils

public class PersistenceUtils
extends Object


Field Summary
static String ATTRIBUTE_VERSION
          Version attribute for every layout persistence utility class.
static String NODE_COMPONENT
          Component node for every layout persistence utility class.
 
Constructor Summary
PersistenceUtils()
           
 
Method Summary
static byte[] bufferStreamToArray(InputStream stream)
          Reads the input stream into a byte array.
static String getDefaultXmlEncoding()
          Get default XML encoding type.
static String getDefaultXmlVersion()
          Get default XML encoding version.
static Document getDocument(InputStream in)
          Get Document from the input stream.
static Document getDocument(String fileName)
          Get Document from the file.
static String getVersion(Document document)
          Get version from the document.
static String intArrayToString(int[] indices)
          Translate an Integer array to a string in a document.
static boolean isXmlFormat(byte[] byteArray)
          Checks if the string inside the byte array is in XML format.
static void saveXMLDocumentToFile(Document document, String fileName, String encoding)
          Save XML document to designated file.
static void saveXMLDocumentToStream(Document document, OutputStream out, String encoding)
          Save XML document to designated output stream.
static void setDefaultXmlEncoding(String defaultXmlEncoding)
          Set default XML encoding type.
static void setDefaultXmlVersion(String defaultXmlVersion)
          Set default XML encoding version.
static int[] stringToIntArray(String s)
          Translate string in a document to an Integer array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NODE_COMPONENT

public static final String NODE_COMPONENT
Component node for every layout persistence utility class.

See Also:
Constant Field Values

ATTRIBUTE_VERSION

public static final String ATTRIBUTE_VERSION
Version attribute for every layout persistence utility class.

See Also:
Constant Field Values
Constructor Detail

PersistenceUtils

public PersistenceUtils()
Method Detail

saveXMLDocumentToFile

public static void saveXMLDocumentToFile(Document document,
                                         String fileName,
                                         String encoding)
                                  throws IOException
Save XML document to designated file.

Parameters:
document - the XML ready to be saved
fileName - the file name to be saved to
encoding - the encoding type
Throws:
IOException - possibly IO exceptions during file writing.

saveXMLDocumentToStream

public static void saveXMLDocumentToStream(Document document,
                                           OutputStream out,
                                           String encoding)
                                    throws IOException
Save XML document to designated output stream.

Parameters:
document - the XML ready to be saved
out - the output stream to be saved to
encoding - the encoding type
Throws:
IOException - possibly IO exceptions during stream output.

getDefaultXmlEncoding

public static String getDefaultXmlEncoding()
Get default XML encoding type.

Returns:
The default XML encoding.

setDefaultXmlEncoding

public static void setDefaultXmlEncoding(String defaultXmlEncoding)
Set default XML encoding type.

Parameters:
defaultXmlEncoding - the default XML encoding

getDefaultXmlVersion

public static String getDefaultXmlVersion()
Get default XML encoding version.

Returns:
The default XML version.

setDefaultXmlVersion

public static void setDefaultXmlVersion(String defaultXmlVersion)
Set default XML encoding version.

Parameters:
defaultXmlVersion - the default XML version

getDocument

public static Document getDocument(InputStream in)
                            throws ParserConfigurationException,
                                   SAXException,
                                   IOException
Get Document from the input stream.

Parameters:
in - the input stream
Returns:
the parsed document.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - If any parse errors occur.
IOException - If the pathname argument is null or any IO errors happen

getDocument

public static Document getDocument(String fileName)
                            throws ParserConfigurationException,
                                   SAXException,
                                   IOException
Get Document from the file.

Parameters:
fileName - the file name
Returns:
the parsed document.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - If any parse errors occur.
IOException - If the pathname argument is null or any IO errors happen

getVersion

public static String getVersion(Document document)
Get version from the document.

Parameters:
document - the document
Returns:
the version.

stringToIntArray

public static int[] stringToIntArray(String s)
Translate string in a document to an Integer array.

Parameters:
s - the string
Returns:
the Integer array.

intArrayToString

public static String intArrayToString(int[] indices)
Translate an Integer array to a string in a document.

Parameters:
indices - the Integer array
Returns:
the string.

isXmlFormat

public static boolean isXmlFormat(byte[] byteArray)
Checks if the string inside the byte array is in XML format.

Parameters:
byteArray - the byte array
Returns:
true if it is XML format. Otherwise false.

bufferStreamToArray

public static byte[] bufferStreamToArray(InputStream stream)
                                  throws IOException
Reads the input stream into a byte array.

Parameters:
stream - the input stream
Returns:
the byte array.
Throws:
IOException - if there is any IO error

JIDE 3.5.15