xtc.parser
Class ModuleMap

java.lang.Object
  extended by xtc.parser.ModuleMap
All Implemented Interfaces:
Renamer.Translation

public class ModuleMap
extends java.lang.Object
implements Renamer.Translation

A mapping between module names. This class has been designed for the efficient renaming of both module dependencies and nonterminals.

Version:
$Revision: 1.6 $
Author:
Robert Grimm

Field Summary
protected  java.util.Map<java.lang.String,ModuleName> map
          The mapping from module names (represented as strings) to module names (represented as module names).
 
Constructor Summary
ModuleMap()
          Create a new module map.
ModuleMap(ModuleList keys, ModuleList values)
          Create a new module map.
ModuleMap(ModuleName key, ModuleName value)
          Create a new module map.
 
Method Summary
 boolean containsKey(ModuleName key)
          Determine whether this module map contains a mapping for the specified module name.
 boolean containsKey(java.lang.String key)
          Determine whether this module map contains a mapping for the specified module name.
 ModuleName get(ModuleName key)
          Look up the specified module name.
 java.lang.String get(java.lang.String key)
          Look up the specified module name.
 NonTerminal map(NonTerminal nt, Analyzer analyzer)
          Map the specified nonterminal to its replacement, which may be the same as the original.
 void put(ModuleName key, ModuleName value)
          Add the specified mapping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected java.util.Map<java.lang.String,ModuleName> map
The mapping from module names (represented as strings) to module names (represented as module names).

Constructor Detail

ModuleMap

public ModuleMap()
Create a new module map.


ModuleMap

public ModuleMap(ModuleName key,
                 ModuleName value)
Create a new module map.

Parameters:
key - The single initial key.
value - The single initial value.

ModuleMap

public ModuleMap(ModuleList keys,
                 ModuleList values)
Create a new module map.

Parameters:
keys - The list of keys.
values - The list of values.
Throws:
java.lang.IllegalArgumentException - Signals that the lists have different lengths.
Method Detail

put

public void put(ModuleName key,
                ModuleName value)
Add the specified mapping.

Parameters:
key - The key.
value - The value.

containsKey

public boolean containsKey(ModuleName key)
Determine whether this module map contains a mapping for the specified module name.

Parameters:
key - The module name.
Returns:
true if this module map has a value for the key.

containsKey

public boolean containsKey(java.lang.String key)
Determine whether this module map contains a mapping for the specified module name.

Parameters:
key - The module name.
Returns:
true if this module map has a value for the key.

get

public ModuleName get(ModuleName key)
Look up the specified module name.

Parameters:
key - The module name.
Returns:
The corresponding value or null if there is no mapping for the module name.

get

public java.lang.String get(java.lang.String key)
Look up the specified module name.

Parameters:
key - The module name.
Returns:
The corresponding value or null if there is no mapping for the module name.

map

public NonTerminal map(NonTerminal nt,
                       Analyzer analyzer)
Description copied from interface: Renamer.Translation
Map the specified nonterminal to its replacement, which may be the same as the original.

Specified by:
map in interface Renamer.Translation
Parameters:
nt - The nonterminal.
analyzer - The analyzer utility.
Returns:
The translated nonterminal.


Copyright © 2012. All Rights Reserved.