Skip to content
Engin1980 edited this page Jan 22, 2018 · 1 revision

Welcome to the Java-Simple-Xml-Serialization wiki!

Description

The idea is simple. Having a simple xml file, like

 <?xml version="1.0" encoding="UTF-8"?>
 <person name="Michal" >
     <surname>Volny</surname>
     <address>
         <street>Novicka</street>
         <houseNumber>58</houseNumber>
         <used>true</used>
     </address>
 </person>

... using a simple command to load the values into the simple class ...

public class Person {
  private String name;
  public String surname;
  private Address address;
  private List phones;
  private List phoneNumbers;
  // getters/setters...

The properties are:

  • Java class
    • private, internal and public fields are filled, static are ignored
    • fields to be skipped can be marked with Annotation
  • XML file
  • values can be set as element attributes or as element values
  • Parsing
  • as Java forget List generic type during compilation, specific mapping must be defined to clarify what should be a data-type of List and its elements
  • by mapping different list elements might be transformed into different type
  • all classes must contain public parameterless constructor. However, there is a possibility to specify own class responsible for a creation of an instance of a class without such parameter
  • fields can be skipped based on regular expression

For more info follow the documentation How-to.

Project

Simple introduction

Common concepts

Clone this wiki locally