org.simantics.databoard.accessor.binary
Class BinaryArray

java.lang.Object
  extended by org.simantics.databoard.accessor.binary.BinaryObject
      extended by org.simantics.databoard.accessor.binary.BinaryArray
All Implemented Interfaces:
Accessor, ArrayAccessor, CloseableAccessor, FileAccessor, FileArrayAccessor

public class BinaryArray
extends BinaryObject
implements ArrayAccessor, FileArrayAccessor

Binary Array is accessor to a byte backed array of elements.

Note, To increase the random access performance of the record, create sub-accessors of its fields.

Author:
Toni Kalajainen

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.simantics.databoard.accessor.Accessor
Accessor.Listener
 
Constructor Summary
BinaryArray(BinaryObject parent, Blob blob, DataType type)
           
 
Method Summary
 void add(Binding binding, java.lang.Object value)
          Add a new value.
 void add(int index, Binding binding, java.lang.Object value)
          Insert a new value.
 void addAll(Binding binding, java.lang.Object[] values)
          Add an array of elements.
 void addAll(int index, Binding binding, java.lang.Object[] values)
          Add an array of elements.
 void addAllNoflush(Binding binding, java.lang.Object[] values)
          Add an array of elements.
 void addAllNoflush(int index, Binding rcb, java.lang.Object[] rcvs)
          Add an array of elements.
 void addNoflush(Binding binding, java.lang.Object value)
          Add a new value.
 void addNoflush(int index, Binding rcb, java.lang.Object rcv)
          Insert a new value.
 java.lang.Object get(int index, Binding valueBinding)
          Get a value
<T extends Accessor>
T
getAccessor(AccessorReference reference)
          Get an accessor to a sub-container.
<T extends Accessor>
T
getAccessor(int index)
          Get an accessor to an element.
 void getAll(Binding valueBinding, java.util.Collection<java.lang.Object> values)
          Get all elements
 void getAll(Binding valueBinding, java.lang.Object[] array)
          Get all elements and place them to an array.
 void remove(int index, int count)
          Remove an element at an index.
 void removeNoflush(int index, int count)
          Remove an element at an index.
 void set(int index, Binding binding, java.lang.Object value)
          Replace a value container with a new value.
 void setNoflush(int index, Binding rcb, java.lang.Object rcv)
          Replace a value container with a new value.
 void setValueNoflush(Binding arrayBinding, java.lang.Object newArray)
          Set all values
 int size()
          Return the number of elements in the array.
 ArrayType type()
          Get structural represtentation of the accessor presented in databoard's type system format.
 
Methods inherited from class org.simantics.databoard.accessor.binary.BinaryObject
addListener, apply, close, createAccessor, file, flush, getBinary, getSource, getValue, removeListener, setValue, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.simantics.databoard.accessor.ArrayAccessor
setValue
 
Methods inherited from interface org.simantics.databoard.accessor.file.FileAccessor
close, file, flush
 
Methods inherited from interface org.simantics.databoard.accessor.Accessor
addListener, apply, getValue, removeListener
 

Constructor Detail

BinaryArray

public BinaryArray(BinaryObject parent,
                   Blob blob,
                   DataType type)
Method Detail

type

public ArrayType type()
Description copied from interface: Accessor
Get structural represtentation of the accessor presented in databoard's type system format.

Specified by:
type in interface Accessor
Specified by:
type in interface ArrayAccessor
Overrides:
type in class BinaryObject
Returns:
type description

setNoflush

public void setNoflush(int index,
                       Binding rcb,
                       java.lang.Object rcv)
                throws AccessorException
Description copied from interface: FileArrayAccessor
Replace a value container with a new value.

Specified by:
setNoflush in interface FileArrayAccessor
Throws:
AccessorException

setValueNoflush

public void setValueNoflush(Binding arrayBinding,
                            java.lang.Object newArray)
                     throws AccessorException
Set all values

Specified by:
setValueNoflush in interface FileAccessor
Specified by:
setValueNoflush in interface FileArrayAccessor
Specified by:
setValueNoflush in class BinaryObject
Parameters:
arrayBinding -
newArray -
Throws:
AccessorException

addNoflush

public void addNoflush(int index,
                       Binding rcb,
                       java.lang.Object rcv)
                throws AccessorException
Description copied from interface: FileArrayAccessor
Insert a new value. If elements are inserted in the middle of the array, existing interest sets are updated to reflect the new positions.

Specified by:
addNoflush in interface FileArrayAccessor
Parameters:
index - position to insert new value to
rcv - value
Throws:
AccessorException

addNoflush

public void addNoflush(Binding binding,
                       java.lang.Object value)
                throws AccessorException
Description copied from interface: FileArrayAccessor
Add a new value.

Specified by:
addNoflush in interface FileArrayAccessor
value - value
Throws:
AccessorException

addAllNoflush

