gnu.text
Class Path

java.lang.Object
  extended by gnu.text.Path
Direct Known Subclasses:
FilePath, URIPath

public abstract class Path
extends java.lang.Object

A generalized path/location, including File and URIs.


Field Summary
static Path defaultPath
           
static FilePath userDirPath
          This is equivalent to the System "user.dir property.
 
Constructor Summary
protected Path()
           
 
Method Summary
static Path coerceToPathOrNull(java.lang.Object path)
           
static Path currentPath()
           
 boolean exists()
           
 Path getAbsolute()
           
 java.lang.String getAuthority()
           
 Path getCanonical()
           
 long getContentLength()
           
 Path getDirectory()
           
 java.lang.String getExtension()
           
 java.lang.String getFragment()
           
 java.lang.String getHost()
           
 java.lang.String getLast()
           
abstract  long getLastModified()
           
 Path getParent()
           
abstract  java.lang.String getPath()
           
 int getPort()
           
 java.lang.String getQuery()
           
abstract  java.lang.String getScheme()
           
 java.lang.String getUserInfo()
           
abstract  boolean isAbsolute()
           
 boolean isDirectory()
          Does this path name a directory? The default implementation returns true only if the path ends with '/' or the separatorChar.
abstract  java.io.InputStream openInputStream()
           
static java.io.InputStream openInputStream(java.lang.Object uri)
           
abstract  java.io.OutputStream openOutputStream()
           
static java.lang.String relativize(java.lang.String in, java.lang.String base)
          Convert an absolute URI to one relatve to a given base.
 Path resolve(Path relative)
           
abstract  Path resolve(java.lang.String relative)
           
static void setCurrentPath(Path path)
           
abstract  java.net.URI toURI()
           
 java.lang.String toURIString()
           
abstract  java.net.URL toURL()
           
static java.net.URL toURL(java.lang.String str)
           
static int uriSchemeLength(java.lang.String uri)
          Helper routine to get the scheme part of a URI.
static boolean uriSchemeSpecified(java.lang.String name)
          Tests if a URL has a scheme.
static Path valueOf(java.lang.Object arg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userDirPath

public static final FilePath userDirPath
This is equivalent to the System "user.dir property. However, the getProperty is tracked dynamically and resolved as needed.


defaultPath

public static Path defaultPath
Constructor Detail

Path

protected Path()
Method Detail

currentPath

public static Path currentPath()

setCurrentPath

public static void setCurrentPath(Path path)

coerceToPathOrNull

public static Path coerceToPathOrNull(java.lang.Object path)

valueOf

public static Path valueOf(java.lang.Object arg)

toURL

public static java.net.URL toURL(java.lang.String str)

uriSchemeLength

public static int uriSchemeLength(java.lang.String uri)
Helper routine to get the scheme part of a URI. The scheme part is "http:" or "file:" or "ftp:" most commonly. This functions searches for the first ':' that doesn't follow a '/'.

Returns:
The length of the scheme component, not counting the colon, (or alternatively the index of the colon), or -1 if the is no scheme.

uriSchemeSpecified

public static boolean uriSchemeSpecified(java.lang.String name)
Tests if a URL has a scheme. For convenience, we treat a 1-character "scheme" as an MS-DOS-style "drive letter" - i.e. not a scheme.


isAbsolute

public abstract boolean isAbsolute()

isDirectory

public boolean isDirectory()
Does this path name a directory? The default implementation returns true only if the path ends with '/' or the separatorChar.


exists

public boolean exists()

getLastModified

public abstract long getLastModified()

getContentLength

public long getContentLength()

getScheme

public abstract java.lang.String getScheme()

getAuthority

public java.lang.String getAuthority()

getUserInfo

public java.lang.String getUserInfo()

getHost

public java.lang.String getHost()

getPath

public abstract java.lang.String getPath()

getDirectory

public Path getDirectory()

getParent

public Path getParent()

getLast

public java.lang.String getLast()

getExtension

public java.lang.String getExtension()

getPort

public int getPort()

getQuery

public java.lang.String getQuery()

getFragment

public java.lang.String getFragment()

toURL

public abstract java.net.URL toURL()

toURI

public abstract java.net.URI toURI()

toURIString

public java.lang.String toURIString()

resolve

public Path resolve(Path relative)

resolve

public abstract Path resolve(java.lang.String relative)

openInputStream

public static java.io.InputStream openInputStream(java.lang.Object uri)
                                           throws java.io.IOException
Throws:
java.io.IOException

openInputStream

public abstract java.io.InputStream openInputStream()
                                             throws java.io.IOException
Throws:
java.io.IOException

openOutputStream

public abstract java.io.OutputStream openOutputStream()
                                               throws java.io.IOException
Throws:
java.io.IOException

relativize

public static java.lang.String relativize(java.lang.String in,
                                          java.lang.String base)
                                   throws java.net.URISyntaxException,
                                          java.io.IOException
Convert an absolute URI to one relatve to a given base. This goes beyond java.net.URI.relativize in that if the arguments have a common prefix, it can create a relative URI using "../" steps.

Throws:
java.net.URISyntaxException
java.io.IOException

getAbsolute

public Path getAbsolute()

getCanonical

public Path getCanonical()