org.tinyradius.dictionary
Class MemoryDictionary

java.lang.Object
  extended by org.tinyradius.dictionary.MemoryDictionary
All Implemented Interfaces:
Dictionary, WritableDictionary
Direct Known Subclasses:
DefaultDictionary

public class MemoryDictionary
extends java.lang.Object
implements WritableDictionary

A dictionary that keeps the values and names in hash maps in the memory. The dictionary has to be filled using the methods addAttributeType and addVendor.

See Also:
addAttributeType(AttributeType), addVendor(int, String), Dictionary, WritableDictionary

Constructor Summary
MemoryDictionary()
           
 
Method Summary
 void addAttributeType(AttributeType attributeType)
          Adds an AttributeType object to the cache.
 void addVendor(int vendorId, java.lang.String vendorName)
          Adds the given vendor to the cache.
 AttributeType getAttributeTypeByCode(int typeCode)
          Returns the AttributeType for the vendor -1 from the cache.
 AttributeType getAttributeTypeByCode(int vendorCode, int typeCode)
          Returns the specified AttributeType object.
 AttributeType getAttributeTypeByName(java.lang.String typeName)
          Retrieves the attribute type with the given name.
 int getVendorId(java.lang.String vendorName)
          Searches the vendor with the given name and returns its code.
 java.lang.String getVendorName(int vendorId)
          Retrieves the name of the vendor with the given code from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryDictionary

public MemoryDictionary()
Method Detail

getAttributeTypeByCode

public AttributeType getAttributeTypeByCode(int typeCode)
Returns the AttributeType for the vendor -1 from the cache.

Specified by:
getAttributeTypeByCode in interface Dictionary
Parameters:
typeCode - attribute type code
Returns:
AttributeType or null
See Also:
Dictionary.getAttributeTypeByCode(int)

getAttributeTypeByCode

public AttributeType getAttributeTypeByCode(int vendorCode,
                                            int typeCode)
Returns the specified AttributeType object.

Specified by:
getAttributeTypeByCode in interface Dictionary
Parameters:
vendorCode - vendor ID or -1 for "no vendor"
typeCode - attribute type code
Returns:
AttributeType or null
See Also:
Dictionary.getAttributeTypeByCode(int, int)

getAttributeTypeByName

public AttributeType getAttributeTypeByName(java.lang.String typeName)
Retrieves the attribute type with the given name.

Specified by:
getAttributeTypeByName in interface Dictionary
Parameters:
typeName - name of the attribute type
Returns:
AttributeType or null
See Also:
Dictionary.getAttributeTypeByName(java.lang.String)

getVendorId

public int getVendorId(java.lang.String vendorName)
Searches the vendor with the given name and returns its code. This method is seldomly used.

Specified by:
getVendorId in interface Dictionary
Parameters:
vendorName - vendor name
Returns:
vendor code or -1
See Also:
Dictionary.getVendorId(java.lang.String)

getVendorName

public java.lang.String getVendorName(int vendorId)
Retrieves the name of the vendor with the given code from the cache.

Specified by:
getVendorName in interface Dictionary
Parameters:
vendorId - vendor number
Returns:
vendor name or null
See Also:
Dictionary.getVendorName(int)

addVendor

public void addVendor(int vendorId,
                      java.lang.String vendorName)
Adds the given vendor to the cache.

Specified by:
addVendor in interface WritableDictionary
Parameters:
vendorId - vendor ID
vendorName - name of the vendor
Throws:
java.lang.IllegalArgumentException - empty vendor name, invalid vendor ID

addAttributeType

public void addAttributeType(AttributeType attributeType)
Adds an AttributeType object to the cache.

Specified by:
addAttributeType in interface WritableDictionary
Parameters:
attributeType - AttributeType object
Throws:
java.lang.IllegalArgumentException - duplicate attribute name/type code