mapget.java :  » Scripting » Pnuts » org » pnuts » lib » Java Open Source

Java Open Source » Scripting » Pnuts 
Pnuts » org » pnuts » lib » mapget.java
/*
 * @(#)mapget.java 1.2 04/12/06
 *
 * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
 *
 * See the file "LICENSE.txt" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */
package org.pnuts.lib;

import pnuts.lang.*;
import java.util.*;

public class mapget extends PnutsFunction {

  public mapget(){
    super("mapget");
  }

  public boolean defined(int nargs){
    return nargs == 2;
  }

  protected Object exec(Object[] args, Context context){
    if (args.length != 2){
      undefined(args, context);
    }
    Map map = (Map)args[0];
    return map.get(args[1]);
  }

  public String toString(){
    return "function mapget(map, key)";
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.