Java Doc for XStream.java in  » XML » xstream-1.3 » com » thoughtworks » xstream » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » xstream 1.3 » com.thoughtworks.xstream 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.thoughtworks.xstream.XStream

All known Subclasses:   com.thoughtworks.xstream.InitializationException,
XStream
public class XStream (Code)
Simple facade to XStream library, a Java-XML serialization tool.


Example
 XStream xstream = new XStream();
 String xml = xstream.toXML(myObject); // serialize to XML
 Object myObject2 = xstream.fromXML(xml); // deserialize from XML
 

Aliasing classes

To create shorter XML, you can specify aliases for classes using the alias() method. For example, you can shorten all occurrences of element <com.blah.MyThing> to <my-thing> by registering an alias for the class.


 xstream.alias("my-thing", MyThing.class);
 

Converters

XStream contains a map of com.thoughtworks.xstream.converters.Converter instances, each of which acts as a strategy for converting a particular type of class to XML and back again. Out of the box, XStream contains converters for most basic types (String, Date, int, boolean, etc) and collections (Map, List, Set, Properties, etc). For other objects reflection is used to serialize each field recursively.

Extra converters can be registered using the registerConverter() method. Some non-standard converters are supplied in the com.thoughtworks.xstream.converters.extended package and you can create your own by implementing the com.thoughtworks.xstream.converters.Converter interface.


Example
 xstream.registerConverter(new SqlTimestampConverter());
 xstream.registerConverter(new DynamicProxyConverter());
 

The default converter, ie the converter which will be used if no other registered converter is suitable, can be configured by either one of the constructors or can be changed using the changeDefaultConverter() method. If not set, XStream uses com.thoughtworks.xstream.converters.reflection.ReflectionConverter as the initial default converter.


Example
 xstream.changeDefaultConverter(new ACustomDefaultConverter());
 

Object graphs

XStream has support for object graphs; a deserialized object graph will keep references intact, including circular references.

XStream can signify references in XML using either relative/absolute XPath or IDs. The mode can be changed using setMode():

xstream.setMode(XStream.XPATH_RELATIVE_REFERENCES); (Default) Uses XPath relative references to signify duplicate references. This produces XML with the least clutter.
xstream.setMode(XStream.XPATH_ABSOLUTE_REFERENCES); Uses XPath absolute references to signify duplicate references. This produces XML with the least clutter.
xstream.setMode(XStream.ID_REFERENCES); Uses ID references to signify duplicate references. In some scenarios, such as when using hand-written XML, this is easier to work with.
xstream.setMode(XStream.NO_REFERENCES); This disables object graph support and treats the object structure like a tree. Duplicate references are treated as two separate objects and circular references cause an exception. This is slightly faster and uses less memory than the other two modes.

Thread safety

The XStream instance is thread-safe. That is, once the XStream instance has been created and configured, it may be shared across multiple threads allowing objects to be serialized/deserialized concurrently.

Implicit collections

To avoid the need for special tags for collections, you can define implicit collections using one of the addImplicitCollection methods.


author:
   Joe Walnes
author:
   Jörg Schaible
author:
   Mauro Talevi
author:
   Guilherme Silveira

Inner Class :public static class InitializationException extends XStreamException

Field Summary
final public static  intID_REFERENCES
    
final public static  intNO_REFERENCES
    
final public static  intPRIORITY_LOW
    
final public static  intPRIORITY_NORMAL
    
final public static  intPRIORITY_VERY_HIGH
    
final public static  intPRIORITY_VERY_LOW
    
final public static  intXPATH_ABSOLUTE_REFERENCES
    
final public static  intXPATH_REFERENCES
    
final public static  intXPATH_RELATIVE_REFERENCES
    

Constructor Summary
public  XStream()
     Constructs a default XStream.
public  XStream(ReflectionProvider reflectionProvider)
     Constructs an XStream with a special ReflectionProvider .
public  XStream(HierarchicalStreamDriver hierarchicalStreamDriver)
     Constructs an XStream with a special HierarchicalStreamDriver .
public  XStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver hierarchicalStreamDriver)
     Constructs an XStream with a special HierarchicalStreamDriver and ReflectionProvider .
public  XStream(ReflectionProvider reflectionProvider, ClassMapper classMapper, HierarchicalStreamDriver driver)
    
public  XStream(ReflectionProvider reflectionProvider, ClassMapper classMapper, HierarchicalStreamDriver driver, String classAttributeIdentifier)
    
public  XStream(ReflectionProvider reflectionProvider, Mapper mapper, HierarchicalStreamDriver driver)
     Constructs an XStream with a special HierarchicalStreamDriver and ReflectionProvider and additionally with a prepared Mapper .
public  XStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver, ClassLoader classLoader)
     Constructs an XStream with a special HierarchicalStreamDriver and ReflectionProvider and additionally with a prepared ClassLoader to use.
public  XStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver, ClassLoader classLoader, Mapper mapper)
     Constructs an XStream with a special HierarchicalStreamDriver and ReflectionProvider and additionally with a prepared Mapper and the ClassLoader in use.
public  XStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver, ClassLoader classLoader, Mapper mapper, ConverterLookup converterLookup, ConverterRegistry converterRegistry)
     Constructs an XStream with a special HierarchicalStreamDriver , ReflectionProvider , a prepared Mapper and the ClassLoader in use and an own ConverterRegistry .

Method Summary
public  voidaddDefaultImplementation(Class defaultImplementation, Class ofType)
     Associate a default implementation of a class with an object.
public  voidaddImmutableType(Class type)
     Add immutable types.
public  voidaddImplicitCollection(Class ownerType, String fieldName)
     Adds a default implicit collection which is used for any unmapped xml tag.
Parameters:
  ownerType - class owning the implicit collection
Parameters:
  fieldName - name of the field in the ownerType.
public  voidaddImplicitCollection(Class ownerType, String fieldName, Class itemType)
     Adds implicit collection which is used for all items of the given itemType.
Parameters:
  ownerType - class owning the implicit collection
Parameters:
  fieldName - name of the field in the ownerType.
public  voidaddImplicitCollection(Class ownerType, String fieldName, String itemFieldName, Class itemType)
     Adds implicit collection which is used for all items of the given element name defined by itemFieldName.
Parameters:
  ownerType - class owning the implicit collection
Parameters:
  fieldName - name of the field in the ownerType.
public  voidalias(String name, Class type)
     Alias a Class to a shorter name to be used in XML elements.
public  voidalias(String name, Class type, Class defaultImplementation)
     Alias a Class to a shorter name to be used in XML elements.
public  voidaliasAttribute(String alias, String attributeName)
    
public  voidaliasAttribute(Class definedIn, String attributeName, String alias)
     Create an alias for an attribute.
public  voidaliasField(String alias, Class definedIn, String fieldName)
     Create an alias for a field name.
public  voidaliasType(String name, Class type)
     Alias a type to a shorter name to be used in XML elements.
public  voidautodetectAnnotations(boolean mode)
     Set the auto-detection mode of the AnnotationMapper.
public  ObjectInputStreamcreateObjectInputStream(Reader xmlReader)
     Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream.
public  ObjectInputStreamcreateObjectInputStream(InputStream in)
     Creates an ObjectInputStream that deserializes a stream of objects from an InputStream using XStream.
public  ObjectInputStreamcreateObjectInputStream(HierarchicalStreamReader reader)
     Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream.
public  ObjectOutputStreamcreateObjectOutputStream(Writer writer)
     Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.
public  ObjectOutputStreamcreateObjectOutputStream(HierarchicalStreamWriter writer)
     Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.
public  ObjectOutputStreamcreateObjectOutputStream(Writer writer, String rootNodeName)
     Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.
public  ObjectOutputStreamcreateObjectOutputStream(OutputStream out)
     Creates an ObjectOutputStream that serializes a stream of objects to the OutputStream using XStream.
public  ObjectOutputStreamcreateObjectOutputStream(OutputStream out, String rootNodeName)
     Creates an ObjectOutputStream that serializes a stream of objects to the OutputStream using XStream.
public  ObjectOutputStreamcreateObjectOutputStream(HierarchicalStreamWriter writer, String rootNodeName)
     Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.
public  ObjectfromXML(String xml)
     Deserialize an object from an XML String.
public  ObjectfromXML(Reader xml)
     Deserialize an object from an XML Reader.
public  ObjectfromXML(InputStream input)
     Deserialize an object from an XML InputStream.
public  ObjectfromXML(String xml, Object root)
     Deserialize an object from an XML String, populating the fields of the given root object instead of instantiating a new one.
public  ObjectfromXML(Reader xml, Object root)
     Deserialize an object from an XML Reader, populating the fields of the given root object instead of instantiating a new one.
public  ObjectfromXML(InputStream xml, Object root)
     Deserialize an object from an XML InputStream, populating the fields of the given root object instead of instantiating a new one.
public  ClassLoadergetClassLoader()
     Change the ClassLoader XStream uses to load classes.
public  ClassMappergetClassMapper()
    
public  ConverterLookupgetConverterLookup()
    
public  MappergetMapper()
     Retrieve the Mapper .
public  ReflectionProvidergetReflectionProvider()
     Retrieve the ReflectionProvider in use.
public  voidmarshal(Object obj, HierarchicalStreamWriter writer)
     Serialize and object to a hierarchical data structure (such as XML).
public  voidmarshal(Object obj, HierarchicalStreamWriter writer, DataHolder dataHolder)
     Serialize and object to a hierarchical data structure (such as XML).
Parameters:
  dataHolder - Extra data you can use to pass to your converters.
public  DataHoldernewDataHolder()
     Create a DataHolder that can be used to pass data to the converters.
public  voidomitField(Class definedIn, String fieldName)
     Prevents a field from being serialized.
public  voidprocessAnnotations(Class[] types)
     Process the annotations of the given types and configure the XStream.
public  voidprocessAnnotations(Class type)
     Process the annotations of the given type and configure the XStream.
public  voidregisterConverter(Converter converter)
    
public  voidregisterConverter(Converter converter, int priority)
    
public  voidregisterConverter(SingleValueConverter converter)
    
public  voidregisterConverter(SingleValueConverter converter, int priority)
    
public  voidregisterLocalConverter(Class definedIn, String fieldName, Converter converter)
     Register a local Converter for a field.
public  voidregisterLocalConverter(Class definedIn, String fieldName, SingleValueConverter converter)
     Register a local SingleValueConverter for a field.
public  voidsetClassLoader(ClassLoader classLoader)
     Change the ClassLoader XStream uses to load classes.
public  voidsetMarshallingStrategy(MarshallingStrategy marshallingStrategy)
    
public  voidsetMode(int mode)
     Change mode for dealing with duplicate references.
protected  voidsetupAliases()
    
protected  voidsetupConverters()
    
protected  voidsetupDefaultImplementations()
    
protected  voidsetupImmutableTypes()
    
public  StringtoXML(Object obj)
     Serialize an object to a pretty-printed XML String.
public  voidtoXML(Object obj, Writer out)
     Serialize an object to the given Writer as pretty-printed XML.
public  voidtoXML(Object obj, OutputStream out)
     Serialize an object to the given OutputStream as pretty-printed XML.
public  Objectunmarshal(HierarchicalStreamReader reader)
     Deserialize an object from a hierarchical data structure (such as XML).
public  Objectunmarshal(HierarchicalStreamReader reader, Object root)
     Deserialize an object from a hierarchical data structure (such as XML), populating the fields of the given root object instead of instantiating a new one.
public  Objectunmarshal(HierarchicalStreamReader reader, Object root, DataHolder dataHolder)
     Deserialize an object from a hierarchical data structure (such as XML).
Parameters:
  root - If present, the passed in object will have its fields populated, as opposed toXStream creating a new instance.
public  voiduseAttributeFor(String fieldName, Class type)
     Use an attribute for a field or a specific type.
public  voiduseAttributeFor(Class definedIn, String fieldName)
     Use an attribute for a field declared in a specific type.
public  voiduseAttributeFor(Class type)
     Use an attribute for an arbitrary type.
protected  booleanuseXStream11XmlFriendlyMapper()
    
protected  MapperWrapperwrapMapper(MapperWrapper next)
    

Field Detail
ID_REFERENCES
final public static int ID_REFERENCES(Code)



NO_REFERENCES
final public static int NO_REFERENCES(Code)



PRIORITY_LOW
final public static int PRIORITY_LOW(Code)



PRIORITY_NORMAL
final public static int PRIORITY_NORMAL(Code)



PRIORITY_VERY_HIGH
final public static int PRIORITY_VERY_HIGH(Code)



PRIORITY_VERY_LOW
final public static int PRIORITY_VERY_LOW(Code)



XPATH_ABSOLUTE_REFERENCES
final public static int XPATH_ABSOLUTE_REFERENCES(Code)



XPATH_REFERENCES
final public static int XPATH_REFERENCES(Code)
XStream.XPATH_RELATIVE_REFERENCESXStream.XPATH_ABSOLUTE_REFERENCES



XPATH_RELATIVE_REFERENCES
final public static int XPATH_RELATIVE_REFERENCES(Code)




Constructor Detail
XStream
public XStream()(Code)
Constructs a default XStream. The instance will use the XppDriver as default and tries to determine the best match for the ReflectionProvider on its own.
throws:
  InitializationException - in case of an initialization problem



XStream
public XStream(ReflectionProvider reflectionProvider)(Code)
Constructs an XStream with a special ReflectionProvider . The instance will use the XppDriver as default.
throws:
  InitializationException - in case of an initialization problem



XStream
public XStream(HierarchicalStreamDriver hierarchicalStreamDriver)(Code)
Constructs an XStream with a special HierarchicalStreamDriver . The instance will tries to determine the best match for the ReflectionProvider on its own.
throws:
  InitializationException - in case of an initialization problem



XStream
public XStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver hierarchicalStreamDriver)(Code)
Constructs an XStream with a special HierarchicalStreamDriver and ReflectionProvider .
throws:
  InitializationException - in case of an initialization problem



XStream
public XStream(ReflectionProvider reflectionProvider, ClassMapper classMapper, HierarchicalStreamDriver driver)(Code)
XStream.XStream(ReflectionProvider,Mapper,HierarchicalStreamDriver)



XStream
public XStream(ReflectionProvider reflectionProvider, ClassMapper classMapper, HierarchicalStreamDriver driver, String classAttributeIdentifier)(Code)
XStream.XStream(ReflectionProvider,Mapper,HierarchicalStreamDriver)



XStream
public XStream(ReflectionProvider reflectionProvider, Mapper mapper, HierarchicalStreamDriver driver)(Code)
Constructs an XStream with a special HierarchicalStreamDriver and ReflectionProvider and additionally with a prepared Mapper .
throws:
  InitializationException - in case of an initialization problemXStream.XStream(ReflectionProvider,HierarchicalStreamDriver,Mapper,ClassLoader)



XStream
public XStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver, ClassLoader classLoader)(Code)
Constructs an XStream with a special HierarchicalStreamDriver and ReflectionProvider and additionally with a prepared ClassLoader to use.
throws:
  InitializationException - in case of an initialization problem
since:
   1.3



XStream
public XStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver, ClassLoader classLoader, Mapper mapper)(Code)
Constructs an XStream with a special HierarchicalStreamDriver and ReflectionProvider and additionally with a prepared Mapper and the ClassLoader in use.

Note, if the class loader should be changed later again, you should provide a ClassLoaderReference as ClassLoader that is also use in the Mapper chain.


throws:
  InitializationException - in case of an initialization problem
since:
   1.3



XStream
public XStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver, ClassLoader classLoader, Mapper mapper, ConverterLookup converterLookup, ConverterRegistry converterRegistry)(Code)
Constructs an XStream with a special HierarchicalStreamDriver , ReflectionProvider , a prepared Mapper and the ClassLoader in use and an own ConverterRegistry .

Note, if the class loader should be changed later again, you should provide a ClassLoaderReference as ClassLoader that is also use in the Mapper chain.


