Class ResourceRequest
- java.lang.Object
-
- org.xmlresolver.ResourceRequest
-
public class ResourceRequest extends java.lang.Object
A resource request.A resource request identifies what should be requested, either looked up in the catalog or looked up in the catalog and then retrieved.
-
-
Field Summary
Fields Modifier and Type Field Description ResolverConfiguration
config
The resolver configuration.java.lang.String
nature
The RDDL nature of the request.java.lang.String
purpose
The RDDL purpose of the request.
-
Constructor Summary
Constructors Constructor Description ResourceRequest(ResolverConfiguration config)
ResourceRequest constructor.ResourceRequest(ResolverConfiguration config, java.lang.String nature, java.lang.String purpose)
ResourceRequest constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.URI
getAbsoluteURI()
Get the absolute URI.java.lang.String
getBaseURI()
Get the base URI.java.lang.String
getEncoding()
Get the requested encoding.java.lang.String
getEntityName()
Get the entity namejava.lang.String
getPublicId()
Get the public identifierjava.lang.String
getSystemId()
Get the system identifier of the request.java.lang.String
getURI()
Get the request URI.boolean
isResolvingAsEntity()
Are we expecting to resolve this request to obtain an entity?boolean
openStream()
Will a readable stream be returned?void
setBaseURI(java.lang.String baseURI)
Set the base URI.void
setBaseURI(java.net.URI baseURI)
Set the base URI.void
setEncoding(java.lang.String encoding)
Set the requested encoding.void
setEntityName(java.lang.String name)
Set the entity name.void
setOpenStream(boolean open)
Return a readable stream?void
setPublicId(java.lang.String publicId)
Set the request public identifier.void
setResolvingAsEntity(boolean asEntity)
Specify whether resolution should be for entities or URIs.void
setURI(java.lang.String uri)
Sets the URI (and system identifier) of the request.void
setURI(java.net.URI uri)
Sets the URI (and system identifier) of the request.java.lang.String
toString()
-
-
-
Field Detail
-
config
public final ResolverConfiguration config
The resolver configuration.
-
nature
public final java.lang.String nature
The RDDL nature of the request.
-
purpose
public final java.lang.String purpose
The RDDL purpose of the request.
-
-
Constructor Detail
-
ResourceRequest
public ResourceRequest(ResolverConfiguration config)
ResourceRequest constructor.This constructor returns a request that accepts any RDDL nature or purpose. It has no other features; setters must be used to provide at least one feature.
- Parameters:
config
- The resolver configuration.
-
ResourceRequest
public ResourceRequest(ResolverConfiguration config, java.lang.String nature, java.lang.String purpose)
ResourceRequest constructor.This constructor returns a request that accepts the requested RDDL nature or purpose. It has no other features; setters must be used to provide at least one feature.
- Parameters:
config
- The resolver configuration.nature
- The RDDL nature.purpose
- The RDDL purpose.
-
-
Method Detail
-
setURI
public void setURI(java.lang.String uri)
Sets the URI (and system identifier) of the request.The request has only a single URI. For convenience, it can be retrieved with either the
getURI()
orgetSystemId()
methods.- Parameters:
uri
- the request URI
-
setURI
public void setURI(java.net.URI uri)
Sets the URI (and system identifier) of the request.The request has only a single URI. For convenience, it can be retrieved with either the
getURI()
orgetSystemId()
methods.- Parameters:
uri
- the request URI
-
setBaseURI
public void setBaseURI(java.lang.String baseURI)
Set the base URI.The base URI should be an absolute URI.
- Parameters:
baseURI
- the request base URI
-
setBaseURI
public void setBaseURI(java.net.URI baseURI)
Set the base URI.The base URI should be an absolute URI.
- Parameters:
baseURI
- the request base URI
-
setEntityName
public void setEntityName(java.lang.String name)
Set the entity name.The entity name is only relevant for some kinds of requests.
- Parameters:
name
- the entity name
-
getURI
public java.lang.String getURI()
Get the request URI. SeesetURI(String)
.- Returns:
- the request URI.
-
getBaseURI
public java.lang.String getBaseURI()
Get the base URI.- Returns:
- the base URI
-
getAbsoluteURI
public java.net.URI getAbsoluteURI() throws java.net.URISyntaxException
Get the absolute URI.This method combines the URI and base URI, returning an absolute URI.
If the request has a base URI, and that URI is absolute, the URI returned will be the request URI made absolute with respect to the base URI.
If the request doesn't have a base URI (or if the base URI isn't absolute), the request URI will be returned if it's an absolute URI. Otherwise,
null
is returned.- Returns:
- the absolute URI
- Throws:
java.net.URISyntaxException
- if the URI or base URI are syntactically invalid
-
getSystemId
public java.lang.String getSystemId()
Get the system identifier of the request.This method returns the request URI, it's synonymous with
getURI()
.- Returns:
- the request URI
-
setPublicId
public void setPublicId(java.lang.String publicId)
Set the request public identifier.Public identifiers only apply to requests to resolve system identifiers.
- Parameters:
publicId
- the public identifier
-
getPublicId
public java.lang.String getPublicId()
Get the public identifier- Returns:
- the request public identifier
-
getEntityName
public java.lang.String getEntityName()
Get the entity name- Returns:
- the request entity name
-
setEncoding
public void setEncoding(java.lang.String encoding)
Set the requested encoding.Not all protocols or systems provide the ability to make the encoding part of the request, but on those that do, this encoding will be used.
- Parameters:
encoding
- the request encoding
-
getEncoding
public java.lang.String getEncoding()
Get the requested encoding.- Returns:
- the request encoding
-
isResolvingAsEntity
public boolean isResolvingAsEntity()
Are we expecting to resolve this request to obtain an entity?There's a (not often especially useful) distinction maintained in the catalog between URI resolution and system identifier resolution. If the request has a DTD or entity nature, an entity name, or a public identifier, it's assumed to be resolving an entity. Otherwise, it's resolving a URI.
- Returns:
- True if the request will be resolved as an entity.
-
setResolvingAsEntity
public void setResolvingAsEntity(boolean asEntity)
Specify whether resolution should be for entities or URIs. SeeisResolvingAsEntity()
.- Parameters:
asEntity
- Resolve the request as an entity?
-
setOpenStream
public void setOpenStream(boolean open)
Return a readable stream?If open stream is true, a resource response will include a stream that can be used to read the response. If you don't need the stream, you can set this flag to false to prevent it from being returned.
Setting this flag to false does not guarantee that no requests will be issued. For example, the resolver may follow redirects to find the final URI, even if it doesn't return a stream.
- Parameters:
open
- true if the open stream should be returned
-
openStream
public boolean openStream()
Will a readable stream be returned?- Returns:
- the open stream setting
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-