Package hec.heclib.util
Class EncoderDecoder
java.lang.Object
hec.heclib.util.EncoderDecoder
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptiondefault constructorEncoderDecoder
(String wrapA, String wrapB, String[] codes, String[] decodes) constructor, accepts the lists in String arrays instead of VectorsEncoderDecoder
(String wrapA, String wrapB, Vector codes, Vector decodes) constructor, accepts list of codes/decodes and the code wrapper symbols -
Method Summary
Modifier and TypeMethodDescriptionprotected void
add_wrappers
(String a, String b) sets the wrapper symbolsboolean
addCodeDecode
(String[][] codeNdecode) add the list of code/decode pairs, accepts String[][] instead of 2 String[] calls fill_HashTableboolean
addCodeDecode
(String[] codes, String[] decodes) add the list of code/decode pairs calls fill_HashTableboolean
addCodeDecode
(String code, String decode) add the code/decode pair to the hashtable just calls the protected versionprotected 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 falsevoid
clear()
clears both hashtables could be very detrimental if not done in combo with an addCodeDecodereturns a String with the codes replaced by their decoded meaningsreturns 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 stringsprotected boolean
fill_HashTable
(String[][] codeNdecode) does the same as above, but accepts String[][] instead of 2 String[]protected boolean
fill_HashTable
(String[] codes, String[] decodes) does the same as above, but accepts String arrays instead of Vectorsprotected 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 addedvoid
setOffMode
(boolean b) sets the off modevoid
setOffMode
(String key) sets the off mode (key feature)protected String
wraps a string with the wrapper symbols (used for the codes) Returns: the wrapped String
-
Field Details
-
DFL_WRAP_A
- See Also:
-
DFL_WRAP_B
- See Also:
-
m_wrappers
-
m_codeList
-
m_decodeList
-
m_offMode
protected boolean m_offMode -
m_offMode_wKey
protected boolean m_offMode_wKey -
m_offModeKey
-
-
Constructor Details
-
EncoderDecoder
public EncoderDecoder()default constructor -
EncoderDecoder
constructor, accepts list of codes/decodes and the code wrapper symbols -
EncoderDecoder
constructor, accepts the lists in String arrays instead of Vectors
-
-
Method Details
-
setOffMode
public void setOffMode(boolean b) sets the off mode -
setOffMode
sets the off mode (key feature) -
add_wrappers
sets the wrapper symbols -
fill_HashTable
fills the code/decode hashTables Returns: true if all the codes/decodes are added false if less than all are added -
fill_HashTable
does the same as above, but accepts String arrays instead of Vectors -
fill_HashTable
does the same as above, but accepts String[][] instead of 2 String[] -
wrap
wraps a string with the wrapper symbols (used for the codes) Returns: the wrapped String -
addWithWrapper
adds the specified code/decode to the hash table lists Returns: true if the code/decode pair is added else false -
addCodeDecode
add the code/decode pair to the hashtable just calls the protected version -
addCodeDecode
add the list of code/decode pairs calls fill_HashTable -
addCodeDecode
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
returns a String with the codes replaced by their decoded meanings -
encodeString
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
-