Class ClassSchema

java.lang.Object
org.simpleframework.xml.core.ClassSchema
All Implemented Interfaces:
Schema

class ClassSchema extends Object implements Schema
The Schema object is used to track which fields within an object have been visited by a converter. This object is necessary for processing Composite objects. In particular it is necessary to keep track of which required nodes have been visited and which have not, if a required not has not been visited then the XML source does not match the XML class schema and serialization must fail before processing any further.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Caller
    This is the pointer to the schema class replace method.
    private final Decorator
    This is the decorator associated with this schema object.
    private final Instantiator
    This is the instantiator used to create all object instances.
    private final boolean
    This is used to specify whether the type is a primitive class.
    private final Version
    This is the version annotation for the XML class schema.
    private final Section
    This represents the XML section defined for the class schema.
    private final Label
    This is used to represent a text value within the schema.
    private final Class
    This is the type that this class schema is representing.
    private final Label
    This is the version label used to read the version attribute.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClassSchema(Scanner schema, Context context)
    Constructor for the Schema object.
  • Method Summary

    Modifier and Type
    Method
    Description
    This is used to acquire the Caller object.
    This is used to acquire the Decorator for this.
    This is used to acquire the instantiator for the type.
    This is the Version for the scanned class.
    This is used to acquire the Section that defines the XML structure for this class schema.
    This returns the Label that represents the text annotation for the scanned class.
    This returns the Label that represents the version annotation for the scanned class.
    boolean
    This is used to determine whether the scanned class represents a primitive type.
    This is used to acquire a description of the schema.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • factory

      private final Instantiator factory
      This is the instantiator used to create all object instances.
    • decorator

      private final Decorator decorator
      This is the decorator associated with this schema object.
    • section

      private final Section section
      This represents the XML section defined for the class schema.
    • revision

      private final Version revision
      This is the version annotation for the XML class schema.
    • caller

      private final Caller caller
      This is the pointer to the schema class replace method.
    • version

      private final Label version
      This is the version label used to read the version attribute.
    • text

      private final Label text
      This is used to represent a text value within the schema.
    • type

      private final Class type
      This is the type that this class schema is representing.
    • primitive

      private final boolean primitive
      This is used to specify whether the type is a primitive class.
  • Constructor Details

    • ClassSchema

      public ClassSchema(Scanner schema, Context context) throws Exception
      Constructor for the Schema object. This is used to wrap the element and attribute XML annotations scanned from a class schema. The schema tracks all fields visited so that a converter can determine if all fields have been serialized.
      Parameters:
      schema - this contains all labels scanned from the class
      context - this is the context object for serialization
      Throws:
      Exception
  • Method Details

    • isPrimitive

      public boolean isPrimitive()
      This is used to determine whether the scanned class represents a primitive type. A primitive type is a type that contains no XML annotations and so cannot be serialized with an XML form. Instead primitives a serialized using transformations.
      Specified by:
      isPrimitive in interface Schema
      Returns:
      this returns true if no XML annotations were found
    • getInstantiator

      public Instantiator getInstantiator()
      This is used to acquire the instantiator for the type. This is used to create object instances based on the constructors that have been annotated. If no constructors have been annotated then this can be used to create default no argument instances.
      Specified by:
      getInstantiator in interface Schema
      Returns:
      this instantiator responsible for creating instances
    • getVersion

      public Label getVersion()
      This returns the Label that represents the version annotation for the scanned class. Only a single version can exist within the class if more than one exists an exception is thrown. This will read only floating point types such as double.
      Specified by:
      getVersion in interface Schema
      Returns:
      this returns the label used for reading the version
    • getRevision

      public Version getRevision()
      This is the Version for the scanned class. It allows the deserialization process to be configured such that if the version is different from the schema class none of the fields and methods are required and unmatched elements and attributes will be ignored.
      Specified by:
      getRevision in interface Schema
      Returns:
      this returns the version of the class that is scanned
    • getDecorator

      public Decorator getDecorator()
      This is used to acquire the Decorator for this. A decorator is an object that adds various details to the node without changing the overall structure of the node. For example comments and namespaces can be added to the node with a decorator as they do not affect the deserialization.
      Specified by:
      getDecorator in interface Schema
      Returns:
      this returns the decorator associated with this
    • getCaller

      public Caller getCaller()
      This is used to acquire the Caller object. This is used to call the callback methods within the object. If the object contains no callback methods then this will return an object that does not invoke any methods that are invoked.
      Specified by:
      getCaller in interface Schema
      Returns:
      this returns the caller for the specified type
    • getSection

      public Section getSection()
      This is used to acquire the Section that defines the XML structure for this class schema. A section, is the section of XML that the class is represented within. A section contains all the elements and attributes defined for the class in a tree like structure.
      Specified by:
      getSection in interface Schema
      Returns:
      this returns the section defined for the schama
    • getText

      public Label getText()
      This returns the Label that represents the text annotation for the scanned class. Only a single text annotation can be used per class, so this returns only a single label rather than a LabelMap object. Also if this is not null then the elements label map will be empty.
      Specified by:
      getText in interface Schema
      Returns:
      this returns the text label for the scanned class
    • toString

      public String toString()
      This is used to acquire a description of the schema. This is useful when debugging an issue as it allows a representation of the instance to be viewed with the class it represents.
      Overrides:
      toString in class Object
      Returns:
      this returns a visible description of the schema