|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.io.FileParent
class FileParent
This package-private class supports by classes like TarUtil
and ZipUtil
.
The getRelativePath
method defines the essential functionality.
This class is multithread safe: its static state is guarded by synchronization, while its instance state is immutable (both its immediate state, as well as the deep state of its fields).
Field Summary | |
---|---|
private static int |
count
|
private File |
file
File that this instance is for. |
private File |
parent
The parent directory of file . |
private String |
rootName
If parent is null,
then this field holds a made up name for an imaginary root directory containing file . |
Constructor Summary | |
---|---|
FileParent(File file)
|
Method Summary | |
---|---|
(package private) String |
getRelativePath(File descendant,
char separator)
Returns descendant's relative path. |
private static String |
nextRootName(File parent)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static int count
private final File file
getRelativePath
method
must equal or be contained inside this value.
Contract: is never null.
private final File parent
file
.
Contract: is null if and only if file is a root directory.
private final String rootName
parent
is null,
then this field holds a made up name for an imaginary root directory containing file
.
Contract: is null if file is a filesystem root directory. Otherwise, is non-null and the value is unique across all instances of this class in a given JVM session.
Constructor Detail |
---|
FileParent(File file) throws IllegalArgumentException
IllegalArgumentException
Method Detail |
---|
private static String nextRootName(File parent)
String getRelativePath(File descendant, char separator) throws IllegalArgumentException
parent
is non-null, then the result is relative to parent.
Otherwise, the result begins with rootName
,
followed by descendant's path relative to file
.
The result always uses separator to distinguish path elements.
Furthermore, if descendant is a directory, then the result is guaranteed to end with separator (since classes like ZipEntry identify directories based on this).
To understand the motivation for this behavior,
see, for example, ZipUtil.archive(File, FileFilter, File[])
.
IllegalArgumentException
- if descendant == null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |