|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simantics.databoard.accessor.binary.BinaryObject
public abstract class BinaryObject
BinaryObject is an accessor to a binary object, usually a random access file. BinaryObject cannot handle files of recursive types.
The file can be opened once. It may not be modified by any other instance other than accessor while accessors are beign used. You must not create more than one instance of BinaryObjects for a file. Binary Object does not close the underlying file.
BinaryArray
,
BinaryBoolean
,
BinaryByte
,
BinaryDouble
,
BinaryFloat
,
BinaryInteger
,
BinaryLong
,
BinaryMap
,
BinaryOptional
,
BinaryRecord
,
BinaryString
,
BinaryUnion
,
BinaryVariant
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.simantics.databoard.accessor.Accessor |
---|
Accessor.Listener |
Method Summary | |
---|---|
void |
addListener(Accessor.Listener listener,
InterestSet interestSet,
AccessorReference path)
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. |
void |
close()
Close the file. |
static BinaryObject |
createAccessor(RandomAccessBinary binary,
DataType type)
|
java.io.File |
file()
Get file if the binary object is based on binary file. |
void |
flush()
Flush the internal write buffer to the disc. |
RandomAccessBinary |
getBinary()
|
RandomAccessBinary |
getSource()
|
java.lang.Object |
getValue(Binding binding)
Get a snapshot of the object model as a single data value. |
void |
removeListener(Accessor.Listener listener)
Remove a listener. |
void |
setValue(Binding binding,
java.lang.Object newValue)
Write a new value and flush the buffer. |
abstract void |
setValueNoflush(Binding binding,
java.lang.Object newValue)
Write a new value and don't flush the buffer |
java.lang.String |
toString()
|
DataType |
type()
Get structural represtentation of the accessor presented in databoard's type system format. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.simantics.databoard.accessor.Accessor |
---|
getAccessor |
Method Detail |
---|
public DataType type()
Accessor
type
in interface Accessor
public void flush() throws AccessorException
FileAccessor
Note, all the write methods of Accessor
and its sub-interfaces
guarantee Durability. They flush the value immediately and do not require
separate FileAccessor.flush()
.
flush
in interface FileAccessor
AccessorException
public RandomAccessBinary getSource()
public void close() throws AccessorException
FileAccessor
close
in interface CloseableAccessor
close
in interface FileAccessor
AccessorException
public java.io.File file()
file
in interface FileAccessor
null
public RandomAccessBinary getBinary()
public void addListener(Accessor.Listener listener, InterestSet interestSet, AccessorReference path) throws AccessorException
Accessor
The synchronization contract is implementation specific, so read the document. A common contract is that the listener object must not make modifications to the accessor within the handle event function. The correct strategy is to collect events and mutate the accessor afterwards.
Each event instance spawned by the listener, is annotated with a reference that describes the reference path of the node to which the event applies to. The path originates from the node where the listener was placed.
Listener is attached to the container 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.
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 void setValue(Binding binding, java.lang.Object newValue) throws AccessorException
setValue
in interface Accessor
binding
- newValue
-
AccessorException
public abstract void setValueNoflush(Binding binding, java.lang.Object newValue) throws AccessorException
setValueNoflush
in interface FileAccessor
binding
- newValue
-
AccessorException
public java.lang.Object getValue(Binding binding) throws AccessorException
Accessor
getValue
in interface Accessor
AccessorException
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 static BinaryObject createAccessor(RandomAccessBinary binary, DataType type) throws AccessorConstructionException
AccessorConstructionException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |