|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectscone.netobjects.SimpleUri
public class SimpleUri
This implementation tries to be compliant with RFC2396 (it is not by default, see below!). However, there are some exceptions:
//b
with base http://a/b
will evaluate to http://a//b
../../../g
with base http://a/b
evaluates to http://a/g
http:g
or http:/g
with base http://server/e/f
are considered opaque URIs
Type java SimpleUri
for a reference!
URIs are parsed into the components
scheme:authority/path?query#fragment
URLs are normally interpreted as
protocol:host/path?query#fragment
therefor this class defines methods to access these field virtually.
http - URIs are also parsed into port, file and extension. The port is deleted if it is set to 80, the file is deleted if it starts with "index." "welcome." or "default."
Unfortunately, the Netscape Navigator evaluates relative URIs in a different way than described in RFC2396:
An empty reference with base http://a/b/c/d;p?q
evaluates to http://a/b/c/
This class mimics the behaviour of the Netscape Navigator/ Internet Explorer by default. If you want to have a clean RFC compliant parsing, set the static variable parseNavigatorLike
to false.
Field Summary | |
---|---|
protected java.lang.String |
authority
|
protected SimpleUri |
base
|
protected java.lang.String |
extension
|
protected java.lang.String |
file
|
protected java.lang.String |
fragment
|
protected static java.util.Hashtable |
mimeTypeTable
|
protected java.lang.String |
opaquePart
|
protected java.lang.String |
originalUriString
|
static boolean |
parseNavigatorLike
|
protected java.lang.String |
path
|
protected java.lang.String |
port
|
protected java.lang.String |
query
|
protected java.lang.String |
scheme
|
Constructor Summary | |
---|---|
SimpleUri(SimpleUri base,
java.lang.String uriString)
Create a new SimpleUri to a base URI. |
|
SimpleUri(java.lang.String uriString)
Create a new SimpleUri from a String. |
Method Summary | |
---|---|
boolean |
equals(SimpleUri uri)
Compare this SimpleUri to another SimpleUri. |
boolean |
equals(java.lang.String uriString)
Compare this SimpleUri to another normalized URI. |
protected void |
findPathAndQuery(java.lang.String s,
int j)
|
java.lang.String |
getAuthority()
|
java.lang.String |
getExtension()
returns the file extension of the URI like html, php or asp. |
java.lang.String |
getFile()
|
java.lang.String |
getFragment()
Returns the fragment part of the URI (the string after the # without the #). |
java.lang.String |
getHexHashCode()
Returns a hashcode hex String to this SimpleUri. |
static java.lang.String |
getHexHashCode(java.lang.String uriString)
Returns a hashcode hex String to a SimpleUri String. |
java.lang.String |
getHexHashCodeofHost()
Returns a hashcode hex String to the "scheme:authority:port"-part of the SimpleUri. |
java.lang.String |
getHost()
|
java.lang.String |
getMainHost()
|
java.lang.String |
getMimeType()
This method returns the mime-type of this URI. |
static java.lang.String |
getMimeTypeFromExtension(java.lang.String extension)
This static method returns the appropiete mime-type to a file extension. |
java.lang.String |
getOpaquePart()
|
java.lang.String |
getOriginalUri()
|
java.lang.String |
getPath()
|
java.lang.String |
getPort()
|
java.lang.String |
getProtocol()
|
java.lang.String |
getQuery()
|
java.lang.String |
getRef()
Returns the fragment part of the URI (the string after the # without the #). |
java.lang.String |
getScheme()
|
java.lang.String |
getUri()
return the URI as String. |
static void |
main(java.lang.String[] args)
This main method is only for test purposes! |
protected void |
normalizeHttpUri()
Shorten the URI as much as useful |
protected java.util.Vector |
parseBase(java.lang.String path)
|
protected void |
parseNetPath(java.lang.String s,
int i)
|
protected void |
parseRelativeUri(java.lang.String s)
|
protected void |
parseUri()
|
protected void |
print()
for test purposes: Print original URI and normalized URI |
protected void |
reset()
clear SimpleURI |
java.lang.String |
toDocString()
This method returns the URI without the fragment (``#创) identifyer... |
java.net.URL |
toDocURL()
This method returns the URI without the fragment identifyer... |
java.lang.String |
toHostString()
|
java.lang.String |
toString()
The complete URI is returned (same as getUri()). |
java.net.URL |
toURL()
The complete URI is returned. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.lang.String scheme
protected java.lang.String authority
protected java.lang.String path
protected java.lang.String query
protected java.lang.String fragment
protected java.lang.String opaquePart
protected java.lang.String port
protected java.lang.String file
protected java.lang.String extension
protected java.lang.String originalUriString
protected SimpleUri base
public static boolean parseNavigatorLike
protected static java.util.Hashtable mimeTypeTable
Constructor Detail |
---|
public SimpleUri(SimpleUri base, java.lang.String uriString)
SimpleUri
- baseUriString
- uriStringpublic SimpleUri(java.lang.String uriString)
Method Detail |
---|
public static void main(java.lang.String[] args)
protected void print()
public boolean equals(java.lang.String uriString)
Example:
http://www.scone.de:80/index.html
equals http://www.scone.de/
public boolean equals(SimpleUri uri)
public java.lang.String getPath()
public java.lang.String getQuery()
public java.lang.String getOpaquePart()
public java.lang.String getOriginalUri()
public java.lang.String getUri()
scheme:authority:port/path/file?query#fragment
public java.lang.String getProtocol()
public java.lang.String getScheme()
public java.lang.String getHost()
public java.lang.String getAuthority()
public java.lang.String getMainHost()
public java.lang.String getPort()
public java.lang.String getFile()
public java.lang.String getExtension()
public java.lang.String getRef()
public java.lang.String getFragment()
public java.lang.String toString()
scheme:authority:port/path/file?query#fragment
toString
in class java.lang.Object
public java.lang.String toDocString()
public java.net.URL toURL()
scheme:authority:port/path/file?query#fragment
public java.net.URL toDocURL()
public java.lang.String toHostString()
public java.lang.String getHexHashCode()
public java.lang.String getHexHashCodeofHost()
public static java.lang.String getHexHashCode(java.lang.String uriString)
String
object is computed as
usings[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
long
arithmetic, where s[i]
is the
ith character of the SimpleUri, n
is the length of
the Uri, and ^
indicates exponentiation.
public java.lang.String getMimeType()
public static java.lang.String getMimeTypeFromExtension(java.lang.String extension)
extension
- the extension of the file or Urlprotected void reset()
protected void parseUri()
protected void parseNetPath(java.lang.String s, int i)
protected void parseRelativeUri(java.lang.String s)
protected java.util.Vector parseBase(java.lang.String path)
protected void findPathAndQuery(java.lang.String s, int j)
protected void normalizeHttpUri()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |