|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.novell.sentinel.uri.GenericURI
public class GenericURI
A class for parsing and rendering URIs as described by RFC 3986.
In addition to the generic URI syntax described the RFC, this class supports the commonly-used query string media type "application/x-www-form-urlencoded" defined by HTML. The default is the HTML form style query.
This class is similar in concept and execution to java.net.URI and exists because java.net.URI class is not available under GWT. Note, however, that unlike java.net.URI, this class's parser does not validate the components it finds. It will not, for example, throw an exception if there is an illegal character in the scheme.
Instances of this class may be used to parse existing URI strings into constituent parts, to build new URI strings from parts, or to parse existing URI strings, modify the URI data, and then build a modified URI string from the result.
More specialized URI classes can be built on top of this class.
Nested Class Summary | |
---|---|
static class |
GenericURI.Authority
A class that manages the authority component of a URI. |
static class |
GenericURI.FormQuery
A class used to parse, store, and output information from the query component of a URI that is interpreted as of the media type "application/x-www-form-urlencoded". |
static class |
GenericURI.Fragment
A class used to parse and output the fragment component of a URI. |
static class |
GenericURI.Path
A class used to parse and store path segments of the path component of a URI. |
static class |
GenericURI.Query
A class supported the generic query string specified by RFC 3986. |
Constructor Summary | |
---|---|
GenericURI()
Construct an empty URI. |
|
GenericURI(GenericURI src)
Make a deep copy of the passed instance. |
|
GenericURI(String uri)
Parse the passed String as a URI and make the components available in the resulting instance. |
Method Summary | |
---|---|
UriConstructor |
appendPath(Collection<String> components)
Append a path to any existing path. |
UriConstructor |
appendPath(String path)
Append a path to any existing path. |
UriConstructor |
appendPathComponent(String pathComponent)
Append a single component of the path to any existing path. |
void |
appendPathComponents(String... pathComponents)
Append multiple path components. |
protected void |
ensureAuthority()
If the private Authority member variable is null, allocate a new Authority instance and set it via setAuthorityImpl. |
protected void |
ensureFragment()
If the private Fragment member variable is null, allocate a new Fragment instance and set it via setFragmentImpl. |
protected void |
ensurePath()
If the private Path member variable is null, allocate a new Path instance and set it via setPathImpl. |
protected void |
ensureQuery()
If the private Query member variable is null, allocate a new Query instance and set it via setQueryImpl. |
protected GenericURI.Authority |
getAuthorityImpl()
Get the private Authority instance. |
String |
getDecodedQuery()
Return the unparsed but percent-decoded query component from the source URI string. |
String |
getFragment()
|
protected GenericURI.Fragment |
getFragmentImpl()
Get the private Fragment instance. |
String |
getHost()
|
List<String> |
getPathComponents()
|
protected GenericURI.Path |
getPathImpl()
Get the private Path instance. |
int |
getPort()
|
protected GenericURI.Query |
getQueryImpl()
Get the private Query instance. |
Map<String,List<String>> |
getQueryItems()
|
String |
getRawAuthority()
Return the raw, unparsed, un-decoded authority component from the source URI string. |
String |
getRawFragment()
Return the raw, unparsed, un-decoded fragment component from the source URI string. |
String |
getRawPath()
Return the raw, unparsed, un-decoded path component from the source URI string. |
String |
getRawQuery()
Return the raw, unparsed, un-decoded query component from the source URI string. |
String |
getScheme()
|
String |
getUserInfo()
|
boolean |
isGenericQuery()
Return true if this instance is treating the query string as a generic string (i.e., not "application/x-www-form-urlencoded"). |
protected void |
parse(String uri)
Parse a string as the basis for this instance. |
protected void |
parseAuthority(String rawAuthority)
Parse the authority component. |
protected void |
parseFragment(String rawFragment)
Parse the fragment component. |
protected void |
parsePath(String rawPath)
Parse the path component. |
protected void |
parseQuery(String rawQuery)
Parse the query component. |
protected void |
parseScheme(String rawScheme)
Parse the scheme component. |
void |
set(String uri)
Set this instance based on the data in the passed URI string. |
protected void |
setAuthorityImpl(GenericURI.Authority authority)
Set the private Authority instance. |
UriConstructor |
setFragment(String fragment)
Set the fragment portion of the URI. |
protected void |
setFragmentImpl(GenericURI.Fragment fragment)
Set the private Fragment instance. |
void |
setGenericQuery(boolean genericQuery)
Set the treatment of the query string. |
void |
setGenericQuery(String genericQuery)
Set the generic query string. |
UriConstructor |
setHost(String host)
Set the host part of the URI authority (e.g., www.novell.com). |
protected void |
setPathImpl(GenericURI.Path path)
Set the private Path instance. |
UriConstructor |
setPort(int port)
Set the port part of the URI authority (e.g., 8443). |
protected void |
setQueryImpl(GenericURI.Query query)
Set the private Query instance. |
UriConstructor |
setQueryItem(String key,
Iterable<String> values)
Set a query item and optional values. |
UriConstructor |
setQueryItem(String key,
String... values)
Set a query item and optional values. |
UriConstructor |
setScheme(String scheme)
Set the URI scheme (e.g., "https"). |
UriConstructor |
setUserInfo(String userInfo)
Set any user information for the URI. |
String |
toString()
Return the string representation of the constructed URI. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GenericURI()
public GenericURI(String uri)
uri
- The URI string to parse.public GenericURI(GenericURI src)
src
- The instance to copy.Method Detail |
---|
public boolean isGenericQuery()
public void setGenericQuery(boolean genericQuery)
If a query string is already associated with this instance, the underlying handling is switched.
genericQuery
- true if the query is to be treated generically.public void set(String uri)
uri
- The URI.public String getScheme()
getScheme
in interface UriDeconstructor
public String getUserInfo()
getUserInfo
in interface UriDeconstructor
public String getHost()
getHost
in interface UriDeconstructor
public int getPort()
getPort
in interface UriDeconstructor
public List<String> getPathComponents()
getPathComponents
in interface UriDeconstructor
public Map<String,List<String>> getQueryItems()
getQueryItems
in interface UriDeconstructor
public String getFragment()
getFragment
in interface UriDeconstructor
public String getRawAuthority()
public String getRawPath()
public String getRawQuery()
public String getDecodedQuery()
Use this if the query string should not be interpreted as "application/x-www-form-urlencoded".
public String getRawFragment()
public UriConstructor setScheme(String scheme)
UriConstructor
setScheme
in interface UriConstructor
scheme
- The scheme name
public UriConstructor setUserInfo(String userInfo)
UriConstructor
setUserInfo
in interface UriConstructor
userInfo
- The user information string.
public UriConstructor setHost(String host)
UriConstructor
setHost
in interface UriConstructor
host
- The host string.
public UriConstructor setPort(int port)
UriConstructor
setPort
in interface UriConstructor
port
- The port value.
public UriConstructor appendPath(String path)
UriConstructor
UriConstructor.appendPathComponent(String)
appendPathComponent).
appendPath
in interface UriConstructor
path
- The path string.
public UriConstructor appendPath(Collection<String> components)
UriConstructor
appendPath
in interface UriConstructor
components
- A collection of components. The components will be appended in the order returned by the Iterator returned by
components.iterator().
public UriConstructor appendPathComponent(String pathComponent)
UriConstructor
appendPathComponent
in interface UriConstructor
pathComponent
- The component value.
public void appendPathComponents(String... pathComponents)
pathComponents
- The path components.public void setGenericQuery(String genericQuery)
genericQuery
- The literal query string.public UriConstructor setQueryItem(String key, String... values)
UriConstructor
setQueryItem
in interface UriConstructor
key
- The name of the query item (e.g., "field" or "query").values
- The value(s) for the query item.
public UriConstructor setQueryItem(String key, Iterable<String> values)
UriConstructor
setQueryItem
in interface UriConstructor
key
- The name of the query item (e.g., "field" or "query").values
- The value(s) for the query item.
public UriConstructor setFragment(String fragment)
UriConstructor
setFragment
in interface UriConstructor
fragment
- The fragment string (not including the '#').
public String toString()
UriConstructor
toString
in interface UriConstructor
toString
in class Object
protected void ensureAuthority()
If a derived class needs to override the base Authority implementation then the derived class must override this method.
protected void ensurePath()
If a derived class needs to override the base Path implementation then the derived class must override this method.
protected void ensureQuery()
If a derived class needs to override the base Query implementation then the derived class must override this method.
protected void ensureFragment()
If a derived class needs to override the base Fragment implementation then the derived class must override this method.
protected GenericURI.Authority getAuthorityImpl()
protected void setAuthorityImpl(GenericURI.Authority authority)
authority
- The Authority instance to set.protected GenericURI.Path getPathImpl()
protected void setPathImpl(GenericURI.Path path)
path
- The Path instance to set.protected GenericURI.Query getQueryImpl()
protected void setQueryImpl(GenericURI.Query query)
query
- The Query instance to set.protected GenericURI.Fragment getFragmentImpl()
protected void setFragmentImpl(GenericURI.Fragment fragment)
fragment
- The Fragment instance to set.protected void parse(String uri)
uri
- The URI string.protected void parseScheme(String rawScheme)
rawScheme
- The scheme component.protected void parseAuthority(String rawAuthority)
rawAuthority
- The encoded authority component string.protected void parsePath(String rawPath)
rawPath
- The encoded path component string.protected void parseQuery(String rawQuery)
rawQuery
- The encoded query component string.protected void parseFragment(String rawFragment)
rawFragment
- The encoded fragment component string.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |