Package weka.core.xml
Class XStream
java.lang.Object
weka.core.xml.XStream
- All Implemented Interfaces:
RevisionHandler
This class is a helper class for XML serialization using XStream . XStream does
not need to be present, since the class-calls are done generically via
Reflection.
- Version:
- $Revision: 10203 $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}org)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringthe extension for XStream files (including '.') -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectdeSerialize(String xmlString) Deserializes an object from the supplied XML stringReturns the revision string.static booleanreturns whether XStream is present or not, i.e.static Objectreads the XML-serialized object from the given filestatic Objectread(InputStream stream) reads the XML-serialized object from the given input streamstatic Objectreads the XML-serialized object from the given Readerstatic Objectreads the XML-serialized object from the given filestatic StringSerializes the supplied object xmlstatic booleanwrite the XML-serialized object to the given filestatic booleanwrite(OutputStream stream, Object o) writes the XML-serialized object to the given output streamstatic booleanwrites the XML-serialized object to the given Writer.static booleanwrites the XML-serialized object to the given file
-
Field Details
-
FILE_EXTENSION
the extension for XStream files (including '.')- See Also:
-
-
Constructor Details
-
XStream
public XStream()
-
-
Method Details
-
isPresent
public static boolean isPresent()returns whether XStream is present or not, i.e. whether the classes are in the classpath or not- Returns:
- whether XStream is available
-
serialize
Serializes the supplied object xml- Parameters:
toSerialize- the object to serialize- Returns:
- the serialized object as an XML string
- Throws:
Exception- if something goes wrong
-
write
writes the XML-serialized object to the given file- Parameters:
filename- the file to serialize the object too- the object to write to the file- Returns:
- whether writing was successful or not
- Throws:
Exception- if something goes wrong while writing to the file
-
write
write the XML-serialized object to the given file- Parameters:
file- the file to serialize the object too- the object to write to the file- Returns:
- whether writing was successful or not
- Throws:
Exception- if something goes wrong while writing to the file
-
write
writes the XML-serialized object to the given output stream- Parameters:
stream- the output streamo- the object to write- Returns:
- true if everything goes ok
- Throws:
Exception
-
write
writes the XML-serialized object to the given Writer.- Parameters:
writer- the WritertoSerialize- the object to write- Returns:
- true if everything goes ok
- Throws:
Exception- if something goes wrong
-
read
reads the XML-serialized object from the given file- Parameters:
filename- the file to deserialize the object from- Returns:
- the deserialized object
- Throws:
Exception- if something goes wrong while reading from the file
-
read
reads the XML-serialized object from the given file- Parameters:
file- the file to deserialize the object from- Returns:
- the deserialized object
- Throws:
Exception- if something goes wrong while reading from the file
-
read
reads the XML-serialized object from the given input stream- Parameters:
stream- the input stream- Returns:
- the deserialized object
- Throws:
Exception- if something goes wrong while reading from stream
-
read
reads the XML-serialized object from the given Reader- Parameters:
r- the reader- Returns:
- the deserialized object
- Throws:
Exception- if something goes wrong while reading from stream
-
deSerialize
Deserializes an object from the supplied XML string- Parameters:
xmlString- the XML to deserialize from- Returns:
- the deserialized object
- Throws:
Exception- if something goes wrong
-
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
-