All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.objectweb.fractal.mind.st.MapDelegateStringTemplate Maven / Gradle / Ivy

There is a newer version: 0.1-beta-2
Show newest version
/**
 * Copyright (C) 2009 STMicroelectronics
 *
 * This file is part of "Mind Compiler" is free software: you can redistribute 
 * it and/or modify it under the terms of the GNU Lesser General Public License 
 * as published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 *
 * Contact: [email protected]
 *
 * Authors: Ali Erdem Ozcan
 * Contributors: 
 */

package org.objectweb.fractal.mind.st;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.antlr.stringtemplate.StringTemplate;
import org.antlr.stringtemplate.StringTemplateGroup;

/**
 * This class extends the StringTemplate and implements a delegate for
 * {@link Map}. The class is designed for passing map object as default formal
 * arguments to {@link StringTemplate} objects. Indeed, the current interface of
 * {@link StringTemplate} accepts only {@link StringTemplate} objects as default
 * values to be assigned to template formal arguments. Thanks to this class, one
 * can also assign {@link Map} objects as default argument value.
 */
public class MapDelegateStringTemplate extends StringTemplate
    implements
      Map {

  // Receiver map
  private Map map = null;

  /** Constructor for {@link StringTemplate} that defines an empty {@link Map} */
  public MapDelegateStringTemplate() {
    super();
    map = new HashMap();
  }

  /** Special constructor for specifying the delegated map */
  public MapDelegateStringTemplate(final Map map) {
    super();
    this.map = map;
  }

  /** Constructor for {@link StringTemplate} that defines an empty {@link Map} */
  public MapDelegateStringTemplate(final String arg0, final Class arg1) {
    super(arg0, arg1);
    map = new HashMap();
  }

  /** Constructor for {@link StringTemplate} that defines an empty {@link Map} */
  public MapDelegateStringTemplate(final String arg0) {
    super(arg0);
    map = new HashMap();
  }

  /** Constructor for {@link StringTemplate} that defines an empty {@link Map} */
  public MapDelegateStringTemplate(final StringTemplateGroup arg0,
      final String arg1, final HashMap arg2) {
    super(arg0, arg1, arg2);
    map = new HashMap();
  }

  /** Constructor for {@link StringTemplate} that defines an empty {@link Map} */
  public MapDelegateStringTemplate(final StringTemplateGroup arg0,
      final String arg1) {
    super(arg0, arg1);
    map = new HashMap();
  }

  /**
   * @see java.util.HashMap#clear()
   */
  public void clear() {
    map.clear();
  }

  /**
   * @param key
   * @return
   * @see java.util.HashMap#containsKey(java.lang.Object)
   */
  public boolean containsKey(final Object key) {
    return map.containsKey(key);
  }

  /**
   * @param value
   * @return
   * @see java.util.HashMap#containsValue(java.lang.Object)
   */
  public boolean containsValue(final Object value) {
    return map.containsValue(value);
  }

  /**
   * @return
   * @see java.util.HashMap#entrySet()
   */
  public Set> entrySet() {
    return map.entrySet();
  }

  /**
   * @param o
   * @return
   * @see java.util.AbstractMap#equals(java.lang.Object)
   */
  @Override
  public boolean equals(final Object o) {
    return map.equals(o);
  }

  /**
   * @param key
   * @return
   * @see java.util.HashMap#get(java.lang.Object)
   */
  public Object get(final Object key) {
    return map.get(key);
  }

  /**
   * @return
   * @see java.util.AbstractMap#hashCode()
   */
  @Override
  public int hashCode() {
    return map.hashCode();
  }

  /**
   * @return
   * @see java.util.HashMap#isEmpty()
   */
  public boolean isEmpty() {
    return map.isEmpty();
  }

  /**
   * @return
   * @see java.util.HashMap#keySet()
   */
  public Set keySet() {
    return map.keySet();
  }

  /**
   * @param key
   * @param value
   * @return
   * @see java.util.HashMap#put(java.lang.Object, java.lang.Object)
   */
  public Object put(final Object key, final Object value) {
    return map.put(key, value);
  }

  /**
   * @param m
   * @see java.util.HashMap#putAll(java.util.Map)
   */
  public void putAll(final Map m) {
    map.putAll(m);
  }

  /**
   * @param key
   * @return
   * @see java.util.HashMap#remove(java.lang.Object)
   */
  public Object remove(final Object key) {
    return map.remove(key);
  }

  /**
   * @return
   * @see java.util.HashMap#size()
   */
  public int size() {
    return map.size();
  }

  /**
   * @return
   * @see java.util.AbstractMap#toString()
   */
  @Override
  public String toString() {
    return map.toString();
  }

  /**
   * @return
   * @see java.util.HashMap#values()
   */
  public Collection values() {
    return map.values();
  }

}