org.codeforamerica.open311.internals.network
Class HTTPNetworkManager

java.lang.Object
  extended by org.codeforamerica.open311.internals.network.HTTPNetworkManager
All Implemented Interfaces:
NetworkManager

public class HTTPNetworkManager
extends Object
implements NetworkManager

Implementation using the Apache HttpComponents library.

Author:
Santiago MunĂ­n

Field Summary
 
Fields inherited from interface org.codeforamerica.open311.internals.network.NetworkManager
CHARSET, POST_CONTENT_TYPE
 
Constructor Summary
HTTPNetworkManager(Format format)
           
 
Method Summary
 String doGet(URL url)
          Sends a GET HTTP request.
 String doPost(URL url, Map<String,String> parameters)
          Sends a POST HTTP request.
 void setFormat(Format format)
          Sets the desired format of the requests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPNetworkManager

public HTTPNetworkManager(Format format)
Method Detail

doGet

public String doGet(URL url)
             throws IOException
Description copied from interface: NetworkManager
Sends a GET HTTP request.

Specified by:
doGet in interface NetworkManager
Parameters:
url - Target.
Returns:
Server response.
Throws:
IOException - If there was any problem with the connection.

doPost

public String doPost(URL url,
                     Map<String,String> parameters)
              throws IOException
Description copied from interface: NetworkManager
Sends a POST HTTP request.

Specified by:
doPost in interface NetworkManager
Parameters:
url - Target.
parameters - Parameters of the POST operation.
Returns:
Server response.
Throws:
IOException - If there was any problem with the connection.

setFormat

public void setFormat(Format format)
Description copied from interface: NetworkManager
Sets the desired format of the requests.

Specified by:
setFormat in interface NetworkManager
Parameters:
format - A serialization format (XML or JSON).


Copyright © 2013 Code for America. All Rights Reserved.