Package ome.util.mem

Class CopiableArray

  • All Implemented Interfaces:
    Copiable

    public abstract class CopiableArray
    extends java.lang.Object
    implements Copiable
    This abstract class provides an implementation of the Copiable interface. It constructs an array of Copiables , note that all subclasses must implement the makeNew(int) method. It provides methods to manipulate elements of the array set(Copiable, int) and get(int). It also implements a copy(int, int) method which allows to copy an element from a specified position in the array into a new specified position. Subclasses inherit the copy() 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 by Copiable.
      void copy​(int from, int to)
      Copies the Copiable from the specified position from into the specified position to.
      Copiable get​(int index)
      Return the Copiable 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 specified Copiable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CopiableArray

        protected CopiableArray​(int size)
        Creates a new instance.
        Parameters:
        size - The size of the array.
        Throws:
        java.lang.IllegalArgumentException - If the size is not strictly positive,
    • 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 specified Copiable.
        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 the Copiable 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)
        Copies the Copiable from the specified position from into the specified position 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 by Copiable.
        Specified by:
        copy in interface Copiable
        Returns:
        The new object.
        See Also:
        Copiable.copy()