public void addAllNoflush(Binding binding,
                          java.lang.Object[] values)
                   throws AccessorException
Description copied from interface: FileArrayAccessor
Add an array of elements.

Specified by:
addAllNoflush in interface FileArrayAccessor
values - value
Throws:
AccessorException

addAllNoflush

public void addAllNoflush(int index,
                          Binding rcb,
                          java.lang.Object[] rcvs)
                   throws AccessorException
Description copied from interface: FileArrayAccessor
Add an array of elements. If elements are inserted in the middle of the array, existing interest sets are updated to reflect the new positions.

Specified by:
addAllNoflush in interface FileArrayAccessor
Parameters:
index - position to insert new value to
Throws:
AccessorException

removeNoflush

public void removeNoflush(int index,
                          int count)
                   throws AccessorException
Description copied from interface: FileArrayAccessor
Remove an element at an index. If there are listeners to elements after the null, the interest sets and accessor paths are updated and decreased. If there was an accessor, it becomes invalid.

Specified by:
removeNoflush in interface FileArrayAccessor
Throws:
AccessorException

get

public java.lang.Object get(int index,
                            Binding valueBinding)
                     throws AccessorException
Description copied from interface: ArrayAccessor
Get a value

Specified by:
get in interface ArrayAccessor
Returns:
the element
Throws:
AccessorException

getAccessor

public <T extends Accessor> T getAccessor(int index)
                               throws AccessorConstructionException
Description copied from interface: ArrayAccessor
Get an accessor to an element. The accessor is invalidated if the element is removed from the array.

The accessor is not to the index, it is to the element. For instance, you get accessor X of [2] then a new value is inserted before 2. The accessor now points to the element at [3].

Specified by:
getAccessor in interface ArrayAccessor
Returns:
the accessor
Throws:
AccessorConstructionException

getAccessor

public <T extends Accessor> T getAccessor(AccessorReference reference)
                               throws AccessorConstructionException
Description copied from interface: Accessor
Get an accessor to a sub-container. If one already exists, the same is returned, otherwise a new is created.

InvalidatedEvent is thrown from the accessor if it is unlinked from the parent hierarchy.

Specified by:
getAccessor in interface Accessor
Parameters:
reference - component reference or null to return _this_ accessor
Returns:
accessor
Throws:
AccessorConstructionException

getAll

public void getAll(Binding valueBinding,
                   java.lang.Object[] array)
            throws AccessorException
Description copied from interface: ArrayAccessor
Get all elements and place them to an array. Exception is thrown if Array length is too short.

Specified by:
getAll in interface ArrayAccessor
Throws:
AccessorException

getAll

public void getAll(Binding valueBinding,
                   java.util.Collection<java.lang.Object> values)
            throws AccessorException
Description copied from interface: ArrayAccessor
Get all elements

Specified by:
getAll in interface ArrayAccessor
Throws:
AccessorException

size

public int size()
         throws AccessorException
Description copied from interface: ArrayAccessor
Return the number of elements in the array.

Specified by:
size in interface ArrayAccessor
Returns:
the number of elements
Throws:
AccessorException

add

public void add(Binding binding,
                java.lang.Object value)
         throws AccessorException
Description copied from interface: ArrayAccessor
Add a new value.

Specified by:
add in interface ArrayAccessor
value - value
Throws:
AccessorException

add

public void add(int index,
                Binding binding,
                java.lang.Object value)
         throws AccessorException
Description copied from interface: ArrayAccessor
Insert a new value. If elements are inserted in the middle of the array, existing interest sets are updated to reflect the new positions.

Specified by:
add in interface ArrayAccessor
Parameters:
index - position to insert new value to
value - value
Throws:
AccessorException

addAll

public void addAll(Binding binding,
                   java.lang.Object[] values)
            throws AccessorException
Description copied from interface: ArrayAccessor
Add an array of elements.

Specified by:
addAll in interface ArrayAccessor
values - value
Throws:
AccessorException

addAll

public void addAll(int index,
                   Binding binding,
                   java.lang.Object[] values)
            throws AccessorException
Description copied from interface: ArrayAccessor
Add an array of elements. If elements are inserted in the middle of the array, existing interest sets are updated to reflect the new positions.

Specified by:
addAll in interface ArrayAccessor
Parameters:
index - position to insert new value to
Throws:
AccessorException

remove

public void remove(int index,
                   int count)
            throws AccessorException
Description copied from interface: ArrayAccessor
Remove an element at an index. If there are listeners to elements after the index, the interest sets and accessor paths are updated and decreased. If there was an accessor, it becomes invalid.

Specified by:
remove in interface ArrayAccessor
Throws:
AccessorException

set

public void set(int index,
                Binding binding,
                java.lang.Object value)
         throws AccessorException
Description copied from interface: ArrayAccessor
Replace a value container with a new value.

Specified by:
set in interface ArrayAccessor
Throws:
AccessorException