gnu.text

Class Path

public abstract class Path extends Object

A generalized path/location, including File and URIs.
Field Summary
static PathdefaultPath
static FilePathuserDirPath
This is equivalent to the System {@code "user.dir} property.
Constructor Summary
protected Path()
Method Summary
static PathcoerceToPathOrNull(Object path)
static PathcurrentPath()
booleanexists()
PathgetAbsolute()
StringgetAuthority()
PathgetCanonical()
longgetContentLength()
PathgetDirectory()
StringgetExtension()
StringgetFragment()
StringgetHost()
StringgetLast()
abstract longgetLastModified()
PathgetParent()
abstract StringgetPath()
intgetPort()
StringgetQuery()
abstract StringgetScheme()
StringgetUserInfo()
abstract booleanisAbsolute()
booleanisDirectory()
Does this path name a directory?
static InputStreamopenInputStream(Object uri)
abstract InputStreamopenInputStream()
abstract OutputStreamopenOutputStream()
static Stringrelativize(String in, String base)
Convert an absolute URI to one relatve to a given base.
Pathresolve(Path relative)
abstract Pathresolve(String relative)
static voidsetCurrentPath(Path path)
abstract URItoURI()
StringtoURIString()
static URLtoURL(String str)
abstract URLtoURL()
static inturiSchemeLength(String uri)
Helper routine to get the scheme part of a URI.
static booleanuriSchemeSpecified(String name)
Tests if a URL has a scheme.
static PathvalueOf(Object arg)

Field Detail

defaultPath

public static Path defaultPath

userDirPath

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

Constructor Detail

Path

protected Path()

Method Detail

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 static InputStream openInputStream(Object uri)

openInputStream

public abstract InputStream openInputStream()

openOutputStream

public abstract OutputStream openOutputStream()

relativize

public static String relativize(String in, String base)
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 Path resolve(Path relative)

resolve

public abstract Path resolve(String relative)

setCurrentPath

public static void setCurrentPath(Path path)

toURI

public abstract URI toURI()

toURIString

public String toURIString()

toURL

public static URL toURL(String str)

toURL

public abstract URL toURL()

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)