- 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
FieldsModifier and TypeFieldDescriptionstatic final SinglePartialURLASinglePartialURLconsisting of all null fields that will match all requests and can serve as a match for a default host.static final StringThe http scheme.static final StringThe https scheme.protected static final StringThe value used to representnullSinglePartialURL.getContextPath()orMultiPartialURL.getContextPaths().protected static final Stringprotected static final charThe character used to represent request-value substitutions.protected static final StringThe character used to represent request-value substitutions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanabstract Iterable<SinglePartialURL> Gets all combinations of single partial URLs represented by this partial URL.abstract SinglePartialURLGets the primary single partial URL for this partial URL.abstract inthashCode()abstract booleanChecks if this partial URL is complete (has nonullfields other than prefix).abstract SinglePartialURLmatches(FieldSource fieldSource) Checks if the givenFieldSourcematches this partial URL.abstract StringtoString()abstract URLtoURL(FieldSource fieldSource) Gets the general-purpose representation ofURLfor this partial URL.static SinglePartialURLGets a partial URL always within the current request.static PartialURLGets a partial URL always within the current request.static PartialURLGets a partial URL always within the current request.static PartialURLvalueOf(Iterable<String> schemes, Iterable<HostAddress> hosts, Iterable<Port> ports, Iterable<Path> contextPaths, Iterable<Path> prefixes) Gets a partial URL supporting requests across multiple schemes/hosts/ports/...static PartialURLGets a partial URL supporting requests across multiple schemes/hosts/ports/...static SinglePartialURLGets 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 representnullSinglePartialURL.getContextPath()orMultiPartialURL.getContextPaths(). -
NULL_PREFIX
-
DEFAULT
ASinglePartialURLconsisting 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 ornullto match all. Must be eithernullor 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 ornullto match all. Must be eithernullor always ends in a slash (/).- See Also:
-
valueOf
public static PartialURL valueOf(Iterable<String> schemes, Iterable<HostAddress> hosts, Iterable<Port> ports, Iterable<Path> contextPaths, Iterable<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.nullelements are skipped.hosts- (Optional) The IP/host to match and/or link tonullelements are skipped.ports- (Optional) The port to match and/or link tonullelements are skipped.contextPaths- (Optional) The contextPath to match and/or link tonullelements are skipped.prefixes- (Optional) The prefix to match against the path ornullto match all. Must be eithernullor always ends in a slash (/).nullelements 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.nullelements are skipped.hosts- (Optional) The IP/host to match and/or link tonullelements are skipped.ports- (Optional) The port to match and/or link tonullelements are skipped.contextPaths- (Optional) The contextPath to match and/or link tonullelements are skipped.prefixes- (Optional) The prefix to match against the path ornullto match all. Must be eithernullor always ends in a slash (/).nullelements are skipped.- See Also:
-
valueOf
Gets a partial URL always within the current request.- Parameters:
prefixes- (Optional) The prefix to match against the path ornullto match all. Must be eithernullor 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 ornullto match all. Must be eithernullor always ends in a slash (/).- See Also:
-
toString
-
equals
-
hashCode
public abstract int hashCode() -
matches
Checks if the givenFieldSourcematches this partial URL.The
SinglePartialURLreturned, 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
SinglePartialURLwith non-null fields selected to match the field source, ornullwhen does not match. When the match isequalstheprimary, returns the same object asgetPrimary(). - Throws:
MalformedURLException
-
isComplete
public abstract boolean isComplete()Checks if this partial URL is complete (has nonullfields other than prefix). A complete URL may be converted to aURLwithout anyfield sourceprovided.- 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
equalto theprimary, returns the same object instance asgetPrimary().- See Also:
-
toURL
Gets the general-purpose representation ofURLfor this partial URL.- Parameters:
fieldSource- Only used when at least one field isnulland uses the value from the source. May benullwhen thisPartialURLis known to have all fields specified.- Throws:
NullPointerException- whenfieldSourcenot provided and at least one field isnull.MalformedURLException- See Also:
-