throws:
  InitializationException - in case of an initialization problem
since:
   1.3




Method Detail
addDefaultImplementation
public void addDefaultImplementation(Class defaultImplementation, Class ofType)(Code)
Associate a default implementation of a class with an object. Whenever XStream encounters an instance of this type, it will use the default implementation instead. For example, java.util.ArrayList is the default implementation of java.util.List.
Parameters:
  defaultImplementation -
Parameters:
  ofType -
throws:
  InitializationException - if no DefaultImplementationsMapper is available



addImmutableType
public void addImmutableType(Class type)(Code)
Add immutable types. The value of the instances of these types will always be written into the stream even if they appear multiple times.
throws:
  InitializationException - if no ImmutableTypesMapper is available



addImplicitCollection
public void addImplicitCollection(Class ownerType, String fieldName)(Code)
Adds a default implicit collection which is used for any unmapped xml tag.
Parameters:
  ownerType - class owning the implicit collection
Parameters:
  fieldName - name of the field in the ownerType. This field must be anjava.util.ArrayList.



addImplicitCollection
public void addImplicitCollection(Class ownerType, String fieldName, Class itemType)(Code)
Adds implicit collection which is used for all items of the given itemType.
Parameters:
  ownerType - class owning the implicit collection
Parameters:
  fieldName - name of the field in the ownerType. This field must be anjava.util.ArrayList.
Parameters:
  itemType - type of the items to be part of this collection.
throws:
  InitializationException - if no ImplicitCollectionMapper is available



addImplicitCollection
public void addImplicitCollection(Class ownerType, String fieldName, String itemFieldName, Class itemType)(Code)
Adds implicit collection which is used for all items of the given element name defined by itemFieldName.
Parameters:
  ownerType - class owning the implicit collection
Parameters:
  fieldName - name of the field in the ownerType. This field must be anjava.util.ArrayList.
Parameters:
  itemFieldName - element name of the implicit collection
Parameters:
  itemType - item type to be aliases be the itemFieldName
throws:
  InitializationException - if no ImplicitCollectionMapper is available



alias
public void alias(String name, Class type)(Code)
Alias a Class to a shorter name to be used in XML elements.
Parameters:
  name - Short name
Parameters:
  type - Type to be aliased
throws:
  InitializationException - if no ClassAliasingMapper is available



alias
public void alias(String name, Class type, Class defaultImplementation)(Code)
Alias a Class to a shorter name to be used in XML elements.
Parameters:
  name - Short name
Parameters:
  type - Type to be aliased
Parameters:
  defaultImplementation - Default implementation of type to use if no other specified.
throws:
  InitializationException - if no DefaultImplementationsMapper or no ClassAliasingMapper is available



aliasAttribute
public void aliasAttribute(String alias, String attributeName)(Code)
Create an alias for an attribute
Parameters:
  alias - the alias itself
Parameters:
  attributeName - the name of the attribute
throws:
  InitializationException - if no AttributeAliasingMapper is available



aliasAttribute
public void aliasAttribute(Class definedIn, String attributeName, String alias)(Code)
Create an alias for an attribute.
Parameters:
  definedIn - the type where the attribute is defined
Parameters:
  attributeName - the name of the attribute
Parameters:
  alias - the alias itself
throws:
  InitializationException - if no AttributeAliasingMapper is available
since:
   1.2.2



aliasField
public void aliasField(String alias, Class definedIn, String fieldName)(Code)
Create an alias for a field name.
Parameters:
  alias - the alias itself
Parameters:
  definedIn - the type that declares the field
Parameters:
  fieldName - the name of the field
throws:
  InitializationException - if no FieldAliasingMapper is available



aliasType
public void aliasType(String name, Class type)(Code)
Alias a type to a shorter name to be used in XML elements. Any class that is assignable to this type will be aliased to the same name.
Parameters:
  name - Short name
Parameters:
  type - Type to be aliased
since:
   1.2
throws:
  InitializationException - if no ClassAliasingMapper is available



autodetectAnnotations
public void autodetectAnnotations(boolean mode)(Code)
Set the auto-detection mode of the AnnotationMapper. Note that auto-detection implies that the XStream is configured while it is processing the XML steams. This is a potential concurrency problem. Also is it technically not possible to detect all class aliases at deserialization. You have been warned!
Parameters:
  mode - true if annotations are auto-detected
since:
   1.3



createObjectInputStream
public ObjectInputStream createObjectInputStream(Reader xmlReader) throws IOException(Code)
Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream.
See Also:   XStream.createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
See Also:   XStream.createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter,String)
since:
   1.0.3



createObjectInputStream
public ObjectInputStream createObjectInputStream(InputStream in) throws IOException(Code)
Creates an ObjectInputStream that deserializes a stream of objects from an InputStream using XStream.
See Also:   XStream.createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
See Also:   XStream.createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter,String)
since:
   1.3



createObjectInputStream
public ObjectInputStream createObjectInputStream(HierarchicalStreamReader reader) throws IOException(Code)
Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream.

Example

 ObjectInputStream in = xstream.createObjectOutputStream(aReader);
 int a = out.readInt();
 Object b = out.readObject();
 Object c = out.readObject();
 

See Also:   XStream.createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter,String)
since:
   1.0.3



createObjectOutputStream
public ObjectOutputStream createObjectOutputStream(Writer writer) throws IOException(Code)
Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.

To change the name of the root element (from <object-stream>), use XStream.createObjectOutputStream(java.io.Writer,String) .


See Also:   XStream.createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter,String)
See Also:   XStream.createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
since:
   1.0.3



createObjectOutputStream
public ObjectOutputStream createObjectOutputStream(HierarchicalStreamWriter writer) throws IOException(Code)
Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.

To change the name of the root element (from <object-stream>), use XStream.createObjectOutputStream(java.io.Writer,String) .


See Also:   XStream.createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter,String)
See Also:   XStream.createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
since:
   1.0.3



createObjectOutputStream
public ObjectOutputStream createObjectOutputStream(Writer writer, String rootNodeName) throws IOException(Code)
Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.
See Also:   XStream.createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter,String)
See Also:   XStream.createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
since:
   1.0.3



createObjectOutputStream
public ObjectOutputStream createObjectOutputStream(OutputStream out) throws IOException(Code)
Creates an ObjectOutputStream that serializes a stream of objects to the OutputStream using XStream.

To change the name of the root element (from <object-stream>), use XStream.createObjectOutputStream(java.io.Writer,String) .


See Also:   XStream.createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter,String)
See Also:   XStream.createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
since:
   1.3



createObjectOutputStream
public ObjectOutputStream createObjectOutputStream(OutputStream out, String rootNodeName) throws IOException(Code)
Creates an ObjectOutputStream that serializes a stream of objects to the OutputStream using XStream.
See Also:   XStream.createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter,String)
See Also:   XStream.createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
since:
   1.3



createObjectOutputStream
public ObjectOutputStream createObjectOutputStream(HierarchicalStreamWriter writer, String rootNodeName) throws IOException(Code)
Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.

Because an ObjectOutputStream can contain multiple items and XML only allows a single root node, the stream must be written inside an enclosing node.

It is necessary to call ObjectOutputStream.close() when done, otherwise the stream will be incomplete.

Example

 ObjectOutputStream out = xstream.createObjectOutputStream(aWriter, "things");
 out.writeInt(123);
 out.writeObject("Hello");
 out.writeObject(someObject)
 out.close();
 

Parameters:
  writer - The writer to serialize the objects to.
Parameters:
  rootNodeName - The name of the root node enclosing the stream of objects.
See Also:   XStream.createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
since:
   1.0.3



fromXML
public Object fromXML(String xml)(Code)
Deserialize an object from an XML String.
throws:
  XStreamException - if the object cannot be deserialized



fromXML
public Object fromXML(Reader xml)(Code)
Deserialize an object from an XML Reader.
throws:
  XStreamException - if the object cannot be deserialized



fromXML
public Object fromXML(InputStream input)(Code)
Deserialize an object from an XML InputStream.
throws:
  XStreamException - if the object cannot be deserialized



