Class Collector

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.Object>, Criteria

    class Collector
    extends java.lang.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:
    Composite
    • Nested Class Summary

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

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

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void commit​(java.lang.Object source)
      This is used to set the values for the methods and fields of the specified object.
      Variable get​(java.lang.Object key)
      This is used to get the Variable that represents a deserialized object.
      Variable get​(Label label)
      This is used to get the Variable that represents a deserialized object.
      java.util.Iterator<java.lang.Object> iterator()
      This is used to acquire an iterator over the named variables.
      Variable remove​(java.lang.Object key)
      This is used to remove the Variable from this criteria object.
      Variable resolve​(java.lang.String path)
      This is used to resolve the Variable by using the union names of a label.
      void set​(Label label, java.lang.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 Detail

      • 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 Detail

      • 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 Detail

      • get

        public Variable get​(java.lang.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 java.lang.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:
        java.lang.Exception
      • resolve

        public Variable resolve​(java.lang.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​(java.lang.Object key)
                        throws java.lang.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:
        java.lang.Exception
      • iterator

        public java.util.Iterator<java.lang.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 java.lang.Iterable<java.lang.Object>
        Returns:
        this returns an iterator of all the variable names
      • set

        public void set​(Label label,
                        java.lang.Object value)
                 throws java.lang.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:
        java.lang.Exception
      • commit

        public void commit​(java.lang.Object source)
                    throws java.lang.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:
        java.lang.Exception