|
Project JXTA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.jxta.util.documentSerializable.DocumentSerializableUtilities
public class DocumentSerializableUtilities
| Constructor Summary | |
|---|---|
DocumentSerializableUtilities()
|
|
| Method Summary | |
|---|---|
static void |
addBoolean(Element element,
String tagName,
boolean value)
Add an Element with the specified tagname and value (converted to a String) |
static void |
addDocumentSerializable(Element element,
String tagName,
DocumentSerializable documentSerializable)
Add an Element with the specified tagname and value (converted to a String) |
static void |
addDouble(Element element,
String tagName,
double value)
Add an Element with the specified tagname and value (converted to a String) |
static void |
addInt(Element element,
String tagName,
int value)
Add an Element with the specified tagname and value (converted to a String) |
static void |
addLong(Element element,
String tagName,
long value)
Add an Element with the specified tagname and value (converted to a String) |
static void |
addString(Element element,
String tagName,
String value)
Add an Element with the specified tagname and value |
static void |
copyChildren(Element toElement,
Element fromElement)
Deeply copy an element into another element |
static DocumentSerializable |
copyDocumentSerializable(DocumentSerializable documentSerializable)
Create a copy of any Document Serializable object. |
static Element |
createChildElement(Element element,
String tagName)
Create a child element of the specified tagName This is done by serializing and then deserializing the object (ie not very efficient) |
static XMLDocument |
createStructuredXmlDocument(String docType,
DocumentSerializable documentSerializable)
Creates a Structured XML Document containing the serialized object |
static boolean |
getBoolean(Element element)
Get the value of an element converted from a String ("true" or "false") |
static boolean |
getBoolean(Element element,
String tagName,
boolean defaultValue)
Get the value of a Child Element |
static Element |
getChildElement(Element element,
String tagName)
Get a child element of the specified tagName This is done by serializing and then deserializing the object (ie not very efficient) |
static DocumentSerializable |
getDocumentSerializable(Element element,
Class clazz)
Create an object from its Document Serialized components |
static DocumentSerializable |
getDocumentSerializable(Element element,
DocumentSerializable documentSerializable)
Initialize an object from its Document Serialized components |
static DocumentSerializable |
getDocumentSerializable(Element element,
String tagName,
Class clazz)
Create an object from its Document Serialized components |
static DocumentSerializable |
getDocumentSerializableFromXml(byte[] buf,
Class clazz)
Create a DocumentSerializable Object from an XML Document |
static DocumentSerializable |
getDocumentSerializableFromXml(InputStream in,
Class clazz)
Create a DocumentSerializable Object from an XML Document |
static DocumentSerializable |
getDocumentSerializableFromXml(String buf,
Class clazz)
Create a DocumentSerializable Object from an XML Document |
static double |
getDouble(Element element)
Get the value of an element converted from a String |
static double |
getDouble(Element element,
String tagName,
double defaultValue)
Get the value of a Child Element |
static int |
getInt(Element element)
Get the value of an element converted from a String |
static int |
getInt(Element element,
String tagName,
int defaultValue)
Get the value of a Child Element |
static long |
getLong(Element element)
Get the value of an element converted from a String |
static long |
getLong(Element element,
String tagName,
long defaultValue)
Get the value of a Child Element |
static String |
getString(Element element)
Get the value of an element as a String |
static String |
getString(Element element,
String tagName,
String defaultValue)
Get the value of a Child Element |
static void |
printAsXmlString(DocumentSerializable documentSerializable)
Write a DocumentSerializable object as an XML Document to StdErr The Root TagName will be 'documentSerializable' by default |
static String |
toXmlString(DocumentSerializable documentSerializable)
Convert a DocumentSerializable object to its XML representation as a String The Root TagName will be 'documentSerializable' by default |
static String |
toXmlString(DocumentSerializable documentSerializable,
String rootTagName)
Convert a DocumentSerializable object to its XML representation as a String The Root TagName will be 'documentSerializable' by default |
static void |
writeAsXmlString(OutputStream out,
DocumentSerializable documentSerializable)
Write a DocumentSerializable object as an XML Document to a Stream The Root TagName will be 'documentSerializable' by default |
static void |
writeAsXmlString(OutputStream out,
DocumentSerializable documentSerializable,
String rootTagName)
Write a DocumentSerializable object as an XML Document to a Stream The Root TagName will be 'documentSerializable' by default |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DocumentSerializableUtilities()
| Method Detail |
|---|
public static XMLDocument createStructuredXmlDocument(String docType,
DocumentSerializable documentSerializable)
throws DocumentSerializationException
DocumentSerializationException - if Unable to parse the serialized object.
public static void copyChildren(Element toElement,
Element fromElement)
toElement - The target ElementfromElement - The source Element
public static void addDocumentSerializable(Element element,
String tagName,
DocumentSerializable documentSerializable)
throws DocumentSerializationException
element - Parent Element that the new child element will be added totagName - TagName to be used for the created Child ElementdocumentSerializable - This value will be serialized into the created child element
\ * @throws DocumentSerializationException if Unable to serialized object.
DocumentSerializationException
public static DocumentSerializable getDocumentSerializable(Element element,
Class clazz)
throws DocumentSerializationException
element - The relative root element of a Document Serialized Objectclazz - The Class of the resurrected object (must implement DocumentSerializable and have a public no-arg constructor)
DocumentSerializationException - if Unable to parse the serialized object.
public static DocumentSerializable getDocumentSerializable(Element element,
DocumentSerializable documentSerializable)
throws DocumentSerializationException
element - The relative root element of a Document Serialized ObjectdocumentSerializable - The object that will be populated from the Element
DocumentSerializationException - if Unable to parse the serialized object.
public static DocumentSerializable getDocumentSerializable(Element element,
String tagName,
Class clazz)
throws DocumentSerializationException
element - The Parent element which has a child Element with the serialized valuetagName - The tagname of the element that contains the relative root element of a Document Serialized ObjecttagName - The Class of the resurrected object (must implement DocumentSerializable and have a public no-arg constructor)clazz - The Class of the resurrected object (must implement DocumentSerializable and have a public no-arg constructor)
DocumentSerializationException - if Unable to parse the serialized object.
public static DocumentSerializable copyDocumentSerializable(DocumentSerializable documentSerializable)
throws DocumentSerializationException
documentSerializable - The Object to be copied
DocumentSerializationException - if Unable to serialize or parse object.
public static Element createChildElement(Element element,
String tagName)
element - The Parent ElementtagName - The Tag Name for the new Element
public static Element getChildElement(Element element,
String tagName)
element - The Parent ElementtagName - The Tag Name for the new Element
public static void addInt(Element element,
String tagName,
int value)
element - Parent Element that the new element will be added totagName - TagName to be used for the created Child Elementvalue - The value that will be stored in the Element as a Stringpublic static int getInt(Element element)
element - Element that contains the value
public static int getInt(Element element,
String tagName,
int defaultValue)
element - The Parant ElementtagName - The Tag Name of the Child Element that will contain the valuedefaultValue - The return value if there is no Child Element with that Tag Name
public static void addLong(Element element,
String tagName,
long value)
element - Parent Element that the new element will be added totagName - TagName to be used for the created Child Elementvalue - The value that will be stored in the Element as a Stringpublic static long getLong(Element element)
element - Element that contains the value
public static long getLong(Element element,
String tagName,
long defaultValue)
element - The Parant ElementtagName - The Tag Name of the Child Element that will contain the valuedefaultValue - The return value if there is no Child Element with that Tag Name
public static void addDouble(Element element,
String tagName,
double value)
element - Parent Element that the new element will be added totagName - TagName to be used for the created Child Elementvalue - The value that will be stored in the Element as a Stringpublic static double getDouble(Element element)
element - Element that contains the value
public static double getDouble(Element element,
String tagName,
double defaultValue)
element - The Parant ElementtagName - The Tag Name of the Child Element that will contain the valuedefaultValue - The return value if there is no Child Element with that Tag Name
public static void addBoolean(Element element,
String tagName,
boolean value)
element - Parent Element that the new element will be added totagName - TagName to be used for the created Child Elementvalue - The value that will be stored in the Element as a Stringpublic static boolean getBoolean(Element element)
element - Element that contains the value
public static boolean getBoolean(Element element,
String tagName,
boolean defaultValue)
element - The Parant ElementtagName - The Tag Name of the Child Element that will contain the valuedefaultValue - The return value if there is no Child Element with that Tag Name
public static void addString(Element element,
String tagName,
String value)
element - Parent Element that the new element will be added totagName - TagName to be used for the created Child Elementvalue - The value that will be stored in the Elementpublic static String getString(Element element)
element - Element that contains the value
public static String getString(Element element,
String tagName,
String defaultValue)
element - The Parant ElementtagName - The Tag Name of the Child Element that will contain the valuedefaultValue - The return value if there is no Child Element with that Tag Name
public static String toXmlString(DocumentSerializable documentSerializable)
throws DocumentSerializationException
documentSerializable - The Object to be converted to an XML Document
DocumentSerializationException - if Unable to serialize object.
public static String toXmlString(DocumentSerializable documentSerializable,
String rootTagName)
throws DocumentSerializationException
documentSerializable - The Object to be converted to an XML DocumenttagName - The Root tagName for the XML Document
DocumentSerializationException - if Unable to serialize object.
public static void writeAsXmlString(OutputStream out,
DocumentSerializable documentSerializable)
throws IOException,
DocumentSerializationException
out - The Stream to write the document todocumentSerializable - The Object to be converted to an XML Document
DocumentSerializationException - if Unable to serialize object.
IOException - if I/O error while writing
public static void writeAsXmlString(OutputStream out,
DocumentSerializable documentSerializable,
String rootTagName)
throws IOException,
DocumentSerializationException
out - The Stream to write the document totagName - The Root tagName for the XML DocumentdocumentSerializable - The Object to be converted to an XML Document
DocumentSerializationException - if Unable to serialize object.
IOException - if I/O error while writingpublic static void printAsXmlString(DocumentSerializable documentSerializable)
out - The Stream to write the document totagName - The Root tagName for the XML DocumentdocumentSerializable - The Object to be converted to an XML Document
public static DocumentSerializable getDocumentSerializableFromXml(String buf,
Class clazz)
throws DocumentSerializationException
buf - The XML document contained in a Stringclazz - The Class of the resurrected object (must implement DocumentSerializable and have a public no-arg constructor)
DocumentSerializationException - if Unable to parse object.
public static DocumentSerializable getDocumentSerializableFromXml(byte[] buf,
Class clazz)
throws DocumentSerializationException
buf - The XML document contained in a byte bufferclazz - The Class of the resurrected object (must implement DocumentSerializable and have a public no-arg constructor)
DocumentSerializationException - if Unable to parse object.
public static DocumentSerializable getDocumentSerializableFromXml(InputStream in,
Class clazz)
throws DocumentSerializationException
in - The Stream containing an XML Document to be readclazz - The Class of the resurrected object (must implement DocumentSerializable and have a public no-arg constructor)
DocumentSerializationException - if Unable to parse object.
|
JXTA J2SE | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||