com.sun.electric.database
Class ImmutableElectricObject

java.lang.Object
  extended by com.sun.electric.database.ImmutableElectricObject
Direct Known Subclasses:
ImmutableArcInst, ImmutableCell, ImmutableExport, ImmutableLibrary, ImmutableNodeInst, ImmutablePortInst

public abstract class ImmutableElectricObject
extends java.lang.Object

This immutable class is the base class of all Electric immutable objects that can be extended with Variables.


Field Summary
 int flags
          flags of this IimmutableElectricObject.
 
Method Summary
abstract  boolean equalsExceptVariables(ImmutableElectricObject o)
          Indicates whether fields of other ImmutableElectricObject are equal to fileds of this object.
 int getNumVariables()
          Method to return the number of Variables on this ImmutableElectricObject.
 Variable getVar(int varIndex)
          Method to return the Variable by its varIndex.
 Variable getVar(Variable.Key key)
          Method to return the Variable on this ImmuatbleElectricObject with a given key.
 java.util.Iterator<Variable> getVariables()
          Method to return an Iterator over all Variables on this ImmutableElectricObject.
<T> T
getVarValue(Variable.Key key, java.lang.Class type)
          Method to return the value of the Variable on this ImmutableElectricObject with a given key and type.
abstract  int hashCodeExceptVariables()
          Return a hash code value for fields of this object.
 int searchVar(Variable.Key key)
          Searches the variables for the specified variable key using the binary search algorithm.
 Variable[] toVariableArray()
          Method to return an array of all Variables on this ImmutableElectricObject.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flags

public final int flags
flags of this IimmutableElectricObject.

Method Detail

getVar

public Variable getVar(Variable.Key key)
Method to return the Variable on this ImmuatbleElectricObject with a given key.

Parameters:
key - the key of the Variable.
Returns:
the Variable with that key, or null if there is no such Variable.
Throws:
java.lang.NullPointerException - if key is null

getVarValue

public <T> T getVarValue(Variable.Key key,
                         java.lang.Class type)
Method to return the value of the Variable on this ImmutableElectricObject with a given key and type.

Parameters:
key - the key of the Variable.
type - the required type of the Variable.
Returns:
the value of the Variable with that key and type, or null if there is no such Variable or default Variable value.
Throws:
java.lang.NullPointerException - if key or type is null

getVariables

public java.util.Iterator<Variable> getVariables()
Method to return an Iterator over all Variables on this ImmutableElectricObject.

Returns:
an Iterator over all Variables on this ImmutableElectricObject.

toVariableArray

public Variable[] toVariableArray()
Method to return an array of all Variables on this ImmutableElectricObject.

Returns:
an array of all Variables on this ImmutableElectricObject.

getNumVariables

public int getNumVariables()
Method to return the number of Variables on this ImmutableElectricObject.

Returns:
the number of Variables on this ImmutableElectricObject.

getVar

public Variable getVar(int varIndex)
Method to return the Variable by its varIndex.

Parameters:
varIndex - index of Variable.
Returns:
the Variable with given varIndex.
Throws:
ArrayIndexOutOfBoundesException - if varIndex out of bounds.

searchVar

public int searchVar(Variable.Key key)
Searches the variables for the specified variable key using the binary search algorithm.

Parameters:
key - the variable key to be searched.
Returns:
index of the search variable, if it is contained in the vars; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the NodeInst would be inserted into the list: the index of the first element greater than the key, or nodes.size(), if all elements in the list are less than the specified name. Note that this guarantees that the return value will be >= 0 if and only if the Variable is found.
Throws:
java.lang.NullPointerException - if key is null

hashCodeExceptVariables

public abstract int hashCodeExceptVariables()
Return a hash code value for fields of this object. Variables of objects are not compared


equalsExceptVariables

public abstract boolean equalsExceptVariables(ImmutableElectricObject o)
Indicates whether fields of other ImmutableElectricObject are equal to fileds of this object. Variables of objects are not compared.

Parameters:
o - other ImmutableElectricObject.
Returns:
true if fields of objects are equal.