/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */
package cx2x.xcodeml.transformation;

import cx2x.xcodeml.xnode.Xmod;

import java.util.HashMap;
import java.util.Map;


/**
 * Transformer interface
 *
 * Transformer stores all the transformation to be applied by a translator.
 *
 * @author clementval
 */
public class ModuleCache {

  private final Map<String, Xmod> _moduleCache;

  /**
   *
   */
  public ModuleCache(){
    _moduleCache = new HashMap<>();
  }

  /**
   *
   * @param moduleName
   * @return
   */
  public boolean isModuleLoaded(String moduleName){
    return _moduleCache.containsKey(moduleName.toLowerCase());
  }

  /**
   *
   * @param moduleName
   * @param module
   */
  public void add(String moduleName, Xmod module){
    _moduleCache.put(moduleName.toLowerCase(), module);
  }

  /**
   *
   * @param moduleName
   * @return
   */
  public Xmod get(String moduleName){
    return _moduleCache.get(moduleName.toLowerCase());
  }


}

@@ -190,16 +190,43 @@
 ashMap;%0A
+import java.util.Iterator;%0A
 import j
@@ -461,24 +461,61 @@
 %0A%0A  /**%0A   *
+ Constructs a new empty module cache.
 %0A   */%0A  pub
@@ -588,44 +588,157 @@
    *
-%0A   * @param moduleName%0A   * @return
+ Check whether a module is in the cache.%0A   * @param moduleName Name of the module.%0A   * @return True if the module is in the cache. False otherwise.
 %0A   
@@ -874,50 +874,128 @@
    *
-%0A   * @param moduleName%0A   * @param module
+ Add a module in the cache by its name.%0A   * @param moduleName Name of the module.%0A   * @param module     Module object.
 %0A   
@@ -1123,148 +1123,436 @@
    *
-%0A   * @param moduleName%0A   * @return%0A   */%0A  public Xmod get(String moduleName)%7B%0A    return _moduleCache.get(moduleName.toLowerCase());%0A  %7D%0A%0A
+ Get a module in the cache by its name.%0A   * @param moduleName Name of the module.%0A   * @return The cached module.%0A   */%0A  public Xmod get(String moduleName)%7B%0A    return _moduleCache.get(moduleName.toLowerCase());%0A  %7D%0A%0A  /**%0A   * Get an iterator over all the module in the cache.%0A   * @return A map entry iterator.%0A   */%0A  public Iterator%3CMap.Entry%3CString, Xmod%3E%3E getIterator()%7B%0A    return _moduleCache.entrySet().iterator();%0A  %7D
 %0A%7D%0A

Add javadoc