Package org.tinyradius.core.dictionary
Class MemoryDictionary
java.lang.Object
org.tinyradius.core.dictionary.MemoryDictionary
- All Implemented Interfaces:
CoreDictionary
,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
methods
addAttributeTemplate
and
addVendor
.-
Constructor Summary
Constructors Constructor Description MemoryDictionary()
-
Method Summary
Modifier and Type Method Description void
addAttributeTemplate(AttributeTemplate attributeTemplate)
Adds an AttributeTemplate object to the cache.void
addVendor(int vendorId, java.lang.String vendorName)
Adds the given vendor to the dictionary.java.util.Optional<AttributeTemplate>
getAttributeTemplate(int vendorCode, byte attributeId)
Retrieves an AttributeTemplate for a vendor-specific attribute.java.util.Optional<AttributeTemplate>
getAttributeTemplate(java.lang.String name)
Retrieves an AttributeTemplate by name.int
getVendorId(java.lang.String vendorName)
Retrieves the ID of the vendor with the given name.java.util.Optional<java.lang.String>
getVendorName(int vendorId)
Retrieves the name of the vendor with the given vendor code.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.tinyradius.core.dictionary.Dictionary
createAttribute, createAttribute, createAttribute, createAttribute, createAttribute, parseAttribute
-
Constructor Details
-
MemoryDictionary
public MemoryDictionary()
-
-
Method Details
-
getAttributeTemplate
public java.util.Optional<AttributeTemplate> getAttributeTemplate(int vendorCode, byte attributeId)Description copied from interface:CoreDictionary
Retrieves an AttributeTemplate for a vendor-specific attribute.- Specified by:
getAttributeTemplate
in interfaceCoreDictionary
- Parameters:
vendorCode
- vendorId if appropriate or -1attributeId
- attributeId 1-255- Returns:
- AttributeTemplate
-
getAttributeTemplate
Description copied from interface:CoreDictionary
Retrieves an AttributeTemplate by name. This includes vendor-specific attribute types whose name is prefixed by the vendor name.- Specified by:
getAttributeTemplate
in interfaceCoreDictionary
- Parameters:
name
- attribute name- Returns:
- AttributeTemplate object or null
-
getVendorId
public int getVendorId(java.lang.String vendorName)Description copied from interface:CoreDictionary
Retrieves the ID of the vendor with the given name.- Specified by:
getVendorId
in interfaceCoreDictionary
- Parameters:
vendorName
- name of the vendor- Returns:
- vendorId or -1
-
getVendorName
public java.util.Optional<java.lang.String> getVendorName(int vendorId)Description copied from interface:CoreDictionary
Retrieves the name of the vendor with the given vendor code.- Specified by:
getVendorName
in interfaceCoreDictionary
- Parameters:
vendorId
- vendor number- Returns:
- vendor name or null
-
addVendor
public void addVendor(int vendorId, java.lang.String vendorName)Description copied from interface:WritableDictionary
Adds the given vendor to the dictionary.- Specified by:
addVendor
in interfaceWritableDictionary
- Parameters:
vendorId
- vendor IDvendorName
- name of the vendor
-
addAttributeTemplate
Adds an AttributeTemplate object to the cache.- Specified by:
addAttributeTemplate
in interfaceWritableDictionary
- Parameters:
attributeTemplate
- AttributeTemplate object- Throws:
java.lang.IllegalArgumentException
- duplicate attribute name/type code
-