public class UsableURI extends LaxURI implements java.lang.CharSequence, java.io.Serializable
URI adding caching
and methods. It cannot be instantiated directly. Go via UURIFactory.
We used to use URI for parsing URIs but ran across
quirky behaviors and bugs. URI is not subclassable --
its final -- and its unlikely that java.net.URI will change any time soon
(See Gordon's considered petition here:
java.net.URI
should have loose/tolerant/compatibility option (or allow reuse)).
This class tries to cache calculated strings such as the extracted host and this class as a string rather than have the parent class rerun its calculation everytime.
URI,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MASSAGEHOST_PATTERN |
static int |
MAX_URL_LENGTH
Consider URIs too long for IE as illegal.
|
HTTP_SCHEME, HTTPS_SCHEME, lax_abs_path, lax_query, lax_rel_path, lax_rel_segment_authority, _fragment, _host, _is_abs_path, _is_hier_part, _is_hostname, _is_IPv4address, _is_IPv6reference, _is_net_path, _is_opaque_part, _is_reg_name, _is_rel_path, _is_server, _opaque, _path, _port, _query, _scheme, _uri, _userinfo, abs_path, absoluteURI, allowed_abs_path, allowed_authority, allowed_fragment, allowed_host, allowed_IPv6reference, allowed_opaque_part, allowed_query, allowed_reg_name, allowed_rel_path, allowed_userinfo, allowed_within_authority, allowed_within_path, allowed_within_query, allowed_within_userinfo, alpha, alphanum, authority, control, defaultDocumentCharset, defaultDocumentCharsetByLocale, defaultDocumentCharsetByPlatform, defaultProtocolCharset, delims, digit, disallowed_opaque_part, disallowed_rel_path, domainlabel, escaped, fragment, hash, hex, hier_part, host, hostname, hostport, IPv4address, IPv6address, IPv6reference, mark, net_path, opaque_part, param, path, path_segments, pchar, percent, port, protocolCharset, query, reg_name, rel_path, rel_segment, relativeURI, reserved, rootPath, scheme, segment, server, space, toplabel, unreserved, unwise, URI_reference, uric, uric_no_slash, userinfo, within_userinfo| Modifier | Constructor and Description |
|---|---|
protected |
UsableURI()
Shutdown access to default constructor.
|
protected |
UsableURI(java.lang.String uri,
boolean escaped) |
protected |
UsableURI(java.lang.String uri,
boolean escaped,
java.lang.String charset) |
protected |
UsableURI(UsableURI base,
UsableURI relative) |
| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int index) |
protected void |
coalesceHostAuthorityStrings()
The two String fields cachedHost and cachedAuthorityMinusUserInfo are
usually identical; if so, coalesce into a single instance.
|
protected void |
coalesceUriStrings()
The two String fields cachedString and cachedEscapedURI are
usually identical; if so, coalesce into a single instance.
|
int |
compareTo(java.lang.Object arg0) |
boolean |
equals(java.lang.Object obj)
Test an object if this UURI is equal to another.
|
java.lang.String |
getAuthorityMinusUserinfo()
Return the authority minus userinfo (if any).
|
java.lang.String |
getEscapedURI() |
java.lang.String |
getHost() |
java.lang.String |
getHostBasename()
Strips www variants from the host.
|
java.lang.String |
getReferencedHost()
Return the referenced host in the UURI, if any, also extracting the
host of a DNS-lookup URI where necessary.
|
java.lang.String |
getSurtForm() |
static boolean |
hasScheme(java.lang.String possibleUrl)
Test if passed String has likely URI scheme prefix.
|
int |
length() |
static java.lang.String |
parseFilename(java.lang.String pathOrUri) |
UsableURI |
resolve(java.lang.String uri) |
UsableURI |
resolve(java.lang.String uri,
boolean e) |
UsableURI |
resolve(java.lang.String uri,
boolean e,
java.lang.String charset) |
java.lang.CharSequence |
subSequence(int start,
int end) |
java.lang.String |
toCustomString()
Returns an alternate, functional String representation -- in this
case, a String of the URI represented by this UURI instance.
|
java.lang.String |
toString()
Override to cache result
TODO: eliminate, moving most callers to toCustomString, to avoid
overloading/diluting toString()
(see http://webteam.archive.org/confluence/display/Heritrix/Preserve+toString%28%29 )
|
java.lang.String |
toUnicodeHostString()
In the case of a puny encoded IDN, this method returns the decoded Unicode version.
|
decode, decode, getPath, getPathQuery, getURI, lax, parseAuthority, parseUriReference, setURI, validate, validateclone, encode, equals, getAboveHierPath, getAuthority, getCurrentHierPath, getDefaultDocumentCharset, getDefaultDocumentCharsetByLocale, getDefaultDocumentCharsetByPlatform, getDefaultProtocolCharset, getEscapedAboveHierPath, getEscapedAuthority, getEscapedCurrentHierPath, getEscapedFragment, getEscapedName, getEscapedPath, getEscapedPathQuery, getEscapedQuery, getEscapedURIReference, getEscapedUserinfo, getFragment, getName, getPort, getProtocolCharset, getQuery, getRawAboveHierPath, getRawAuthority, getRawCurrentHierPath, getRawCurrentHierPath, getRawFragment, getRawHost, getRawName, getRawPath, getRawPathQuery, getRawQuery, getRawScheme, getRawURI, getRawURIReference, getRawUserinfo, getScheme, getURIReference, getUserinfo, hasAuthority, hasFragment, hashCode, hasQuery, hasUserinfo, indexFirstOf, indexFirstOf, indexFirstOf, indexFirstOf, isAbsoluteURI, isAbsPath, isHierPart, isHostname, isIPv4address, isIPv6reference, isNetPath, isOpaquePart, isRegName, isRelativeURI, isRelPath, isServer, normalize, normalize, prevalidate, removeFragmentIdentifier, resolvePath, setDefaultDocumentCharset, setDefaultProtocolCharset, setEscapedAuthority, setEscapedFragment, setEscapedPath, setEscapedQuery, setFragment, setPath, setQuery, setRawAuthority, setRawFragment, setRawPath, setRawQuerypublic static final int MAX_URL_LENGTH
public static final java.lang.String MASSAGEHOST_PATTERN
protected UsableURI()
protected UsableURI(java.lang.String uri,
boolean escaped,
java.lang.String charset)
throws org.apache.commons.httpclient.URIException
uri - String representation of an absolute URI.escaped - If escaped.charset - Charset to use.org.apache.commons.httpclient.URIExceptionprotected UsableURI(UsableURI base, UsableURI relative) throws org.apache.commons.httpclient.URIException
relative - String representation of URI.base - Parent UURI to use derelativizing.org.apache.commons.httpclient.URIExceptionprotected UsableURI(java.lang.String uri,
boolean escaped)
throws org.apache.commons.httpclient.URIException,
java.lang.NullPointerException
uri - String representation of a URI.escaped - If escaped.java.lang.NullPointerExceptionorg.apache.commons.httpclient.URIExceptionpublic UsableURI resolve(java.lang.String uri) throws org.apache.commons.httpclient.URIException
uri - URI as string that is resolved relative to this UURI.org.apache.commons.httpclient.URIExceptionpublic UsableURI resolve(java.lang.String uri, boolean e) throws org.apache.commons.httpclient.URIException
uri - URI as string that is resolved relative to this UURI.e - True if escaped.org.apache.commons.httpclient.URIExceptionpublic UsableURI resolve(java.lang.String uri, boolean e, java.lang.String charset) throws org.apache.commons.httpclient.URIException
uri - URI as string that is resolved relative to this UURI.e - True if uri is escaped.charset - Charset to use.org.apache.commons.httpclient.URIExceptionpublic boolean equals(java.lang.Object obj)
equals in class org.apache.commons.httpclient.URIobj - an object to comparepublic java.lang.String getHostBasename()
throws org.apache.commons.httpclient.URIException
org.apache.commons.httpclient.URIExceptionpublic java.lang.String toCustomString()
public java.lang.String toString()
toString in interface java.lang.CharSequencetoString in class org.apache.commons.httpclient.URIpublic java.lang.String toUnicodeHostString()
Most of this implementation is copied from URI.setURI().
public java.lang.String getEscapedURI()
getEscapedURI in class org.apache.commons.httpclient.URIprotected void coalesceUriStrings()
public java.lang.String getHost()
throws org.apache.commons.httpclient.URIException
getHost in class org.apache.commons.httpclient.URIorg.apache.commons.httpclient.URIExceptionprotected void coalesceHostAuthorityStrings()
public java.lang.String getReferencedHost()
throws org.apache.commons.httpclient.URIException
org.apache.commons.httpclient.URIExceptionpublic java.lang.String getSurtForm()
public java.lang.String getAuthorityMinusUserinfo()
throws org.apache.commons.httpclient.URIException
org.apache.commons.httpclient.URIExceptionpublic int length()
length in interface java.lang.CharSequencepublic char charAt(int index)
charAt in interface java.lang.CharSequencepublic java.lang.CharSequence subSequence(int start,
int end)
subSequence in interface java.lang.CharSequencepublic int compareTo(java.lang.Object arg0)
compareTo in interface java.lang.ComparablecompareTo in class org.apache.commons.httpclient.URIpublic static boolean hasScheme(java.lang.String possibleUrl)
possibleUrl - URL string to examine.public static java.lang.String parseFilename(java.lang.String pathOrUri)
throws java.net.URISyntaxException
pathOrUri - A file path or a URI.pathOrUri.java.net.URISyntaxExceptionCopyright © 2019 The International Internet Preservation Consortium. All Rights Reserved.