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 methods addAttributeType and addVendor.
  • Constructor Summary

    Constructors 
    Constructor Description
    MemoryDictionary()  
  • Method Summary

    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 vendorCode, byte type)
    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

    Methods inherited from interface org.tinyradius.dictionary.Dictionary

    getAttributeTypeByCode
  • Constructor Details

  • Method Details

    • getAttributeTypeByCode

      public AttributeType getAttributeTypeByCode​(int vendorCode, byte type)
      Returns the specified AttributeType object.
      Specified by:
      getAttributeTypeByCode in interface Dictionary
      Parameters:
      vendorCode - vendor ID or -1 for "no vendor"
      type - attribute type code
      Returns:
      AttributeType or null
    • 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
    • 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
    • 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
    • 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