Class JavaObject

java.lang.Object
org.armedbear.lisp.LispObject
org.armedbear.lisp.JavaObject
All Implemented Interfaces:
Serializable

public final class JavaObject extends LispObject implements Serializable
See Also:
  • Field Details

    • JAVA_CLASS_JCLASS

      public static final Symbol JAVA_CLASS_JCLASS
    • JAVA_CLASS

      public static final Symbol JAVA_CLASS
    • ENSURE_JAVA_CLASS

      public static final Symbol ENSURE_JAVA_CLASS
    • JAVA_OBJECT_TO_STRING_LENGTH

      public static LispObject JAVA_OBJECT_TO_STRING_LENGTH
    • _JAVA_OBJECT_TO_STRING_LENGTH

      public static final Symbol _JAVA_OBJECT_TO_STRING_LENGTH
    • NULL

      public static final Symbol NULL
    • TRUE

      public static final Symbol TRUE
    • FALSE

      public static final Symbol FALSE
  • Constructor Details

    • JavaObject

      public JavaObject(Object obj)
    • JavaObject

      public JavaObject(Object obj, Class<?> intendedClass)
      Constructs a Java Object with the given intended class, used to access the object reflectively. If the class represents a primitive type, the corresponding wrapper type is used instead.
      Throws:
      ClassCastException - if the object is not an instance of the intended class.
  • Method Details

    • typeOf

      public LispObject typeOf()
      Overrides:
      typeOf in class LispObject
    • classOf

      public LispObject classOf()
      Overrides:
      classOf in class LispObject
    • typep

      public LispObject typep(LispObject type)
      Overrides:
      typep in class LispObject
    • STRING

      public LispObject STRING()
      Overrides:
      STRING in class LispObject
    • getObject

      public final Object getObject()
    • getInstance

      public static final LispObject getInstance(Object obj)
      Encapsulates obj, if required. If obj is a LispObject, it's returned as-is.
      Parameters:
      obj - Any java object
      Returns:
      obj or a new JavaObject encapsulating obj
    • getInstance

      public static final LispObject getInstance(Object obj, Class<?> intendedClass)
      Encapsulates obj, if required. If obj is a LispObject, it's returned as-is. If not, a java object with the specified intended class is returned.
      Parameters:
      obj - Any java object
      intendedClass - the class that shall be used to access obj
      Returns:
      obj or a new JavaObject encapsulating obj
    • getInstance

      public static final LispObject getInstance(Object obj, boolean translated)
      Encapsulates obj, if required. If obj is a LispObject, it's returned as-is. If obj is of a type which can be mapped to a lisp type, an object of the mapped type is returned, if translated is true.
      Parameters:
      obj -
      translated -
      Returns:
      a LispObject representing or encapsulating obj
    • getInstance

      public static final LispObject getInstance(Object obj, boolean translated, Class<?> intendedClass)
      Encapsulates obj, if required. If obj is a LispObject, it's returned as-is. If obj is of a type which can be mapped to a lisp type, an object of the mapped type is returned, if translated is true.
      Parameters:
      obj -
      translated -
      intendedClass - the class that shall be used to reflectively access obj; it is an error for obj not to be an instance of this class. This parameter is ignored if translated == true and the object can be converted to a Lisp object.
      Returns:
      a LispObject representing or encapsulating obj
    • javaInstance

      public Object javaInstance()
      Overrides:
      javaInstance in class LispObject
    • javaInstance

      public Object javaInstance(Class<?> c)
      Overrides:
      javaInstance in class LispObject
    • lockableInstance

      public Object lockableInstance()
      Returns the encapsulated Java object for interoperability with wait, notify, synchronized, etc.
      Overrides:
      lockableInstance in class LispObject
      Returns:
      The encapsulated object
    • getIntendedClass

      public Class<?> getIntendedClass()
    • getObject

      public static final Object getObject(LispObject o)
    • equal

      public final boolean equal(LispObject other)
      Overrides:
      equal in class LispObject
    • equalp

      public final boolean equalp(LispObject other)
      Overrides:
      equalp in class LispObject
    • sxhash

      public int sxhash()
      Overrides:
      sxhash in class LispObject
    • printObject

      public String printObject()
      Overrides:
      printObject in class LispObject
    • getDescription

      public LispObject getDescription()
      Overrides:
      getDescription in class LispObject
    • getParts

      public LispObject getParts()
      Description copied from class: LispObject
      Implementing the getParts() protocol will allow INSPECT to return information about the substructure of a descendent of LispObject. The protocol is to return a List of Cons pairs, where the car of each pair contains a decriptive string, and the cdr returns a subobject for inspection.
      Overrides:
      getParts in class LispObject
    • doClassHierarchy

      public static void doClassHierarchy(Class<?> clss, LispObject callback)
      Executes a function recursively over and its superclasses and interfaces.
    • mapcarClassHierarchy

      public static LispObject mapcarClassHierarchy(Class<?> clss, LispObject fn)
    • describeJavaObject

      public static String describeJavaObject(JavaObject javaObject)
    • registerJavaClass

      public static LispObject registerJavaClass(Class<?> javaClass, LispObject classMetaObject)
    • findJavaClass

      public static LispObject findJavaClass(Class<?> javaClass)