NaiveUserAgent is a simple implementation of UserAgentCallback which places no restrictions on what
XML, CSS or images are loaded.
The NaiveUserAgent has a simple per-run cache for images so that the same image is not embedded in a document multiple times.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| public static class | |
| public static class | |
| public static class | |
| public static class | |
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| protected final Map | |
| protected String | |
| protected final LinkedHashMap | _imageCache
a (simple) cache This is only useful for the one run. |
| protected Map | |
| protected FSUriResolver | |
| protected final FSUriResolver |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | checkAccessAllowed(String uriOrResolved, ExternalResourceType type, ExternalResourceControlPriority priority)
|
| public void | |
| public void | documentLoaded()
Implements com.
Deprecated
Indicates document layout has complete, e.g. document is fully "loaded" for display; this is not a callback for the document source (e.g. XML) being loaded. |
| public void | documentStarted()
Implements com.
Deprecated
Indicates document has been requested (e.g. a new document is going to be loaded). |
| protected String | |
| public String | getBaseURL()
Implements com. Returns the current baseUrl for this class. |
| public byte[] | getBinaryResource(String uri, ExternalResourceType type)
Implements com. Retrieves a binary resource located at a given URI and returns its contents
as a byte array or |
| public CSSResource | Returns: A CSSResource containing the CSS reader or null if not available.Location of the CSS source. uri, ExternalResourceType type)Implements com. Retrieves the CSS located at the given URI. |
| public FSUriResolver | |
| public ImageResource | Returns: An ImageResource containing the image.Location of the image source. uri, ExternalResourceType type)Implements com. Retrieves the image located at the given URI. |
| protected FSStreamFactory | |
| public XMLResource | Returns: An XMLResource containing the image.Location of the XML source. uri, ExternalResourceType Either xhtml or svg. type)Implements com. Retrieves the XML located at the given URI. |
| protected boolean | |
| public boolean | Returns: Always false; visits are not tracked in the NaiveUserAgent.A URI which might have been visited. uri)Implements com. Returns true if the given URI was visited, meaning it was requested at some point since initialization. |
| public void | onLayoutException(Throwable t)
Implements com.
Deprecated
Called when document layout failed with an exception. |
| public void | onRenderException(Throwable t)
Implements com.
Deprecated
Called when document render failed with an exception. |
| protected Reader | |
| protected InputStream | |
| protected String | |
| public String | resolveURI(String
an absolute or relative (to baseURL) uri to be resolved. uri)Implements com. Used to find a uri that may be relative to the BaseURL. |
| public String | resolveUri(String baseUri, String uri)
Implements com.
|
| public void | setAccessController(ExternalResourceControlPriority prio, BiPredicate<String, ExternalResourceType> controller)
|
| public void | setBaseURL(String
A URI which anchors other, possibly relative URIs. uri)Implements com. URL relative to which URIs are resolved. |
| public void | |
| public void |
| _accessControllers | back to summary |
|---|---|
| protected final Map<ExternalResourceControlPriority, BiPredicate<String, ExternalResourceType>> _accessControllers | |
| _baseUri | back to summary |
|---|---|
| protected String _baseUri | |
| _imageCache | back to summary |
|---|---|
| protected final LinkedHashMap<String, ImageResource> _imageCache a (simple) cache This is only useful for the one run. | |
| _protocolsStreamFactory | back to summary |
|---|---|
| protected Map<String, FSStreamFactory> _protocolsStreamFactory | |
| _resolver | back to summary |
|---|---|
| protected FSUriResolver _resolver | |
| DEFAULT_URI_RESOLVER | back to summary |
|---|---|
| protected final FSUriResolver DEFAULT_URI_RESOLVER | |
| NaiveUserAgent | back to summary |
|---|---|
| public NaiveUserAgent() | |
| checkAccessAllowed | back to summary |
|---|---|
| public boolean checkAccessAllowed(String uriOrResolved, ExternalResourceType type, ExternalResourceControlPriority priority) | |
| clearImageCache | back to summary |
|---|---|
| public void clearImageCache()
Deprecated
Empties the image cache entirely.
| |
| documentLoaded | back to summary |
|---|---|
| public void documentLoaded() Implements com. Doc from com. Deprecated
Indicates document layout has complete, e.g. document is fully "loaded" for display; this is not a callback for the document source (e.g. XML) being loaded. This method will be called on every layout run (including, for example, after panel resizes).
| |
| documentStarted | back to summary |
|---|---|
| public void documentStarted() Implements com. Doc from com. Deprecated
Indicates document has been requested (e.g. a new document is going to be loaded). This will be called before any activity takes place for the document.
| |
| extractProtocol | back to summary |
|---|---|
| protected String extractProtocol(String uri) throws URISyntaxException | |
| getBaseURL | back to summary |
|---|---|
| public String getBaseURL() Implements com. Returns the current baseUrl for this class.
| |
| getBinaryResource | back to summary |
|---|---|
| public byte[] getBinaryResource(String uri, ExternalResourceType type) Implements com. Doc from com. Retrieves a binary resource located at a given URI and returns its contents
as a byte array or
| |
| getCSSResource | back to summary |
|---|---|
| public CSSResource getCSSResource(String uri, ExternalResourceType type) Implements com. Retrieves the CSS located at the given URI. It's assumed the URI does point to a CSS file--the URI will be resolved, accessed (using the set FSStreamFactory or URL::openStream), opened, read and then passed into the CSS parser. The result is packed up into an CSSResource for later consumption.
| |
| getDefaultUriResolver | back to summary |
|---|---|
| public FSUriResolver getDefaultUriResolver() | |
| getImageResource | back to summary |
|---|---|
| public ImageResource getImageResource(String uri, ExternalResourceType type) Implements com. Retrieves the image located at the given URI. It's assumed the URI does point to an image--the URI will be accessed (using the set HttpStreamFactory or URL::openStream), opened, read and then passed into the JDK image-parsing routines. The result is packed up into an ImageResource for later consumption.
| |
| getProtocolFactory | back to summary |
|---|---|
| protected FSStreamFactory getProtocolFactory(String protocol) | |
| getXMLResource | back to summary |
|---|---|
| public XMLResource getXMLResource(String uri, ExternalResourceType type) Implements com. Retrieves the XML located at the given URI. It's assumed the URI does point to a XML--the URI will be accessed (using the set HttpStreamFactory or URL::openStream), opened, read and then passed into the XML parser (XMLReader) configured for Flying Saucer. The result is packed up into an XMLResource for later consumption.
| |
| hasProtocolFactory | back to summary |
|---|---|
| protected boolean hasProtocolFactory(String protocol) | |
| isVisited | back to summary |
|---|---|
| public boolean isVisited(String uri) Implements com. Returns true if the given URI was visited, meaning it was requested at some point since initialization. | |
| onLayoutException | back to summary |
|---|---|
| public void onLayoutException(Throwable t) Implements com. Doc from com. Deprecated
Called when document layout failed with an exception. All
| |
| onRenderException | back to summary |
|---|---|
| public void onRenderException(Throwable t) Implements com. Doc from com. Deprecated
Called when document render failed with an exception. All
| |
| openReader | back to summary |
|---|---|
| protected Reader openReader(String uri) Gets a reader for the identified resource by a resolved URI. | |
| openStream | back to summary |
|---|---|
| protected InputStream openStream(String uri) Gets a InputStream for the resource identified by a resolved URI. | |
| readAll | back to summary |
|---|---|
| protected String readAll(Reader reader) throws IOException | |
| resolveURI | back to summary |
|---|---|
| public String resolveURI(String uri) Implements com. Doc from com. Used to find a uri that may be relative to the BaseURL. The returned value will always only be used via methods in the same implementation of this interface, therefore may be a private uri-space. | |
| resolveUri | back to summary |
|---|---|
| public String resolveUri(String baseUri, String uri) Implements com.
| |
| setAccessController | back to summary |
|---|---|
| public void setAccessController(ExternalResourceControlPriority prio, BiPredicate<String, ExternalResourceType> controller) | |
| setBaseURL | back to summary |
|---|---|
| public void setBaseURL(String uri) Implements com. URL relative to which URIs are resolved. | |
| setProtocolsStreamFactory | back to summary |
|---|---|
| public void setProtocolsStreamFactory(Map<String, FSStreamFactory> protocolsStreamFactory) | |
| setUriResolver | back to summary |
|---|---|
| public void setUriResolver(FSUriResolver resolver) | |
| Modifier and Type | Field and Description |
|---|---|
| private final byte[] |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Reader | |
| public InputStream |
| input | back to summary |
|---|---|
| private final byte[] input | |
| ByteStream | back to summary |
|---|---|
| pack-priv ByteStream(byte[] input) | |
| getReader | back to summary |
|---|---|
| public Reader getReader() Implements com.
| |
| getStream | back to summary |
|---|---|
| public InputStream getStream() Implements com.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public FSStream |
| DataUriFactory | back to summary |
|---|---|
| public DataUriFactory() | |
| getUrl | back to summary |
|---|---|
| public FSStream getUrl(String url) Implements com.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | test(String
the first input argument uri, ExternalResourceType the second input argument resourceType)Implements java. Evaluates this predicate on the given arguments. |
| DefaultAccessController | back to summary |
|---|---|
| public DefaultAccessController() | |
| test | back to summary |
|---|---|
| public boolean test(String uri, ExternalResourceType resourceType) Implements java. Doc from java. Evaluates this predicate on the given arguments.
| |
| Modifier and Type | Field and Description |
|---|---|
| private InputStream |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Reader | |
| public InputStream |
| strm | back to summary |
|---|---|
| private InputStream strm | |
| DefaultHttpStream | back to summary |
|---|---|
| public DefaultHttpStream(InputStream strm) | |
| getReader | back to summary |
|---|---|
| public Reader getReader() Implements com.
| |
| getStream | back to summary |
|---|---|
| public InputStream getStream() Implements com.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | |
| pack-priv final int | |
| pack-priv static final int | |
| pack-priv final int |
| Access | Constructor and Description |
|---|---|
| public | DefaultHttpStreamFactory(int connectTimeout, int readTimeout)
Create a FSStreamFactory for http, https with specified timeouts. |
| public | DefaultHttpStreamFactory()
Create a FSStreamFactory with 10 second connect timeout and 30 second read timeout. |
| Modifier and Type | Method and Description |
|---|---|
| public FSStream |
| CONNECTION_TIMEOUT | back to summary |
|---|---|
| pack-priv static final int CONNECTION_TIMEOUT | |
| connectTimeout | back to summary |
|---|---|
| pack-priv final int connectTimeout | |
| READ_TIMEOUT | back to summary |
|---|---|
| pack-priv static final int READ_TIMEOUT | |
| readTimeout | back to summary |
|---|---|
| pack-priv final int readTimeout | |
| DefaultHttpStreamFactory | back to summary |
|---|---|
| public DefaultHttpStreamFactory(int connectTimeout, int readTimeout) Create a FSStreamFactory for http, https with specified timeouts. Uses URLConnection to perform requests. Zero value for timeout specifies no timeout. | |
| DefaultHttpStreamFactory | back to summary |
|---|---|
| public DefaultHttpStreamFactory() Create a FSStreamFactory with 10 second connect timeout and 30 second read timeout. | |
| getUrl | back to summary |
|---|---|
| public FSStream getUrl(String uri) Implements com.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | Returns: A URI as String, resolved, or null if there was an exception (for example if the URI is malformed).A URI, possibly relative. uri)Implements com. Resolves the URI; if absolute, leaves as is, if relative, returns an absolute URI based on the baseUrl for the agent. |
| DefaultUriResolver | back to summary |
|---|---|
| public DefaultUriResolver() | |
| resolveURI | back to summary |
|---|---|
| public String resolveURI(String baseUri, String uri) Implements com. Resolves the URI; if absolute, leaves as is, if relative, returns an absolute URI based on the baseUrl for the agent. | |