Esri Geoportal Server
1.0

com.esri.gpt.framework.http
Class ContentProvider

java.lang.Object
  extended by com.esri.gpt.framework.http.ContentBase
      extended by com.esri.gpt.framework.http.ContentProvider
Direct Known Subclasses:
ByteArrayProvider, StreamProvider

public abstract class ContentProvider
extends ContentBase

Provider for the content of an HTTP request body.


Constructor Summary
ContentProvider()
          Default constructor.
 
Method Summary
static byte[] asBytes(String content)
          Converts a String to a UTF-8 encoded byte array.
static String ensureContentTypeEncoding(String contentType, String charset)
          Ensures that an HTTP Contype-Type string contains a supplied encoding (i.e.
abstract  long getContentLength()
          Gets the content length (in bytes) to be provided in the HTTP request header.
abstract  String getContentType()
          Gets the content type to be provided in the HTTP request header.
abstract  boolean isRepeatable()
          Tests if the HTTP request content can be written to the output stream more than once.
 void prepareForWrite(HttpClientRequest request)
          Provides an opportunity to prepare content prior to writing the HTTP request body.
abstract  void writeRequest(HttpClientRequest request, OutputStream destination)
          Writes the content of the HTTP request body to an output stream.
 
Methods inherited from class com.esri.gpt.framework.http.ContentBase
executeIO, executeIO, getInitialBufferlength, getLoggableContent, setInitialBufferLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentProvider

public ContentProvider()
Default constructor.

Method Detail

getContentLength

public abstract long getContentLength()
Gets the content length (in bytes) to be provided in the HTTP request header.

Returns:
the request content length (in bytes, use -1 if unknown);

getContentType

public abstract String getContentType()
Gets the content type to be provided in the HTTP request header.
Include a charset if applicable, e.g. text/xml; charset=UTF-8

Returns:
the request content type

isRepeatable

public abstract boolean isRepeatable()
Tests if the HTTP request content can be written to the output stream more than once.

Returns:
true if the content can written more than once (typically via a cache)

asBytes

public static byte[] asBytes(String content)
Converts a String to a UTF-8 encoded byte array.
if nuul is passwd, null will be returned.

Parameters:
content - the String to convert

ensureContentTypeEncoding

public static String ensureContentTypeEncoding(String contentType,
                                               String charset)
Ensures that an HTTP Contype-Type string contains a supplied encoding (i.e. charset reference).

Parameters:
contentType - the HTTP Contype-Type string to check
charset - the charset to enforce
Returns:
the resultant HTTP Content-Type string

prepareForWrite

public void prepareForWrite(HttpClientRequest request)
                     throws IOException
Provides an opportunity to prepare content prior to writing the HTTP request body.
Content can be cached if required o this step.
The default behavior does nothing.

Parameters:
request - the HTTP request that is executing
Throws:
IOException - if an exception occurs

writeRequest

public abstract void writeRequest(HttpClientRequest request,
                                  OutputStream destination)
                           throws IOException
Writes the content of the HTTP request body to an output stream.

Parameters:
request - the HTTP request that is executing
destination - the output stream to which data will be written
Throws:
IOException - if an exception occurs

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.