deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

org.deegree.commons.utils
Class HttpUtils

java.lang.Object
  extended by org.deegree.commons.utils.HttpUtils

public class HttpUtils
extends Object

HttpUtils Example use from rhino: var u = org.deegree.commons.utils.HttpUtils u.retrieve(u.UTF8STRING, "http://demo.deegree.org/deegree-wms/services?request=capabilities&service=WMS")

Version:
$Revision: 18171 $, $Date: 2009-06-17 16:00:07 +0200 (Mi, 17 Jun 2009) $
Author:
Andreas Schmitz, last edited by: $Author: mschneider $

Nested Class Summary
static interface HttpUtils.Worker<T>
          Worker is used to specify how to return the stream from the remote location.
 
Field Summary
static HttpUtils.Worker<BufferedImage> IMAGE
          Returns a BufferedImage.
static HttpUtils.Worker<InputStream> STREAM
          Directly returns the stream.
static HttpUtils.Worker<String> UTF8STRING
          Returns a decoded String.
static HttpUtils.Worker<XMLAdapter> XML
          Returns streaming XMLAdapter.
static HttpUtils.Worker<XMLStreamReaderWrapper> XML_STREAM
          Returns streaming XMLAdapter.
(package private) static XMLInputFactory xmlInputFactory
           
 
Constructor Summary
HttpUtils()
           
 
Method Summary
static
<T> T
get(HttpUtils.Worker<T> worker, String url, Map<String,String> headers)
          Performs an HTTP-Get request and provides typed access to the response.
static HttpUtils.Worker<String> getStringWorker(String encoding)
           
static
<T> T
post(HttpUtils.Worker<T> worker, String url, InputStream postBody, Map<String,String> headers)
          Performs an HTTP-Get request and provides typed access to the response.
static
<T> T
retrieve(HttpUtils.Worker<T> worker, String url)
           
static
<T> T
retrieve(HttpUtils.Worker<T> worker, String url, Map<String,String> map)
           
static
<T> T
retrieve(HttpUtils.Worker<T> worker, URL url)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlInputFactory

static final XMLInputFactory xmlInputFactory

STREAM

public static final HttpUtils.Worker<InputStream> STREAM
Directly returns the stream.


XML

public static final HttpUtils.Worker<XMLAdapter> XML
Returns streaming XMLAdapter.


XML_STREAM

public static final HttpUtils.Worker<XMLStreamReaderWrapper> XML_STREAM
Returns streaming XMLAdapter.


UTF8STRING

public static final HttpUtils.Worker<String> UTF8STRING
Returns a decoded String.


IMAGE

public static final HttpUtils.Worker<BufferedImage> IMAGE
Returns a BufferedImage.

Constructor Detail

HttpUtils

public HttpUtils()
Method Detail

getStringWorker

public static HttpUtils.Worker<String> getStringWorker(String encoding)
Parameters:
encoding -
Returns:
a string producer for a specific encoding

retrieve

public static <T> T retrieve(HttpUtils.Worker<T> worker,
                             URL url)
                  throws IOException
Type Parameters:
T -
Parameters:
worker -
url -
Returns:
some object from the url
Throws:
IOException

retrieve

public static <T> T retrieve(HttpUtils.Worker<T> worker,
                             String url)
                  throws MalformedURLException,
                         IOException
Type Parameters:
T -
Parameters:
worker -
url -
Returns:
some object from the url
Throws:
MalformedURLException
IOException

retrieve

public static <T> T retrieve(HttpUtils.Worker<T> worker,
                             String url,
                             Map<String,String> map)
                  throws MalformedURLException,
                         IOException
Type Parameters:
T -
Parameters:
worker -
url -
map -
Returns:
some object from the url
Throws:
IOException
MalformedURLException

post

public static <T> T post(HttpUtils.Worker<T> worker,
                         String url,
                         InputStream postBody,
                         Map<String,String> headers)
              throws org.apache.commons.httpclient.HttpException,
                     IOException
Performs an HTTP-Get request and provides typed access to the response.

Type Parameters:
T -
Parameters:
worker -
url -
postBody -
headers -
Returns:
some object from the url
Throws:
org.apache.commons.httpclient.HttpException
IOException

get

public static <T> T get(HttpUtils.Worker<T> worker,
                        String url,
                        Map<String,String> headers)
             throws org.apache.commons.httpclient.HttpException,
                    IOException
Performs an HTTP-Get request and provides typed access to the response.

Type Parameters:
T -
Parameters:
worker -
url -
headers -
Returns:
some object from the url
Throws:
org.apache.commons.httpclient.HttpException
IOException

deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org

]]>