public class OOLibrary extends Library
Constructor and Description |
---|
OOLibrary()
library theory
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
bindDynamicObject(Term id,
java.lang.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) |
java.lang.Object |
getRegisteredDynamicObject(Struct id)
Gets a registered dynamic object (returns null if not presents)
|
java.lang.Object |
getRegisteredObject(Struct id)
Gets the reference to an object previously registered
|
java.lang.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)
Sets the value of the field 'i' with '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)
Deprecated from tuProlog 3.0 use new_class
|
boolean |
java_object_3(Term className,
Term argl,
Term id)
Deprecated from tuProlog 3.0 use new_object
|
boolean |
new_class_4(Term clSource,
Term clName,
Term clPathes,
Term id)
The java class/4 creates, compiles and loads a new Java class from a source text
|
<T> boolean |
new_lambda_3(Term interfaceName,
Term implementation,
Term id) |
boolean |
new_object_3(Term className,
Term argl,
Term id)
Creates of a java object - not backtrackable case
|
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(java.lang.Object obj)
Registers an object, with automatic creation of the identifier.
|
boolean |
register(Struct id,
java.lang.Object obj)
Register an object with the specified id.
|
Struct |
registerDynamic(java.lang.Object obj)
Registers an object for the query life-time, with the automatic
generation of the identifier.
|
void |
registerDynamic(Struct id,
java.lang.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 java.lang.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 new_object_3(Term className, Term argl, Term id) throws JavaException
className
- argl
- id
- JavaException
public <T> boolean new_lambda_3(Term interfaceName, Term implementation, Term id) throws JavaException, java.lang.Exception
interfaceName
- represent the name of the target interface i.e. 'java.util.function.Predicateimplementation
- contains the function implementation i.e. 's -> s.length()>4 'id
- represent the identification_name of the created object function i.e. MyLambdaJavaException,
- ExceptionJavaException
java.lang.Exception
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 new_class_4(Term clSource, Term clName, Term clPathes, Term id) throws JavaException
clSource:
- is a string representing the text source of the new Java classclName:
- full class nameclPathes:
- is a (possibly empty) Prolog list of class paths that may be required for a successful dynamic compilation of this classid:
- reference to an instance of the meta-class java.lang.Class rep- resenting the newly-created classJavaException
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
obj_id
- i
- what
- JavaException
public boolean register(Struct id, java.lang.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(java.lang.Object obj)
obj
- object to be registered.public java.lang.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, java.lang.Object obj)
id
- object identifierobj
- objectpublic Struct registerDynamic(java.lang.Object obj)
obj
- object to be registeredpublic java.lang.Object getRegisteredDynamicObject(Struct id) throws InvalidObjectIdException
InvalidObjectIdException
public boolean unregisterDynamic(Struct id)
id
- object identifierprotected boolean bindDynamicObject(Term id, java.lang.Object obj)
protected Struct generateFreshId()