Class EncoderDecoder

java.lang.Object
hec.heclib.util.EncoderDecoder
All Implemented Interfaces:
Serializable

public class EncoderDecoder extends Object implements Serializable
public class EncoderDecoder DATA TYPE PURPOSE m_wrappers String[2] the enclosing symbols for a code DFL_WRAP_* final String default values for m_wrappers m_codeList Hashtable the look up table for codes m_decodeList Hashtable the corresponding table for decodes // hashtables were used for quick searches m_offMode boolean this tells the class whether or not to utilize the off feature m_offMode_wKey boolean implements feature #2 m_offModeKey String the key to look for to implement feature #2
See Also:
  • Field Details

    • DFL_WRAP_A

      protected final String DFL_WRAP_A
      See Also:
    • DFL_WRAP_B

      protected final String DFL_WRAP_B
      See Also:
    • m_wrappers

      protected String[] m_wrappers
    • m_codeList

      protected Hashtable m_codeList
    • m_decodeList

      protected Hashtable m_decodeList
    • m_offMode

      protected boolean m_offMode
    • m_offMode_wKey

      protected boolean m_offMode_wKey
    • m_offModeKey

      protected String m_offModeKey
  • Constructor Details

    • EncoderDecoder

      public EncoderDecoder()
      default constructor
    • EncoderDecoder

      public EncoderDecoder(String wrapA, String wrapB, Vector codes, Vector decodes)
      constructor, accepts list of codes/decodes and the code wrapper symbols
    • EncoderDecoder

      public EncoderDecoder(String wrapA, String wrapB, String[] codes, String[] decodes)
      constructor, accepts the lists in String arrays instead of Vectors
  • Method Details

    • setOffMode

      public void setOffMode(boolean b)
      sets the off mode
    • setOffMode

      public void setOffMode(String key)
      sets the off mode (key feature)
    • add_wrappers

      protected void add_wrappers(String a, String b)
      sets the wrapper symbols
    • fill_HashTable

      protected boolean fill_HashTable(Vector codes, Vector decodes)
      fills the code/decode hashTables Returns: true if all the codes/decodes are added false if less than all are added
    • fill_HashTable

      protected boolean fill_HashTable(String[] codes, String[] decodes)
      does the same as above, but accepts String arrays instead of Vectors
    • fill_HashTable

      protected boolean fill_HashTable(String[][] codeNdecode)
      does the same as above, but accepts String[][] instead of 2 String[]
    • wrap

      protected String wrap(String s)
      wraps a string with the wrapper symbols (used for the codes) Returns: the wrapped String
    • addWithWrapper

      protected boolean addWithWrapper(String code, String decode)
      adds the specified code/decode to the hash table lists Returns: true if the code/decode pair is added else false
    • addCodeDecode

      public boolean addCodeDecode(String code, String decode)
      add the code/decode pair to the hashtable just calls the protected version
    • addCodeDecode

      public boolean addCodeDecode(String[] codes, String[] decodes)
      add the list of code/decode pairs calls fill_HashTable
    • addCodeDecode

      public boolean addCodeDecode(String[][] codeNdecode)
      add the list of code/decode pairs, accepts String[][] instead of 2 String[] calls fill_HashTable
    • clear

      public void clear()
      clears both hashtables could be very detrimental if not done in combo with an addCodeDecode
    • decodeString

      public String decodeString(String s)
      returns a String with the codes replaced by their decoded meanings
    • encodeString

      public String encodeString(String s)
      returns a String with the meaningful strings replaced by their codes much more intensive than above; uses a double for loop;it gets faster with time and is fast with small strings