Package snap.props

Class PropArchiver

java.lang.Object
snap.props.PropArchiver
Direct Known Subclasses:
PropArchiverJS, PropArchiverXML

public class PropArchiver extends Object
This class primarily converts a PropObject (graph) to/from a PropNode (graph). The graph of PropNodes can easily be converted to/from XML, JSON, etc.
  • Field Details

  • Constructor Details

    • PropArchiver

      public PropArchiver()
      Constructor.
  • Method Details

    • getRootObject

      public PropObject getRootObject()
      Returns the object to read properties into.
    • setRootObject

      public void setRootObject(PropObject rootObject)
      Sets the object to read properties into.
    • convertNativeToNode

      protected PropNode convertNativeToNode(PropObject aPropObj, Prop aProp)
      Returns a PropNode for given PropObject.
    • convertNativeToNodeForProps

      protected void convertNativeToNodeForProps(PropObject aPropObj, PropNode aPropNode, Prop[] theProps)
      Returns a PropNode for given PropObject.
    • convertNativeToNodeForPropRelation

      protected Object convertNativeToNodeForPropRelation(Prop aProp, Object nativeValue)
      Converts given native relation object to PropNode/PropNode[].
    • convertNodeToNative

      protected PropObject convertNodeToNative(PropNode propNode, Prop aProp, PropObject aPropObject)
      Converts a PropNode (graph) to PropObject.
    • getClassMap

      public Map<String,Class<?>> getClassMap()
      Returns the map of names to class names.
    • createClassMap

      protected Map<String,Class<?>> createClassMap()
      Creates the map of names to class names.
    • addClassMapClass

      public void addClassMapClass(Class<? extends PropObject> aClass)
      Adds a Class to class map.
    • getClassForName

      public Class<?> getClassForName(String aName)
      Returns a class for name.
    • createPropObjectForPropNode

      protected PropObject createPropObjectForPropNode(PropNode aPropNode, Prop aProp)
      Creates a PropObject for PropNode.
    • getPropObjectClassForPropNode

      protected Class<?> getPropObjectClassForPropNode(PropNode aPropNode, Prop aProp)
      Returns a PropObject class for PropNode.
    • createPropObjectForClass

      protected PropObject createPropObjectForClass(Class<?> aClass)
      Convenience newInstance.
    • copyPropObject

      public <T extends PropObject> T copyPropObject(T aPropObject)
      Returns a copy of the given PropObject using archival.
    • getResources

      public PropArchiver.Resource[] getResources()
      Returns the list of optional resources associated with this archiver.
    • getResource

      public PropArchiver.Resource getResource(int anIndex)
      Returns an individual resource associated with this archiver, by index.
    • getResourceForName

      public PropArchiver.Resource getResourceForName(String aName)
      Returns an individual resource associated with this archiver, by name.
    • addResource

      public String addResource(String aName, byte[] theBytes)
      Adds a byte array resource to this archiver (only if absent).