Package org.armedbear.lisp
Class JavaObject
- java.lang.Object
-
- org.armedbear.lisp.LispObject
-
- org.armedbear.lisp.JavaObject
-
- All Implemented Interfaces:
java.io.Serializable
public final class JavaObject extends LispObject implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Symbol
_JAVA_OBJECT_TO_STRING_LENGTH
static Symbol
ENSURE_JAVA_CLASS
static Symbol
FALSE
static Symbol
JAVA_CLASS
static Symbol
JAVA_CLASS_JCLASS
static LispObject
JAVA_OBJECT_TO_STRING_LENGTH
static Symbol
NULL
static Symbol
TRUE
-
Constructor Summary
Constructors Constructor Description JavaObject(java.lang.Object obj)
JavaObject(java.lang.Object obj, java.lang.Class<?> intendedClass)
Constructs a Java Object with the given intended class, used to access the object reflectively.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LispObject
classOf()
static java.lang.String
describeJavaObject(JavaObject javaObject)
static void
doClassHierarchy(java.lang.Class<?> clss, LispObject callback)
Executes a function recursively overand its superclasses and interfaces. boolean
equal(LispObject other)
boolean
equalp(LispObject other)
static LispObject
findJavaClass(java.lang.Class<?> javaClass)
LispObject
getDescription()
static LispObject
getInstance(java.lang.Object obj)
Encapsulates obj, if required.static LispObject
getInstance(java.lang.Object obj, boolean translated)
Encapsulates obj, if required.static LispObject
getInstance(java.lang.Object obj, boolean translated, java.lang.Class<?> intendedClass)
Encapsulates obj, if required.static LispObject
getInstance(java.lang.Object obj, java.lang.Class<?> intendedClass)
Encapsulates obj, if required.java.lang.Class<?>
getIntendedClass()
java.lang.Object
getObject()
static java.lang.Object
getObject(LispObject o)
LispObject
getParts()
Implementing the getParts() protocol will allow INSPECT to return information about the substructure of a descendent of LispObject.java.lang.Object
javaInstance()
java.lang.Object
javaInstance(java.lang.Class<?> c)
java.lang.Object
lockableInstance()
Returns the encapsulated Java object for interoperability with wait, notify, synchronized, etc.static LispObject
mapcarClassHierarchy(java.lang.Class<?> clss, LispObject fn)
java.lang.String
printObject()
static LispObject
registerJavaClass(java.lang.Class<?> javaClass, LispObject classMetaObject)
LispObject
STRING()
int
sxhash()
LispObject
typeOf()
LispObject
typep(LispObject type)
-
Methods inherited from class org.armedbear.lisp.LispObject
ABS, add, add, aref, AREF, AREF, aref_long, aset, aset, aset, ash, ash, atom, ATOM, caddr, cadr, car, cddr, cdr, CHAR, characterp, CHARACTERP, chars, COMPLEXP, constantp, CONSTANTP, copyToArray, decr, DENOMINATOR, dispatch, divideBy, doubleValue, elt, endp, ENDP, EQ, eql, eql, eql, EQL, equal, EQUAL, equalp, evenp, EVENP, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, floatp, FLOATP, floatValue, getBooleanValue, getCallCount, getDocumentation, getFixnumSlotValue, getHotCount, getInstance, getPropertyList, getSlotValue, getSlotValue_0, getSlotValue_1, getSlotValue_2, getSlotValue_3, getSlotValueAsBoolean, getStringChars, getStringValue, getSymbolFunction, getSymbolFunctionOrDie, getSymbolSetfFunction, getSymbolSetfFunctionOrDie, getSymbolValue, incr, incrementCallCount, incrementHotCount, integerp, INTEGERP, intValue, IS_E, IS_GE, IS_GT, IS_LE, IS_LT, IS_NE, isEqualTo, isEqualTo, isGreaterThan, isGreaterThan, isGreaterThanOrEqualTo, isGreaterThanOrEqualTo, isLessThan, isLessThan, isLessThanOrEqualTo, isLessThanOrEqualTo, isNotEqualTo, isNotEqualTo, isSpecialOperator, isSpecialVariable, LDB, length, LENGTH, listp, LISTP, LOGAND, LOGAND, LOGIOR, LOGIOR, LOGNOT, LOGXOR, LOGXOR, longValue, minusp, MINUSP, MOD, MOD, multiplyBy, multiplyBy, negate, noFillPointer, NOT, nreverse, NTH, NTH, nthcdr, numberp, NUMBERP, NUMERATOR, oddp, ODDP, plusp, PLUSP, princToString, psxhash, psxhash, push, rationalp, RATIONALP, realp, REALP, resolve, reverse, RPLACA, RPLACD, SCHAR, setCallCount, setCar, setCdr, setDocumentation, setHotCount, setPropertyList, setSlotValue, setSlotValue, setSlotValue_0, setSlotValue_1, setSlotValue_2, setSlotValue_3, SIMPLE_STRING_P, SLOT_VALUE, stringp, STRINGP, subtract, subtract, SVREF, svset, SYMBOLP, truncate, unreadableString, unreadableString, VECTOR_PUSH_EXTEND, VECTOR_PUSH_EXTEND, vectorp, VECTORP, vectorPushExtend, zerop, ZEROP
-
-
-
-
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
-
typeOf
public LispObject typeOf()
- Overrides:
typeOf
in classLispObject
-
classOf
public LispObject classOf()
- Overrides:
classOf
in classLispObject
-
typep
public LispObject typep(LispObject type)
- Overrides:
typep
in classLispObject
-
STRING
public LispObject STRING()
- Overrides:
STRING
in classLispObject
-
getObject
public final java.lang.Object getObject()
-
getInstance
public static final LispObject getInstance(java.lang.Object obj)
Encapsulates obj, if required. If obj is aLispObject
, 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 aLispObject
, it's returned as-is. If not, a java object with the specified intended class is returned.- Parameters:
obj
- Any java objectintendedClass
- 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 aLispObject
, 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 aLispObject
, 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()
- Overrides:
javaInstance
in classLispObject
-
javaInstance
public java.lang.Object javaInstance(java.lang.Class<?> c)
- Overrides:
javaInstance
in classLispObject
-
lockableInstance
public java.lang.Object lockableInstance()
Returns the encapsulated Java object for interoperability with wait, notify, synchronized, etc.- Overrides:
lockableInstance
in classLispObject
- Returns:
- The encapsulated object
-
getIntendedClass
public java.lang.Class<?> getIntendedClass()
-
getObject
public static final java.lang.Object getObject(LispObject o)
-
equal
public final boolean equal(LispObject other)
- Overrides:
equal
in classLispObject
-
equalp
public final boolean equalp(LispObject other)
- Overrides:
equalp
in classLispObject
-
sxhash
public int sxhash()
- Overrides:
sxhash
in classLispObject
-
printObject
public java.lang.String printObject()
- Overrides:
printObject
in classLispObject
-
getDescription
public LispObject getDescription()
- Overrides:
getDescription
in classLispObject
-
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 classLispObject
-
doClassHierarchy
public static void doClassHierarchy(java.lang.Class<?> clss, LispObject callback)
Executes a function recursively overand 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)
-
-