public class MergePath extends FilesystemPath
In the following example, "first" has priority over "second".
If test.xml exists in both "first" and "second", the open will
return "first/test.xml".
MergePage merge = new MergePath();
merge.addMergePath(Vfs.lookup("first");
merge.addMergePath(Vfs.lookup("second");
Path path = merge.lookup("test.xml");
ReadStream is = path.openRead();
MergePath corresponds to the "merge:" Vfs schema
Path path = Vfs.lookup("merge:(../custom-foo;foo)");
Path.FileChannelFactory_bindRoot, _pathname, _root, _userPath_pathSeparatorChar, _schemeMap, _separatorChar, L| Modifier | Constructor and Description |
|---|---|
|
MergePath()
Creates a new merge path.
|
protected |
MergePath(MergePath root,
java.lang.String userPath,
java.util.Map<java.lang.String,java.lang.Object> attributes,
java.lang.String path) |
|
MergePath(Path... paths) |
|
MergePath(java.lang.String userPath,
java.lang.String path,
Path... paths) |
| Modifier and Type | Method and Description |
|---|---|
void |
addClassPath()
Adds the classpath as paths in the MergePath.
|
void |
addClassPath(java.lang.ClassLoader loader)
Adds the classpath for the loader as paths in the MergePath.
|
void |
addClassPath(java.lang.String classpath)
Adds the classpath for the loader as paths in the MergePath.
|
void |
addLocalClassPath()
Adds the classpath as paths in the MergePath.
|
void |
addLocalClassPath(java.lang.ClassLoader loader)
Adds the classpath for the loader as paths in the MergePath.
|
void |
addMergePath(Path path)
Adds a new path to the end of the merge path.
|
void |
addResourceClassPath(java.lang.ClassLoader loader)
Adds the classpath for the loader as paths in the MergePath.
|
boolean |
canRead()
Returns true if the best path can be read.
|
boolean |
canWrite()
Returns true if the best path can be written to.
|
Path |
copy() |
PersistentDependency |
createDepend()
Creates a dependency.
|
protected MergePath |
createMergePath() |
boolean |
exists()
True if any file matching this path exists.
|
Path |
fsWalk(java.lang.String userPath,
java.util.Map<java.lang.String,java.lang.Object> attributes,
java.lang.String path)
Walking down the path just extends the path.
|
Path |
getBestPath()
Returns the first matching path.
|
long |
getLastModified()
Returns the last modified time of the best path.
|
long |
getLength()
Returns the length of the best path.
|
java.util.ArrayList<Path> |
getMergePaths()
Return the list of paths searched in the merge path.
|
int |
getMode()
Returns equivalent of struct stat.st_mode if appropriate.
|
protected java.util.ArrayList<Path> |
getPathList() |
java.lang.String |
getRelativePath()
Returns the relative path into the merge path.
|
java.util.ArrayList<Path> |
getResources()
Returns all the resources matching the path.
|
java.util.ArrayList<Path> |
getResources(java.lang.String pathName)
Returns all the resources matching the path.
|
java.lang.String |
getScheme()
Returns the scheme of the best path.
|
Path |
getWritePath()
Returns the first matching path.
|
boolean |
isDirectory()
True if the best path is a directory.
|
boolean |
isExecutable()
Tests if the path is marked as executable
|
boolean |
isFile()
True if the best path is a file.
|
java.lang.String[] |
list()
List the merged directories.
|
boolean |
mkdir()
XXX: Probably should mkdir in the first path
|
boolean |
mkdirs()
XXX: Probably should mkdir in the first path
|
StreamImpl |
openAppendImpl()
Opens the best path for appending.
|
RandomAccessStream |
openFileRandomAccess()
Opens the best path for random access.
|
StreamImpl |
openReadImpl()
Opens the best path for reading.
|
StreamImpl |
openReadWriteImpl()
Opens the best path for reading and writing.
|
StreamImpl |
openWriteImpl()
Opens the best path for writing.
|
boolean |
remove()
Remove the matching path.
|
boolean |
renameTo(Path path)
Renames the path.
|
Path |
schemeWalk(java.lang.String userPath,
java.util.Map<java.lang.String,java.lang.Object> attributes,
java.lang.String filePath,
int offset)
schemeWalk is called by Path for a scheme lookup like file:/tmp/foo
|
java.lang.String |
toString()
Returns a name for the path
|
bind, createRoot, equals, getFullPath, getParent, getPath, getRoot, getTail, getUserPath, hashCode, init, normalizePath, normalizePath, setUserPathcacheCopy, canExecute, changeGroup, changeGroup, changeOwner, changeOwner, chmod, clearStatusCache, compareTo, createLink, createNewFile, createRoot, createTempFile, escapeURL, fileChannelFactory, getAttribute, getAttributeNames, getBlockCount, getBlockSize, getCache, getCertificates, getContentType, getCrc64, getCreateTime, getDevice, getDeviceId, getDiskSpaceFree, getDiskSpaceTotal, getFileSeparatorChar, getGroup, getHost, getInode, getLastAccessTime, getLastStatusChangeTime, getNativePath, getNewlineString, getNumberOfLinks, getObject, getOwner, getPathSeparatorChar, getPort, getQuery, getSchemeMap, getSeparatorChar, getURL, getUser, getUserDir, getValue, isBlockDevice, isCharacterDevice, isFIFO, isHardLink, isLink, isObject, isPathCacheable, isSocket, isSymbolicLink, isWindows, isWindowsInsecure, iterator, lookup, lookup, lookup, lookupChild, lookupImpl, lookupNative, lookupNative, lookupRelativeNativePath, openAppend, openMemoryMappedFile, openRandomAccess, openRead, openReadWrite, openReadWrite, openReadWrite, openWrite, putCache, readLink, realPath, removeAll, renameTo, scanScheme, sendfile, setDefaultSchemeMap, setExecutable, setLastModified, setObject, setTestWindows, setValue, truncate, truncate, unbind, unwrap, writeToStream, writeToStreampublic MergePath()
public MergePath(java.lang.String userPath,
java.lang.String path,
Path... paths)
public MergePath(Path... paths)
protected MergePath(MergePath root, java.lang.String userPath, java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.String path)
path - canonical pathpublic Path schemeWalk(java.lang.String userPath, java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.String filePath, int offset)
schemeWalk in class FilesystemPathuserPath - the user's lookup() pathattributes - the user's attributesfilePath - the actual lookup() pathoffset - offset into filePathprotected MergePath createMergePath()
public void addMergePath(Path path)
path - the new path to searchpublic void addClassPath()
public void addClassPath(java.lang.ClassLoader loader)
loader - class loader whose classpath should be used to search.public void addResourceClassPath(java.lang.ClassLoader loader)
loader - class loader whose classpath should be used to search.public void addLocalClassPath()
public void addLocalClassPath(java.lang.ClassLoader loader)
loader - class loader whose classpath should be used to search.public void addClassPath(java.lang.String classpath)
classpath - class loader whose classpath should be used to search.public java.util.ArrayList<Path> getMergePaths()
public Path fsWalk(java.lang.String userPath, java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.String path)
fsWalk in class FilesystemPathuserPath - the exact string passed by the user's lookup()attributes - the user's new attributespath - the normalized real pathpublic java.lang.String getScheme()
public java.lang.String getRelativePath()
getRelativePath in class Pathpublic boolean exists()
public int getMode()
public boolean isExecutable()
isExecutable in class Pathpublic boolean isDirectory()
isDirectory in class Pathpublic long getLength()
public long getLastModified()
getLastModified in class Pathpublic boolean canRead()
public boolean canWrite()
public java.util.ArrayList<Path> getResources(java.lang.String pathName)
getResources in class Pathpublic java.util.ArrayList<Path> getResources()
getResources in class Pathpublic java.lang.String[] list()
throws java.io.IOException
public boolean mkdir()
throws java.io.IOException
public boolean mkdirs()
throws java.io.IOException
public boolean remove()
throws java.io.IOException
public boolean renameTo(Path path) throws java.io.IOException
public StreamImpl openReadImpl() throws java.io.IOException
openReadImpl in class Pathjava.io.IOExceptionpublic StreamImpl openWriteImpl() throws java.io.IOException
openWriteImpl in class Pathjava.io.IOExceptionpublic StreamImpl openReadWriteImpl() throws java.io.IOException
openReadWriteImpl in class Pathjava.io.IOExceptionpublic StreamImpl openAppendImpl() throws java.io.IOException
openAppendImpl in class Pathjava.io.IOExceptionpublic RandomAccessStream openFileRandomAccess() throws java.io.IOException
openFileRandomAccess in class Pathjava.io.IOExceptionpublic Path getWritePath()
public PersistentDependency createDepend()
createDepend in class Pathpublic Path getBestPath()
protected java.util.ArrayList<Path> getPathList()