net.ontopia.infoset.impl.basic
Class URILocator

java.lang.Object
  extended by net.ontopia.infoset.impl.basic.AbstractLocator
      extended by net.ontopia.infoset.impl.basic.URILocator
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, LocatorIF

public class URILocator
extends AbstractLocator
implements java.io.Externalizable

PUBLIC: A Uniform Resource Identifier locator. Only URI locators should be used with this locator class. The notation is 'URI'.

The address is always normalized by the constructor. The address given to the constructor must be absolute.

See Also:
Serialized Form

Field Summary
protected  java.lang.String address
           
protected  short authorityEnd
           
protected  short fragmentStart
           
protected  short lastSlash
           
protected  short schemeEnd
           
 
Constructor Summary
  URILocator()
          INTERNAL: No-argument constructor used by serialization.
  URILocator(java.io.File file)
          PUBLIC: Creates a URILocator containing a file URL referring to the file represented by the File object.
  URILocator(java.lang.String address)
          PUBLIC: Creates a URILocator representing the URI given.
protected URILocator(java.lang.String normalized, short schemeEnd, short authorityEnd, short lastSlash, short fragmentStart)
          INTERNAL: Special constructor used when resolving a URI relative to a base URI.
  URILocator(java.net.URL url)
          PUBLIC: Creates a URILocator representing the URL given.
 
Method Summary
static URILocator create(java.lang.String uriAddress)
          INTERNAL: Parses the URI and returns an instance of URILocator if the URI is valid.
 boolean equals(java.lang.Object object)
          PUBLIC: Two LocatorIFs are considered equal if they have the same address and notation properties.
 java.lang.String getAddress()
          PUBLIC: Returns the locator address in absolute and normalized form.
 java.lang.String getExternalForm()
          PUBLIC: Returns the address of the locator in external form; that is, with special characters that need to be escaped escaped using the escape syntax of the locator notation.
 java.lang.String getNotation()
          PUBLIC: Gets the locator notation.
 java.net.URL getURL()
          Deprecated. Because not all URIs can be represented as URL objects.
 int hashCode()
          PUBLIC: Returns the hashcode of the address property.
protected  java.lang.String normalize(java.lang.String address)
           
 int parseDirectoryPart(char[] uri, int ix, int length)
           
 void readExternal(java.io.ObjectInput in)
           
 LocatorIF resolveAbsolute(java.lang.String rel)
          PUBLIC: Given a locator address string that is relative to this locator, return an absolute locator.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class net.ontopia.infoset.impl.basic.AbstractLocator
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

address

protected java.lang.String address

schemeEnd

protected short schemeEnd

authorityEnd

protected short authorityEnd

lastSlash

protected short lastSlash

fragmentStart

protected short fragmentStart
Constructor Detail

URILocator

public URILocator()
INTERNAL: No-argument constructor used by serialization. Do not use this constructor in application code.


URILocator

public URILocator(java.lang.String address)
           throws java.net.MalformedURLException
PUBLIC: Creates a URILocator representing the URI given. Note that the URI string should be in external form, and that it must be absolute.

Throws:
java.net.MalformedURLException

URILocator

public URILocator(java.net.URL url)
           throws java.net.MalformedURLException
PUBLIC: Creates a URILocator representing the URL given.

Throws:
java.net.MalformedURLException

URILocator

public URILocator(java.io.File file)
PUBLIC: Creates a URILocator containing a file URL referring to the file represented by the File object.

Since:
1.3.4

URILocator

protected URILocator(java.lang.String normalized,
                     short schemeEnd,
                     short authorityEnd,
                     short lastSlash,
                     short fragmentStart)
INTERNAL: Special constructor used when resolving a URI relative to a base URI. Since the base URI is already normalized we can avoid repeating the normalization, and thus save time.

Method Detail

normalize

protected java.lang.String normalize(java.lang.String address)
                              throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

getURL

public java.net.URL getURL()
                    throws java.net.MalformedURLException
Deprecated. Because not all URIs can be represented as URL objects.

INTERNAL: Returns the URI as a URL object.

Throws:
java.net.MalformedURLException

getNotation

public java.lang.String getNotation()
Description copied from interface: LocatorIF
PUBLIC: Gets the locator notation. The default notation is URI. Ontopia will never use notation names which begin with 'x-'. Notation names are case-insensitive.

Note that only the URI notation is supported in release OKS 4.0 and newer.

Specified by:
getNotation in interface LocatorIF

getAddress

public java.lang.String getAddress()
Description copied from interface: LocatorIF
PUBLIC: Returns the locator address in absolute and normalized form. Whether addresses are case-sensitive or not depends on the locator notation.

Specified by:
getAddress in interface LocatorIF

resolveAbsolute

public LocatorIF resolveAbsolute(java.lang.String rel)
Description copied from interface: LocatorIF
PUBLIC: Given a locator address string that is relative to this locator, return an absolute locator. If the input locator address is absolute the returned locator object will simply contain that absolute locator address.

Specified by:
resolveAbsolute in interface LocatorIF

getExternalForm

public java.lang.String getExternalForm()
Description copied from interface: LocatorIF
PUBLIC: Returns the address of the locator in external form; that is, with special characters that need to be escaped escaped using the escape syntax of the locator notation.

Specified by:
getExternalForm in interface LocatorIF

parseDirectoryPart

public int parseDirectoryPart(char[] uri,
                              int ix,
                              int length)
                       throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

hashCode

public int hashCode()
Description copied from class: AbstractLocator
PUBLIC: Returns the hashcode of the address property. All subclasses of AbstractLocator must use the same hashCode implementation in order to guarantee interoperability. E.g. when looking up LocatorIFs in Maps.

Overrides:
hashCode in class AbstractLocator

equals

public boolean equals(java.lang.Object object)
Description copied from class: AbstractLocator
PUBLIC: Two LocatorIFs are considered equal if they have the same address and notation properties.

Overrides:
equals in class AbstractLocator

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

create

public static URILocator create(java.lang.String uriAddress)
INTERNAL: Parses the URI and returns an instance of URILocator if the URI is valid. If the URI is invalid null is returned.

Since:
3.0


Copyright © 2000-2012 Ontopia.