package jxl.biff.formula;

import common.Logger;
import java.util.HashMap;
import java.util.Locale;
import java.util.ResourceBundle;

public class FunctionNames {
  private static Logger logger = Logger.getLogger(FunctionNames.class);
  
  private HashMap names;
  
  private HashMap functions;
  
  public FunctionNames(Locale l) {
    ResourceBundle rb = ResourceBundle.getBundle("functions", l);
    this.names = new HashMap(Function.functions.length);
    this.functions = new HashMap(Function.functions.length);
    Function f = null;
    String n = null;
    String propname = null;
    for (int i = 0; i < Function.functions.length; i++) {
      f = Function.functions[i];
      propname = f.getPropertyName();
      n = (propname.length() != 0) ? rb.getString(propname) : null;
      if (n != null) {
        this.names.put(f, n);
        this.functions.put(n, f);
      } 
    } 
  }
  
  Function getFunction(String s) {
    return (Function)this.functions.get(s);
  }
  
  String getName(Function f) {
    return (String)this.names.get(f);
  }
}