fromXML
public Object fromXML(String xml, Object root)(Code)
Deserialize an object from an XML String, populating the fields of the given root object instead of instantiating a new one. Note, that this is a special use case! With the ReflectionConverter XStream will write directly into the raw memory area of the existing object. Use with care!
throws:
  XStreamException - if the object cannot be deserialized



fromXML
public Object fromXML(Reader xml, Object root)(Code)
Deserialize an object from an XML Reader, populating the fields of the given root object instead of instantiating a new one. Note, that this is a special use case! With the ReflectionConverter XStream will write directly into the raw memory area of the existing object. Use with care!
throws:
  XStreamException - if the object cannot be deserialized



fromXML
public Object fromXML(InputStream xml, Object root)(Code)
Deserialize an object from an XML InputStream, populating the fields of the given root object instead of instantiating a new one. Note, that this is a special use case! With the ReflectionConverter XStream will write directly into the raw memory area of the existing object. Use with care!
throws:
  XStreamException - if the object cannot be deserialized



getClassLoader
public ClassLoader getClassLoader()(Code)
Change the ClassLoader XStream uses to load classes.
since:
   1.1.1



getClassMapper
public ClassMapper getClassMapper()(Code)

throws:
  ClassCastException - if mapper is not really a deprecated ClassMapper instanceXStream.getMapper



getConverterLookup
public ConverterLookup getConverterLookup()(Code)



getMapper
public Mapper getMapper()(Code)
Retrieve the Mapper . This is by default a chain of MapperWrapper MapperWrappers . the mapper
since:
   1.2



getReflectionProvider
public ReflectionProvider getReflectionProvider()(Code)
Retrieve the ReflectionProvider in use. the mapper
since:
   1.2.1



marshal
public void marshal(Object obj, HierarchicalStreamWriter writer)(Code)
Serialize and object to a hierarchical data structure (such as XML).
throws:
  XStreamException - if the object cannot be serialized



marshal
public void marshal(Object obj, HierarchicalStreamWriter writer, DataHolder dataHolder)(Code)
Serialize and object to a hierarchical data structure (such as XML).
Parameters:
  dataHolder - Extra data you can use to pass to your converters. Use this as you want. Ifnot present, XStream shall create one lazily as needed.
throws:
  XStreamException - if the object cannot be serialized



newDataHolder
public DataHolder newDataHolder()(Code)
Create a DataHolder that can be used to pass data to the converters. The DataHolder is provided with a call to XStream.marshal(Object,HierarchicalStreamWriter,DataHolder) or XStream.unmarshal(HierarchicalStreamReader,Object,DataHolder) . a new DataHolder



omitField
public void omitField(Class definedIn, String fieldName)(Code)
Prevents a field from being serialized. To omit a field you must always provide the declaring type and not necessarily the type that is converted.
since:
   1.1.3
throws:
  InitializationException - if no FieldAliasingMapper is available



processAnnotations
public void processAnnotations(Class[] types)(Code)
Process the annotations of the given types and configure the XStream.
Parameters:
  types - the types with XStream annotations
since:
   1.3



processAnnotations
public void processAnnotations(Class type)(Code)
Process the annotations of the given type and configure the XStream. A call of this method will automatically turn the auto-detection mode for annotations off.
Parameters:
  type - the type with XStream annotations
since:
   1.3



registerConverter
public void registerConverter(Converter converter)(Code)



registerConverter
public void registerConverter(Converter converter, int priority)(Code)



registerConverter
public void registerConverter(SingleValueConverter converter)(Code)



registerConverter
public void registerConverter(SingleValueConverter converter, int priority)(Code)



registerLocalConverter
public void registerLocalConverter(Class definedIn, String fieldName, Converter converter)(Code)
Register a local Converter for a field.
Parameters:
  definedIn - the class type the field is defined in
Parameters:
  fieldName - the field name
Parameters:
  converter - the converter to use
since:
   1.3



registerLocalConverter
public void registerLocalConverter(Class definedIn, String fieldName, SingleValueConverter converter)(Code)
Register a local SingleValueConverter for a field.
Parameters:
  definedIn - the class type the field is defined in
