es.uc3m.it.xbe32
Class XBE32Dictionary

java.lang.Object
  extended byes.uc3m.it.xbe32.XBE32Dictionary

public class XBE32Dictionary
extends Object

This class allows XBE32 Elements' identifiers to be translated into/from names.

The dictionary can be filled with the add() method, or directly from a Properties file:

      # name '=' identifier ('0x' hex or decimal format)
      #
      service = 1
      type    = 0x2102
      addr    = 0x2C03
      ports   = 0x2904
      options = 0xC005
      color   = 6
 


Constructor Summary
XBE32Dictionary()
          Creates an empty XBE32Dictionary.
XBE32Dictionary(String file)
          Creates a XBE32Dictionary from the specified Properties filename.
 
Method Summary
 void add(int id, String name)
          Adds the specified identifier-name translation pair to the dictionary
 int getId(String name)
          Returns the XBE32 Element identifier associated to the specified name
 String getName(int id)
          Returns the XBE32 Element name associated to the specified identifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XBE32Dictionary

public XBE32Dictionary()
Creates an empty XBE32Dictionary.


XBE32Dictionary

public XBE32Dictionary(String file)
                throws IOException,
                       NumberFormatException
Creates a XBE32Dictionary from the specified Properties filename.

Parameters:
file - the file to load the dictionary from
Throws:
IOException - if an error occurs while loading the file
NumberFormatException - if an identifier cannot be parsed as a hexadecimal or decimal number
Method Detail

add

public void add(int id,
                String name)
Adds the specified identifier-name translation pair to the dictionary

Parameters:
id - the XBE32 Element identifier
name - the XBE32 Element name

getName

public String getName(int id)
Returns the XBE32 Element name associated to the specified identifier

Parameters:
id - the XBE32 Element identifier to translate into a name
Returns:
the associated name or null if the name is not found

getId

public int getId(String name)
Returns the XBE32 Element identifier associated to the specified name

Parameters:
name - the XBE32 Element name to translate into a identifier
Returns:
the associated identifier or 0 if the name is not found