Package snap.util

Class JSArchiver

java.lang.Object
snap.util.JSArchiver

public class JSArchiver extends Object
An archiver to read/write objects from/to JSON.
  • Constructor Details

    • JSArchiver

      public JSArchiver()
      Creates a new archiver.
    • JSArchiver

      public JSArchiver(String... theImports)
      Creates a new archiver for given import(s).
  • Method Details

    • getRootObject

      public Object getRootObject()
      Returns the object to be loaded into (null by default).
    • setRootObject

      public JSArchiver setRootObject(Object anObj)
      Sets the object to be loaded into (null by default).
    • getClassId

      public String getClassId()
      Returns the class string.
    • readSource

      public Object readSource(Object aSource)
      Read an object from JSON.
    • readString

      public Object readString(String aString)
      Read an object from JSON.
    • readNode

      public Object readNode(JSValue aNode)
      Read an object from JSON.
    • writeObject

      public JSValue writeObject(Object anObj)
      Write an object to JSON.
    • getValue

      protected Object getValue(Object anObj, String aKey)
      Returns a value for a key.
    • setValue

      protected void setValue(Object anObj, String aKey, Object aValue)
      Set a value for a key.
    • addImport

      public JSArchiver addImport(String... theImports)
      Adds an import.
    • getClassPath

      protected String getClassPath(Object anObj)
      Returns a class path for an object (shortend if in imports).
    • getClassPathImpl

      protected String getClassPathImpl(String classPath)
      Returns a class path for an object (shortend if in imports).
    • getClassForName

      protected Class getClassForName(String aClassName)
      Returns a class for name.
    • getClassForNameImpl

      protected Class getClassForNameImpl(String aClassName)
      Returns a class for name.