Class ReadGraph

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map

    class ReadGraph
    extends java.util.HashMap
    The ReadGraph object is used to build a graph of the objects that have been deserialized from the XML document. This is required so that cycles in the object graph can be recreated such that the deserialized object is an exact duplicate of the object that was serialized. Objects are stored in the graph using unique keys, which for this implementation are unique strings.
    See Also:
    WriteGraph
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String label
      This is the label used to mark the type of an object.
      private java.lang.String length
      This is used to represent the length of array object values.
      private Loader loader
      This is the class loader that is used to load the types used.
      private java.lang.String mark
      This is the attribute used to mark the identity of an object.
      private java.lang.String refer
      This is the attribute used to refer to an existing instance.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReadGraph​(Contract contract, Loader loader)
      Constructor for the ReadGraph object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Value read​(Type type, NodeMap node)
      This is used to recover the object references from the document using the special attributes specified.
      private Value readArray​(Type type, java.lang.Class real, NodeMap node)
      This is used to acquire the Value which can be used to represent the deserialized value.
      private Value readInstance​(Type type, java.lang.Class real, NodeMap node)
      This is used to recover the object references from the document using the special attributes specified.
      private Value readReference​(Type type, java.lang.Class real, NodeMap node)
      This is used to recover the object references from the document using the special attributes specified.
      private Value readValue​(Type type, java.lang.Class real, NodeMap node)
      This is used to acquire the Value which can be used to represent the deserialized value.
      private Value readValue​(Type type, java.lang.Class real, NodeMap node, java.lang.String key)
      This is used to acquire the Value which can be used to represent the deserialized value.
      • Methods inherited from class java.util.HashMap

        clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        equals, hashCode
    • Field Detail

      • loader

        private final Loader loader
        This is the class loader that is used to load the types used.
      • length

        private final java.lang.String length
        This is used to represent the length of array object values.
      • label

        private final java.lang.String label
        This is the label used to mark the type of an object.
      • mark

        private final java.lang.String mark
        This is the attribute used to mark the identity of an object.
      • refer

        private final java.lang.String refer
        This is the attribute used to refer to an existing instance.
    • Constructor Detail

      • ReadGraph

        public ReadGraph​(Contract contract,
                         Loader loader)
        Constructor for the ReadGraph object. This is used to create graphs that are used for reading objects from the XML document. The specified strategy is used to acquire the names of the special attributes used during the serialization.
        Parameters:
        contract - this is the name scheme used by the strategy
        loader - this is the class loader to used for the graph
    • Method Detail

      • read

        public Value read​(Type type,
                          NodeMap node)
                   throws java.lang.Exception
        This is used to recover the object references from the document using the special attributes specified. This allows the element specified by the NodeMap to be used to discover exactly which node in the object graph the element represents.
        Parameters:
        type - the type of the field or method in the instance
        node - this is the XML element to be deserialized
        Returns:
        this is used to return the type to acquire the value
        Throws:
        java.lang.Exception
      • readInstance

        private Value readInstance​(Type type,
                                   java.lang.Class real,
                                   NodeMap node)
                            throws java.lang.Exception
        This is used to recover the object references from the document using the special attributes specified. This allows the element specified by the NodeMap to be used to discover exactly which node in the object graph the element represents.
        Parameters:
        type - the type of the field or method in the instance
        real - this is the overridden type from the XML element
        node - this is the XML element to be deserialized
        Returns:
        this is used to return the type to acquire the value
        Throws:
        java.lang.Exception
      • readReference

        private Value readReference​(Type type,
                                    java.lang.Class real,
                                    NodeMap node)
                             throws java.lang.Exception
        This is used to recover the object references from the document using the special attributes specified. This allows the element specified by the NodeMap to be used to discover exactly which node in the object graph the element represents.
        Parameters:
        type - the type of the field or method in the instance
        real - this is the overridden type from the XML element
        node - this is the XML element to be deserialized
        Returns:
        this is used to return the type to acquire the value
        Throws:
        java.lang.Exception
      • readValue

        private Value readValue​(Type type,
                                java.lang.Class real,
                                NodeMap node)
                         throws java.lang.Exception
        This is used to acquire the Value which can be used to represent the deserialized value. The type create cab be added to the graph of created instances if the XML element has an identification attribute, this allows cycles to be completed.
        Parameters:
        type - the type of the field or method in the instance
        real - this is the overridden type from the XML element
        node - this is the XML element to be deserialized
        Returns:
        this is used to return the type to acquire the value
        Throws:
        java.lang.Exception
      • readValue

        private Value readValue​(Type type,
                                java.lang.Class real,
                                NodeMap node,
                                java.lang.String key)
                         throws java.lang.Exception
        This is used to acquire the Value which can be used to represent the deserialized value. The type create cab be added to the graph of created instances if the XML element has an identification attribute, this allows cycles to be completed.
        Parameters:
        type - the type of the field or method in the instance
        real - this is the overridden type from the XML element
        node - this is the XML element to be deserialized
        key - the key the instance is known as in the graph
        Returns:
        this is used to return the type to acquire the value
        Throws:
        java.lang.Exception
      • readArray

        private Value readArray​(Type type,
                                java.lang.Class real,
                                NodeMap node)
                         throws java.lang.Exception
        This is used to acquire the Value which can be used to represent the deserialized value. The type create cab be added to the graph of created instances if the XML element has an identification attribute, this allows cycles to be completed.
        Parameters:
        type - the type of the field or method in the instance
        real - this is the overridden type from the XML element
        node - this is the XML element to be deserialized
        Returns:
        this is used to return the type to acquire the value
        Throws:
        java.lang.Exception