Coverage Report - org.codeforamerica.open311.internals.network.NetworkManager
 
Classes in this File Line Coverage Branch Coverage Complexity
NetworkManager
N/A
N/A
1
 
 1  
 package org.codeforamerica.open311.internals.network;
 2  
 
 3  
 import java.io.IOException;
 4  
 import java.net.URL;
 5  
 import java.util.Map;
 6  
 
 7  
 import org.apache.http.protocol.HTTP;
 8  
 import org.codeforamerica.open311.facade.Format;
 9  
 
 10  
 /**
 11  
  * Specifies the required operations of a NetworkManager
 12  
  * 
 13  
  * @author Santiago MunĂ­n <santimunin@gmail.com>
 14  
  */
 15  
 public interface NetworkManager {
 16  
 
 17  
         public static final String POST_CONTENT_TYPE = "application/x-www-form-urlencoded";
 18  
         public static final String CHARSET = HTTP.UTF_8;
 19  
 
 20  
         /**
 21  
          * Sends a GET HTTP request.
 22  
          * 
 23  
          * @param url
 24  
          *            Target.
 25  
          * @return Server response.
 26  
          * @throws IOException
 27  
          *             If there was any problem with the connection.
 28  
          */
 29  
         public String doGet(URL url) throws IOException;
 30  
 
 31  
         /**
 32  
          * Sends a POST HTTP request.
 33  
          * 
 34  
          * @param url
 35  
          *            Target.
 36  
          * @param parameters
 37  
          *            Parameters of the POST operation.
 38  
          * @return Server response.
 39  
          * @throws IOException
 40  
          *             If there was any problem with the connection.
 41  
          */
 42  
         public String doPost(URL url, Map<String, String> parameters)
 43  
                         throws IOException;
 44  
 
 45  
         /**
 46  
          * Sets the desired format of the requests.
 47  
          * 
 48  
          * @param format
 49  
          *            A serialization format (XML or JSON).
 50  
          */
 51  
         public void setFormat(Format format);
 52  
 }