|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.rim.device.api.browser.field2.BrowserFieldResponse
public class BrowserFieldResponse
This class can be used to create a static (simulated) response to be used by the BrowserField component to display web content. This is useful in scenarios where you want to simulate a http response without having to implement your own HttpConnection.
| Field Summary |
|---|
| Constructor Summary | ||
|---|---|---|
BrowserFieldResponse(int responseCode,
String responseMessage,
String url,
InputStream input,
HttpHeaders responseHeaders)
Creates a BrowserFieldResponse using the provided InputStream data. |
||
BrowserFieldResponse(String url,
byte[] data,
String contentType)
Creates a BrowserFieldResponse using the provided byte data and content type. |
||
BrowserFieldResponse(String url,
byte[] data,
HttpHeaders responseHeaders)
Creates a BrowserFieldResponse using the provided byte data. |
||
BrowserFieldResponse(String url,
InputStream input,
String contentType)
Creates a BrowserFieldResponse using the provided InputStream data and content type. |
||
BrowserFieldResponse(String url,
InputStream input,
HttpHeaders responseHeaders)
Creates a BrowserFieldResponse using the provided InputStream data. |
||
| Method Summary | ||
|---|---|---|
void |
close()
Close the connection. |
|
long |
getDate()
Returns the value of the date header field. |
|
String |
getEncoding()
Returns a string describing the encoding of the content which the resource connected to is providing. |
|
long |
getExpiration()
Returns the value of the expires header field. |
|
String |
getFile()
Not implemented - will always return null unless overridden |
|
String |
getHeaderField(int n)
Gets a header field value by index. |
|
String |
getHeaderField(String name)
Returns the value of the named header field. |
|
long |
getHeaderFieldDate(String name,
long def)
Returns the value of the named field parsed as date. |
|
int |
getHeaderFieldInt(String name,
int def)
Returns the value of the named field parsed as a number. |
|
String |
getHeaderFieldKey(int n)
Gets a header field key by index. |
|
String |
getHost()
Returns the host information of the URL of this HttpConnection. e.g. host name or IPv4 address |
|
long |
getLastModified()
Returns the value of the last-modified header field. |
|
long |
getLength()
Returns the length of the content which is being provided. |
|
int |
getPort()
Always returns 80 |
|
String |
getProtocol()
Always returns null |
|
String |
getQuery()
Always returns null |
|
String |
getRef()
Always returns null |
|
String |
getRequestMethod()
Always returns null |
|
String |
getRequestProperty(String key)
Always returns null |
|
int |
getResponseCode()
Returns the HTTP response status code. |
|
String |
getResponseMessage()
Gets the HTTP response message, if any, returned along with the response code from a server. |
|
String |
getType()
Returns the type of content that the resource connected to is providing. |
|
String |
getURL()
Return a string representation of the URL for this connection. |
|
DataInputStream |
openDataInputStream()
Open and return a data input stream for a connection. |
|
DataOutputStream |
openDataOutputStream()
Always returns null |
|
InputStream |
openInputStream()
Open and return an input stream for a connection. |
|
OutputStream |
openOutputStream()
Always returns null |
|
void |
setRequestMethod(String method)
This method does nothing |
|
void |
setRequestProperty(String key,
String value)
This method does nothing |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BrowserFieldResponse(String url,
byte[] data,
String contentType)
public BrowserFieldResponse(String url,
InputStream input,
String contentType)
public BrowserFieldResponse(String url,
byte[] data,
HttpHeaders responseHeaders)
public BrowserFieldResponse(String url,
InputStream input,
HttpHeaders responseHeaders)
public BrowserFieldResponse(int responseCode,
String responseMessage,
String url,
InputStream input,
HttpHeaders responseHeaders)
| Method Detail |
|---|
public long getDate()
throws IOException
HttpConnectiondate header field.
getDate in interface HttpConnection0 if not known. The value returned is the
number of milliseconds since January 1, 1970 GMT.
IOException - if an error occurred connecting to the server.HttpConnection.getDate()
public long getExpiration()
throws IOException
HttpConnectionexpires header field.
getExpiration in interface HttpConnectionIOException - if an error occurred connecting to the server.HttpConnection.getExpiration()public String getFile()
getFile in interface HttpConnectionHttpConnection.
null is returned if there is no file.
public String getHeaderField(int n)
throws IOException
HttpConnection
getHeaderField in interface HttpConnectionn - the index of the header field
null if the array index is out of range.
An empty String is returned if the field does not have a value.
IOException - if an error occurred connecting to the server.HttpConnection.getHeaderField(int)
public String getHeaderField(String name)
throws IOException
HttpConnection
getHeaderField in interface HttpConnectionname - of a header field.
null
if there is no such field in the header.
IOException - if an error occurred connecting to the server.HttpConnection.getHeaderField(String)
public long getHeaderFieldDate(String name,
long def)
throws IOException
HttpConnection
This form of getHeaderField exists because some
connection types (e.g., http-ng) have pre-parsed
headers. Classes for that connection type can override this method
and short-circuit the parsing.
getHeaderFieldDate in interface HttpConnectionname - the name of the header field.def - a default value.
def argument is returned if the field is
missing or malformed.
IOException - if an error occurred connecting to the server.HttpConnection.getHeaderFieldDate(String,long)
public int getHeaderFieldInt(String name,
int def)
throws IOException
HttpConnection
This form of getHeaderField exists because some
connection types (e.g., http-ng) have pre-parsed
headers. Classes for that connection type can override this method
and short-circuit the parsing.
getHeaderFieldInt in interface HttpConnectionname - the name of the header field.def - the default value.
def value is returned if the field is
missing or malformed.
IOException - if an error occurred connecting to the server.HttpConnection.getHeaderFieldInt(String,int)
public String getHeaderFieldKey(int n)
throws IOException
HttpConnection
getHeaderFieldKey in interface HttpConnectionn - the index of the header field
null if the array index is out of range.
IOException - if an error occurred connecting to the server.HttpConnection.getHeaderFieldKey(int)public String getHost()
HttpConnectionHttpConnection. e.g. host name or IPv4 address
getHost in interface HttpConnectionHttpConnection.HttpConnection.getHost()
public long getLastModified()
throws IOException
HttpConnectionlast-modified header field.
The result is the number of milliseconds since January 1, 1970 GMT.
getLastModified in interface HttpConnectionHttpConnection was last modified, or
0 if not known.
IOException - if an error occurred connecting to the server.HttpConnection.getLastModified()public int getPort()
getPort in interface HttpConnectionHttpConnection.
The default HTTP port number (80) is returned if there was
no port number in the string passed to Connector.open.public String getProtocol()
getProtocol in interface HttpConnectionHttpConnection.public String getQuery()
getQuery in interface HttpConnectionHttpConnection.
null is returned if there is no value.public String getRef()
getRef in interface HttpConnectionHttpConnection.
null is returned if there is no value.public String getRequestMethod()
getRequestMethod in interface HttpConnectionHttpConnection.setRequestMethod(java.lang.String)public String getRequestProperty(String key)
getRequestProperty in interface HttpConnectionkey - the keyword by which the request property is
known (e.g., "accept").
null is returned.HttpConnection.setRequestProperty(java.lang.String, java.lang.String)
public int getResponseCode()
throws IOException
HttpConnectionHTTP/1.0 200 OK HTTP/1.0 401 Unauthorizedand extracts the ints 200 and 401 respectively. from the response (i.e., the response is not valid HTTP).
getResponseCode in interface HttpConnectionIOException - if an error occurred connecting to the server.HttpConnection.getResponseCode()
public String getResponseMessage()
throws IOException
HttpConnectionHTTP/1.0 200 OK HTTP/1.0 404 Not FoundExtracts the Strings "OK" and "Not Found" respectively. Returns null if none could be discerned from the responses (the result was not valid HTTP).
getResponseMessage in interface HttpConnectionnull
IOException - if an error occurred connecting to the server.HttpConnection.getResponseMessage()public String getURL()
HttpConnection
getURL in interface HttpConnectionHttpConnection.getURL()
public void setRequestMethod(String method)
throws IOException
setRequestMethod in interface HttpConnectionmethod - the HTTP method
IOException - if the method cannot be reset or if
the requested method isn't valid for HTTP.HttpConnection.getRequestMethod()
public void setRequestProperty(String key,
String value)
throws IOException
setRequestProperty in interface HttpConnectionkey - the keyword by which the request is known
(e.g., "accept").value - the value associated with it.
IOException - is thrown if the connection is in the
connected state.HttpConnection.getRequestProperty(java.lang.String)public String getType()
ContentConnectioncontent-type header field is returned.
getType in interface ContentConnectionnull if not known.ContentConnection.getType()public String getEncoding()
ContentConnectioncontent-encoding header field is returned.
getEncoding in interface ContentConnectionnull if not known.ContentConnection.getEncoding()public long getLength()
ContentConnectioncontent-length header field is returned.
getLength in interface ContentConnection-1 if the content length is
not known.ContentConnection.getLength()
public InputStream openInputStream()
throws IOException
InputConnection
openInputStream in interface InputConnectionIOException - If an I/O error occursInputConnection.openInputStream()
public DataInputStream openDataInputStream()
throws IOException
InputConnection
openDataInputStream in interface InputConnectionIOException - If an I/O error occursInputConnection.openDataInputStream()
public OutputStream openOutputStream()
throws IOException
openOutputStream in interface OutputConnectionIOException - If an I/O error occurs
public DataOutputStream openDataOutputStream()
throws IOException
openDataOutputStream in interface OutputConnectionIOException - If an I/O error occurs
public void close()
throws IOException
ConnectionWhen a connection has been closed, access to any of its methods except this close() will cause an an IOException to be thrown. Closing an already closed connection has no effect. Streams derived from the connection may be open when method is called. Any open streams will cause the connection to be held open until they themselves are closed. In this latter case access to the open streams is permitted, but access to the connection is not.
BlackBerry Implementation Note: When developing applications for the BlackBerry Wireless handheld, note that the stream must be flushed or closed before the program exits, otherwise all pending data will be lost.
close in interface ConnectionIOException - If an I/O error occursConnection.close()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.