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(Vendor vendor)
Adds the given vendor to the dictionary.java.util.Optional<AttributeTemplate>
getAttributeTemplate(int vendorCode, int attributeId)
Retrieves an AttributeTemplate for a vendor-specific attribute.java.util.Optional<AttributeTemplate>
getAttributeTemplate(java.lang.String name)
Retrieves an AttributeTemplate by name.java.util.Optional<Vendor>
getVendor(int vendorId)
Retrieves the vendor with the given vendor code.java.util.Optional<Vendor>
getVendor(java.lang.String vendorName)
Retrieves the ID of the vendor with the given name.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
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
-
getVendor
Description copied from interface:CoreDictionary
Retrieves the ID of the vendor with the given name.- Specified by:
getVendor
in interfaceCoreDictionary
- Parameters:
vendorName
- name of the vendor- Returns:
- vendorId or -1
-
getVendor
Description copied from interface:CoreDictionary
Retrieves the vendor with the given vendor code.- Specified by:
getVendor
in interfaceCoreDictionary
- Parameters:
vendorId
- vendor number- Returns:
- vendor
-
addVendor
Description copied from interface:WritableDictionary
Adds the given vendor to the dictionary.- Specified by:
addVendor
in interfaceWritableDictionary
- Parameters:
vendor
- 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
-