import java.util.*;

/**
   Assign the OID for each MIB Object
   @author Sugiharto Widjaja
   @version 10/30/02
*/
public class IDAssigner
{
   /**
      Construct the ID assigner
   */
   public IDAssigner()
   {
      list = new ArrayList();
   }

   /**
      Add new OID to the storage
      @param obj the MIB object
      @param id the OID of the object
   */
   public void addNewOID(String obj, String id)
   {
      list.add(obj + ":" + id);
   }

   /**
      Get the OID of a MIB object
      @param obj the MIB object
      @return the OID of the MIB object
   */
   public String getID(String obj)
   {
      int size = list.size();
      boolean done = false;
      String result = "";
      for(int i = 0; i < size && !done; i++)
      {
         String objId = (String) list.get(i);
         StringTokenizer token = new StringTokenizer(objId, ":");
         if(obj.equals(token.nextToken()))
         {
            result = token.nextToken();
            done = true;
         }
      }
      return result;
   }

   // The storage to store the MIB OID
   private ArrayList list;
}
