public class DocumentInfo

  1. Object
  2. DocumentInfo
DocumentInfo holds important information about a document that is loading. This class is constructed internally by HTMLComponent and HTMLForm and is sent to the RequestHandler. It is intended for the RequestHandler to use and update (For example update encoding according to the HTTP response, update URL in case of a redirect etc.)

Fields

public static final String ENCODING_ISO = "ISO-8859-1"ISO-8859-1 encoding, the default one
public static final String ENCODING_UTF8 = "UTF-8"UTF8 encoding, very common
public static final int TYPE_HTML = 0Indicates that the request is for a page
public static final int TYPE_IMAGE = 1Indicates that the request is for an image
public static final int TYPE_CSS = 2Indicates that the request is for a CSS file

Methods

public static void setDefaultEncoding(String encoding)Sets the default encoding for the document e.g. ENCODING_UTF8
public String getUrl()Returns the absolute URL associated with this DocumentInfo object
public void setUrl(String url)Sets the URL to the specified URL
public String getFullUrl()Returns the full url string including parameters in GET request
public int getExpectedContentType()Returns the expected content type, one of TYPE_HTML, TYPE_IMAGE or TYPE_CSS
public void setExpectedContentType(int requestType)Sets this expected content type to be either TYPE_HTML, TYPE_IMAGE or TYPE_CSS When the document itself is requested the type will be TYPE_HTML and when images in the document are requested the type will be TYPE_IMAGE The differentiation is…
public boolean isPostRequest()Returns whether this document request is a POST request or not
public void setPostRequest(boolean postRequest)Sets this DocumentInfo as using a POST request or not
public String getParams()Returns the request paramter as a percentage-encoded string
public void setParams(String params)Sets the request paramters of this request
public String getEncoding()Returns a string describing the document’s encoding
public void setEncoding(String encoding)Sets the document encoding (This can be determined via the charset attribute in the response)
public String getBaseURL()Returns the base URL for this document
public void setBaseURL(String baseURL)Sets the base URL for this document.

Inherited methods

Field details

ENCODING_ISO

public static final String ENCODING_ISO = "ISO-8859-1"
ISO-8859-1 encoding, the default one

ENCODING_UTF8

public static final String ENCODING_UTF8 = "UTF-8"
UTF8 encoding, very common

TYPE_HTML

public static final int TYPE_HTML = 0
Indicates that the request is for a page

TYPE_IMAGE

public static final int TYPE_IMAGE = 1
Indicates that the request is for an image

TYPE_CSS

public static final int TYPE_CSS = 2
Indicates that the request is for a CSS file

Method details

setDefaultEncoding

public static void setDefaultEncoding(String encoding)
Sets the default encoding for the document e.g. ENCODING_UTF8

Parameters

encoding String
the encoding string matching ISO standards

getUrl

public String getUrl()
Returns the absolute URL associated with this DocumentInfo object

Returns

the absolute URL associated with this DocumentInfo object

setUrl

public void setUrl(String url)
Sets the URL to the specified URL

Parameters

url String
the URL to set as the URL of the document

getFullUrl

public String getFullUrl()
Returns the full url string including parameters in GET request

Returns

the full url string including parameters in GET request

getExpectedContentType

public int getExpectedContentType()
Returns the expected content type, one of TYPE_HTML, TYPE_IMAGE or TYPE_CSS

Returns

the expected content type, one of TYPE_HTML, TYPE_IMAGE or TYPE_CSS

setExpectedContentType

public void setExpectedContentType(int requestType)
Sets this expected content type to be either TYPE_HTML, TYPE_IMAGE or TYPE_CSS When the document itself is requested the type will be TYPE_HTML and when images in the document are requested the type will be TYPE_IMAGE The differentiation is important to handle cases in which the HTMLComponent expects one type but the URL is has a resource of another type

Parameters

requestType int
the requestType to set, one of TYPE_HTML, TYPE_IMAGE or TYPE_CSS

isPostRequest

public boolean isPostRequest()
Returns whether this document request is a POST request or not

Returns

true if the document was requested via POST, false otherwise

setPostRequest

public void setPostRequest(boolean postRequest)
Sets this DocumentInfo as using a POST request or not

Parameters

postRequest boolean
true if this is a POST request, false otherwise

getParams

public String getParams()
Returns the request paramter as a percentage-encoded string

Returns

the request paramter as an encoded string

setParams

public void setParams(String params)
Sets the request paramters of this request

Parameters

params String
The request paramters to set, should be as a percentage encoded string

getEncoding

public String getEncoding()
Returns a string describing the document’s encoding

Returns

the document’s encoding

setEncoding

public void setEncoding(String encoding)
Sets the document encoding (This can be determined via the charset attribute in the response)

Parameters

encoding String
the encoding to set. It is recommended to use the ENCODING_* constants when possible to avoid typos

getBaseURL

public String getBaseURL()
Returns the base URL for this document

Returns

the baseURL

setBaseURL

public void setBaseURL(String baseURL)
Sets the base URL for this document. Usually this is deduced automatically from the page URL, but in some cases this is different, for example when an HREF attribute is provided in the BASE tag

Parameters

baseURL String
the baseURL to set