gov.nist.antd.optical
Class AbstractObject

java.lang.Object
  |
  +--gov.nist.antd.optical.AbstractObject
Direct Known Subclasses:
AlgorithmContainer, Fiber, OpticalChannel, OpticalConnection, OpticalPath, PathContainer

public abstract class AbstractObject
extends java.lang.Object

This abstract superclass provides the array manipulation methods.

 This interface was developed at the National Institute of Standards and
 Technology by employees of the Federal Government in the course of
 their official duties. Pursuant to title 17 Section 105 of the United
 States Code this software is not subject to copyright protection and
 is in the public domain.
 NIST assumes no responsibility whatsoever for its use by other parties,
 and makes no guarantees, expressed or implied, about its quality,
 reliability, or any other characteristic.
 
We would appreciate acknowledgement if the software is used.
NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.

Author:
borchert
, rouil

Field Summary
protected static int INITIAL_ARRAY_SIZE
          The initial size of an array.
 
Constructor Summary
protected AbstractObject()
          Default constructor.
 
Method Summary
protected  boolean addElement(java.lang.Object element, int elements, java.lang.Object[] array)
          Adds the specified Object to the given Array.
protected  void clear(java.lang.Object[] array)
          set all elements in the array to null.
protected abstract  java.lang.Object[] createArray(int size)
          Creates an array of the specified size.
protected  boolean isElementOf(java.lang.Object element, java.lang.Object[] array)
          Checks if the element is already in the array.
protected  boolean removeElement(java.lang.Object element, int elements, java.lang.Object[] array)
          Removes the given element from the given array.
protected abstract  void setNoElements(int size)
          Set the number of elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_ARRAY_SIZE

protected static final int INITIAL_ARRAY_SIZE
The initial size of an array.

See Also:
Constant Field Values
Constructor Detail

AbstractObject

protected AbstractObject()
Default constructor.

Method Detail

addElement

protected boolean addElement(java.lang.Object element,
                             int elements,
                             java.lang.Object[] array)
Adds the specified Object to the given Array. ATTENTION: This method calls the setNoElements() to update the element counter. and createArray() to increase the data containing array. Each element can be added only once.

Parameters:
element - The element to add.
elements - The number of elements in the array.
array - The array to add the element to.
Returns:
true if the element is added successfull.

isElementOf

protected boolean isElementOf(java.lang.Object element,
                              java.lang.Object[] array)
Checks if the element is already in the array. This check uses the "==" operator.

Parameters:
element - The element that is looking for.
array - The array that will be examined.
Returns:
true if the element is part of the array, otherwise false.

clear

protected void clear(java.lang.Object[] array)
set all elements in the array to null.

Parameters:
array - The array to clear.

createArray

protected abstract java.lang.Object[] createArray(int size)
Creates an array of the specified size. The implementation class must set this array to the internal work array. Otherwise the method addElements will throw an exception later on. The implementation should be synchronized.

Parameters:
size - the given size.
Returns:
an array of the specified size.

setNoElements

protected abstract void setNoElements(int size)
Set the number of elements. The implementation should be synchronized.

Parameters:
size - the new number of elements.

removeElement

protected boolean removeElement(java.lang.Object element,
                                int elements,
                                java.lang.Object[] array)
Removes the given element from the given array. The comparism will be done by the == method. This method calls the setNoElements() to update the element counter.

Parameters:
element - The given element.
elements - The number of elements in the array.
array - The array the element has to be removed from.
Returns:
true if the element was removed successfull; otherwise false.