Class Reference
java.lang.Object
is.galia.http.Reference
Immutable URI class.
Although instances cannot be modified, new modified versions can be
created via rebuilder().
Only the schemes in SUPPORTED_SCHEMES are supported.
Components are stored unencoded in order to enable assembly of a
partially or fully encoded URI string via one of the toString()
overloads.
Also, no checked exceptions are thrown, making it less of a pain to use
than URL and URI.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Reference.Builderbuilder()static Stringstatic StringbooleangetHost()getPath()intgetPort()getQuery()getUser()inthashCode()voidsetPathSegment(int segmentIndex, String segment) Updates a segment (token between slashes) of the path.toString()toString(boolean encodePath) Overload that encodes all parts of the URI except the path, which is assumed to already be encoded.toURI()
-
Field Details
-
SUPPORTED_SCHEMES
-
-
Constructor Details
-
Reference
public Reference()Constructs an "empty" instance with thehttpscheme. -
Reference
(Deep) copy constructor. -
Reference
- Throws:
IllegalArgumentException- if the argument is not a valid URI or has an unrecognized scheme.
-
Reference
-
Reference
Constructor for a file URI.
-
-
Method Details
-
builder
-
decode
-
encode
-
equals
-
getAuthority
- Returns:
- Authority (userinfo + host + port). Never
null. If the port is the standard port for the scheme, it is omitted.
-
getFragment
- Returns:
- The fragment, or an empty string if not set.
-
getHost
- Returns:
- The host, or an empty string if not set.
-
getPath
- Returns:
- The path, or an empty string if not set.
-
getPathSegments
-
getPathExtension
- Returns:
- String after the last period in the last path segment, or an empty string if the last path segment does not contain a period or the period is at the first index in the segment.
-
getPort
public int getPort()- Returns:
-1unless the instance has a nonstandard port number set.
-
getQuery
- Returns:
- The query, or an empty instance if not set.
-
getScheme
- Returns:
- Lowercase scheme, or an empty string if not set.
-
getSecret
- Returns:
- The secret, or an empty string if not set.
-
getUser
- Returns:
- The user, or an empty string if not set.
-
hashCode
-
rebuilder
- Returns:
Reference.Builderof a new instance based on this one.
-
setPathSegment
Updates a segment (token between slashes) of the path.- Parameters:
segmentIndex- Zero-based path component index.segment- Path segment.- Throws:
IndexOutOfBoundsException- if the given index is greater than the number of path components minus one.
-
toString
-
toString
Overload that encodes all parts of the URI except the path, which is assumed to already be encoded. -
toURI
-