Class EndpointUrl
URI construction.
Three factory methods are provided:
fromString(String)— parses a URL string using simple string operations (no URI construction)fromComponents(String, String, int, String)— creates from individual components (no query/fragment)fromUri(URI)— creates from an existing URI (pre-populates the cached URI field, preserves query and fragment)
-
Method Summary
Modifier and TypeMethodDescriptionReturns the encoded path (e.g., "/bucket/key"), or an empty string if no path is present.booleanstatic EndpointUrlfromComponents(String scheme, String host, int port, String encodedPath) Create anEndpointUrlfrom individual components.static EndpointUrlfromComponents(String scheme, String host, int port, String encodedPath, String queryAndFragment) Create anEndpointUrlfrom individual components, including query and fragment.static EndpointUrlfromString(String url) Parse a URL string into its components without constructing aURI.static EndpointUrlCreate anEndpointUrlfrom an existingURI.inthashCode()host()Returns the hostname (e.g., "s3.us-east-1.amazonaws.com").intport()Returns the port number, or -1 if not explicitly specified.Returns the query and fragment portion of the URL (e.g.,"?key=value#section"), or an empty string if neither is present.scheme()Returns the URL scheme (e.g., "https").toString()toUri()Returns theURIrepresentation.
-
Method Details
-
fromString
Parse a URL string into its components without constructing aURI.Performs minimal string splitting only. The original URL string is retained for faithful URI reconstruction via
toUri(). Path, query and fragment components (if present) MUST already be url encoded.Expected format:
scheme://[userinfo@]host[:port][/encodedPath][?query][#fragment]Component extraction matches
URIfor well-formed URLs:- Userinfo is excluded from
host(), matchingURI.getHost(). It remains part of the string returned bytoUri(), matchingURI.toString(). - A trailing
':'with no digits (e.g.https://example.com:) yields a port of-1, matchingURI.getPort(). - An IPv6 literal is stored with its enclosing brackets (e.g.
[::1]).
- Parameters:
url- the URL string to parse- Returns:
- a new
EndpointUrlwith pre-parsed components - Throws:
IllegalArgumentException- if the URL has no scheme, has a non-numeric or out-of-range port, has more than one':'separating host and port, or has an unterminated IPv6 literal
- Userinfo is excluded from
-
fromComponents
Create anEndpointUrlfrom individual components.Used internally (e.g., by
addHostPrefixand codegen) to avoid re-parsing. TherawUrlfield isnullin this case, sotoUri()reconstructs the URI from components. No query or fragment is included.Equivalence contract: For any valid endpoint URL string
swith no query or fragment,fromComponents(scheme, host, port, path)MUST produce anEndpointUrlthat equalsfromString(scheme + "://" + host + (port >= 0 ? ":" + port : "") + path). The codegen relies on this equivalence — seeEndpointUrlCodeEmitter.- Parameters:
scheme- the URL scheme (e.g., "https")host- the hostname (e.g., "s3.us-east-1.amazonaws.com")port- the port number, or -1 if not specifiedencodedPath- the encoded path (e.g., "/bucket/key"), or empty string if no path- Returns:
- a new
EndpointUrl
-
fromComponents
public static EndpointUrl fromComponents(String scheme, String host, int port, String encodedPath, String queryAndFragment) Create anEndpointUrlfrom individual components, including query and fragment.This overload is used when reconstructing an EndpointUrl with modifications (e.g., host prefix) while preserving the original query and fragment components.
- Parameters:
scheme- the URL scheme (e.g., "https")host- the hostname (e.g., "s3.us-east-1.amazonaws.com")port- the port number, or -1 if not specifiedencodedPath- the encoded path (e.g., "/bucket/key"), or empty string if no pathqueryAndFragment- the query and fragment string (e.g., "?key=value#section"), or empty string if none- Returns:
- a new
EndpointUrl
-
fromUri
-
scheme
Returns the URL scheme (e.g., "https"). -
host
Returns the hostname (e.g., "s3.us-east-1.amazonaws.com"). -
port
public int port()Returns the port number, or -1 if not explicitly specified. -
encodedPath
Returns the encoded path (e.g., "/bucket/key"), or an empty string if no path is present. -
queryAndFragment
Returns the query and fragment portion of the URL (e.g.,"?key=value#section"), or an empty string if neither is present. -
toUri
Returns theURIrepresentation. Lazily constructed on first call using double-checked locking.When created via
fromString(String), uses the original URL string for faithful reconstruction. When created viafromComponents(String, String, int, String)reconstructs from components (no query/fragment). When created viafromUri(URI), returns the original URI instance.- Returns:
- the URI representation of this endpoint URL
-
equals
-
hashCode
-
toString
-