Parameters:
  fieldName - the field name
Parameters:
  converter - the converter to use
since:
   1.3



setClassLoader
public void setClassLoader(ClassLoader classLoader)(Code)
Change the ClassLoader XStream uses to load classes.
since:
   1.1.1



setMarshallingStrategy
public void setMarshallingStrategy(MarshallingStrategy marshallingStrategy)(Code)



setMode
public void setMode(int mode)(Code)
Change mode for dealing with duplicate references. Valid values are XPATH_ABSOLUTE_REFERENCES, XPATH_RELATIVE_REFERENCES, XStream.ID_REFERENCES and XStream.NO_REFERENCES.
throws:
  IllegalArgumentException - if the mode is not one of the declared types
See Also:   XStream.XPATH_ABSOLUTE_REFERENCES
See Also:   XStream.XPATH_RELATIVE_REFERENCES
See Also:   XStream.ID_REFERENCES
See Also:   XStream.NO_REFERENCES



setupAliases
protected void setupAliases()(Code)



setupConverters
protected void setupConverters()(Code)



setupDefaultImplementations
protected void setupDefaultImplementations()(Code)



setupImmutableTypes
protected void setupImmutableTypes()(Code)



toXML
public String toXML(Object obj)(Code)
Serialize an object to a pretty-printed XML String.
throws:
  XStreamException - if the object cannot be serialized



toXML
public void toXML(Object obj, Writer out)(Code)
Serialize an object to the given Writer as pretty-printed XML.
throws:
  XStreamException - if the object cannot be serialized



toXML
public void toXML(Object obj, OutputStream out)(Code)
Serialize an object to the given OutputStream as pretty-printed XML.
throws:
  XStreamException - if the object cannot be serialized



unmarshal
public Object unmarshal(HierarchicalStreamReader reader)(Code)
Deserialize an object from a hierarchical data structure (such as XML).
throws:
  XStreamException - if the object cannot be deserialized



unmarshal
public Object unmarshal(HierarchicalStreamReader reader, Object root)(Code)
Deserialize an object from a hierarchical data structure (such as XML), populating the fields of the given root object instead of instantiating a new one. Note, that this is a special use case! With the ReflectionConverter XStream will write directly into the raw memory area of the existing object. Use with care!
throws:
  XStreamException - if the object cannot be deserialized



unmarshal
public Object unmarshal(HierarchicalStreamReader reader, Object root, DataHolder dataHolder)(Code)
Deserialize an object from a hierarchical data structure (such as XML).
Parameters:
  root - If present, the passed in object will have its fields populated, as opposed toXStream creating a new instance. Note, that this is a special use case! With the ReflectionConverter XStream will write directly into the raw memory area of the existing object. Use with care!
Parameters:
  dataHolder - Extra data you can use to pass to your converters. Use this as you want. Ifnot present, XStream shall create one lazily as needed.
throws:
  XStreamException - if the object cannot be deserialized



useAttributeFor
public void useAttributeFor(String fieldName, Class type)(Code)
Use an attribute for a field or a specific type.
Parameters:
  fieldName - the name of the field
Parameters:
  type - the Class of the type to be rendered as XML attribute
throws:
  InitializationException - if no AttributeMapper is available
since:
   1.2



useAttributeFor
public void useAttributeFor(Class definedIn, String fieldName)(Code)
Use an attribute for a field declared in a specific type.
Parameters:
  fieldName - the name of the field
Parameters:
  definedIn - the Class containing such field
throws:
  InitializationException - if no AttributeMapper is available
since:
   1.2.2



useAttributeFor
public void useAttributeFor(Class type)(Code)
Use an attribute for an arbitrary type.
Parameters:
  type - the Class of the type to be rendered as XML attribute
throws:
  InitializationException - if no AttributeMapper is available
since:
   1.2



useXStream11XmlFriendlyMapper
protected boolean useXStream11XmlFriendlyMapper()(Code)



wrapMapper
protected MapperWrapper wrapMapper(MapperWrapper next)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.