public class JavaLibrary extends Library
Constructor and Description |
---|
JavaLibrary()
library theory
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
bindDynamicObject(Term id,
Object obj)
Tries to bind specified id to a provided java object.
|
boolean |
destroy_object_1(Term id)
Destroy the link to a java object - called not directly, but from
predicate java_object (as second choice, for backtracking)
|
void |
dismiss()
method invoked by prolog engine when library is
going to be removed
|
void |
dismissAll() |
protected Struct |
generateFreshId()
Generates a fresh numeric identifier
|
boolean |
get_classpath_1(Term paths) |
Object |
getRegisteredDynamicObject(Struct id)
Gets a registered dynamic object (returns null if not presents)
|
Object |
getRegisteredObject(Struct id)
Gets the reference to an object previously registered
|
String |
getTheory()
Gets the theory provided with the library
Empty theory is provided by default.
|
boolean |
java_array_get_primitive_3(Term obj_id,
Term i,
Term what) |
boolean |
java_array_set_primitive_3(Term obj_id,
Term i,
Term what) |
boolean |
java_call_3(Term objId,
Term method_name,
Term idResult)
Calls a method of a Java object
|
boolean |
java_class_4(Term clSource,
Term clName,
Term clPathes,
Term id)
Creates of a java class
|
boolean |
java_object_3(Term className,
Term argl,
Term id) |
void |
onSolveBegin(Term goal)
method invoked when the engine is going
to demonstrate a goal
|
void |
onSolveEnd() |
protected void |
preregisterObjects()
objects actually pre-registered in order to be available since the
beginning of demonstration
|
boolean |
register_1(Term id)
Register an object with the specified id.
|
Struct |
register(Object obj)
Registers an object, with automatic creation of the identifier.
|
boolean |
register(Struct id,
Object obj)
Register an object with the specified id.
|
Struct |
registerDynamic(Object obj)
Registers an object for the query life-time, with the automatic
generation of the identifier.
|
void |
registerDynamic(Struct id,
Object obj)
Registers an object only for the running query life-time
|
boolean |
set_classpath_1(Term paths) |
boolean |
unregister_1(Term id)
Unregister an object with the specified id.
|
boolean |
unregister(Struct id)
Unregisters an object, given its identifier
|
boolean |
unregisterDynamic(Struct id)
Unregister the object, only for dynamic case
|
evalExpression, getEngine, getName, getPrimitives, getSynonymMap, getTheory, match, onSolveHalt, setEngine, unify
public String getTheory()
Library
public void dismiss()
Library
public void dismissAll()
public void onSolveBegin(Term goal)
Library
onSolveBegin
in class Library
public void onSolveEnd()
onSolveEnd
in class Library
protected void preregisterObjects()
public boolean java_object_3(Term className, Term argl, Term id) throws JavaException
JavaException
public boolean destroy_object_1(Term id) throws JavaException
JavaException
public boolean java_class_4(Term clSource, Term clName, Term clPathes, Term id) throws JavaException
JavaException
public boolean java_call_3(Term objId, Term method_name, Term idResult) throws JavaException
JavaException
public boolean set_classpath_1(Term paths) throws JavaException
JavaException
public boolean get_classpath_1(Term paths) throws JavaException
JavaException
public boolean java_array_set_primitive_3(Term obj_id, Term i, Term what) throws JavaException
JavaException
public boolean java_array_get_primitive_3(Term obj_id, Term i, Term what) throws JavaException
JavaException
public boolean register(Struct id, Object obj) throws InvalidObjectIdException
id
- object identifierobj
- the objectInvalidObjectIdException
- if the object id is not validpublic boolean register_1(Term id) throws JavaException
id
- object identifierJavaException
- if the object id is not validpublic boolean unregister_1(Term id) throws JavaException
id
- object identifierJavaException
- if the object id is not validpublic Struct register(Object obj)
obj
- object to be registered.public Object getRegisteredObject(Struct id) throws InvalidObjectIdException
id
- object idInvalidObjectIdException
public boolean unregister(Struct id) throws InvalidObjectIdException
id
- object identifierInvalidObjectIdException
- if the id is not valid (e.g. is not ground)public void registerDynamic(Struct id, Object obj)
id
- object identifierobj
- objectpublic Struct registerDynamic(Object obj)
obj
- object to be registeredpublic Object getRegisteredDynamicObject(Struct id) throws InvalidObjectIdException
InvalidObjectIdException
public boolean unregisterDynamic(Struct id)
id
- object identifierprotected boolean bindDynamicObject(Term id, Object obj)
protected Struct generateFreshId()