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

📄 commformat.java

📁 OO 图书馆系统
💻 JAVA
字号:
  import java.net.*;
  import org.apache.axis.message.SOAPEnvelope;
  import org.w3c.dom.*;
 // The classes that implement a concrete strategy should implement this
 // The CommFormt class uses this to call the concrete strategy
  interface IStrategy
  {
    public Document getResponse();
  }

  // Implements the algorithm using the strategy interface
  class ConcreteStrategySOAP implements IStrategy
  {
  	//create a request SOAPEvelope object 
    private SOAPEnvelope requestenv;
  	//create Document object
  	private Document doc;
    //create a URL object
    private URL url;
    
    //constructor initialization
    public ConcreteStrategySOAP(URL url,SOAPEnvelope env){
  	
  	  this.url=url;
  	  this.requestenv=env;
  	
  	
    }
  	
    public Document getResponse()
    {
       CommSoapProxy x = new CommSoapProxy(url,requestenv);
       x.sendRequest();
                
       this.doc = x.getResponse();
       return doc;
    }
  }

  class ConcreteStrategyREST implements IStrategy
  {
    //create Document object
  	private Document doc;
    //create a URL object
    private URL url;
    
    //constructor initialization
    public ConcreteStrategyREST(URL url){
  	
  	this.url=url;
  	 	
    }
    
    public Document getResponse()
    {
    	
    	CommRESTProxy x = new CommRESTProxy(url);
        x.sendRequest();
        this.doc = x.getResponse();
        return doc;
      
    }
  }


  // Configured with a ConcreteStrategy object and maintains a reference to a Strategy object
  class CommFormat
  {
    private IStrategy strategy;
    //create a document object
    private Document doc;

    // Constructor
    public CommFormat(IStrategy strategy)
    {
      this.strategy = strategy;
    }

    public Document getResponse()
    {
      this.doc=strategy.getResponse();
      return doc;
    }
  }

⌨️ 快捷键说明

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