Class AddressParser
- java.lang.Object
-
- org.simpleframework.common.parse.Parser
-
- org.simpleframework.http.parse.AddressParser
-
- All Implemented Interfaces:
Address
public class AddressParser extends Parser implements Address
This parser is used to parse uniform resource identifiers. The uniform resource identifier syntax is given in RFC 2396. This parser can parse relative and absolute URI's. The uniform resource identifier syntax that this parser will parse are based on the generic web based URL similar to the syntax represented in RFC 2616 section 3.2.2. The syntax used to parse this URI is a modified version of RFC 2396URI = (absoluteURI | relativeURI) absoluteURI = scheme ":" ("//" netpath | relativeURI) relativeURI = path ["?" querypart] netpath = domain [":" port] relativeURI path = *("/" segment) segment = *pchar *( ";" param )
This implements theAddress
interface and provides methods that access the various parts of the URI. The parameters in the path segments of the uniform resource identifier are stored in name value pairs. If parameter names are not unique across the path segments then only the deepest parameter will be stored from the path segment. For example if the URI represented washttp://domain/path1;x=y/path2;x=z
the value for the parameter namedx
would bez
.This will normalize the path part of the uniform resource identifier. A normalized path is one that contains no back references like "./" and "../". The normalized path will not contain the path parameters.
The
setPath
method is used to reset the path this uniform resource identifier has, it also resets the parameters. The parameters are extracted from the new path given.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
AddressParser.ParameterMap
TheParameterMap
is uses to store the parameters that are to be encoded in to the address.private class
AddressParser.Token
This is used as an alternative to theParseBuffer
for extracting tokens from the URI without allocating memory.
-
Field Summary
Fields Modifier and Type Field Description private Query
data
This contains the query parameters for the address.private AddressParser.Token
domain
Used to track the characters that form the domain.private AddressParser.Token
name
Used to track the name characters of a parameter.private Path
normal
This is the path used to represent the address path.private AddressParser.ParameterMap
param
Parameters are stored so that the can be viewed.private AddressParser.Token
path
Used to track the characters that form the path.private int
port
Contains the port number if it was specified.private AddressParser.Token
query
Used to track the characters that form the query.private AddressParser.Token
scheme
References the scheme that this URI contains.private AddressParser.Token
value
Used to track the value characters of a parameter.
-
Constructor Summary
Constructors Constructor Description AddressParser()
Default constructor will create aAddressParser
that contains no specifics.AddressParser(java.lang.String text)
This is primarily a convenience constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
absoluteURI()
This is a specific definition of a type of URI.private boolean
alpha(char c)
This is used to determine wheather or not a given unicode character is an alphabetic character.private boolean
alphanum(char c)
This is used to determine wheather or not a given unicode character is an alphabetic character or a digit character.private boolean
binary(int peek)
This method determines, using a peek character, whether the sequence of escaped characters within the URI is binary data.private char
bits(int data)
Defines behaviour for UCS-2 versus UCS-4 conversion from four octets.private int
convert(char high, char low)
This will convert the two hexidecimal characters to a real integer value, which is returned.private void
domain()
This is used to extract the domain from the given URI.private void
escape()
This converts an encountered escaped sequence, that is all embedded hexidecimal characters into a native UCS character value.java.lang.String
getDomain()
This is used to retrieve the domain of this URI.KeyMap<java.lang.String>
getParameters()
This extracts the parameter values from the uniform resource identifier represented by this object.Path
getPath()
This is used to retrieve the path of this URI.int
getPort()
This is used to retrieve the port of the uniform resource identifier.Query
getQuery()
This is used to retrieve the query of this URI.java.lang.String
getScheme()
This allows the scheme of the URL given to be returned.private boolean
hex(char ch)
This is used to determine wheather a char is a hexidecimalchar
or not.private void
hostPort()
This is used to extract the host and port combination.protected void
init()
This will empty each tokens cache.private void
insert()
This method adds the name and value to a map so that the next name and value can be collected.private void
insert(java.lang.String name, java.lang.String value)
This will add the given name and value to the parameters map.private void
insert(AddressParser.Token name, AddressParser.Token value)
This will add the given name and value to the parameters map.private boolean
mark(char c)
This is a character set defined by RFC 2396 it checks the valididity of cetain chars within a uniform resource identifier.private void
name()
This extracts the name of the parameter from the character buffer.private void
netPath()
The network path is the path that contains the network address of the host that this URI is targeted at.private void
param()
This is an expression that is defined by RFC 2396 it is used in the definition of a segment expression.protected void
parse()
This will check to see what type of URI this is if it is anabsoluteURI
or arelativeURI
.private void
parseDomain(java.lang.String value)
This will set the domain to whatever value is in the string parameter.private void
parsePath(java.lang.String path)
This is used to parse the path given with thesetPath
method.private void
path()
This is used to extract the segments from the given URI.private boolean
pchar(char c)
This is a character set defined by RFC 2396 it is used to check the valididity of cetain chars within a generic uniform resource identifier.private int
peek(int pos)
This will return the escape expression specified from the URI as an integer value of the hexidecimal sequence.private void
port()
This is used to extract the optional port from a given URI.private void
query()
This is used to extract the query from the given URI.private void
relativeURI()
This is a specific definition of a type of URI.private boolean
reserved(char c)
This is a character set defined by RFC 2396, it checks the valididity of certain chars in a uniform resource identifier.private void
scheme()
This will check to see if there is a scheme in the URI.private boolean
schemeChar(char c)
This method is used to assist the scheme method.void
setDomain(java.lang.String value)
This will set the domain to whatever value is in the string parameter.void
setPath(java.lang.String text)
This will set the path to whatever value it is given.void
setPath(Path path)
This will set the path to whatever value it is given.void
setPort(int port)
This will set the port to whatever value it is given.void
setQuery(java.lang.String value)
This will set the query to whatever value it is given.void
setQuery(Query query)
This will set the query to whatever value it is given.void
setScheme(java.lang.String value)
This allows the scheme for the URI to be specified.java.lang.String
toString()
This is used to convert this URI object into aString
object.private boolean
unicode(int peek)
This method determines, using a peek character, whether the sequence of escaped characters within the URI is in UTF-8.private boolean
unicode(int peek, int more)
This method will decode the specified amount of escaped characters from the URI and convert them into a single Java UCS-2 character.private boolean
unicode(int peek, int more, int pos)
This will decode the specified amount of trailing UTF-8 bits from the URI.private boolean
unreserved(char c)
This is a character set defined by RFC 2396 it is used to determine the valididity of certainchars
within a Uniform Resource Identifier.private void
value()
This extracts a parameter value from a path segment.
-
-
-
Field Detail
-
param
private AddressParser.ParameterMap param
Parameters are stored so that the can be viewed.
-
normal
private Path normal
This is the path used to represent the address path.
-
data
private Query data
This contains the query parameters for the address.
-
path
private AddressParser.Token path
Used to track the characters that form the path.
-
domain
private AddressParser.Token domain
Used to track the characters that form the domain.
-
query
private AddressParser.Token query
Used to track the characters that form the query.
-
name
private AddressParser.Token name
Used to track the name characters of a parameter.
-
value
private AddressParser.Token value
Used to track the value characters of a parameter.
-
scheme
private AddressParser.Token scheme
References the scheme that this URI contains.
-
port
private int port
Contains the port number if it was specified.
-
-
Constructor Detail
-
AddressParser
public AddressParser()
Default constructor will create aAddressParser
that contains no specifics. The instance will returnnull
for all the get methods. The parsers get methods are populated by using theparse
method.
-
AddressParser
public AddressParser(java.lang.String text)
This is primarily a convenience constructor. This will parse theString
given to extract the specifics. This could be achieved by calling the default no-arg constructor and then using the instance to invoke theparse
method on thatString
to extract the parts.- Parameters:
text
- aString
containing a URI value
-
-
Method Detail
-
getScheme
public java.lang.String getScheme()
This allows the scheme of the URL given to be returned. If the URI does not contain a scheme then this will return null. The scheme of the URI is the part that specifies the type of protocol that the URI is used for, an examplegopher://domain/path
is a URI that is intended for the gopher protocol. The scheme is the stringgopher
.
-
getDomain
public java.lang.String getDomain()
This is used to retrieve the domain of this URI. The domain part in the URI is an optional part, an examplehttp://domain/path?querypart
. This will return the value of the domain part. If there is no domain part then this will return null otherwise the domain value found in the uniform resource identifier.
-
getPath
public Path getPath()
This is used to retrieve the path of this URI. The path part is the most fundamental part of the URI. This will return the value of the path. If there is no path part then this will return/
to indicate the root.The
Path
object returned by this will contain no path parameters. The path parameters are available using theAddress
methods. The reason that this does not contain any of the path parameters is so that if the path is needed to be converted into an OS specific path then the path parameters will not need to be separately parsed out.
-
getQuery
public Query getQuery()
This is used to retrieve the query of this URI. The query part in the URI is an optional part. This will return the value of the query part. If there is no query part then this will return an emptyQuery
object. The query is an optional member of a URI and comes after the path part, it is preceded by a question mark,?
character. For example the following URI containsquery
for its query part,http://host:port/path?query
.This returns a
org.simpleframework.http.Query
object that can be used to interact directly with the query values. TheQuery
object is a read-only interface to the query parameters, and so will not affect the URI.
-
getPort
public int getPort()
This is used to retrieve the port of the uniform resource identifier. The port part in this is an optional part, an examplehttp://host:port/path?querypart
. This will return the value of the port. If there is no port then this will return-1
because this represents an impossible uniform resource identifier port. The port is an optional part.
-
getParameters
public KeyMap<java.lang.String> getParameters()
This extracts the parameter values from the uniform resource identifier represented by this object. The parameters that a uniform resource identifier contains are embedded in the path part of the URI. If the path contains no parameters then this will return an emptyMap
instance.This will produce unique name and value parameters. Thus if the URI contains several path segments with similar parameter names this will return the deepest parameter. For example if the URI represented was
http://domain/path1;x=y/path2;x=z
the value for the parameter namedx
would bez
.- Specified by:
getParameters
in interfaceAddress
- Returns:
- this will return the parameter names found in the URI
-
setScheme
public void setScheme(java.lang.String value)
This allows the scheme for the URI to be specified. If the URI does not contain a scheme then this will attach the scheme and the://
identifier to ensure that theAddress.toString
will produce the correct syntax.Caution must be taken to ensure that the port and the scheme are consistent. So if the original URI was
http://domain:80/path
and the scheme was changed toftp
the port number that remains is the standard HTTP port not the FTP port.- Parameters:
value
- this specifies the protocol this URI is intended for
-
setDomain
public void setDomain(java.lang.String value)
This will set the domain to whatever value is in the string parameter. If the string is null then this URI objectstoString
method will not contain the domain. The result of thetoString
method will be/path/path?query
. If the path is non-null this URI will contain the path.- Parameters:
value
- this will be the new domain of this uniform resource identifier, if it is not null
-
parseDomain
private void parseDomain(java.lang.String value)
This will set the domain to whatever value is in the string parameter. If the string is null then this URI objectstoString
method will not contain the domain. The result of thetoString
method will be/path/path?query
. If the path is non-null this URI will contain the path.- Parameters:
value
- this will be the new domain of this uniform resource identifier, if it is not null
-
setPort
public void setPort(int port)
This will set the port to whatever value it is given. If the value is 0 or less then thetoString
will will not contain the optional port. If port number is above 0 then thetoString
method will produce a URI likehttp://host:123/path
but only if there is a valid domain.- Parameters:
port
- the port value that this URI is to have
-
setPath
public void setPath(java.lang.String text)
This will set the path to whatever value it is given. If the value is null then thisAddress.toString
method will not contain the path, that is if path is null then it will be interpreted as/
.This will reset the parameters this URI has. If the value given to this method has embedded parameters these will form the parameters of this URI. The value given may not be the same value that the
getPath
produces. The path will have all back references and parameters stripped.- Parameters:
text
- the path that this URI is to be set with
-
setPath
public void setPath(Path path)
This will set the path to whatever value it is given. If the value is null then thisAddress.toString
method will not contain the path, that is if path is null then it will be interpreted as/
.This will reset the parameters this URI has. If the value given to this method has embedded parameters these will form the parameters of this URI. The value given may not be the same value that the
getPath
produces. The path will have all back references and parameters stripped.- Parameters:
path
- the path that this URI is to be set with
-
parsePath
private void parsePath(java.lang.String path)
This is used to parse the path given with thesetPath
method. The path contains name and value pairs. These parameters are embedded into the path segments using a semicolon character, ';'. Since the parameters to not form part of the actual path mapping they are removed from the path and stored. Each parameter can then be extracted from this parser using the methods provided by theAddress
interface.- Parameters:
path
- this is the path that is to be parsed and have the parameter values extracted
-
setQuery
public void setQuery(java.lang.String value)
This will set the query to whatever value it is given. If the value is null then thisAddress.toString
method will not contain the query. If the query wasabc
then thetoString
method would produce a string likehttp://host:port/path?abc
. If the query is null this URI would have no query part. The query must not contain the?
character.- Parameters:
value
- the query that this uniform resource identifier is to be set to if it is non-null
-
setQuery
public void setQuery(Query query)
This will set the query to whatever value it is given. If the value is null then thisAddress.toString
method will not contain the query. If theQuery.toString
returns null then the query will be empty. This is basically thesetQuery(String)
method with the string value from the issuedQuery.toString
method.- Parameters:
query
- aQuery
object that contains the name value parameters for the query
-
parse
protected void parse()
This will check to see what type of URI this is if it is anabsoluteURI
or arelativeURI
. To see the definition of a URI see RFC 2616 for the definition of a URL and for more specifics see RFC 2396 for the expressions.
-
init
protected void init()
This will empty each tokens cache. A tokens cache is used to represent a token once the token'stoString
method has been called. Thus when thetoString
method is called then the token depends on the value of the cache alone in further calls totoString
. However if a URI has just been parsed and that method has not been invoked then the cache is created from the buf if its length is greater than zero.
-
absoluteURI
private void absoluteURI()
This is a specific definition of a type of URI. An absolute URI is a URI that contains a host and port. It is the most frequently used type of URI. This will define the host and the optional port part. As well as the relative URI part. This uses a simpler syntax than the one specified in RFC 2396
This syntax is sufficient to handle HTTP style URI's as well as GOPHER and FTP and various other 'simple' schemes. See RFC 2396 for the syntax of anabsoluteURI = scheme ":" ("//" netpath | relativeURI) relativeURI = path ["?" querypart] netpath = domain [":" port] relativeURI path = *("/" segment) segment = *pchar *( ";" param )
absoluteURI
.
-
scheme
private void scheme()
This will check to see if there is a scheme in the URI. If there is a scheme found in the URI this returns true and removes that scheme tag of the form "ftp:" or "http:" or whatever the protocol scheme tag may be for the URI.The syntax for the scheme is given in RFC 2396 as follows
This will however also skips the "://" from the tag so of the URI wasscheme = alpha *( alpha | digit | "+" | "-" | "." )
gopher://domain/path
then the URI would bedomain/path
afterwards.
-
schemeChar
private boolean schemeChar(char c)
This method is used to assist the scheme method. This will check to see if the type of the character is the same as those described in RFC 2396 for a scheme character. The scheme tag can contain an alphanumeric of the following"+", "-", "."
.- Parameters:
c
- this is the character that is being checked- Returns:
- this returns true if the character is a valid scheme character
-
netPath
private void netPath()
The network path is the path that contains the network address of the host that this URI is targeted at. This will parse the domain name of the host and also a port number before parsing a relativeURI
This syntax is modified from the URI specification on RFC 2396.netpath = domain [":" port] relativeURI
-
hostPort
private void hostPort()
This is used to extract the host and port combination. Typically a URI will not explicitly specify a port, however if there is a semicolon at the end of the domain it should be interpreted as the port part of the URI.
-
relativeURI
private void relativeURI()
This is a specific definition of a type of URI. A relative URI is a URI that contains no host or port. It is basically the resource within the host. This will extract the path and the optional query part of the URI. Rfc2396 has the proper definition of arelativeURI
.
-
port
private void port()
This is used to extract the optional port from a given URI. This will read a sequence of digit characters and convert theString
of digit characters into a decimal number. The digits will be added to the port variable. If there is no port number this will not update the read offset.
-
domain
private void domain()
This is used to extract the domain from the given URI. This will firstly initialize the token object that represents the domain. This allows the token'stoString
method to return the extracted value of the token rather than getting confused with previous values set by a previous parse method.This uses the following delimiters to determine the end of the domain
?
,:
and/
. This ensures that the read offset does not go out of bounds and consequently throw an
IndexOutOfBoundsException
.
-
path
private void path()
This is used to extract the segments from the given URI. This will firstly initialize the token object that represents the path. This allows the token'stoString
method to return the extracted value of the token rather than getting confused with previous values set by a previous parse method.This is slightly different from RFC 2396 in that it defines a pchar as the RFC 2396 definition of a pchar without the escaped chars. So this method has to ensure that no escaped chars go unchecked. This ensures that the read offset does not go out of bounds and throw an
IndexOutOfBoundsException
.
-
query
private void query()
This is used to extract the query from the given URI. This will firstly initialize the token object that represents the query. This allows the token'stoString
method to return the extracted value of the token rather than getting confused with previous values set by a previous parse method. The calculation of the query part of a URI is basically the end of the URI.
-
param
private void param()
This is an expression that is defined by RFC 2396 it is used in the definition of a segment expression. This is basically a list of pchars.This method has to ensure that no escaped chars go unchecked. This ensures that the read offset does not goe out of bounds and consequently throw an out of bounds exception.
-
name
private void name()
This extracts the name of the parameter from the character buffer. The name of a parameter is defined as a set of pchars including escape sequences. This will extract the parameter name and buffer the chars. The name ends when a equals character, "=", is encountered or in the case of a malformed parameter when the next character is not a pchar.
-
value
private void value()
This extracts a parameter value from a path segment. The parameter value consists of a sequence of pchars and some escape sequences. The parameter value is buffered so that the name and values can be paired. The end of the value is determined as the end of the buffer or the last pchar.
-
insert
private void insert()
This method adds the name and value to a map so that the next name and value can be collected. The name and value are added to the map as string objects. Once added to the map theToken
objects are set to have zero length so they can be reused to collect further values. This will add the values to the map as an array of type string. This is done so that if there are multiple values that they can be stored.
-
insert
private void insert(AddressParser.Token name, AddressParser.Token value)
This will add the given name and value to the parameters map. This will only store a single value per parameter name, so only the parameter that was latest encountered will be saved. ThegetQuery
method can be used to collect the parameter values using the parameter name.- Parameters:
name
- this is the name of the value to be insertedvalue
- this is the value of a that is to be inserted
-
insert
private void insert(java.lang.String name, java.lang.String value)
This will add the given name and value to the parameters map. This will only store a single value per parameter name, so only the parameter that was latest encountered will be saved. ThegetQuery
method can be used to collect the parameter values using the parameter name.- Parameters:
name
- this is the name of the value to be insertedvalue
- this is the value of a that is to be inserted
-
escape
private void escape()
This converts an encountered escaped sequence, that is all embedded hexidecimal characters into a native UCS character value. This does not take any characters from the stream it just prepares the buffer with the correct byte. The escaped sequence within the URI will be interpreded as UTF-8.This will leave the next character to read from the buffer as the character encoded from the URI. If there is a fully valid escaped sequence, that is
"%" HEX HEX
. This decodes the escaped sequence using UTF-8 encoding, all encoded sequences should be in UCS-2 to fit in a Java char.
-
binary
private boolean binary(int peek)
This method determines, using a peek character, whether the sequence of escaped characters within the URI is binary data. If the data within the escaped sequence is binary then this will ensure that the next character read from the URI is the binary octet. This is used strictly for backward compatible parsing of URI strings, binary data should never appear.- Parameters:
peek
- this is the first escaped character from the URI- Returns:
- currently this implementation always returns true
-
unicode
private boolean unicode(int peek)
This method determines, using a peek character, whether the sequence of escaped characters within the URI is in UTF-8. If a UTF-8 character can be successfully decoded from the URI it will be the next character read from the buffer. This can check for both UCS-2 and UCS-4 characters. However, because the Javachar
can only hold UCS-2, the UCS-4 characters will have only the low order octets stored.The WWW Consortium provides a reference implementation of a UTF-8 decoding for Java, in this the low order octets in the UCS-4 sequence are used for the character. So, in the absence of a defined behaviour, the W3C behaviour is assumed.
- Parameters:
peek
- this is the first escaped character from the URI- Returns:
- this returns true if a UTF-8 character is decoded
-
unicode
private boolean unicode(int peek, int more)
This method will decode the specified amount of escaped characters from the URI and convert them into a single Java UCS-2 character. If there are not enough characters within the URI then this will return false and leave the URI alone.The number of characters left is determined from the first UTF-8 octet, as specified in RFC 2279, and because this is a URI there must that number of
"%" HEX HEX
sequences left. If successful the next character read is the UTF-8 sequence decoded into a native UCS-2 character.- Parameters:
peek
- contains the bits read from the first UTF octetmore
- this specifies the number of UTF octets left- Returns:
- this returns true if a UTF-8 character is decoded
-
unicode
private boolean unicode(int peek, int more, int pos)
This will decode the specified amount of trailing UTF-8 bits from the URI. The trailing bits are those following the first UTF-8 octet, which specifies the length, in octets, of the sequence. The trailing octets are if the form 10xxxxxx, for each of these octets only the last six bits are valid UCS bits. So a conversion is basically an accumulation of these.If at any point during the accumulation of the UTF-8 bits there is a parsing error, then parsing is aborted an false is returned, as a result the URI is left unchanged.
- Parameters:
peek
- bytes that have been accumulated from the URImore
- this specifies the number of UTF octets leftpos
- this specifies the position the parsing begins- Returns:
- this returns true if a UTF-8 character is decoded
-
bits
private char bits(int data)
Defines behaviour for UCS-2 versus UCS-4 conversion from four octets. The UTF-8 encoding scheme enables UCS-4 characters to be encoded and decodeded. However, Java supports the 16-bit UCS-2 character set, and so the 32-bit UCS-4 character set is not compatable. This basically decides what to do with UCS-4.- Parameters:
data
- up to four octets to be converted to UCS-2 format- Returns:
- this returns a native UCS-2 character from the int
-
peek
private int peek(int pos)
This will return the escape expression specified from the URI as an integer value of the hexidecimal sequence. This does not make any changes to the buffer it simply checks to see if the characters at the position specified are an escaped set characters of the form"%" HEX HEX
, if so, then it will convert that hexidecimal string in to an integer value, or -1 if the expression is not hexidecimal.- Parameters:
pos
- this is the position the expression starts from- Returns:
- the integer value of the hexidecimal expression
-
convert
private int convert(char high, char low)
This will convert the two hexidecimal characters to a real integer value, which is returned. This requires characters within the range of 'A' to 'F' and 'a' to 'f', and also the digits '0' to '9'. The characters encoded using the ISO-8859-1 encoding scheme, if the characters are not with in the range specified then this returns -1.- Parameters:
high
- this is the high four bits within the integerlow
- this is the low four bits within the integer- Returns:
- this returns the indeger value of the conversion
-
hex
private boolean hex(char ch)
This is used to determine wheather a char is a hexidecimalchar
or not. A hexidecimal character is consdered to be a character within the range of0 - 9
and betweena - f
andA - F
. This will returntrue
if the character is in this range.- Parameters:
ch
- this is the character which is to be determined here- Returns:
- true if the character given has a hexidecimal value
-
unreserved
private boolean unreserved(char c)
This is a character set defined by RFC 2396 it is used to determine the valididity of certainchars
within a Uniform Resource Identifier. RFC 2396 defines an unreserved char asalphanum | mark
.- Parameters:
c
- the character value that is being checked- Returns:
- true if the character has an unreserved value
-
alphanum
private boolean alphanum(char c)
This is used to determine wheather or not a given unicode character is an alphabetic character or a digit character. That is withing the range0 - 9
and betweena - z
it usesiso-8859-1
to compare the character.- Parameters:
c
- the character value that is being checked- Returns:
- true if the character has an alphanumeric value
-
alpha
private boolean alpha(char c)
This is used to determine wheather or not a given unicode character is an alphabetic character. This uses encodingiso-8859-1
to compare the characters.- Parameters:
c
- the character value that is being checked- Returns:
- true if the character has an alphabetic value
-
mark
private boolean mark(char c)
This is a character set defined by RFC 2396 it checks the valididity of cetain chars within a uniform resource identifier. The RFC 2396 defines a mark char as"-", "_", ".", "!", "~", "*", "'", "(", ")"
.- Parameters:
c
- the character value that is being checked- Returns:
- true if the character is a mark character
-
pchar
private boolean pchar(char c)
This is a character set defined by RFC 2396 it is used to check the valididity of cetain chars within a generic uniform resource identifier. The RFC 2396 defines a pchar char as unreserved or escaped or one of the following characters":", "@", "=", "&", "+", "$", ","
this will not check to see if the char is an escaped char, that is% HEX HEX
. Because this takes 3 chars.- Parameters:
c
- the character value that is being checked- Returns:
- true if the character is a pchar character
-
reserved
private boolean reserved(char c)
This is a character set defined by RFC 2396, it checks the valididity of certain chars in a uniform resource identifier. The RFC 2396 defines a reserved char as";", "/", "?", ":", "@", "&", "=", "+", "$", ","
.- Parameters:
c
- the character value that is being checked- Returns:
- true if the character is a reserved character
-
toString
public java.lang.String toString()
This is used to convert this URI object into aString
object. This will only convert the parts of the URI that exist, so the URI may not contain the domain or the query part and it will not contain the path parameters. If the URI contains all these parts then it will return somthing likescheme://host:port/path/path?querypart
It can return
/path/path?querypart
style relative URI's. If any of the parts are set to null then that part will be missing, for example ifsetDomain
method is invoked with a null parameter then the domain and port will be missing from the resulting URI. If the path part is set to null using thesetPath
then the path will be/
. An example URI with the path part of null would bescheme://host:port/?querypart
-
-