XStream Quick Start Albert Guo [email_address]
Agenda Brief Introduction to XStream What is XStream XStream Features Official Site FAQ Use Cases Use Case 1: JavaBean To XML Use Case 2 : XML To JavaBean Using Alias Using Implicit Collection © 2006 PTC
What is XStream XStream is a simple library to serialize objects to XML and back again. © 2006 PTC serialize objects XML
XStream Features (1/2) Ease of use A high level facade is supplied that simplifies common use cases. No mappings required Most objects can be serialized without need for specifying mappings. Performance Speed and low memory footprint are a crucial part of the design, making it suitable for large object graphs or systems with high message throughput. Clean XML No information is duplicated that can be obtained via reflection. This results in XML that is easier to read for humans and more compact than native Java serialization. . © 2006 PTC
XStream Features (2/2) Requires no modifications to objects Serializes internal fields, including private and final. Supports non-public and inner classes. Classes are not required to have default constructor. Full object graph support Duplicate references encountered in the object-model will be maintained. Supports circular references. Integrates with other XML APIs By implementing an interface, XStream can serialize directly to/from any tree structure (not just XML). Customizable conversion strategies Strategies can be registered allowing customization of how particular types are represented as XML. Error messages When an exception occurs due to malformed XML, detailed diagnostics are provided to help isolate and fix the problem © 2006 PTC
Official Site © 2006 PTC http://xstream.codehaus.org/index.html
Quick Start © 2006 PTC
XStream FAQ © 2006 PTC
Use Case 1: JavaBean To XML serialize objects XML
Use Case 1: JavaBean To XML Prepared two persons’ contact information, including first name, last name phone call and fax number System should write these contact information into Person.xml correctly © 2006 PTC serialize objects XML
Four Steps © 2006 PTC
Step1. Creating classes to be serialized © 2006 PTC
Step2. Preparing data © 2006 PTC
Step3. Initializing XStream © 2006 PTC
Step4. Serializing an object to XML and writing XML object into file © 2006 PTC Source Code
Use Case 2 : XML To JavaBean serialize objects XML
Use Case 2 : XML To JavaBean Read from Person.xml Parse the xml file and put contact info into Person bean © 2006 PTC XML To JavaBean serialize objects XML
Four Steps © 2006 PTC
Using Alias
Alias Based on the xml file above we shall create some model classes and configure XStream to write/read from this format. © 2006 PTC
Step1. Creating classes to be serialized © 2006 PTC
Step2. Preparing data © 2006 PTC
Step3. Initializing XStream and serializing an object to XML © 2006 PTC
Step3. Initializing XStream and serializing an object to XML © 2006 PTC
Use Alias © 2006 PTC
Using Implicit Collection
Using Implicit Collection Now let's implement what was called an  implicit collection : whenever you have a collection which doesn't need to display it's root tag, you can map it as an implicit collection. In our example, we do not want to display the orderList tag, but simply show the Order tags one after another. A simple call to the  addImplicitCollection  method shall configure XStream and let it know that we do not want to write the orderList tag as described above: © 2006 PTC
The Model © 2006 PTC
Simple Test © 2006 PTC
Simple Test © 2006 PTC
Simple Test © 2006 PTC
Result © 2006 PTC

More Related Content

PPT
Utilized JAXB to generate POJOs automatically
PPT
LINQ to XML
PDF
Stax parser
ODP
Xml processing in scala
PPTX
Xml writers
PPT
DOSUG XML Beans overview by Om Sivanesian
PPT
6 311 W
PPTX
Linq to xml
Utilized JAXB to generate POJOs automatically
LINQ to XML
Stax parser
Xml processing in scala
Xml writers
DOSUG XML Beans overview by Om Sivanesian
6 311 W
Linq to xml

What's hot (15)

PPTX
PPTX
Applied xml programming for microsoft
PPTX
Back-2-Basics: .NET Coding Standards For The Real World
PPT
ASP.NET Session 11 12
PDF
JAXB: Create, Validate XML Message and Edit XML Schema
PDF
Python xml processing
DOCX
PPT
Lecture 6. ADO.NET Overview.
PDF
PPTX
AAC Room
PDF
XML parsing using jaxb
PDF
Data Persistence in Android with Room Library
PPT
Applied xml programming for microsoft
Back-2-Basics: .NET Coding Standards For The Real World
ASP.NET Session 11 12
JAXB: Create, Validate XML Message and Edit XML Schema
Python xml processing
Lecture 6. ADO.NET Overview.
AAC Room
XML parsing using jaxb
Data Persistence in Android with Room Library
Ad

Similar to XStream Quick Start (19)

PPT
Utilized XStrem in Green Integration
PDF
XStream
PDF
Tool Development 05 - XML Schema, INI, JSON, YAML
PPTX
Xml serialization
PPT
It seminar-xml serialization
PPT
It seminar-xml serialization
PPTX
Working with XML and JSON Serializing
ODP
SCDJWS 6. REST JAX-P
PPTX
Java Serialization Facts and Fallacies
PDF
Extbase object to xml mapping
PPTX
File Handling - Serialization.pptx
PPTX
Serialization and performance by Sergey Morenets
PDF
Java EE 8 - An instant snapshot
PDF
Persistent Session Storage
PPTX
C# Xml serialization
PDF
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
PPTX
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
PDF
Wcf difference faqs- 2
PDF
Jdom how it works & how it opened the java process
Utilized XStrem in Green Integration
XStream
Tool Development 05 - XML Schema, INI, JSON, YAML
Xml serialization
It seminar-xml serialization
It seminar-xml serialization
Working with XML and JSON Serializing
SCDJWS 6. REST JAX-P
Java Serialization Facts and Fallacies
Extbase object to xml mapping
File Handling - Serialization.pptx
Serialization and performance by Sergey Morenets
Java EE 8 - An instant snapshot
Persistent Session Storage
C# Xml serialization
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
(De)serial Killers - BSides Las Vegas & AppSec IL 2018
Wcf difference faqs- 2
Jdom how it works & how it opened the java process
Ad

More from Guo Albert (20)

PPTX
AWS IAM (Identity and Access Management) Policy Simulator
PPTX
TOEIC 準備心得
PDF
DBM專案環境建置
PDF
JPA Optimistic Locking With @Version
PDF
OCEJPA Study Notes
PPTX
OCEJPA(1Z0-898) Preparation Tips
PPTX
JPA lifecycle events practice
PPTX
XDate - a modern java-script date library
PDF
How to avoid check style errors
PDF
NIG系統報表開發指南
PDF
Ease Your Effort of Putting Data into History Table
PDF
NIG 系統開發指引
PDF
NIG系統開發文件閱讀步驟
PDF
Form Bean Creation Process for NIG System
PDF
A Short Intorduction to JasperReports
PPTX
Apply Template Method Pattern in Report Implementation
PPTX
Utilize Commons BeansUtils to do copy object
PPTX
Apply my eclipse to do entity class generation
PPTX
Nig project setup quickly tutorial
PPTX
Spring JDBCTemplate
AWS IAM (Identity and Access Management) Policy Simulator
TOEIC 準備心得
DBM專案環境建置
JPA Optimistic Locking With @Version
OCEJPA Study Notes
OCEJPA(1Z0-898) Preparation Tips
JPA lifecycle events practice
XDate - a modern java-script date library
How to avoid check style errors
NIG系統報表開發指南
Ease Your Effort of Putting Data into History Table
NIG 系統開發指引
NIG系統開發文件閱讀步驟
Form Bean Creation Process for NIG System
A Short Intorduction to JasperReports
Apply Template Method Pattern in Report Implementation
Utilize Commons BeansUtils to do copy object
Apply my eclipse to do entity class generation
Nig project setup quickly tutorial
Spring JDBCTemplate

Recently uploaded (20)

PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Five Habits of High-Impact Board Members
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
Modernising the Digital Integration Hub
PDF
STKI Israel Market Study 2025 version august
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
Tartificialntelligence_presentation.pptx
PDF
Architecture types and enterprise applications.pdf
PPTX
Benefits of Physical activity for teenagers.pptx
DOCX
search engine optimization ppt fir known well about this
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
The various Industrial Revolutions .pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Univ-Connecticut-ChatGPT-Presentaion.pdf
DP Operators-handbook-extract for the Mautical Institute
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Five Habits of High-Impact Board Members
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Modernising the Digital Integration Hub
STKI Israel Market Study 2025 version august
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
observCloud-Native Containerability and monitoring.pptx
Group 1 Presentation -Planning and Decision Making .pptx
A novel scalable deep ensemble learning framework for big data classification...
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Tartificialntelligence_presentation.pptx
Architecture types and enterprise applications.pdf
Benefits of Physical activity for teenagers.pptx
search engine optimization ppt fir known well about this
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Module 1.ppt Iot fundamentals and Architecture
The various Industrial Revolutions .pptx

XStream Quick Start

  • 1. XStream Quick Start Albert Guo [email_address]
  • 2. Agenda Brief Introduction to XStream What is XStream XStream Features Official Site FAQ Use Cases Use Case 1: JavaBean To XML Use Case 2 : XML To JavaBean Using Alias Using Implicit Collection © 2006 PTC
  • 3. What is XStream XStream is a simple library to serialize objects to XML and back again. © 2006 PTC serialize objects XML
  • 4. XStream Features (1/2) Ease of use A high level facade is supplied that simplifies common use cases. No mappings required Most objects can be serialized without need for specifying mappings. Performance Speed and low memory footprint are a crucial part of the design, making it suitable for large object graphs or systems with high message throughput. Clean XML No information is duplicated that can be obtained via reflection. This results in XML that is easier to read for humans and more compact than native Java serialization. . © 2006 PTC
  • 5. XStream Features (2/2) Requires no modifications to objects Serializes internal fields, including private and final. Supports non-public and inner classes. Classes are not required to have default constructor. Full object graph support Duplicate references encountered in the object-model will be maintained. Supports circular references. Integrates with other XML APIs By implementing an interface, XStream can serialize directly to/from any tree structure (not just XML). Customizable conversion strategies Strategies can be registered allowing customization of how particular types are represented as XML. Error messages When an exception occurs due to malformed XML, detailed diagnostics are provided to help isolate and fix the problem © 2006 PTC
  • 6. Official Site © 2006 PTC http://xstream.codehaus.org/index.html
  • 7. Quick Start © 2006 PTC
  • 8. XStream FAQ © 2006 PTC
  • 9. Use Case 1: JavaBean To XML serialize objects XML
  • 10. Use Case 1: JavaBean To XML Prepared two persons’ contact information, including first name, last name phone call and fax number System should write these contact information into Person.xml correctly © 2006 PTC serialize objects XML
  • 11. Four Steps © 2006 PTC
  • 12. Step1. Creating classes to be serialized © 2006 PTC
  • 13. Step2. Preparing data © 2006 PTC
  • 15. Step4. Serializing an object to XML and writing XML object into file © 2006 PTC Source Code
  • 16. Use Case 2 : XML To JavaBean serialize objects XML
  • 17. Use Case 2 : XML To JavaBean Read from Person.xml Parse the xml file and put contact info into Person bean © 2006 PTC XML To JavaBean serialize objects XML
  • 18. Four Steps © 2006 PTC
  • 20. Alias Based on the xml file above we shall create some model classes and configure XStream to write/read from this format. © 2006 PTC
  • 21. Step1. Creating classes to be serialized © 2006 PTC
  • 22. Step2. Preparing data © 2006 PTC
  • 23. Step3. Initializing XStream and serializing an object to XML © 2006 PTC
  • 24. Step3. Initializing XStream and serializing an object to XML © 2006 PTC
  • 25. Use Alias © 2006 PTC
  • 27. Using Implicit Collection Now let's implement what was called an implicit collection : whenever you have a collection which doesn't need to display it's root tag, you can map it as an implicit collection. In our example, we do not want to display the orderList tag, but simply show the Order tags one after another. A simple call to the addImplicitCollection method shall configure XStream and let it know that we do not want to write the orderList tag as described above: © 2006 PTC
  • 28. The Model © 2006 PTC
  • 29. Simple Test © 2006 PTC
  • 30. Simple Test © 2006 PTC
  • 31. Simple Test © 2006 PTC