Package com.google.common.jimfs
Class JimfsPath
- java.lang.Object
-
- com.google.common.jimfs.JimfsPath
-
- All Implemented Interfaces:
java.lang.Comparable<java.nio.file.Path>,java.lang.Iterable<java.nio.file.Path>,java.nio.file.Path,java.nio.file.Watchable
final class JimfsPath extends java.lang.Object implements java.nio.file.PathJimfs implementation ofPath. Creation of newPathobjects is delegated to the file system'sPathService.
-
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.collect.ImmutableList<Name>namesprivate PathServicepathServiceprivate @Nullable Nameroot
-
Constructor Summary
Constructors Constructor Description JimfsPath(PathService pathService, @Nullable Name root, java.lang.Iterable<Name> names)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.List<java.nio.file.Path>asList()private @Nullable JimfsPathcheckPath(java.nio.file.Path other)intcompareTo(java.nio.file.Path other)booleanendsWith(java.lang.String other)booleanendsWith(java.nio.file.Path other)booleanequals(@Nullable java.lang.Object obj)@Nullable JimfsPathgetFileName()java.nio.file.FileSystemgetFileSystem()JimfsFileSystemgetJimfsFileSystem()Equivalent togetFileSystem()but with a return type ofJimfsFileSystem.JimfsPathgetName(int index)intgetNameCount()@Nullable JimfsPathgetParent()@Nullable JimfsPathgetRoot()inthashCode()booleanisAbsolute()booleanisEmptyPath()Returns whether or not this is the empty path, with no root and a single, empty string, name.private booleanisNormal()Returns whether or not this path is in a normalized form.java.util.Iterator<java.nio.file.Path>iterator()@Nullable Namename()Returns the file name of this path.com.google.common.collect.ImmutableList<Name>names()Returns the list of name elements.JimfsPathnormalize()java.nio.file.WatchKeyregister(java.nio.file.WatchService watcher, java.nio.file.WatchEvent.Kind<?>... events)java.nio.file.WatchKeyregister(java.nio.file.WatchService watcher, java.nio.file.WatchEvent.Kind<?>[] events, java.nio.file.WatchEvent.Modifier... modifiers)JimfsPathrelativize(java.nio.file.Path other)(package private) JimfsPathresolve(Name name)Resolves the given name against this path.JimfsPathresolve(java.lang.String other)JimfsPathresolve(java.nio.file.Path other)JimfsPathresolveSibling(java.lang.String other)JimfsPathresolveSibling(java.nio.file.Path other)@Nullable Nameroot()Returns the root name, or null if there is no root.booleanstartsWith(java.lang.String other)booleanstartsWith(java.nio.file.Path other)private static booleanstartsWith(java.util.List<?> list, java.util.List<?> other)Returns true if list starts with all elements of other in the same order.JimfsPathsubpath(int beginIndex, int endIndex)JimfsPathtoAbsolutePath()java.io.FiletoFile()JimfsPathtoRealPath(java.nio.file.LinkOption... options)java.lang.StringtoString()java.net.URItoUri()
-
-
-
Field Detail
-
root
private final @Nullable Name root
-
names
private final com.google.common.collect.ImmutableList<Name> names
-
pathService
private final PathService pathService
-
-
Constructor Detail
-
JimfsPath
public JimfsPath(PathService pathService, @Nullable Name root, java.lang.Iterable<Name> names)
-
-
Method Detail
-
root
public @Nullable Name root()
Returns the root name, or null if there is no root.
-
names
public com.google.common.collect.ImmutableList<Name> names()
Returns the list of name elements.
-
name
public @Nullable Name name()
Returns the file name of this path. UnlikegetFileName(), this may return the name of the root if this is a root path.
-
isEmptyPath
public boolean isEmptyPath()
Returns whether or not this is the empty path, with no root and a single, empty string, name.
-
getFileSystem
public java.nio.file.FileSystem getFileSystem()
- Specified by:
getFileSystemin interfacejava.nio.file.Path
-
getJimfsFileSystem
public JimfsFileSystem getJimfsFileSystem()
Equivalent togetFileSystem()but with a return type ofJimfsFileSystem.getFileSystem()'s return type is left asFileSystemto make testing paths easier (as long as methods that access the file system in some way are not called, the file system can be a fake file system instance).
-
isAbsolute
public boolean isAbsolute()
- Specified by:
isAbsolutein interfacejava.nio.file.Path
-
getRoot
public @Nullable JimfsPath getRoot()
- Specified by:
getRootin interfacejava.nio.file.Path
-
getFileName
public @Nullable JimfsPath getFileName()
- Specified by:
getFileNamein interfacejava.nio.file.Path
-
getParent
public @Nullable JimfsPath getParent()
- Specified by:
getParentin interfacejava.nio.file.Path
-
getNameCount
public int getNameCount()
- Specified by:
getNameCountin interfacejava.nio.file.Path
-
getName
public JimfsPath getName(int index)
- Specified by:
getNamein interfacejava.nio.file.Path
-
subpath
public JimfsPath subpath(int beginIndex, int endIndex)
- Specified by:
subpathin interfacejava.nio.file.Path
-
startsWith
private static boolean startsWith(java.util.List<?> list, java.util.List<?> other)Returns true if list starts with all elements of other in the same order.
-
startsWith
public boolean startsWith(java.nio.file.Path other)
- Specified by:
startsWithin interfacejava.nio.file.Path
-
startsWith
public boolean startsWith(java.lang.String other)
- Specified by:
startsWithin interfacejava.nio.file.Path
-
endsWith
public boolean endsWith(java.nio.file.Path other)
- Specified by:
endsWithin interfacejava.nio.file.Path
-
endsWith
public boolean endsWith(java.lang.String other)
- Specified by:
endsWithin interfacejava.nio.file.Path
-
normalize
public JimfsPath normalize()
- Specified by:
normalizein interfacejava.nio.file.Path
-
isNormal
private boolean isNormal()
Returns whether or not this path is in a normalized form. It's normal if it both contains no "." names and contains no ".." names in a location other than the start of the path.
-
resolve
JimfsPath resolve(Name name)
Resolves the given name against this path. The name is assumed not to be a root name.
-
resolve
public JimfsPath resolve(java.nio.file.Path other)
- Specified by:
resolvein interfacejava.nio.file.Path
-
resolve
public JimfsPath resolve(java.lang.String other)
- Specified by:
resolvein interfacejava.nio.file.Path
-
resolveSibling
public JimfsPath resolveSibling(java.nio.file.Path other)
- Specified by:
resolveSiblingin interfacejava.nio.file.Path
-
resolveSibling
public JimfsPath resolveSibling(java.lang.String other)
- Specified by:
resolveSiblingin interfacejava.nio.file.Path
-
relativize
public JimfsPath relativize(java.nio.file.Path other)
- Specified by:
relativizein interfacejava.nio.file.Path
-
toAbsolutePath
public JimfsPath toAbsolutePath()
- Specified by:
toAbsolutePathin interfacejava.nio.file.Path
-
toRealPath
public JimfsPath toRealPath(java.nio.file.LinkOption... options) throws java.io.IOException
- Specified by:
toRealPathin interfacejava.nio.file.Path- Throws:
java.io.IOException
-
register
public java.nio.file.WatchKey register(java.nio.file.WatchService watcher, java.nio.file.WatchEvent.Kind<?>[] events, java.nio.file.WatchEvent.Modifier... modifiers) throws java.io.IOException- Specified by:
registerin interfacejava.nio.file.Path- Specified by:
registerin interfacejava.nio.file.Watchable- Throws:
java.io.IOException
-
register
public java.nio.file.WatchKey register(java.nio.file.WatchService watcher, java.nio.file.WatchEvent.Kind<?>... events) throws java.io.IOException- Specified by:
registerin interfacejava.nio.file.Path- Specified by:
registerin interfacejava.nio.file.Watchable- Throws:
java.io.IOException
-
toUri
public java.net.URI toUri()
- Specified by:
toUriin interfacejava.nio.file.Path
-
toFile
public java.io.File toFile()
- Specified by:
toFilein interfacejava.nio.file.Path
-
iterator
public java.util.Iterator<java.nio.file.Path> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.nio.file.Path>- Specified by:
iteratorin interfacejava.nio.file.Path
-
asList
private java.util.List<java.nio.file.Path> asList()
-
compareTo
public int compareTo(java.nio.file.Path other)
- Specified by:
compareToin interfacejava.lang.Comparable<java.nio.file.Path>- Specified by:
compareToin interfacejava.nio.file.Path
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Specified by:
equalsin interfacejava.nio.file.Path- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.nio.file.Path- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfacejava.nio.file.Path- Overrides:
toStringin classjava.lang.Object
-
checkPath
private @Nullable JimfsPath checkPath(java.nio.file.Path other)
-
-