Package overit.geocall.util
Class ObjectPipe
java.lang.Object
overit.geocall.util.ObjectPipe
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
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionObjectPipe(int maxsize) Creates a new empty ObjectPipe with the desired maximum lengthObjectPipe(Object o, int maxsize) Creates a new ObjectPipe and fills it with a number of objects o, passed as parameter, equals to the maximum sizeObjectPipe(ObjectPipe[] oopp) Creates a new ObjectPipe using the array of ObjectPipe passed as parameter; every element of the array defines a sub pipe. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the object to the ObjectPipe, in the last positionbooleanaddAll(Collection c) Adds all the elements of theCollectionto the ObjectPipeAdds the Object to the ObjectPipe in the first positionAdds the Object to the ObjectPipe in the last positionget(int i) Returns the i-th Object element of the ObjectPipeReturns a copy of the ObjectPipegetSubPipe(int i) Returns the i-th sub pipeintReturns the number of sub pipes that compose the ObjectPipeiterator()Returns a new Iterator over the ObjectPipe elementsintmaxSize()Returns the maximum size of the ObjectPipeintsize()Returns the current number of elements of the ObjectPipetoString()Returns a string representation of the ObjectPipeprotected StringReturns a string representation of the ObjectPipe
-
Field Details
-
_ll
-
_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
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 pipemaxsize- The maximum length of the pipe
-
ObjectPipe
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
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
Adds the Object to the ObjectPipe in the first position- Parameters:
o- The Object to add- Returns:
- Returns
nullif 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
Adds the Object to the ObjectPipe in the last position- Parameters:
o- The Object to add- Returns:
- Returns
nullif 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
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
Returns a new Iterator over the ObjectPipe elements- Returns:
- An Iterator
-
toString
Returns a string representation of the ObjectPipe- Parameters:
begin- The string that defines the start of the string representationsep- The separator string between each element of the ObjectPipeend- 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
Returns a string representation of the ObjectPipe -
getContentCopy
Returns a copy of the ObjectPipe- Returns:
- An
ArrayListthat is a copy of the ObjectPipe; it will contains all the elements in the right order
-
add
Adds the object to the ObjectPipe, in the last position- Parameters:
o- The object to add- Returns:
true
-
addAll
Adds all the elements of theCollectionto the ObjectPipe- Parameters:
c- The elements Collection to add- Returns:
falseif the Collection is empty,trueotherwise
-