edu.umd.cfar.lamp.viper.util
Class Equivalencies

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.util.Equivalencies

public class Equivalencies
extends java.lang.Object

This allows equivalency between two different Strings. Unlike a Map, it can take Many-Many mappings.

Author:
David Mihalcik

Constructor Summary
Equivalencies()
          Creates a new object of the Equivalency class.
 
Method Summary
 void addToList(java.lang.Object target, java.lang.Object candidate)
          Adds a new entry saying that target is equivalent to candidate.
 boolean containsKey(java.lang.Object key)
          Determines if the specified key / right Object is in the list of Pairings.
 boolean containsValue(java.lang.Object value)
          Determines if the specified Value / left Object is in the list of Pairings.
 boolean eq(java.lang.Object target, java.lang.Object candidate)
          Determines if the given key and value are equivalent under this set of Equivalencies
 java.lang.Object[] findMatches(java.lang.Object target)
          Returns all values associated with the key.
 int hashCode()
          Generates a hash value for this object.
 boolean parseMapping(java.util.Vector paths)
          Parses in an Equivalency class in ViPER format.
 boolean parseMapping(VReader reader)
          Parses in an Equivalency class in ViPER format.
 void printMapping(java.io.PrintWriter out)
          Prints the Equivalencies to a PrintStream in classic ViPER format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Equivalencies

public Equivalencies()
Creates a new object of the Equivalency class.

Method Detail

containsKey

public boolean containsKey(java.lang.Object key)
Determines if the specified key / right Object is in the list of Pairings.

Parameters:
key - The key to search for.
Returns:
true iff this list holds the key

containsValue

public boolean containsValue(java.lang.Object value)
Determines if the specified Value / left Object is in the list of Pairings.

Parameters:
value - - the value to search for
Returns:
true iff the list holds the value

hashCode

public int hashCode()
Generates a hash value for this object.

Returns:
an integer that any other Equivalencies class with the same pairings would generate

addToList

public void addToList(java.lang.Object target,
                      java.lang.Object candidate)
Adds a new entry saying that target is equivalent to candidate.

Parameters:
target - The key / left Object
candidate - The value / right Object

findMatches

public java.lang.Object[] findMatches(java.lang.Object target)
Returns all values associated with the key.

Parameters:
target - The key to find.
Returns:
An array containing all Objects equivalent to the key.

eq

public boolean eq(java.lang.Object target,
                  java.lang.Object candidate)
Determines if the given key and value are equivalent under this set of Equivalencies

Parameters:
target - The key / left Object.
candidate - The value / right Object.
Returns:
true iff the pairing is found.

printMapping

public void printMapping(java.io.PrintWriter out)
Prints the Equivalencies to a PrintStream in classic ViPER format.

Parameters:
out - A PrintWriter to write into.

parseMapping

public boolean parseMapping(java.util.Vector paths)
Parses in an Equivalency class in ViPER format.

Parameters:
paths - A Vector containing the names of any files containing Equivalency information
Returns:
true if parsing is successful

parseMapping

public boolean parseMapping(VReader reader)
Parses in an Equivalency class in ViPER format.

Parameters:
reader - A VReader containing Equivalency data.
Returns:
true if Parsing is successful.