⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flickrphotosearch.java

📁 OO 图书馆系统
💻 JAVA
字号:
import java.net.URL;
import org.w3c.dom.*;
//one sample application using flickr.photos.search method 
public class FlickrPhotoSearch{
	
	//rest---REST
	//soap---SOAP
	String requestformat;
	String method="flickr.photos.search";
	String tag;
	String parameter="tags";
	String api_key;
	Integer no_display;
	URL url;

	public FlickrPhotoSearch (String api_key, String requestformat,String tag,Integer no_display){

		this.api_key = api_key;
		this.requestformat=requestformat;
		this.tag=tag;
		this.no_display = no_display;
		
	
	}

	
	public static void main(String args[]){
		
		// set the firewall proxy to pass the SIT firewall 
		// comment out the following three lines if you are using the program at home
	    //System.setProperty("proxySet", "true");
		//System.setProperty("http.proxyHost", "www-cache.cs.usyd.edu.au");
		//System.setProperty("http.proxyPort","8000"); 

		FlickrPhotoSearch flickrphotosearch = new FlickrPhotoSearch("596dcd0930202d1c338ebb17261fae8c", args[0], args[1], Integer.parseInt(args[2]));
		flickrphotosearch.searchByTag();
	}

	/**
	 * Assumming only one tag is used to search
	 * 
	 */
	public void searchByTag(){
        try {
        	//REST 
            if(requestformat.equals("rest")){
            
              //using factory MessageFormatFactory 
			  this.url = new URL(MessageFormatFactory.generateRest(method,parameter,tag,api_key));
	          //using strategy to show searched photos
	          
              CommContext commcontext = new CommContext(new ConcreteStrategyREST(url,1,no_display));
              commcontext.execute();
              
            
            }
            //SOAP
            else if(requestformat.equals("soap")){
              this.url=new URL("http://api.flickr.com/services/soap/");
              
              CommContext commcontext = new CommContext(new ConcreteStrategySOAP(url,MessageFormatFactory.generateSoap(method,parameter,tag,api_key),1,no_display));
              commcontext.execute();
            	
            }
            else{
            	
            System.out.println("Invalid RequestFormat !");
            	
            return;
            }
           
           
                    
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
		
	
}		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -