- Direct Known Subclasses:
MultiPartialURL
,SinglePartialURL
PartialURL
matches and completes URLs.
All fields are optional.
This is not a general-purpose representation of a URL. It only contains the
fields specifically used for matching a request to a virtual host (TODO: Links to projects). For
an instance of URL
, see toURL(com.aoapps.net.partialurl.FieldSource)
.
All partial URLs are immutable value types.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final SinglePartialURL
ASinglePartialURL
consisting of all null fields that will match all requests and can serve as a match for a default host.static final String
The http scheme.static final String
The https scheme.protected static final String
The value used to representnull
SinglePartialURL.getContextPath()
orMultiPartialURL.getContextPaths()
.protected static final String
protected static final char
The character used to represent request-value substitutions.protected static final String
The character used to represent request-value substitutions. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
abstract Iterable
<SinglePartialURL> Gets all combinations of single partial URLs represented by this partial URL.abstract SinglePartialURL
Gets the primary single partial URL for this partial URL.abstract int
hashCode()
abstract boolean
Checks if this partial URL is complete (has nonull
fields other than prefix).abstract SinglePartialURL
matches
(FieldSource fieldSource) Checks if the givenFieldSource
matches this partial URL.abstract String
toString()
abstract URL
toURL
(FieldSource fieldSource) Gets the general-purpose representation ofURL
for this partial URL.static SinglePartialURL
Gets a partial URL always within the current request.static PartialURL
Gets a partial URL always within the current request.static PartialURL
Gets a partial URL always within the current request.static PartialURL
valueOf
(Iterable<? extends String> schemes, Iterable<? extends HostAddress> hosts, Iterable<? extends Port> ports, Iterable<? extends Path> contextPaths, Iterable<? extends Path> prefixes) Gets a partial URL supporting requests across multiple schemes/hosts/ports/...static PartialURL
Gets a partial URL supporting requests across multiple schemes/hosts/ports/...static SinglePartialURL
Gets a partial URL supporting requests across multiple schemes/hosts/ports/...
-
Field Details
-
HTTP
The http scheme.- See Also:
-
HTTPS
The https scheme.- See Also:
-
WILDCARD_CHAR
protected static final char WILDCARD_CHARThe character used to represent request-value substitutions.- See Also:
-
WILDCARD_STRING
The character used to represent request-value substitutions.- See Also:
-
NULL_CONTEXT_PATH
The value used to representnull
SinglePartialURL.getContextPath()
orMultiPartialURL.getContextPaths()
. -
NULL_PREFIX
-
DEFAULT
ASinglePartialURL
consisting of all null fields that will match all requests and can serve as a match for a default host.This default host is after all others in
SinglePartialURL.compareTo(com.aoapps.net.partialurl.SinglePartialURL)
andPartialURLMap.get(com.aoapps.net.partialurl.FieldSource)
.
-
-
Constructor Details
-
PartialURL
protected PartialURL()Creates a new partial URL.
-
-
Method Details
-
valueOf
public static SinglePartialURL valueOf(String scheme, HostAddress host, Port port, Path contextPath, Path prefix) Gets a partial URL supporting requests across multiple schemes/hosts/ports/...- Parameters:
scheme
- (Optional) The scheme (http/https/...) to match and/or link to, converted to lower-case.host
- (Optional) The IP/host to match and/or link toport
- (Optional) The port to match and/or link tocontextPath
- (Optional) The contextPath to match and/or link toprefix
- (Optional) The prefix to match against the path ornull
to match all. Must be eithernull
or always ends in a slash (/).- See Also:
-
valueOf
Gets a partial URL always within the current request.- Parameters:
prefix
- (Optional) The prefix to match against the path ornull
to match all. Must be eithernull
or always ends in a slash (/).- See Also:
-
valueOf
public static PartialURL valueOf(Iterable<? extends String> schemes, Iterable<? extends HostAddress> hosts, Iterable<? extends Port> ports, Iterable<? extends Path> contextPaths, Iterable<? extends Path> prefixes) Gets a partial URL supporting requests across multiple schemes/hosts/ports/...- Parameters:
schemes
- (Optional) The scheme (http/https/...) to match and/or link to, converted to lower-case.null
elements are skipped.hosts
- (Optional) The IP/host to match and/or link tonull
elements are skipped.ports
- (Optional) The port to match and/or link tonull
elements are skipped.contextPaths
- (Optional) The contextPath to match and/or link tonull
elements are skipped.prefixes
- (Optional) The prefix to match against the path ornull
to match all. Must be eithernull
or always ends in a slash (/).null
elements are skipped.- See Also:
-
valueOf
public static PartialURL valueOf(String[] schemes, HostAddress[] hosts, Port[] ports, Path[] contextPaths, Path... prefixes) Gets a partial URL supporting requests across multiple schemes/hosts/ports/...- Parameters:
schemes
- (Optional) The scheme (http/https/...) to match and/or link to, converted to lower-case.null
elements are skipped.hosts
- (Optional) The IP/host to match and/or link tonull
elements are skipped.ports
- (Optional) The port to match and/or link tonull
elements are skipped.contextPaths
- (Optional) The contextPath to match and/or link tonull
elements are skipped.prefixes
- (Optional) The prefix to match against the path ornull
to match all. Must be eithernull
or always ends in a slash (/).null
elements are skipped.- See Also:
-
valueOf
Gets a partial URL always within the current request.- Parameters:
prefixes
- (Optional) The prefix to match against the path ornull
to match all. Must be eithernull
or always ends in a slash (/).- See Also:
-
valueOf
Gets a partial URL always within the current request.- Parameters:
prefixes
- (Optional) The prefix to match against the path ornull
to match all. Must be eithernull
or always ends in a slash (/).- See Also:
-
toString
-
equals
-
hashCode
public abstract int hashCode() -
matches
Checks if the givenFieldSource
matches this partial URL.The
SinglePartialURL
returned, if any, is also in the set of partial URLs provided bygetCombinations()
. Specifically, the match must be equivalent to the first match found by iterative calls to the results ofgetCombinations()
, usingSinglePartialURL.matches(com.aoapps.net.partialurl.FieldSource)
on each single partial. The implementation, however, does not need to be iterative.Ordering is consistent with:
- Parameters:
fieldSource
- When all fields arenull
(this isDEFAULT
), this is not used and may benull
.- Returns:
- The
SinglePartialURL
with non-null fields selected to match the field source, ornull
when does not match. When the match isequals
theprimary
, returns the same object asgetPrimary()
. - Throws:
MalformedURLException
-
isComplete
public abstract boolean isComplete()Checks if this partial URL is complete (has nonull
fields other than prefix). A complete URL may be converted to aURL
without anyfield source
provided.- See Also:
-
getPrimary
Gets the primary single partial URL for this partial URL.This will always be found in
getCombinations()
.- See Also:
-
getCombinations
Gets all combinations of single partial URLs represented by this partial URL.Ordering is consistent with:
matches(com.aoapps.net.partialurl.FieldSource)
SinglePartialURL.compareTo(com.aoapps.net.partialurl.SinglePartialURL)
PartialURLMap.get(com.aoapps.net.partialurl.FieldSource)
When one of the results is
equal
to theprimary
, returns the same object instance asgetPrimary()
.- See Also:
-
toURL
Gets the general-purpose representation ofURL
for this partial URL.- Parameters:
fieldSource
- Only used when at least one field isnull
and uses the value from the source. May benull
when thisPartialURL
is known to have all fields specified.- Throws:
NullPointerException
- whenfieldSource
not provided and at least one field isnull
.MalformedURLException
- See Also:
-