Package org.tinyradius.dictionary
Class MemoryDictionary
- java.lang.Object
-
- org.tinyradius.dictionary.MemoryDictionary
-
- All Implemented Interfaces:
Dictionary
,WritableDictionary
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 methodsaddAttributeType
andaddVendor
.
-
-
Constructor Summary
Constructors Constructor Description MemoryDictionary()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
Method Detail
-
getAttributeTypeByCode
public AttributeType getAttributeTypeByCode(int typeCode)
Returns the AttributeType for the vendor -1 from the cache.- Specified by:
getAttributeTypeByCode
in interfaceDictionary
- 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 interfaceDictionary
- 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 interfaceDictionary
- Parameters:
typeName
- name of the attribute type- Returns:
- AttributeType or null
-
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 interfaceDictionary
- Parameters:
vendorName
- vendor name- Returns:
- vendor code or -1
-
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 interfaceDictionary
- Parameters:
vendorId
- vendor number- Returns:
- vendor name or null
-
addVendor
public void addVendor(int vendorId, java.lang.String vendorName)
Adds the given vendor to the cache.- Specified by:
addVendor
in interfaceWritableDictionary
- Parameters:
vendorId
- vendor IDvendorName
- 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 interfaceWritableDictionary
- Parameters:
attributeType
- AttributeType object- Throws:
java.lang.IllegalArgumentException
- duplicate attribute name/type code
-
-