Skip to content
/ fasax Public

The fastest way to unmarshall XML to Java on Android

Notifications You must be signed in to change notification settings

evant/fasax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fasax

The fastest way to unmarshall XML to Java on Android.

Note: This project is far from complete, but can unmarshell simple xml documments.

Unlike other implementations, this libary generates SAX parsing code at compile time. This makes it's performace virtually the same as a handwritten SAX parser. Annotations are inspired from Simple XML.

Example

<enterprise>
 <corporation>Agile Analytics</corporation>
  <software-license type="Proprietary" year="2014">Agile Analytics Software Licences™</software-license>
  <software>Cloud Big Data Management</software>
  <software>JVMXMLRPP</software>
  <software>Addition as a Service</software>
  <employees>
    <employee>
      <name>Vendelín Gamil</name>
      <title>Senior Architect</title>
      <date-started>2010-12-01</date-started>
    </employee>
    <employee>
      <name>Huw Andrea</name>
      <title>Junior Architect</title>
      <date-started>2013-06-12</date-started>
    </employee>
    <employee>
      <name>Benjy Teodors</name>
      <title>Head Senior Architect</title>
      <date-started>2011-10-24</date-started>
    </employee>
  </employees>
</enterprise>
@Xml
pubic class Enterprise {
    @Element
    public String corperation;

    @Element(name="software-license")
    public SoftwareLicense softwareLicense;

    @ElementList(entry="software", inline=true)
    public List<String> software;

    @ElementList(entry="employee")
    public List<Employee> employees;

    @Xml
    public static class SoftwareLicense {
        @Attribute
        public String type;

        @Attribute
        public String year;

        @Text
        public String name;
    }

    @Xml
    public static class Employee {
        @Element
        public String name;

        @Element
        public String title;

        @Converter(DateConverter.class)
        @Element(name="date-started")
        public Date dateStarted;
    }
}
Fasax fasax = new Fasax();
InputStream in = getXmlInputStream();
Enterprise enterprise = fasax.fromXml(in, Enterprise.class);

TODO

  • Allow use of setters instead of public fields
  • Write XML
  • Namespaces
  • Split compile-time and runtime dependencies

About

The fastest way to unmarshall XML to Java on Android

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages