Class ObjectPipe

java.lang.Object
overit.geocall.util.ObjectPipe

public class ObjectPipe extends Object
This utility object implements a pipe that can contain objects of various types, which can also be ObjectPipe. This pipe has a maximum size, definable at the time of construction and exposes various management methods for adding and retrieving the elements
  • Field Details

    • _ll

      protected LinkedList _ll
    • _oopp

      protected ObjectPipe[] _oopp
    • _maxsize

      protected int _maxsize
  • Constructor Details

    • ObjectPipe

      public ObjectPipe(int maxsize)
      Creates a new empty ObjectPipe with the desired maximum length
      Parameters:
      maxsize - The maximum length of the pipe
    • ObjectPipe

      public ObjectPipe(Object o, int maxsize)
      Creates a new ObjectPipe and fills it with a number of objects o, passed as parameter, equals to the maximum size
      Parameters:
      o - The Object used to fill the pipe
      maxsize - The maximum length of the pipe
    • ObjectPipe

      public ObjectPipe(ObjectPipe[] oopp)
      Creates a new ObjectPipe using the array of ObjectPipe passed as parameter; every element of the array defines a sub pipe. The maximum size of the ObjectPipe created will be equal to the sum of the maximum size of each sub pipe
      Parameters:
      oopp - The array of ObjectPipe that will compose the new ObjectPipe
  • Method Details

    • getSubPipe

      public ObjectPipe getSubPipe(int i)
      Returns the i-th sub pipe
      Parameters:
      i - The index of the desired sub pipe
      Returns:
      The ObjectPipe that corresponds to the i-th sub pipe
    • getSubPipeSize

      public int getSubPipeSize()
      Returns the number of sub pipes that compose the ObjectPipe
      Returns:
      The number of sub pipes of the ObjectPipe
    • addFirst

      public Object addFirst(Object o)
      Adds the Object to the ObjectPipe in the first position
      Parameters:
      o - The Object to add
      Returns:
      Returns null if after the add, the size of the ObjectPipe is lower than the maximum size.
      Returns the last element of the ObjectPipe if, adding the element, the size is greater than the maximum size; in this case the last element is extracted from the pipe and returned.
    • addLast

      public Object addLast(Object o)
      Adds the Object to the ObjectPipe in the last position
      Parameters:
      o - The Object to add
      Returns:
      Returns null if after the add, the size of the ObjectPipe is lower than the maximum size.
      Returns the first element of the ObjectPipe if, adding the element, the size is greater than the maximum size; in this case the first element is extracted from the pipe and returned.
    • size

      public int size()
      Returns the current number of elements of the ObjectPipe
      Returns:
      The number of the elements
    • maxSize

      public int maxSize()
      Returns the maximum size of the ObjectPipe
      Returns:
      The maximum size of the pipe
    • get

      public Object get(int i)
      Returns the i-th Object element of the ObjectPipe
      Parameters:
      i - The position of the Object to extract
      Returns:
      The Object in the desired position
    • iterator

      public Iterator iterator()
      Returns a new Iterator over the ObjectPipe elements
      Returns:
      An Iterator
    • toString

      protected String toString(String begin, String sep, String end)
      Returns a string representation of the ObjectPipe
      Parameters:
      begin - The string that defines the start of the string representation
      sep - The separator string between each element of the ObjectPipe
      end - The string that defines the end of the string representation
      Returns:
      A string in which the elements of the ObjectPipe are between the begin and the end string passed as first and last parameters and each element is separated from the others by the separator string passed as second parameter
    • toString

      public String toString()
      Returns a string representation of the ObjectPipe
      Overrides:
      toString in class Object
      Returns:
      A string in which the elements of the ObjectPipe are between two square brackets and each element is separated from the others by the comma character
    • getContentCopy

      public ArrayList getContentCopy()
      Returns a copy of the ObjectPipe
      Returns:
      An ArrayList that is a copy of the ObjectPipe; it will contains all the elements in the right order
    • add

      public boolean add(Object o)
      Adds the object to the ObjectPipe, in the last position
      Parameters:
      o - The object to add
      Returns:
      true
    • addAll

      public boolean addAll(Collection c)
      Adds all the elements of the Collection to the ObjectPipe
      Parameters:
      c - The elements Collection to add
      Returns:
      false if the Collection is empty, true otherwise