Class JavaObject

  • All Implemented Interfaces:
    java.io.Serializable

    public final class JavaObject
    extends LispObject
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Field Detail

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

      • JavaObject

        public JavaObject​(java.lang.Object obj)
      • JavaObject

        public JavaObject​(java.lang.Object obj,
                          java.lang.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:
        java.lang.ClassCastException - if the object is not an instance of the intended class.
    • Method Detail

      • getObject

        public final java.lang.Object getObject()
      • getInstance

        public static final LispObject getInstance​(java.lang.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​(java.lang.Object obj,
                                                   java.lang.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​(java.lang.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​(java.lang.Object obj,
                                                   boolean translated,
                                                   java.lang.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 java.lang.Object javaInstance​(java.lang.Class<?> c)
        Overrides:
        javaInstance in class LispObject
      • lockableInstance

        public java.lang.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 java.lang.Class<?> getIntendedClass()
      • getObject

        public static final java.lang.Object getObject​(LispObject o)
      • 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​(java.lang.Class<?> clss,
                                            LispObject callback)
        Executes a function recursively over and its superclasses and interfaces.
      • mapcarClassHierarchy

        public static LispObject mapcarClassHierarchy​(java.lang.Class<?> clss,
                                                      LispObject fn)
      • describeJavaObject

        public static java.lang.String describeJavaObject​(JavaObject javaObject)
      • registerJavaClass

        public static LispObject registerJavaClass​(java.lang.Class<?> javaClass,
                                                   LispObject classMetaObject)
      • findJavaClass

        public static LispObject findJavaClass​(java.lang.Class<?> javaClass)