|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simantics.databoard.accessor.java.JavaObject
public abstract class JavaObject
Accessor to a Java Object.
The monitoring contract forbids modifications to the object outside this
accessor object. If you do modifications to the value using other mechanisms,
you must notify the listeners of the accessor with notifyValueChanged()
.
If a lock is not provided, operations cannot be performed simulataneously in multiple-threads.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.simantics.databoard.accessor.Accessor |
---|
Accessor.Listener |
Constructor Summary | |
---|---|
JavaObject(Accessor parent,
Binding binding,
java.lang.Object initialValue,
AccessorParams params)
Create a new accessor to a Java Object. |
Method Summary | |
---|---|
void |
addListener(Accessor.Listener listener,
InterestSet interestSet,
ChildReference path,
java.util.concurrent.Executor executor)
Place a listener to an accessor node. |
void |
apply(java.util.List<Event> cs,
java.util.LinkedList<Event> rollback)
Apply a change set in a single transaction operation. |
static JavaObject |
createAccessor(Accessor parent,
Binding b,
java.lang.Object v,
AccessorParams params)
|
static JavaObject |
createSubAccessor(Accessor parent,
Binding b,
java.lang.Object v,
AccessorParams params)
|
Binding |
getBinding()
|
java.lang.Object |
getObject()
Get the Java Object |
AccessorParams |
getParams()
Get accessor parameters |
java.util.concurrent.locks.Lock |
getReadLock()
Get lock if available. |
java.lang.Object |
getValue(Binding binding)
Get a snapshot of the object as a single data value. |
void |
getValue(Binding binding,
java.lang.Object obj)
Read a copy of the accessor's object into an instance. |
java.util.concurrent.locks.Lock |
getWriteLock()
Get lock if available. |
void |
notifyValueChanged()
The Java Object was changed by means other than Accessor. |
void |
removeListener(Accessor.Listener listener)
Remove a listener. |
java.lang.String |
toString()
|
Datatype |
type()
Get structural represtentation of the accessor presented in databoard's type system. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.simantics.databoard.accessor.Accessor |
---|
getComponent, setValue |
Constructor Detail |
---|
public JavaObject(Accessor parent, Binding binding, java.lang.Object initialValue, AccessorParams params)
Read and write locks may optionally be provided for locking mechanisms. ReadWriteLock can be provied or a signle MutualExclusion lock.
parent
- parent, or nullbinding
- initialValue
- the java objectparams
- accessor paramsMethod Detail |
---|
public java.lang.Object getObject()
public Binding getBinding()
public AccessorParams getParams()
ParametrisedAccessor
getParams
in interface ParametrisedAccessor
public Datatype type()
Accessor
type
in interface Accessor
public java.util.concurrent.locks.Lock getReadLock()
public java.util.concurrent.locks.Lock getWriteLock()
public java.lang.Object getValue(Binding binding) throws AccessorException
Accessor
Accessor makes type adaption to users binding if possible.
getValue
in interface Accessor
AccessorException
public void getValue(Binding binding, java.lang.Object obj) throws AccessorException
Accessor
Accessor makes type adaption to users binding if possible.
getValue
in interface Accessor
obj
- object to read the value to
AccessorException
public void addListener(Accessor.Listener listener, InterestSet interestSet, ChildReference path, java.util.concurrent.Executor executor) throws AccessorException
Accessor
When events are emited and in which thread processed is implementation specific. It is also implementation specific, whether the object can be mutated in the listener or whether it has to be done afterwards.
In many implementations there is a pluggable event handling strategy EventEmitter. The default behaviour is to emit events as they are spawned in the current thread.
There is a reference in each event instance that describes the path from the accessor where listener was placed to the node to which the event applies to.
Listener is attached to the object that holds the value at the time at the of the adding. For example, If a listener is attached to an array of element at index 3, and a new value is inserted at position 2, the listener still monitors the same container, which is now at index 4. The references of incoming the events are modified to have the new index.
Also, if a new value is assigned to the parent of an object that is listened, the listener keeps on monitoring the new value at the same reference. This doesn't apply when a new value is set to a union of different tag, to a variant with a new type, or value is removed from Optional type. In these two cases the listener is invalidated.
See ChangeSet
is an implementation that collects events.
Executor argument determines the thread where the onEvents method is
handled. null argument denotes current thread.
addListener
in interface Accessor
path
- path to the accessor or null
. This is used in the events the accessor produces
AccessorException
collects events
public void removeListener(Accessor.Listener listener) throws AccessorException
Accessor
removeListener
in interface Accessor
AccessorException
public static JavaObject createAccessor(Accessor parent, Binding b, java.lang.Object v, AccessorParams params) throws AccessorConstructionException
AccessorConstructionException
public static JavaObject createSubAccessor(Accessor parent, Binding b, java.lang.Object v, AccessorParams params) throws AccessorConstructionException
AccessorConstructionException
public void apply(java.util.List<Event> cs, java.util.LinkedList<Event> rollback) throws AccessorException
Accessor
apply
in interface Accessor
rollback
- log to be filled with rollback events or null
AccessorException
- failed to apply change setpublic java.lang.String toString()
toString
in class java.lang.Object
public void notifyValueChanged()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |