Class Collector

java.lang.Object
org.simpleframework.xml.core.Collector
All Implemented Interfaces:
Iterable<Object>, Criteria

class Collector extends Object implements Criteria
The Collector object is used to store variables for a deserialized object. Each variable contains the label and value for a field or method. The Composite object uses this to store deserialized values before committing them to the objects methods and fields.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    The Registry object is used to store variables for the collector.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Collector.Registry
    This is the registry that contains variables mapped to paths.
    private final Collector.Registry
    This is the registry containing all the variables collected.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the Collector object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    commit(Object source)
    This is used to set the values for the methods and fields of the specified object.
    get(Object key)
    This is used to get the Variable that represents a deserialized object.
    get(Label label)
    This is used to get the Variable that represents a deserialized object.
    This is used to acquire an iterator over the named variables.
    This is used to remove the Variable from this criteria object.
    This is used to resolve the Variable by using the union names of a label.
    void
    set(Label label, Object value)
    This is used to create a Variable and set it for this criteria.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • registry

      private final Collector.Registry registry
      This is the registry containing all the variables collected.
    • alias

      private final Collector.Registry alias
      This is the registry that contains variables mapped to paths.
  • Constructor Details

    • Collector

      public Collector()
      Constructor for the Collector object. This is used to store variables for an objects fields and methods. Each variable is stored using the name of the label.
  • Method Details

    • get

      public Variable get(Object key)
      This is used to get the Variable that represents a deserialized object. The variable contains all the meta data for the field or method and the value that is to be set on the method or field.
      Specified by:
      get in interface Criteria
      Parameters:
      key - this is the key of the variable to be acquired
      Returns:
      this returns the keyed variable if it exists
    • get

      public Variable get(Label label) throws Exception
      This is used to get the Variable that represents a deserialized object. The variable contains all the meta data for the field or method and the value that is to be set on the method or field.
      Specified by:
      get in interface Criteria
      Parameters:
      label - this is the label to resolve the variable with
      Returns:
      this returns the variable associated with the label
      Throws:
      Exception
    • resolve

      public Variable resolve(String path)
      This is used to resolve the Variable by using the union names of a label. This will also acquire variables based on the actual name of the variable.
      Specified by:
      resolve in interface Criteria
      Parameters:
      path - this is the path of the variable to be acquired
      Returns:
      this returns the variable mapped to the path
    • remove

      public Variable remove(Object key) throws Exception
      This is used to remove the Variable from this criteria object. When removed, the variable will no longer be used to set the method or field when the commit method is invoked.
      Specified by:
      remove in interface Criteria
      Parameters:
      key - this is the key associated with the variable
      Returns:
      this returns the keyed variable if it exists
      Throws:
      Exception
    • iterator

      public Iterator<Object> iterator()
      This is used to acquire an iterator over the named variables. Providing an Iterator allows the criteria to be used in a for each loop. This is primarily for convenience.
      Specified by:
      iterator in interface Iterable<Object>
      Returns:
      this returns an iterator of all the variable names
    • set

      public void set(Label label, Object value) throws Exception
      This is used to create a Variable and set it for this criteria. The variable can be retrieved at a later stage using the name of the label. This allows for repeat reads as the variable can be used to acquire the labels converter.
      Specified by:
      set in interface Criteria
      Parameters:
      label - this is the label used to create the variable
      value - this is the value of the object to be read
      Throws:
      Exception
    • commit

      public void commit(Object source) throws Exception
      This is used to set the values for the methods and fields of the specified object. Invoking this performs the population of an object being deserialized. It ensures that each value is set after the XML element has been fully read.
      Specified by:
      commit in interface Criteria
      Parameters:
      source - this is the object that is to be populated
      Throws:
      Exception