Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| deegree 2.4 (2010/11/11 10:47 build-27-official)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.deegree.framework.util
Class NetWorker

    java.lang.Object
      org.deegree.framework.util.NetWorker

    public class NetWorker

extends Object

Performs a HTTP request using the service URL submitted to the constructor

Version:
  $Revision: 18195 $
Author:
  Andreas Poth

Constructor Summary
`NetWorker(String encoding, URL url)` constructor for initializing a HTTP GET connection with a user defined encoding
`NetWorker(String encoding, URL url, String request)` constructor for initializing a HTTP POST connection with a user defined encoding
`NetWorker(URL url)` constructor for initializing a HTTP GET connection with with default character encoding
`NetWorker(URL url, String request)` constructor for initializing a HTTP POST connection with UTF-8 as character encoding

Method Summary
`static boolean` | `existsURL(URL url)`
`String` | `getContentType()`
`byte[]` | `getDataAsByteArr(int expectedDataSize)` performs the request and returns the result as a byte array.
`InputStream` | `getInputStream()` returns an `InputStream` from the et resource
`void` | `sendRequest()` sends the request that have been passed to the constructor without expecting to receive a response.
`static String` | `url2String(URL url)` Returns the original form of a `URL` as as `String`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### NetWorker

    public NetWorker(URL url)

  constructor for initializing a HTTP GET connection with with default character encoding

  Parameters:
    `url` - URL to the net resource containing the URI

### NetWorker

    public NetWorker(String encoding,
                     URL url)

  constructor for initializing a HTTP GET connection with a user defined encoding

  Parameters:
    `encoding` - desired character encoding
    `url` - URL to the net resource containing the URI

### NetWorker

    public NetWorker(URL url,
                     String request)

  constructor for initializing a HTTP POST connection with UTF-8 as character encoding

  Parameters:
    `url` - URL to the net resource (without URI parameters)
    `request` - request that shall be posted to the net resource

### NetWorker

    public NetWorker(String encoding,
                     URL url,
                     String request)

  constructor for initializing a HTTP POST connection with a user defined encoding

  Parameters:
    `encoding` - desired character encoding
    `url` - URL to the net resource (without URI parameters)
    `request` - request that shall be posted to the net resource

Method Detail

### getContentType

    public String getContentType()

  Returns:
    the content type of the response from the connected net resource. this method shall be called after `getInputStream` or `getDataAsByteArr` has been called.

### sendRequest

    public void sendRequest()
                     throws IOException

  sends the request that have been passed to the constructor without expecting to receive a response.

  Throws:
    `IOException`

### getInputStream

    public InputStream getInputStream()
                               throws IOException

  returns an `InputStream` from the et resource

  Returns:
    InputStream accessing the net resource
  Throws:
    `IOException`

### getDataAsByteArr

    public byte[] getDataAsByteArr(int expectedDataSize)
                            throws IOException

  performs the request and returns the result as a byte array.

  Parameters:
    `expectedDataSize` - size a the data in bytes expected to be returned from the net resource. this value will be replaced if the resource is able to return the available data size.
  Returns:
    a byte array containing the content of the net resource
  Throws:
    `IOException`

### url2String

    public static String url2String(URL url)

  Returns the original form of a `URL` as as `String`. Handles local filenames correctly, C:/foo is formatted as file:///C:/foo (and not as file:/C:/foo as returned by the toString () method of the object.

  Parameters:
    `url` - `URL` to be converted
  Returns:
    `String` representation of the given `URL`

### existsURL

    public static boolean existsURL(URL url)

  Parameters:
    `url` -
  Returns:
    true if a connection to the submitted `URL` can be opend

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| deegree 2.4 (2010/11/11 10:47 build-27-official)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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