edu.wpi.cs.dsrg.utils
Class BindingTable

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--edu.wpi.cs.dsrg.utils.BindingTable

public class BindingTable
extends java.util.Hashtable

This class defines the BindingTable, which is used to represent variable binding within the tree.

Since:
1.0
See Also:
Serialized Form

Constructor Summary
BindingTable()
          The default BindingTable constructor.
BindingTable(int initialCapacity)
          The BindingTable constructor using given capacity.
BindingTable(int initialCapacity, float loadFactor)
          The BindingTable constructor.
BindingTable(java.util.Map t)
          The BindingTable constructor.
 
Method Summary
 NavigationStep[] computeSimplifiedFullPath(java.lang.String key)
          Compute the full path of a given variable.
 boolean contains(java.lang.String key)
          Check if a value exists in the hashtable
 java.lang.Object get(java.lang.Object key)
          Deprecated. You should use getVariableValue(...) instead. Note: Disable the usage of the original get() outside of this class.
 java.util.Vector getChain(java.lang.String key)
          It will get all the VarStep alone this Key in the binding table.
 java.util.Vector getChainRecursive(java.lang.String key)
          Get all the VarStep alone this Key in the binding table.
 java.lang.String getKeyByValue(java.lang.String value)
          Get the key by the variable binding.
 java.lang.String getKeyByXMLValue(java.lang.String value)
          Given an XML path, plus "/SOURCE", return the Key as a string
 java.util.Vector getKeysByXMLValue(java.lang.String value)
          Given an XML path, plus "/SOURCE", return the Key as a string If more than one mapping can exist, use the method that returns a vector
static java.lang.String getTagValue(java.lang.String element)
          Get the tag value from an open/close tag of an XML element.
 NavigationStep[] getVariableValue(java.lang.String varName)
          Accepts a string varName and returns the path that it represents according to the variableTable.
 NavigationStep[] getVariableValue(java.lang.String varName, boolean recursiveLookup)
          Accepts a string varName and returns the path that it represents according to the this.
protected  NavigationStep[] getVariableValueRecursive(java.lang.String varName, boolean recursiveLookup)
          Accepts a string varName and returns the path that it represents according to the this.
 java.lang.String navStepsToString(NavigationStep[] steps)
          Convert a NavigationStep into String.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Deprecated. You should use updateVariableTable(..,..) instead.
 void replaceKey(java.lang.String newKey, java.lang.String oldKey)
          Replace ALL the occurances of the oldKey with the newKey.
 java.lang.String simpleToXMLString(NavigationStep[] steps)
          Take a set of Navigation steps, and produce a XML path, minus text This method is useful for getKeyByXMLValue().
 java.lang.String toString()
          Convert BindingTable into a String.
 java.lang.String toString(boolean fullpath)
          Output the String format of this BindingTable.
 void updateVariableTable(java.lang.String oldKey, ListPattern newBinding)
          Put a listPattern into the binding table by converting the pattern into navigation steps.
 void updateVariableTable(java.lang.String oldKey, NavigationStep[] newBinding)
          Remove the entry for oldKey and make it bound to binding
 void updateVariableTable(java.lang.String newKey, java.lang.String oldKey)
          Make whatever is bound to the oldKey to be bound to the newKey
 void updateVariableTable(java.lang.String oldKey, java.util.Vector newBinding)
          Remove the entry for oldKey and make it bound to binding
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, hashCode, isEmpty, keys, keySet, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BindingTable

public BindingTable()
The default BindingTable constructor.
Since:
1.0

BindingTable

public BindingTable(int initialCapacity)
The BindingTable constructor using given capacity.
Parameters:
initialCapacity - The capacity of the BindingTable.
Since:
1.0

BindingTable

public BindingTable(int initialCapacity,
                    float loadFactor)
The BindingTable constructor.
Parameters:
initialCapacity - The capacity of the BindingTable.
loadFactor - float
Since:
1.0

BindingTable

public BindingTable(java.util.Map t)
The BindingTable constructor.
Parameters:
t - The Map for BindingTable.
Since:
1.0
Method Detail

computeSimplifiedFullPath

public NavigationStep[] computeSimplifiedFullPath(java.lang.String key)
Compute the full path of a given variable. The full path will be simplified by the following logics: 1) (_x_(E.p.)).p. = E.p. 2) (_x_(_p_E)).p. = _p_E 3) (_x_(E.q.)).p. = E.r., where .p., .q., and .r. follow following table: .p. .q. .r. 'path. .//. .path. .path. .*. .path. .//. .any. .path..//. .*. .any. .path. 4) if there are more than one items in the tagger, then based on the distributility: _x_(E + F) = _x_E + _x_F
Parameters:
Key - The given variable computing path for.
Returns:
NavigationStep[] The computed full path for a given virable.
Since:
1.0

contains

public boolean contains(java.lang.String key)
Check if a value exists in the hashtable
Parameters:
key - The variable looking for.
Returns:
boolean Trur: The given key exists in hashtable. False: otherwise.
Since:
1.0

get

public java.lang.Object get(java.lang.Object key)
Deprecated. You should use getVariableValue(...) instead. Note: Disable the usage of the original get() outside of this class.

Get the variable binding of a given key.
Overrides:
get in class java.util.Hashtable
Parameters:
key - The key of the variable binding looking for.
Returns:
Object The Binding value for a given key.

getChain

