class DefaultLocalCreation extends LocalCreation {

  /** if no prefix is given, this one's used */
  public static final String DEFAULT_PREFIX = "soot";

  private final Set<String> locals;
  private int counter;

  /**
   * all actions are done on the given locals-chain. as prefix the <code>DEFAULT-PREFIX</code> will be used.
   *
   * @param locals
   *          the locals-chain of a Jimple-body
   */
  public DefaultLocalCreation(Collection<Local> locals) {
    this(locals, DEFAULT_PREFIX);
  }

  /**
   * whenever <code>newLocal(type)</code> will be called, the given prefix is used.
   *
   * @param locals
   *          the locals-chain of a Jimple-body
   * @param prefix
   *          prefix overrides the DEFAULT-PREFIX
   */
  public DefaultLocalCreation(Collection<Local> locals, String prefix) {
    super(locals, prefix);
    this.locals = new HashSet<String>(locals.size());
    for (Local l : locals) {
      this.locals.add(l.getName());
    }
    this.counter = 0; // try the first one with suffix 0.
  }

  @Override
  public Local newLocal(Type type) {
    return newLocal(this.prefix, type);
  }

  @Override
  public Local newLocal(String prefix, Type type) {<FILL_FUNCTION_BODY>}
}

    int suffix = prefix.equals(this.prefix) ? this.counter : 0;
    while (this.locals.contains(prefix + suffix)) {
      suffix++;
    }
    if (prefix.equals(this.prefix)) {
      this.counter = suffix + 1;
    }
    String newName = prefix + suffix;
    Local newLocal = Jimple.v().newLocal(newName, type);
    this.localChain.add(newLocal);
    this.locals.add(newName);
    return newLocal;
  
<methods>public void <init>(Collection<soot.Local>, java.lang.String) ,public abstract soot.Local newLocal(soot.Type) ,public abstract soot.Local newLocal(java.lang.String, soot.Type) <variables>protected final non-sealed Collection<soot.Local> localChain,protected final non-sealed java.lang.String prefix