public abstract class HttpTransactionQueryBase extends QueryBase implements HttpTransactionQueryInterface
METHOD_GET, METHOD_POST, REDIRECT_AUTOMATIC, REDIRECT_MANAGED, REDIRECT_MANAGED_SINGLESTEP| Constructor and Description |
|---|
HttpTransactionQueryBase()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearParameters()
Clear the parameter list
|
Element |
getBody(Document pageDocument)
Locate the HTML BODY element in the page document
|
boolean |
getFollowRedirects()
Should URLConnection follow redirects?
|
Element |
getFormElement(Document pageDocument,
String formName)
Find a named FORM element
|
String |
getParameter(String name)
Get a named parameter
|
String |
getParameterName(String value)
Get the parameter name associated with the 1st occurance of this value
|
Document |
getQueryDocument(String consumer)
Fetch the final query form as a DOM document
|
String |
getQueryMethod()
Fetch the current HTTP query method
|
String |
getQueryUrl(String consumer)
Fetch the URL for the query
|
byte[] |
getResponseBytes()
Get the server response text
|
String |
getResponseCharacterSet()
Fetch the response character set
|
Document |
getResponseDocument()
Parse the server response (override as required)
|
String |
getResponseHeader(String name)
Fetch a named HTTP response parameter
|
String |
getResponseString()
Get the server response text
|
String |
getSearchString()
Fetch the current search text
|
SessionContext |
getSessionContext()
Get the SessionContext object for this user
|
String |
getSessionParameter(String consumer,
String name)
Fetch the requested general purpose parameter
|
Object |
getSessionValue(String consumer,
String name)
Fetch the requested general purpose parameter
|
String |
getUrl()
Fetch the current search URL
|
void |
initialize(SessionContext session)
One time initialization
|
URL |
newFullUrl(String baseComponent,
String relativeComponent)
Construct a new URL from base and relative components
|
void |
removeQueryUrl(String consumer)
Delete a stored query URL
|
void |
removeSessionParameter(String consumer,
String name)
Delete the requested general purpose parameter
|
void |
setDefaultCharacterSet(String cs)
Set the default character set for this transaction
|
void |
setParameter(String name,
String value)
Set up a name=value pair
|
void |
setParametersFromFormInputs(Document pageDocument,
String formName,
List nameList)
Produce a target URL for this query by combining the form "action" value
with the base URL of the query page
|
void |
setParametersFromInputNames(Document pageDocument,
List nameList)
Set query parameters based on page-wide INPUTs
|
void |
setParametersFromInputs(Document pageDocument,
List nameList)
Deprecated.
Replaced by
#setParametersFromInputNames() |
void |
setParametersFromInputValues(Document pageDocument,
List nameList)
Set query parameters based on page-wide INPUTs
|
void |
setParametersFromNameList(NodeList nodeList,
List nameList)
Set query parameters based on element names (save name=value pairs)
|
void |
setParametersFromValueList(NodeList nodeList,
List nameList)
Set query parameters based on element values (save name=value pairs)
|
void |
setPreserveBaseUrlFile(boolean state)
Set the "file preservation state" for getBaseUrlSpecification()
|
void |
setQueryDocument(String consumer,
Document queryForm)
Save the final query form as a DOM document
|
void |
setQueryMethod(String method)
Set the HTTP query method (post or get)
|
void |
setQueryUrl(String consumer,
String queryUrl)
Save the URL for the query page
|
void |
setRedirectBehavior(int behavior)
Establish a mechanism for handling redirects
|
void |
setSearchString(String searchString)
Specify the search text
|
void |
setSessionParameter(String consumer,
String name,
String value)
Save a general purpose parameter
|
void |
setSessionValue(String consumer,
String name,
Object value)
Save a general purpose parameter
|
void |
setUrl(String url)
Set search URL
|
void |
setUrl(URL url)
Set search URL
|
void |
setUrlFromAnchor(Element anchor)
Produce a target URL for this query by combining an anchor "href" value
with the base URL of the query page
|
void |
setUrlFromForm(Document pageDocument,
String formName)
Produce a target URL for this query by combining the form "action" value
with the base URL of the query page
|
int |
submit()
Submit a request (POST or GET) and read the response.
|
getIntegerRequestParameter, getRequestParameter, getRequestParameterMap, parseRequest, populateRequestParametersclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdoQuerypublic void initialize(SessionContext session)
initialize in interface QueryInterfacesession - SessionContext objectpublic void setUrl(String url)
url - URL stringpublic void setUrl(URL url)
url - URL objectpublic String getUrl()
public void setSearchString(String searchString)
searchString - Text to look forpublic String getSearchString()
getSearchString in class QueryBasepublic void setQueryMethod(String method)
setQueryMethod in interface HttpTransactionQueryInterfacemethod - METHOD_POST or METHOD_GETpublic String getQueryMethod()
public String getResponseHeader(String name)
name - Parameter namepublic void setDefaultCharacterSet(String cs)
cs - Character set (UTF-8, ISO-8859-1, etc)public String getResponseCharacterSet()
public void setQueryUrl(String consumer, String queryUrl)
consumer - A unique name for the "user" of this objectqueryUrl - Address of the final query pagepublic String getQueryUrl(String consumer)
consumer - A unique name for the "user" of this objectpublic void removeQueryUrl(String consumer)
consumer - A unique name for the "user" of this objectpublic void setQueryDocument(String consumer, Document queryForm)
consumer - A unique name for the "user" of this objectqueryForm - Query page as a DOM documentpublic Document getQueryDocument(String consumer)
consumer - A unique name for the "user" of this objectpublic void setSessionParameter(String consumer, String name, String value)
consumer - A unique name for the "user" of this objectname - Parameter namevalue - Parameter valuepublic String getSessionParameter(String consumer, String name)
consumer - A unique name for the "user" of this objectname - Parameter namepublic void setSessionValue(String consumer, String name, Object value)
consumer - A unique name for the "user" of this objectname - Parameter namevalue - Parameter valuepublic void removeSessionParameter(String consumer, String name)
consumer - A unique name for the "user" of this objectname - Parameter namepublic Object getSessionValue(String consumer, String name)
consumer - A unique name for the "user" of this objectname - Parameter namepublic SessionContext getSessionContext()
public void setRedirectBehavior(int behavior)
throws SearchException
setRedirectBehavior in interface HttpTransactionQueryInterfacebehavior - Specifies the desired behavior. Use one of:
URLConnection handles
all redirects
submit() code
handles any redirects
SearchExceptionpublic void setPreserveBaseUrlFile(boolean state)
state - true to preserve URL file portionpublic boolean getFollowRedirects()
public void setParameter(String name, String value)
name - Parameter namevalue - Parameter valuepublic String getParameter(String name)
name - Parameter namepublic String getParameterName(String value)
value - Parameter valuepublic void clearParameters()
public int submit()
throws SearchException
SearchExceptionpublic String getResponseString()
getResponseString in interface QueryInterfacepublic byte[] getResponseBytes()
getResponseBytes in interface QueryInterfacepublic Document getResponseDocument() throws SearchException
SearchExceptionpublic Element getBody(Document pageDocument)
pageDocument - An HTML page (as a DOM)public URL newFullUrl(String baseComponent, String relativeComponent)
baseComponent - Base URL - the relative URL is added to thisrelativeComponent - A partial (or full) URL that represents our targetpublic void setParametersFromInputs(Document pageDocument, List nameList)
#setParametersFromInputNames()pageDocument - The search engine query page (as a DOM Document)nameList - A list of the parameters we're looking forpublic void setParametersFromInputNames(Document pageDocument, List nameList)
pageDocument - The search engine query page (as a DOM Document)nameList - A list of the parameters we're looking forpublic void setParametersFromInputValues(Document pageDocument, List nameList)
pageDocument - The search engine query page (as a DOM Document)nameList - A list of the parameters we're looking forpublic void setParametersFromFormInputs(Document pageDocument, String formName, List nameList) throws SearchException
pageDocument - The search engine query page (as a DOM Document)formName - The name of the FORM to lookup
(eg FORM name="formName")nameList - A list of the parameters we're looking forSearchExceptionpublic void setParametersFromNameList(NodeList nodeList, List nameList)
nodeList - List of Elements to evaluatenameList - A list of the parameters we're looking forpublic void setParametersFromValueList(NodeList nodeList, List nameList)
nodeList - List of Elements to evaluatenameList - A list of the parameters we're looking forpublic void setUrlFromAnchor(Element anchor) throws SearchException
anchor - Anchor elementSearchExceptionpublic void setUrlFromForm(Document pageDocument, String formName) throws SearchException
pageDocument - The search engine query page (as a DOM Document)formName - The name of the FORM to lookup
(eg FORM name="formName")SearchExceptionCopyright © 2004–2019 Indiana University Library Information Technology. All rights reserved.