public java.util.Vector getChain(java.lang.String key)
It will get all the VarStep alone this Key in the binding table.
Parameters:
key - The Key searching for.
Returns:
Vector A Vector of VarStep value, which indicate where the key coming from.
Since:
1.0

getChainRecursive

public java.util.Vector getChainRecursive(java.lang.String key)
Get all the VarStep alone this Key in the binding table.
Parameters:
key - The Key searching for.
Returns:
Vector A Vector of VarStep value, which indicate where the key coming from.
Since:
1.0

getKeyByValue

public java.lang.String getKeyByValue(java.lang.String value)
Get the key by the variable binding.
Parameters:
value - The value searching for.
Returns:
String The key of given binding.
Since:
1.0

getKeyByXMLValue

public java.lang.String getKeyByXMLValue(java.lang.String value)
Given an XML path, plus "/SOURCE", return the Key as a string
Parameters:
value - An XML path.
Returns:
String The key of the given XML path.
Since:
1.0

getKeysByXMLValue

public java.util.Vector getKeysByXMLValue(java.lang.String value)
Given an XML path, plus "/SOURCE", return the Key as a string If more than one mapping can exist, use the method that returns a vector
Parameters:
value - The XML value searching for.
Returns:
String The vector containing all the keys of given XML value.
Since:
1.0

getTagValue

public static java.lang.String getTagValue(java.lang.String element)
Get the tag value from an open/close tag of an XML element. The following cases will be handled: 1. Open tag: 2. Open tag with attributes: 3. Close tag: 4. brief tag:
Parameters:
element - The XML element searching for.
Returns:
String The Tag value of a given XML element.
Since:
1.0

getVariableValue

public NavigationStep[] getVariableValue(java.lang.String varName)
Accepts a string varName and returns the path that it represents according to the variableTable. If the path contains a VarStep, then this method will be recursively called The end result will be the full path for a given column name.
Parameters:
varName - The variable looking up.
Returns:
NavigationStep[] The array containing all the variable's path.
Since:
1.0

getVariableValue

public NavigationStep[] getVariableValue(java.lang.String varName,
                                         boolean recursiveLookup)
Accepts a string varName and returns the path that it represents according to the this. If the path contains a VarStep, then this method will be recursively called The end result will be the full path for a given column name.
Parameters:
varName - containing the variable to look up.
Returns:
NavigationStep[] containing the variable's path
Since:
1.0

getVariableValueRecursive

protected NavigationStep[] getVariableValueRecursive(java.lang.String varName,
                                                     boolean recursiveLookup)
Accepts a string varName and returns the path that it represents according to the this. If the path contains a VarStep, then this method will be recursively called The end result will be the full path for a given column name.
Parameters:
varName - containing the variable to look up.
Returns:
NavigationStep[] containing the variable's path
Since:
1.0

navStepsToString

public java.lang.String navStepsToString(NavigationStep[] steps)
Convert a NavigationStep into String.
Parameters:
steps - The NavigationStep array converting for.
Returns:
String The string represent the given Navigation Step.
Since:
1.0

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Deprecated. You should use updateVariableTable(..,..) instead.

Put the variable binding and its key into the BindingTable.
Overrides:
put in class java.util.Hashtable

replaceKey

public void replaceKey(java.lang.String newKey,
                       java.lang.String oldKey)
Replace ALL the occurances of the oldKey with the newKey.
Parameters:
newKey - The old key replaced.
oldKey - The new key replacing.
Returns:
void
Since:
1.0

simpleToXMLString

public java.lang.String simpleToXMLString(NavigationStep[] steps)
Take a set of Navigation steps, and produce a XML path, minus text This method is useful for getKeyByXMLValue().
Parameters:
steps - The source NavigationStep[].
Returns:
The converted result string.
Since:
1.0

toString

public java.lang.String toString()
Convert BindingTable into a String.
Overrides:
toString in class java.util.Hashtable
Returns:
The converted result.
Since:
1.0

toString

public java.lang.String toString(boolean fullpath)
Output the String format of this BindingTable.
Parameters:
fullpath - True: output the fullpath of variable binding. False: otherwise.
Returns:
The converted result string.
Since:
1.0

updateVariableTable

public void updateVariableTable(java.lang.String oldKey,
                                NavigationStep[] newBinding)
Remove the entry for oldKey and make it bound to binding
Parameters:
newBinding - The new variable binding for given key.
oldKey - The key of the variable which will be replaced.
Since:
1.0

updateVariableTable

public void updateVariableTable(java.lang.String oldKey,
                                ListPattern newBinding)
Put a listPattern into the binding table by converting the pattern into navigation steps. ASSUMPTION: No consideration of the attribute here. Otherwise, we have to removed this method, and use the DOMPattern directly. It will persistent as the first-order traverse of the tree.
Parameters:
newBinding - The new variable binding for given key.
oldKey - The key of the variable which will be replaced.
Since:
1.0

updateVariableTable

public void updateVariableTable(java.lang.String newKey,
                                java.lang.String oldKey)
Make whatever is bound to the oldKey to be bound to the newKey
Parameters:
newkey - The new variable binding for given key.
oldKey - The key of the variable which will be replaced.
Since:
1.0

updateVariableTable

public void updateVariableTable(java.lang.String oldKey,
                                java.util.Vector newBinding)
Remove the entry for oldKey and make it bound to binding
Parameters:
newBinding - The new variable binding for given key.
oldKey - The key of the variable which will be replaced.
Since:
1.0