Package net.ontopia.infoset.impl.basic
Class URILocator
- java.lang.Object
-
- net.ontopia.infoset.impl.basic.AbstractLocator
-
- net.ontopia.infoset.impl.basic.URILocator
-
- All Implemented Interfaces:
Externalizable,Serializable,LocatorIF
public class URILocator extends AbstractLocator implements 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
Fields Modifier and Type Field Description protected Stringaddressprotected shortauthorityEndprotected shortfragmentStartprotected shortlastSlashprotected shortschemeEnd
-
Constructor Summary
Constructors Modifier Constructor Description URILocator()INTERNAL: No-argument constructor used by serialization.URILocator(File file)PUBLIC: Creates a URILocator containing a file URL referring to the file represented by the File object.URILocator(String address)PUBLIC: Creates a URILocator representing the URI given.protectedURILocator(String normalized, short schemeEnd, short authorityEnd, short lastSlash, short fragmentStart)INTERNAL: Special constructor used when resolving a URI relative to a base URI.URILocator(URL url)PUBLIC: Creates a URILocator representing the URL given.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static URILocatorcreate(String uriAddress)INTERNAL: Parses the URI and returns an instance of URILocator if the URI is valid.booleanequals(Object object)PUBLIC: Two LocatorIFs are considered equal if they have the same address and notation properties.StringgetAddress()PUBLIC: Returns the locator address in absolute and normalized form.StringgetExternalForm()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.StringgetNotation()PUBLIC: Gets the locator notation.inthashCode()PUBLIC: Returns the hashcode of the address property.protected Stringnormalize(String address)intparseDirectoryPart(char[] uri, int ix, int length)voidreadExternal(ObjectInput in)LocatorIFresolveAbsolute(String rel)PUBLIC: Given a locator address string that is relative to this locator, return an absolute locator.protected static StringtoExternalForm(String address)voidwriteExternal(ObjectOutput out)-
Methods inherited from class net.ontopia.infoset.impl.basic.AbstractLocator
toString
-
-
-
-
Field Detail
-
address
protected 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(String address) throws 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:
MalformedURLException
-
URILocator
public URILocator(URL url) throws MalformedURLException
PUBLIC: Creates a URILocator representing the URL given.- Throws:
MalformedURLException
-
URILocator
public URILocator(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(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 String normalize(String address) throws MalformedURLException
- Throws:
MalformedURLException
-
getNotation
public String getNotation()
Description copied from interface:LocatorIFPUBLIC: 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:
getNotationin interfaceLocatorIF
-
getAddress
public String getAddress()
Description copied from interface:LocatorIFPUBLIC: Returns the locator address in absolute and normalized form. Whether addresses are case-sensitive or not depends on the locator notation.- Specified by:
getAddressin interfaceLocatorIF
-
resolveAbsolute
public LocatorIF resolveAbsolute(String rel)
Description copied from interface:LocatorIFPUBLIC: 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:
resolveAbsolutein interfaceLocatorIF
-
getExternalForm
public String getExternalForm()
Description copied from interface:LocatorIFPUBLIC: 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:
getExternalFormin interfaceLocatorIF
-
parseDirectoryPart
public int parseDirectoryPart(char[] uri, int ix, int length) throws MalformedURLException- Throws:
MalformedURLException
-
hashCode
public int hashCode()
Description copied from class:AbstractLocatorPUBLIC: 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:
hashCodein classAbstractLocator
-
equals
public boolean equals(Object object)
Description copied from class:AbstractLocatorPUBLIC: Two LocatorIFs are considered equal if they have the same address and notation properties.- Overrides:
equalsin classAbstractLocator
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
create
public static URILocator create(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
-
-