org.webmacro.util
Class Atomizer

java.lang.Object
  |
  +--org.webmacro.util.Atomizer
All Implemented Interfaces:
java.lang.Cloneable

public final class Atomizer
extends java.lang.Object
implements java.lang.Cloneable

Atomize an object into an atomic number, and provide a means to turn that atomic number back into the original object.


Constructor Summary
Atomizer()
          Create an atomizer with space for 100 atoms
Atomizer(int size)
          Create an atomizer with space for the specified number of atoms.
 
Method Summary
 int atomize(java.lang.Object o)
          Put an object in the atomizer, return its atomic number.
 java.lang.Object clone()
          Clone this Atomizer
 java.lang.Object get(int atom)
          Get the Object matching this atom
 java.util.Iterator iterator()
          Get an iterator capable of walking through all the values in the atomizer.
 int lookup(java.lang.Object o)
          Get the atomic number for o.
static void main(java.lang.String[] arg)
          Test based on command line args
 java.lang.Object remove(int atom)
          Remove an entry by atomic number, returning its former value.
 void remove(java.lang.Object o)
          Remove an entry by value
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Atomizer

public Atomizer()
Create an atomizer with space for 100 atoms

Atomizer

public Atomizer(int size)
Create an atomizer with space for the specified number of atoms.
Method Detail

clone

public java.lang.Object clone()
Clone this Atomizer
Overrides:
clone in class java.lang.Object

lookup

public int lookup(java.lang.Object o)
Get the atomic number for o. If o does not have an atomic number return -1.

atomize

public int atomize(java.lang.Object o)
Put an object in the atomizer, return its atomic number. You will need this atomic number later to access the object. If the object is already in the atomizer you will get back the same atomic number as last time.

get

public java.lang.Object get(int atom)
Get the Object matching this atom

remove

public java.lang.Object remove(int atom)
Remove an entry by atomic number, returning its former value.

remove

public void remove(java.lang.Object o)
Remove an entry by value

iterator

public java.util.Iterator iterator()
Get an iterator capable of walking through all the values in the atomizer.

main

public static void main(java.lang.String[] arg)
Test based on command line args