Package ome.util.mem
Class CopiableArray
- java.lang.Object
-
- ome.util.mem.CopiableArray
-
- All Implemented Interfaces:
Copiable
public abstract class CopiableArray extends java.lang.Object implements Copiable
This abstract class provides an implementation of theCopiable
interface. It constructs an array ofCopiable
s , note that all subclasses must implement themakeNew(int)
method. It provides methods to manipulate elements of the arrayset(Copiable, int)
andget(int)
. It also implements acopy(int, int)
method which allows to copy an element from a specified position in the array into a new specified position. Subclasses inherit thecopy()
method- Since:
- OME2.2
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CopiableArray(int size)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Object
copy()
Implements the method as specified byCopiable
.void
copy(int from, int to)
Copiable
get(int index)
Return theCopiable
at the specified position.int
getSize()
Returns the number of elements in the array.protected abstract CopiableArray
makeNew(int size)
Creates a new array of the speficied size.void
set(Copiable element, int index)
Replaces the element at the specified position with the specifiedCopiable
.
-
-
-
Method Detail
-
makeNew
protected abstract CopiableArray makeNew(int size)
Creates a new array of the speficied size.- Parameters:
size
- The size of the array.- Returns:
- See above.
-
getSize
public int getSize()
Returns the number of elements in the array.- Returns:
- See above.
-
set
public void set(Copiable element, int index)
Replaces the element at the specified position with the specifiedCopiable
.- Parameters:
element
- Copiable to set.index
- The position in the array.- Throws:
java.lang.IllegalArgumentException
- If the index is not valid.
-
get
public Copiable get(int index)
Return theCopiable
at the specified position.- Parameters:
index
- The position in the array.- Returns:
- See above.
- Throws:
java.lang.IllegalArgumentException
- If the index is not valid.
-
copy
public void copy(int from, int to)
- Parameters:
from
- The starting position.to
- The ending position.- Throws:
java.lang.IllegalArgumentException
- If the indexes are not valid.
-
copy
public java.lang.Object copy()
Implements the method as specified byCopiable
.- Specified by:
copy
in interfaceCopiable
- Returns:
- The new object.
- See Also:
Copiable.copy()
-
-