Package io.sf.carte.doc.agent
Class AbstractUserAgent
java.lang.Object
io.sf.carte.doc.agent.AbstractUserAgent
- All Implemented Interfaces:
UserAgent
,UserAgent.AgentControl
,Serializable
- Direct Known Subclasses:
DOMCSSStyleSheetFactory.WrapperUserAgent
public abstract class AbstractUserAgent
extends Object
implements UserAgent, UserAgent.AgentControl, Serializable
Abstract base class for User Agents, with cookie handling.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.agent.UserAgent
UserAgent.AgentControl
-
Constructor Summary
-
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 URLConnection
createConnection
(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 OriginPolicy
protected EnumSet<Parser.Flag>
getProperty
(String propertyName) Gets a control property.boolean
isVisitedURL
(URL url) Has the provided url been visited by this user agent.protected URLConnection
openConnection
(URL url, long creationDate) Open a URL connection according to the given document creation date.protected void
readCookies
(HttpURLConnection hcon, long creationDate) void
setConnectionTimeout
(int timeout) Sets the connection timeout.void
setOriginPolicy
(OriginPolicy originPolicy) void
setProperty
(String propertyName, String value) Sets a control property.void
setUseragentId
(String userAgentId) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.sf.carte.doc.agent.UserAgent
readURL, setEntityResolver
-
Constructor Details
-
AbstractUserAgent
-
-
Method Details
-
getOriginPolicy
-
setOriginPolicy
-
getAgentControl
Description copied from interface:UserAgent
Get the control object for this user agent.- Specified by:
getAgentControl
in 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:
getCookieConfig
in interfaceUserAgent.AgentControl
- Returns:
- the default user-agent cookie config.
-
getCookies
-
getParserFlags
-
getProperty
Description copied from interface:UserAgent.AgentControl
Gets a control property.- Specified by:
getProperty
in 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:
setProperty
in 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:
getAuthenticationCredentials
in 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:
authenticationCredentials
in 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:
setConnectionTimeout
in interfaceUserAgent.AgentControl
- Parameters:
timeout
- the connection timeout, in milliseconds. Atimeout
of 0 means no timeout (the default).
-
isVisitedURL
Description copied from interface:UserAgent
Has the provided url been visited by this user agent.- Specified by:
isVisitedURL
in interfaceUserAgent
- Parameters:
url
- the URL to test.- Returns:
true
if the URL was visited by this agent,false
if 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
-