public class DictionaryWorker.Dictionary
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,ScopedSymbolDictionary<java.lang.Object>> |
dictList
Stores all named dictionaries that are active.
|
Constructor and Description |
---|
Dictionary()
Default constructor which creates an instance and initializes.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addDictionary(java.lang.String dict,
boolean sensitive)
Adds a new named dictionary to the list of those available.
|
boolean |
addDictionaryBoolean(java.lang.String dict,
java.lang.String key,
java.lang.Boolean value)
Adds/replaces a key/value pair to a named dictionary, in the top
scope.
|
boolean |
addDictionaryDouble(java.lang.String dict,
java.lang.String key,
java.lang.Double value)
Adds/replaces a key/value pair to a named dictionary, in the top
scope.
|
boolean |
addDictionaryInteger(java.lang.String dict,
java.lang.String key,
java.lang.Integer value)
Adds/replaces a key/value pair to a named dictionary, in the top
scope.
|
boolean |
addDictionaryLong(java.lang.String dict,
java.lang.String key,
java.lang.Long value)
Adds/replaces a key/value pair to a named dictionary, in the top
scope.
|
boolean |
addDictionaryObject(java.lang.String dict,
java.lang.String key,
java.lang.Object value)
Adds/replaces a key/value pair to a named dictionary, in the top
scope.
|
boolean |
addDictionaryString(java.lang.String dict,
java.lang.String key,
java.lang.String value)
Adds/replaces a key/value pair to a named dictionary, in the top
scope.
|
private boolean |
addGeneric(java.lang.String dict,
java.lang.String key,
java.lang.Object value)
Generic worker to add/replace a key/value pair in a named dictionary,
in the top scope.
|
boolean |
addScope(java.lang.String dict)
Creates a new scope in the named dictionary.
|
boolean |
deleteDictionary(java.lang.String dict)
Deletes a named dictionary from the list of those available.
|
boolean |
deleteScope(java.lang.String dict)
Deletes the current top of stack scope in the named dictionary.
|
boolean |
dictionaryContains(java.lang.String dict,
java.lang.String key)
Tests for the existence of a specified key in a named dictionary.
|
int |
dictionaryKeyDepth(java.lang.String dict,
java.lang.String key)
Tests for the existence of a specified key in a named dictionary
and returns the 0-based depth at which the key is found or -1 if
the key does not exist.
|
java.util.List<java.lang.Object> |
dictionaryListMatches(java.lang.String dict,
java.lang.String key)
Returns the list of all matches of a specified key in a named dictionary.
|
int |
dictionaryMaxDepth(java.lang.String dict)
Queries the total number of scopes in the dictionary (including a
global scope if it exists).
|
int |
dictionaryNumMatches(java.lang.String dict,
java.lang.String key)
Returns the number of matches of a specified key in a named
dictionary.
|
java.util.Set<java.lang.String> |
dictionarySymbolSet(java.lang.String dict)
Returns a set containing all defined symbol names as strings, for the given dictionary.
|
java.util.Set<java.lang.String> |
dictionarySymbolSet(java.lang.String dict,
int scope)
Returns a set containing all defined symbol names as strings, for the given scope in the
given dictionary.
|
int |
dictionaryValueDepth(java.lang.String dict,
java.lang.String key,
java.lang.Object value)
Locate the 0-based scope depth of the specified value of specified
variable.
|
void |
dumpDictionary(java.lang.String dict)
Dump the contents of the specifified dictionary to
stdout . |
java.lang.Boolean |
lookupDictionaryBoolean(java.lang.String dict,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.Boolean |
lookupDictionaryBooleanAtScope(java.lang.String dict,
int scope,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.Double |
lookupDictionaryDouble(java.lang.String dict,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.Double |
lookupDictionaryDoubleAtScope(java.lang.String dict,
int scope,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.Integer |
lookupDictionaryInteger(java.lang.String dict,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.Integer |
lookupDictionaryIntegerAtScope(java.lang.String dict,
int scope,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.Long |
lookupDictionaryLong(java.lang.String dict,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.Long |
lookupDictionaryLongAtScope(java.lang.String dict,
int scope,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.Object |
lookupDictionaryObject(java.lang.String dict,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.Object |
lookupDictionaryObjectAtScope(java.lang.String dict,
int scope,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.String |
lookupDictionaryString(java.lang.String dict,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
java.lang.String |
lookupDictionaryStringAtScope(java.lang.String dict,
int scope,
java.lang.String key)
Searches the named dictionary for the value associated with a
specified key or
null if the key does not exist. |
private java.lang.Object |
lookupGeneric(java.lang.String dict,
java.lang.String key)
Generic worker to search the named dictionary in all scopes from the
top of the stack down for a given key.
|
private java.lang.Object |
lookupGenericAtScope(java.lang.String dict,
int scope,
java.lang.String key)
Generic worker to search the named dictionary in all scopes from the
top of the stack down for a given key.
|
private ScopedSymbolDictionary<java.lang.Object> |
obtainDict(java.lang.String dict)
Returns the existing dictionary of the given name or if a dictionary
does not exist, a case-insensitive dictionary will be created and
then returned.
|
boolean |
setDictionaryBooleanAtScope(java.lang.String dict,
int scope,
java.lang.String key,
java.lang.Boolean value)
Replace value of the key/value pair in the specified scope depth.
|
boolean |
setDictionaryDoubleAtScope(java.lang.String dict,
int scope,
java.lang.String key,
java.lang.Double value)
Replace value of the key/value pair in the specified scope depth.
|
boolean |
setDictionaryIntegerAtScope(java.lang.String dict,
int scope,
java.lang.String key,
java.lang.Integer value)
Replace value of the key/value pair in the specified scope depth.
|
boolean |
setDictionaryLongAtScope(java.lang.String dict,
int scope,
java.lang.String key,
java.lang.Long value)
Replace value of the key/value pair in the specified scope depth.
|
boolean |
setDictionaryObjectAtScope(java.lang.String dict,
int scope,
java.lang.String key,
java.lang.Object value)
Replace value of the key/value pair in the specified scope depth.
|
boolean |
setDictionaryStringAtScope(java.lang.String dict,
int scope,
java.lang.String key,
java.lang.String value)
Replace value of the key/value pair in the specified scope depth.
|
private boolean |
setGenericAtScope(java.lang.String dict,
int scope,
java.lang.String key,
java.lang.Object value)
Generic worker to replace a key/value pair in a named dictionary,
in the specified scope depth.
|
private java.util.Map<java.lang.String,ScopedSymbolDictionary<java.lang.Object>> dictList
public Dictionary()
public boolean addDictionary(java.lang.String dict, boolean sensitive)
dict
- The name of the new dictionary.sensitive
- If true
the dictionary will match on a case-
sensitive basis, false
specifies
case-insensitive matching.true
if the dictionary was created or already
exists, false
on error.public boolean deleteDictionary(java.lang.String dict)
dict
- The name of the new dictionary.true
.public boolean addScope(java.lang.String dict)
dict
- The name of the dictionary.true
.public boolean deleteScope(java.lang.String dict)
dict
- The name of the dictionary.true
.public boolean addDictionaryString(java.lang.String dict, java.lang.String key, java.lang.String value)
dict
- The name of the dictionary.key
- The name of the entry to be made.value
- The value to be added.true
if the entry has been added,
false
if its value has been replaced.public boolean addDictionaryLong(java.lang.String dict, java.lang.String key, java.lang.Long value)
dict
- The name of the dictionary.key
- The name of the entry to be made.value
- The value to be added.true
if the entry has been added,
false
if its value has been replaced.public boolean addDictionaryInteger(java.lang.String dict, java.lang.String key, java.lang.Integer value)
dict
- The name of the dictionary.key
- The name of the entry to be made.value
- The value to be added.true
if the entry has been added,
false
if its value has been replaced.public boolean addDictionaryDouble(java.lang.String dict, java.lang.String key, java.lang.Double value)
dict
- The name of the dictionary.key
- The name of the entry to be made.value
- The value to be added.true
if the entry has been added,
false
if its value has been replaced.public boolean addDictionaryBoolean(java.lang.String dict, java.lang.String key, java.lang.Boolean value)
dict
- The name of the dictionary.key
- The name of the entry to be made.value
- The value to be added.true
if the entry has been added,
false
if its value has been replaced.public boolean addDictionaryObject(java.lang.String dict, java.lang.String key, java.lang.Object value)
dict
- The name of the dictionary.key
- The name of the entry to be made.value
- The value to be added.true
if the entry has been added,
false
if its value has been replaced.public boolean setDictionaryStringAtScope(java.lang.String dict, int scope, java.lang.String key, java.lang.String value)
dict
- The name of the dictionary.scope
- The scope depth at which value must be set.key
- The name of the entry to be made.value
- The value to be returned from a lookup.true
if the symbol has been replaced,
false
if no such dictionary/key or no such
scope depth.public boolean setDictionaryLongAtScope(java.lang.String dict, int scope, java.lang.String key, java.lang.Long value)
dict
- The name of the dictionary.scope
- The scope depth at which value must be set.key
- The name of the entry to be made.value
- The value to be returned from a lookup.true
if the symbol has been replaced,
false
if no such dictionary/key or no such
scope depth.public boolean setDictionaryIntegerAtScope(java.lang.String dict, int scope, java.lang.String key, java.lang.Integer value)
dict
- The name of the dictionary.scope
- The scope depth at which value must be set.key
- The name of the entry to be made.value
- The value to be returned from a lookup.true
if the symbol has been replaced,
false
if no such dictionary/key or no such
scope depth.public boolean setDictionaryBooleanAtScope(java.lang.String dict, int scope, java.lang.String key, java.lang.Boolean value)
dict
- The name of the dictionary.scope
- The scope depth at which value must be set.key
- The name of the entry to be made.value
- The value to be returned from a lookup.true
if the symbol has been replaced,
false
if no such dictionary/key or no such
scope depth.public boolean setDictionaryDoubleAtScope(java.lang.String dict, int scope, java.lang.String key, java.lang.Double value)
dict
- The name of the dictionary.scope
- The scope depth at which value must be set.key
- The name of the entry to be made.value
- The value to be returned from a lookup.true
if the symbol has been replaced,
false
if no such dictionary/key or no such
scope depth.public boolean setDictionaryObjectAtScope(java.lang.String dict, int scope, java.lang.String key, java.lang.Object value)
dict
- The name of the dictionary.scope
- The scope depth at which value must be set.key
- The name of the entry to be made.value
- The value to be returned from a lookup.true
if the symbol has been replaced,
false
if no such dictionary/key or no such
scope depth.public int dictionaryMaxDepth(java.lang.String dict)
dict
- The name of the dictionary.public boolean dictionaryContains(java.lang.String dict, java.lang.String key)
dict
- The name of the dictionary.key
- The name of the entry to be found.true
if the key exists.public java.util.List<java.lang.Object> dictionaryListMatches(java.lang.String dict, java.lang.String key)
dict
- The name of the dictionary.key
- The name of the entry to be found.public int dictionaryNumMatches(java.lang.String dict, java.lang.String key)
dict
- The name of the dictionary.key
- The name of the entry to be found.public int dictionaryKeyDepth(java.lang.String dict, java.lang.String key)
dict
- The name of the dictionary.key
- The name of the entry to be found.public int dictionaryValueDepth(java.lang.String dict, java.lang.String key, java.lang.Object value)
dict
- The name of the dictionary.key
- The name of the entry to be found.value
- The value of the entry to compare with.public java.util.Set<java.lang.String> dictionarySymbolSet(java.lang.String dict)
dict
- The name of the dictionary.public java.util.Set<java.lang.String> dictionarySymbolSet(java.lang.String dict, int scope)
dict
- The name of the dictionary.scope
- The depth (in number of scopes from the top of the stack) from which the
symbols are collected. Use -1 to reference the global scope.public java.lang.String lookupDictionaryStringAtScope(java.lang.String dict, int scope, java.lang.String key)
null
if the key does not exist.
The search is limited to specified scope.
The value must be a string.dict
- The name of the dictionary.scope
- The scope at which value should be located.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Long lookupDictionaryLongAtScope(java.lang.String dict, int scope, java.lang.String key)
null
if the key does not exist.
The search is limited to specified scope.
The value must be a long.dict
- The name of the dictionary.scope
- The scope at which value should be located.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Integer lookupDictionaryIntegerAtScope(java.lang.String dict, int scope, java.lang.String key)
null
if the key does not exist.
The search is limited to specified scope.
The value must be an integer.dict
- The name of the dictionary.scope
- The scope at which value should be located.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Double lookupDictionaryDoubleAtScope(java.lang.String dict, int scope, java.lang.String key)
null
if the key does not exist.
The search is limited to specified scope.
The value must be a double.dict
- The name of the dictionary.scope
- The scope at which value should be located.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Boolean lookupDictionaryBooleanAtScope(java.lang.String dict, int scope, java.lang.String key)
null
if the key does not exist.
The search is limited to specified scope.
The value must be a boolean.dict
- The name of the dictionary.scope
- The scope at which value should be located.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Object lookupDictionaryObjectAtScope(java.lang.String dict, int scope, java.lang.String key)
null
if the key does not exist.
The search is limited to specified scope.dict
- The name of the dictionary.scope
- The scope at which value should be located.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.String lookupDictionaryString(java.lang.String dict, java.lang.String key)
null
if the key does not exist.
The value must be a string.dict
- The name of the dictionary.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Long lookupDictionaryLong(java.lang.String dict, java.lang.String key)
null
if the key does not exist.
The value must be a long.dict
- The name of the dictionary.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Integer lookupDictionaryInteger(java.lang.String dict, java.lang.String key)
null
if the key does not exist.
The value must be an integer.dict
- The name of the dictionary.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Double lookupDictionaryDouble(java.lang.String dict, java.lang.String key)
null
if the key does not exist.
The value must be a double.dict
- The name of the dictionary.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Boolean lookupDictionaryBoolean(java.lang.String dict, java.lang.String key)
null
if the key does not exist.
The value must be a boolean.dict
- The name of the dictionary.key
- The name of the entry to be found.null
if the key does not exist.public java.lang.Object lookupDictionaryObject(java.lang.String dict, java.lang.String key)
null
if the key does not exist.dict
- The name of the dictionary.key
- The name of the entry to be found.null
if the key does not exist.public void dumpDictionary(java.lang.String dict)
stdout
. Prints an error message if the given dictionary
is not found.dict
- The name of the dictionary.private boolean addGeneric(java.lang.String dict, java.lang.String key, java.lang.Object value)
dict
- The name of the dictionary.key
- The name of the entry to be made.value
- The value to be returned from a lookup.true
if the symbol has been added,
false
if its value has been replaced.private boolean setGenericAtScope(java.lang.String dict, int scope, java.lang.String key, java.lang.Object value)
dict
- The name of the dictionary.scope
- The scope depth at which value must be set.key
- The name of the entry to be made.value
- The value to be returned from a lookup.true
if the symbol has been replaced,
false
if no such dictionary/key or no such
scope depth.private java.lang.Object lookupGeneric(java.lang.String dict, java.lang.String key)
dict
- The name of the dictionary.key
- The name of the entry to be found.null
if not found.private java.lang.Object lookupGenericAtScope(java.lang.String dict, int scope, java.lang.String key)
dict
- The name of the dictionary.scope
- The scope depth at which value must be retrieved.key
- The name of the entry to be found.null
if not found.private ScopedSymbolDictionary<java.lang.Object> obtainDict(java.lang.String dict)
dict
- The name of the dictionary.null
if the input string
is null
.