gnu.text

Class Path

Known Direct 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

Path()

Method Summary

static Path
coerceToPathOrNull(Object path)
static Path
currentPath()
boolean
exists()
Path
getAbsolute()
String
getAuthority()
Path
getCanonical()
long
getContentLength()
Path
getDirectory()
String
getExtension()
String
getFragment()
String
getHost()
String
getLast()
abstract long
getLastModified()
Path
getParent()
abstract String
getPath()
int
getPort()
String
getQuery()
abstract String
getScheme()
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 InputStream
openInputStream()
static InputStream
openInputStream(Object uri)
abstract OutputStream
openOutputStream()
static String
relativize(String in, String base)
Convert an absolute URI to one relatve to a given base.
abstract Path
resolve(String relative)
Path
resolve(Path relative)
static void
setCurrentPath(Path path)
abstract URI
toURI()
String
toURIString()
abstract URL
toURL()
static URL
toURL(String str)
static int
uriSchemeLength(String uri)
Helper routine to get the scheme part of a URI.
static boolean
uriSchemeSpecified(String name)
Tests if a URL has a scheme.
static Path
valueOf(Object arg)

Field Details

defaultPath

public static Path defaultPath

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.

Constructor Details

Path

protected Path()

Method Details

coerceToPathOrNull

public static Path coerceToPathOrNull(Object path)

currentPath

public static Path currentPath()

exists

public boolean exists()

getAbsolute

public Path getAbsolute()

getAuthority

public String getAuthority()

getCanonical

public Path getCanonical()

getContentLength

public long getContentLength()

getDirectory

public Path getDirectory()

getExtension

public String getExtension()

getFragment

public String getFragment()

getHost

public String getHost()

getLast

public String getLast()

getLastModified

public abstract long getLastModified()

getParent

public Path getParent()

getPath

public abstract String getPath()

getPort

public int getPort()

getQuery

public String getQuery()

getScheme

public abstract String getScheme()

getUserInfo

public String getUserInfo()

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.

openInputStream

public abstract InputStream openInputStream()
            throws IOException

openInputStream

public static InputStream openInputStream(Object uri)
            throws IOException

openOutputStream

public abstract OutputStream openOutputStream()
            throws IOException

relativize

public static String relativize(String in,
                                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.

resolve

public abstract Path resolve(String relative)

resolve

public Path resolve(Path relative)

setCurrentPath

public static void setCurrentPath(Path path)

toURI

public abstract URI toURI()

toURIString

public String toURIString()

toURL

public abstract URL toURL()

toURL

public static URL toURL(String str)

uriSchemeLength

public static int uriSchemeLength(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(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.

valueOf

public static Path valueOf(Object arg)