java.lang.Object
io.sf.carte.doc.agent.AbstractUserAgent
- All Implemented Interfaces:
UserAgent,UserAgent.AgentControl
- Direct Known Subclasses:
DOMCSSStyleSheetFactory.WrapperUserAgent
Abstract base class for User Agents, with cookie handling.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.agent.UserAgent
UserAgent.AgentControl -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticationCredentials(String host, String realm) Gives the credentials for the given hostname and realm, creating a new one if there is none.protected URLConnectioncreateConnection(URL url) Opens a connection to the given URL.Get the control object for this user agent.getAuthenticationCredentials(URL url, String realm) Gets the authentication credentials for the given URL.Gets the global, useragent-wide default cookie config.getCookies(String host) protected OriginPolicyprotected EnumSet<Parser2.Flag>getProperty(String propertyName) Gets a control property.booleanisVisitedURL(URL url) Has the provided url been visited by this user agent.protected URLConnectionopenConnection(URL url, long creationDate) Open a URL connection according to the given document creation date.protected voidreadCookies(HttpURLConnection hcon, long creationDate) voidsetConnectionTimeout(int timeout) Sets the connection timeout.voidsetOriginPolicy(OriginPolicy originPolicy) voidsetProperty(String propertyName, String value) Sets a control property.voidsetUseragentId(String userAgentId) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.sf.carte.doc.agent.UserAgent
readURL, setEntityResolver
-
Constructor Details
-
AbstractUserAgent
-
-
Method Details
-
getOriginPolicy
-
setOriginPolicy
-
getAgentControl
Description copied from interface:UserAgentGet the control object for this user agent.- Specified by:
getAgentControlin interfaceUserAgent- Returns:
- the control object for this user agent, or null if this agent has no control.
-
getCookieConfig
Gets the global, useragent-wide default cookie config.- Specified by:
getCookieConfigin interfaceUserAgent.AgentControl- Returns:
- the default user-agent cookie config.
-
getCookies
-
getParserFlags
-
getProperty
Description copied from interface:UserAgent.AgentControlGets a control property.- Specified by:
getPropertyin interfaceUserAgent.AgentControl- Parameters:
propertyName- the property name.- Returns:
- the string representation of the property value, or null if the property is not set.
-
setProperty
Sets a control property.- Specified by:
setPropertyin interfaceUserAgent.AgentControl- Parameters:
propertyName- the name of the property to set.value- the string representation of the property value.
-
getAuthenticationCredentials
Gets the authentication credentials for the given URL.- Specified by:
getAuthenticationCredentialsin interfaceUserAgent.AgentControl- Parameters:
url- the url for which the credential is required.realm- the realm name, or null if there is no realm, in which case any valid credential will be returned.- Returns:
- the authentication credentials, or null if there is none.
-
authenticationCredentials
Gives the credentials for the given hostname and realm, creating a new one if there is none.- Specified by:
authenticationCredentialsin interfaceUserAgent.AgentControl- Parameters:
host- the host.realm- the realm. Cannot be null.- Returns:
- the credentials.
-
setConnectionTimeout
public void setConnectionTimeout(int timeout) Sets the connection timeout.- Specified by:
setConnectionTimeoutin interfaceUserAgent.AgentControl- Parameters:
timeout- the connection timeout, in milliseconds. Atimeoutof 0 means no timeout (the default).
-
isVisitedURL
Description copied from interface:UserAgentHas the provided url been visited by this user agent.- Specified by:
isVisitedURLin interfaceUserAgent- Parameters:
url- the URL to test.- Returns:
trueif the URL was visited by this agent,falseif not visited or this agent does not support history.
-
setUseragentId
-
openConnection
Open a URL connection according to the given document creation date.- Parameters:
url- the URL to connect to.creationDate- the creation date.- Returns:
- the connection.
- Throws:
IOException- if an I/O exception occurs opening the connection.
-
createConnection
Opens a connection to the given URL.- Parameters:
url- the URL to connect to.- Returns:
- a URLConnection linking to the URL.
- Throws:
IOException- if an I/O exception occurs opening the connection.
-
readCookies
-