WEB开发网
开发学院软件开发Java 用 Flickr API 扩展 Project Zero 和 WebSphere s... 阅读

用 Flickr API 扩展 Project Zero 和 WebSphere sMash 的脚本平台

 2009-11-17 00:00:00 来源:WEB开发网   
核心提示: 清单 10. FlickrBindings 类packagezero.services.flickr;importjava.io.FileNotFoundException;importjava.util.Map;importorg.codehaus.groovy.runtime.MethodC


清单 10. FlickrBindings 类
package zero.services.flickr; 
 
import java.io.FileNotFoundException; 
import java.util.Map; 
 
import org.codehaus.groovy.runtime.MethodClosure; 
 
import zero.core.groovysupport.bindings.InvokeBindings; 
import zero.json.java.JSONObject; 
 
public class FlickrBindings extends InvokeBindings 
{ 
  private static final String _SCRIPT = "flickr.groovy"; 
     
  private static final String _FLICKR = "flickr"; 
  private static final String _ORIGINAL = "original"; 
  private static final String _THUMBNAIL = "thumbnail"; 
     
  public void addVariables(Map<String, Object> variables) 
  { 
    super.addVariables(variables); 
    variables.put(_FLICKR, new MethodClosure(this, _FLICKR)); 
    variables.put(_ORIGINAL, new MethodClosure(this, _ORIGINAL)); 
    variables.put(_THUMBNAIL, new MethodClosure(this, _THUMBNAIL)); 
  } 
   
  public void flickr() 
    throws FileNotFoundException, NoSuchMethodException 
  { 
    invokeMethod(_SCRIPT, _FLICKR, null); 
  } 
     
  public String original(JSONObject photo) 
    throws FileNotFoundException, NoSuchMethodException 
  { 
    Object gstring = invokeMethod(_SCRIPT, _ORIGINAL, new Object[]{ photo }); 
    return gstring.toString(); 
  } 
     
  public String thumbnail(JSONObject photo) 
      throws FileNotFoundException, NoSuchMethodException 
  { 
    Object gstring = invokeMethod(_SCRIPT, _THUMBNAIL, new Object[]{ photo }); 
    return gstring.toString(); 
  } 
} 

上一页  2 3 4 5 6 7 8 9  下一页

Tags:Flickr API 扩展

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接