|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectMutableURI
FreezableMutableURI
public class FreezableMutableURI
A mutable class for creating URIs that can be set to "frozen" such that it becomes immutable. After this class is frozen, any calls to methods to set the data components of the URI will throw
Field Summary |
---|
Fields inherited from class MutableURI |
---|
DEFAULT_ENCODING, UNDEFINED_PORT |
Constructor Summary | |
---|---|
FreezableMutableURI()
Constructs a FreezableMutableURI . |
|
FreezableMutableURI(String uriString,
boolean encoded)
Constructs a FreezableMutableURI . |
|
FreezableMutableURI(String scheme,
String userInfo,
String host,
int port,
String path,
String query,
String fragment)
Constructs a FreezableMutableURI . |
|
FreezableMutableURI(URI uri)
Constructs a FreezableMutableURI . |
|
FreezableMutableURI(URL url)
Constructs a FreezableMutableURI . |
Method Summary | |
---|---|
void |
addParameter(String name,
String value,
boolean encoded)
Add a parameter for the query string. |
void |
addParameters(Map newParams,
boolean encoded)
Add a parameter to the query string. |
boolean |
equals(Object o)
Determines if the passed-in Object is equivalent to this MutableURI. |
int |
hashCode()
Returns a hash code value for the object. |
boolean |
isFrozen()
|
void |
removeParameter(String name)
Removes the given parameter. |
void |
setEncoding(String encoding)
Set the encoding used when adding unencoded parameters. |
void |
setFragment(String fragment)
Sets the fragment. |
void |
setFrozen(boolean frozen)
Sets a flag indicating that the URI is immutable (or not). |
void |
setHost(String host)
Sets the host. |
void |
setOpaque(String scheme,
String schemeSpecificPart)
Sets the URI to be opaque using the given scheme and schemeSpecificPart. |
void |
setPath(String path)
Sets the path. |
void |
setPort(int port)
Sets the port. |
void |
setQuery(String query)
Sets (and resets) the query string. |
void |
setScheme(String scheme)
Sets the protocol/scheme. |
void |
setURI(String uriString,
boolean encoded)
Reset the value of the FreezableMutableURI . |
void |
setUserInfo(String userInfo)
Sets the userInfo. |
Methods inherited from class MutableURI |
---|
encode, encode, encodeURI, getDefaultContext, getEncoding, getFragment, getHost, getParameter, getParameters, getParameters, getPath, getPort, getQuery, getScheme, getSchemeSpecificPart, getURIString, getUserInfo, indexFirstOf, isAbsolute, isOpaque, setSchemeSpecificPart, setURI |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FreezableMutableURI()
FreezableMutableURI
.
public FreezableMutableURI(String uriString, boolean encoded) throws URISyntaxException
FreezableMutableURI
.
uriString
- the string to be parsed into a URIencoded
- Flag indicating whether the string is
already encoded.
URISyntaxException
public FreezableMutableURI(String scheme, String userInfo, String host, int port, String path, String query, String fragment)
FreezableMutableURI
.
scheme
- the name of the protocol to useuserInfo
- the username and passwordhost
- the name of the hostport
- the port number on the hostpath
- the file on the hostquery
- the query part of this URIfragment
- the fragment part of this URI (internal reference in the URL)public FreezableMutableURI(URI uri)
FreezableMutableURI
.
uri
- the initial value for this mutable URIpublic FreezableMutableURI(URL url) throws URISyntaxException
FreezableMutableURI
.
This is just a convenience constructor that functions the same as
FreezableMutableURI(URI)
constructor with
URL.toURI()
as the argument.
Note, any URL instance that complies with RFC 2396 can be converted
to a URI. However, some URLs that are not strictly in compliance
can not be converted to a URI. See URL
url
- the initial value for this mutable URI
URISyntaxException
- if this URL is not formatted strictly
to RFC2396 and cannot be converted to a URI.URL.toURI()
Method Detail |
---|
public final boolean isFrozen()
public void setFrozen(boolean frozen)
frozen
- flag to indicate if the URI is now immutable or not.public void setURI(String uriString, boolean encoded) throws URISyntaxException
FreezableMutableURI
.
This method can also be used to clear the FreezableMutableURI
.
setURI
in class MutableURI
uriString
- the string to be parsed into a URIencoded
- Flag indicating whether the string is
already encoded.
URISyntaxException
public void setEncoding(String encoding)
setEncoding
in class MutableURI
encoding
- public void setScheme(String scheme)
setScheme
in class MutableURI
scheme
- protocol/schemepublic void setUserInfo(String userInfo)
setUserInfo
in class MutableURI
userInfo
- userInfopublic void setHost(String host)
setHost
in class MutableURI
host
- hostpublic void setPort(int port)
setPort
in class MutableURI
port
- portpublic void setPath(String path)
setPath
in class MutableURI
path
- pathpublic void setQuery(String query)
setQuery
in class MutableURI
query
- Query stringpublic void addParameter(String name, String value, boolean encoded)
If the encoded flag is true then this method assumes that the name and value do not need encoding or are already encoded correctly. Otherwise, it translates the name and value with the character encoding of this URI and adds them to the set of parameters for the query. If the encoding for this URI has not been set, then the default encoding used is "UTF-8".
Multiple values for the same parameter can be set by calling this method multiple times with the same name.
addParameter
in class MutableURI
name
- namevalue
- valueencoded
- Flag indicating whether the names and values are
already encoded.public void addParameters(Map newParams, boolean encoded)
If the encoded flag is true then this method assumes that the name and value do not need encoding or are already encoded correctly. Otherwise, it translates the name and value with the character encoding of this URI and adds them to the set of parameters for the query. If the encoding for this URI has not been set, then the default encoding used is "UTF-8".
addParameters
in class MutableURI
newParams
- the map of new parameters to add to the URIencoded
- Flag indicating whether the names and values are
already encoded.public void removeParameter(String name)
removeParameter
in class MutableURI
name
- namepublic void setFragment(String fragment)
setFragment
in class MutableURI
fragment
- fragmentpublic void setOpaque(String scheme, String schemeSpecificPart)
From URI
: "A URI is opaque if, and only
if, it is absolute and its scheme-specific part does not begin with
a slash character ('/'). An opaque URI has a scheme, a
scheme-specific part, and possibly a fragment; all other components
are undefined."
setOpaque
in class MutableURI
scheme
- the scheme component of this URIschemeSpecificPart
- the scheme-specific part of this URIpublic boolean equals(Object o)
MutableURI
equals
in class MutableURI
o
- the Object to test for equality.
public int hashCode()
MutableURI
Implemented in conjunction with equals() override.
This is a mutable class implying that we're basing the hash code on the member data that can change. Therefor it's important not to use this class as a key in a hashtable as it would still appear with an enumeration but not when calling contains. I.E. The object could get lost in the hashtable. A call for the hashcode would return a different value than when it was first placed in the hashtable.
With this in mind, we simply return the same value to support the rules of equality.
hashCode
in class MutableURI
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |