Package com.osohq.oso
Class Host
- java.lang.Object
-
- com.osohq.oso.Host
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
acceptExpression
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
cacheClass(Class<?> cls, String name)
Store a Java class in the cache by name.Long
cacheInstance(Object instance, Long id)
Cache an instance of a Java class.Host
clone()
Class<?>
getClass(String name)
Get a registered Java class.Object
getInstance(long instanceId)
Get a cached Java instance.boolean
hasInstance(long instanceId)
Determine if a Java instance has been cached.boolean
isa(org.json.JSONObject instance, String classTag)
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.Object
makeInstance(String className, List<Object> initargs, long id)
Make an instance of a Java class from aList<Object>
of fields.boolean
operator(String op, List<Object> args)
HashMap<String,Object>
polarDictToJava(org.json.JSONObject dict)
Convert a JSONified Polar dictionary to a Java MapList<Object>
polarListToJava(org.json.JSONArray list)
Convert a JSONified Polar List to a Java Listvoid
registerMros()
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.Object
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.
-
-
-
Constructor Detail
-
Host
public Host(Ffi.Polar polarPtr)
-
-
Method Detail
-
setAcceptExpression
protected void setAcceptExpression(boolean acceptExpression)
-
getClass
public Class<?> getClass(String name) throws Exceptions.UnregisteredClassError
Get a registered Java class.
-
cacheClass
public String cacheClass(Class<?> cls, String name) throws Exceptions.DuplicateClassAliasError
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
public Object getInstance(long instanceId) throws Exceptions.UnregisteredInstanceError
Get a cached Java instance.
-
hasInstance
public boolean hasInstance(long instanceId)
Determine if a Java instance has been cached.
-
cacheInstance
public Long cacheInstance(Object instance, Long id) throws Exceptions.OsoException
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
public boolean isSubclass(String leftTag, String rightTag)
Return true if left is a subclass (or the same class) as right.
-
operator
public boolean operator(String op, List<Object> args) throws Exceptions.OsoException
- Throws:
Exceptions.OsoException
-
toPolarTerm
public org.json.JSONObject toPolarTerm(Object value) throws Exceptions.OsoException
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
-
-