Package com.osohq.oso
Class Host
java.lang.Object
com.osohq.oso.Host
- All Implemented Interfaces:
Cloneable
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncacheClass
(Class<?> cls, String name) Store a Java class in the cache by name.cacheInstance
(Object instance, Long id) Cache an instance of a Java class.clone()
Class
<?> Get a registered Java class.getInstance
(long instanceId) Get a cached Java instance.boolean
hasInstance
(long instanceId) Determine if a Java instance has been cached.boolean
Check if a Java instance is an instance of a class.boolean
isSubclass
(String leftTag, String rightTag) Return true if left is a subclass (or the same class) as right.makeInstance
(String className, List<Object> initargs, long id) Make an instance of a Java class from aList<Object>
of fields.boolean
polarDictToJava
(org.json.JSONObject dict) Convert a JSONified Polar dictionary to a Java MappolarListToJava
(org.json.JSONArray list) Convert a JSONified Polar List to a Java Listvoid
Register a list of base classes (MRO list) for all registered classes.protected void
setAcceptExpression
(boolean acceptExpression) boolean
subspecializer
(long instanceId, String leftTag, String rightTag) Check if a class specializer is more specific than another class specializer.toJava
(org.json.JSONObject term) Turn a Polar term passed across the FFI boundary into a Java Object.org.json.JSONObject
toPolarTerm
(Object value) Convert Java Objects to Polar (JSON) terms.
-
Field Details
-
acceptExpression
protected boolean acceptExpression
-
-
Constructor Details
-
Host
-
-
Method Details
-
clone
-
setAcceptExpression
protected void setAcceptExpression(boolean acceptExpression) -
getClass
Get a registered Java class. -
cacheClass
Store a Java class in the cache by name.- Parameters:
name
- The name used to reference the class from within Polar.- Throws:
Exceptions.DuplicateClassAliasError
- If the name is already registered.
-
registerMros
public void registerMros()Register a list of base classes (MRO list) for all registered classes. The list is in method resolution order (MRO), meaning the superclasses are ordered from most to least specific. -
getInstance
Get a cached Java instance. -
hasInstance
public boolean hasInstance(long instanceId) Determine if a Java instance has been cached. -
cacheInstance
Cache an instance of a Java class.- Throws:
Exceptions.OsoException
-
makeInstance
public Object makeInstance(String className, List<Object> initargs, long id) throws Exceptions.OsoException Make an instance of a Java class from aList<Object>
of fields.- Throws:
Exceptions.OsoException
-
subspecializer
public boolean subspecializer(long instanceId, String leftTag, String rightTag) throws Exceptions.UnregisteredClassError, Exceptions.UnregisteredInstanceError Check if a class specializer is more specific than another class specializer. -
isa
public boolean isa(org.json.JSONObject instance, String classTag) throws Exceptions.UnregisteredClassError, Exceptions.UnregisteredInstanceError, Exceptions.UnexpectedPolarTypeError, Exceptions.OsoException Check if a Java instance is an instance of a class. -
isSubclass
Return true if left is a subclass (or the same class) as right. -
operator
- Throws:
Exceptions.OsoException
-
toPolarTerm
Convert Java Objects to Polar (JSON) terms.- Throws:
Exceptions.OsoException
-
toJava
public Object toJava(org.json.JSONObject term) throws Exceptions.UnregisteredInstanceError, Exceptions.UnexpectedPolarTypeError, Exceptions.OsoException Turn a Polar term passed across the FFI boundary into a Java Object. -
polarDictToJava
public HashMap<String,Object> polarDictToJava(org.json.JSONObject dict) throws Exceptions.UnregisteredInstanceError, Exceptions.UnexpectedPolarTypeError, Exceptions.OsoException Convert a JSONified Polar dictionary to a Java Map -
polarListToJava
public List<Object> polarListToJava(org.json.JSONArray list) throws Exceptions.UnregisteredInstanceError, Exceptions.UnexpectedPolarTypeError, Exceptions.OsoException Convert a JSONified Polar List to a Java List
-