edu.mit.csail.sdg.alloy4compiler.sim
Class SimAtom

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4compiler.sim.SimAtom

public final class SimAtom
extends java.lang.Object

Immutable; represents an atom.

Outside of this class, we guarantee for any SimAtom x and y, then "x.equals(y) iff x==y".
Even though that means "equals()" and "==" are equivalent,
the equals() method is much slower than "==" for SimAtom,
so you should always try to use "==" on SimAtom.

Thread Safety: Safe.


Field Summary
static SimAtom EMPTYSTRING
          Preconstructed atom representing emptystring.
static SimAtom ONE
          Preconstructed atom representing 1.
static SimAtom ZERO
          Preconstructed atom representing 0.
 
Method Summary
 boolean equals(java.lang.Object that)
          
 int hashCode()
          
static SimAtom make(int i)
          Construct a SimAtom for the given integer, or if an existing SimAtom hasn't been garbage collected yet then return that instead.
static SimAtom make(long i)
          Construct a SimAtom for the given integer, or if an existing SimAtom hasn't been garbage collected yet then return that instead.
static SimAtom make(java.lang.String label)
          Construct a SimAtom for the given label, or if an existing SimAtom hasn't been garbage collected yet then return that instead.
 SimTuple product(SimAtom that)
          Return the product of this atom and that atom.
 java.lang.Integer toInt(java.lang.Integer defaultValue)
          If the atom starts with "-" or "0-9" then convert it into a 32-bit int (here we assume that it came from a 32-bit int)
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTYSTRING

public static final SimAtom EMPTYSTRING
Preconstructed atom representing emptystring.


ZERO

public static final SimAtom ZERO
Preconstructed atom representing 0.


ONE

public static final SimAtom ONE
Preconstructed atom representing 1.

Method Detail

make

public static SimAtom make(java.lang.String label)
Construct a SimAtom for the given label, or if an existing SimAtom hasn't been garbage collected yet then return that instead.


make

public static SimAtom make(int i)
Construct a SimAtom for the given integer, or if an existing SimAtom hasn't been garbage collected yet then return that instead.


make

public static SimAtom make(long i)
Construct a SimAtom for the given integer, or if an existing SimAtom hasn't been garbage collected yet then return that instead.


toInt

public java.lang.Integer toInt(java.lang.Integer defaultValue)
                        throws java.lang.NumberFormatException
If the atom starts with "-" or "0-9" then convert it into a 32-bit int (here we assume that it came from a 32-bit int)

If the atom does not start with "-" or "0-9", then return defaultValue.

Throws:
java.lang.NumberFormatException

product

public SimTuple product(SimAtom that)
Return the product of this atom and that atom.


equals

public boolean equals(java.lang.Object that)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object