Class ShrinkWrapPath
- java.lang.Object
-
- org.jboss.shrinkwrap.impl.nio.file.ShrinkWrapPath
-
- 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
public class ShrinkWrapPath extends java.lang.Object implements java.nio.file.Path
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DIR_BACK
private static java.lang.String
DIR_THIS
private ShrinkWrapFileSystem
fileSystem
OwningShrinkWrapFileSystem
private static java.util.logging.Logger
log
private java.lang.String
path
Internal representation
-
Constructor Summary
Constructors Constructor Description ShrinkWrapPath(java.lang.String path, ShrinkWrapFileSystem fileSystem)
Constructs a new instance using the specified (required) canonical form and backingShrinkWrapFileSystem
ShrinkWrapPath(ArchivePath path, ShrinkWrapFileSystem fileSystem)
Constructs a new instance using the specified (required) path and backingShrinkWrapFileSystem
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(java.nio.file.Path other)
private int
countOccurrences(java.lang.String string, char c, int offset)
Returns the number of occurrences of the specified character in the specifiedString
, starting at the specified offsetboolean
endsWith(java.lang.String other)
boolean
endsWith(java.nio.file.Path other)
boolean
equals(java.lang.Object obj)
private java.nio.file.Path
fromString(java.lang.String path)
Creates a newShrinkWrapPath
instance from the specified inputString
java.nio.file.Path
getFileName()
java.nio.file.FileSystem
getFileSystem()
java.nio.file.Path
getName(int index)
int
getNameCount()
java.nio.file.Path
getParent()
java.nio.file.Path
getRoot()
int
hashCode()
boolean
isAbsolute()
java.util.Iterator<java.nio.file.Path>
iterator()
java.nio.file.Path
normalize()
private static java.lang.String
normalize(java.util.List<java.lang.String> path, boolean absolute)
Normalizes the tokenized view of the pathjava.nio.file.WatchKey
register(java.nio.file.WatchService watcher, java.nio.file.WatchEvent.Kind<?>... events)
java.nio.file.WatchKey
register(java.nio.file.WatchService watcher, java.nio.file.WatchEvent.Kind<?>[] events, java.nio.file.WatchEvent.Modifier... modifiers)
java.nio.file.Path
relativize(java.nio.file.Path other)
private static ShrinkWrapPath
relativizeCommonRoot(ShrinkWrapPath thisOriginal, java.nio.file.Path thisCurrent, java.nio.file.Path otherOriginal, java.nio.file.Path otherCurrent, int backupCount)
Relativizes the paths recursivelyjava.nio.file.Path
resolve(java.lang.String other)
java.nio.file.Path
resolve(java.nio.file.Path other)
java.nio.file.Path
resolveSibling(java.lang.String other)
java.nio.file.Path
resolveSibling(java.nio.file.Path other)
boolean
startsWith(java.lang.String other)
boolean
startsWith(java.nio.file.Path other)
java.nio.file.Path
subpath(int beginIndex, int endIndex)
java.nio.file.Path
toAbsolutePath()
Resolves relative paths against the root directory, normalizing as well.java.io.File
toFile()
private static java.util.List<java.lang.String>
tokenize(ShrinkWrapPath path)
Returns the components of this path in order from root outjava.nio.file.Path
toRealPath(java.nio.file.LinkOption... options)
java.lang.String
toString()
java.net.URI
toUri()
-
-
-
Field Detail
-
log
private static final java.util.logging.Logger log
-
DIR_BACK
private static final java.lang.String DIR_BACK
- See Also:
- Constant Field Values
-
DIR_THIS
private static final java.lang.String DIR_THIS
- See Also:
- Constant Field Values
-
path
private final java.lang.String path
Internal representation
-
fileSystem
private final ShrinkWrapFileSystem fileSystem
OwningShrinkWrapFileSystem
-
-
Constructor Detail
-
ShrinkWrapPath
ShrinkWrapPath(java.lang.String path, ShrinkWrapFileSystem fileSystem) throws java.lang.IllegalArgumentException
Constructs a new instance using the specified (required) canonical form and backingShrinkWrapFileSystem
- Parameters:
path
-fileSystem
-- Throws:
java.lang.IllegalArgumentException
- If the path or file system is not specified
-
ShrinkWrapPath
ShrinkWrapPath(ArchivePath path, ShrinkWrapFileSystem fileSystem) throws java.lang.IllegalArgumentException
Constructs a new instance using the specified (required) path and backingShrinkWrapFileSystem
- Parameters:
path
- to be evaluated usingArchivePath.get()
fileSystem
-- Throws:
java.lang.IllegalArgumentException
- If the path or file system is not specifiedjava.lang.IllegalArgumentException
- If the delegate is not specified
-
-
Method Detail
-
getFileSystem
public java.nio.file.FileSystem getFileSystem()
- Specified by:
getFileSystem
in interfacejava.nio.file.Path
- See Also:
Path.getFileSystem()
-
isAbsolute
public boolean isAbsolute()
- Specified by:
isAbsolute
in interfacejava.nio.file.Path
- See Also:
Path.isAbsolute()
-
getRoot
public java.nio.file.Path getRoot()
- Specified by:
getRoot
in interfacejava.nio.file.Path
- See Also:
Path.getRoot()
-
getFileName
public java.nio.file.Path getFileName()
- Specified by:
getFileName
in interfacejava.nio.file.Path
- See Also:
Path.getFileName()
-
getParent
public java.nio.file.Path getParent()
- Specified by:
getParent
in interfacejava.nio.file.Path
- See Also:
Path.getParent()
-
getNameCount
public int getNameCount()
- Specified by:
getNameCount
in interfacejava.nio.file.Path
- See Also:
Path.getNameCount()
-
countOccurrences
private int countOccurrences(java.lang.String string, char c, int offset)
Returns the number of occurrences of the specified character in the specifiedString
, starting at the specified offset- Parameters:
string
-c
-offset
-- Returns:
-
getName
public java.nio.file.Path getName(int index)
- Specified by:
getName
in interfacejava.nio.file.Path
- See Also:
Path.getName(int)
-
subpath
public java.nio.file.Path subpath(int beginIndex, int endIndex)
- Specified by:
subpath
in interfacejava.nio.file.Path
- See Also:
Path.subpath(int, int)
-
startsWith
public boolean startsWith(java.nio.file.Path other)
- Specified by:
startsWith
in interfacejava.nio.file.Path
- See Also:
Path.startsWith(java.nio.file.Path)
-
startsWith
public boolean startsWith(java.lang.String other)
- Specified by:
startsWith
in interfacejava.nio.file.Path
- See Also:
Path.startsWith(java.lang.String)
-
endsWith
public boolean endsWith(java.nio.file.Path other)
- Specified by:
endsWith
in interfacejava.nio.file.Path
- See Also:
Path.endsWith(java.nio.file.Path)
-
endsWith
public boolean endsWith(java.lang.String other)
- Specified by:
endsWith
in interfacejava.nio.file.Path
- See Also:
Path.endsWith(java.lang.String)
-
normalize
public java.nio.file.Path normalize()
- Specified by:
normalize
in interfacejava.nio.file.Path
- See Also:
Path.normalize()
-
resolve
public java.nio.file.Path resolve(java.nio.file.Path other)
- Specified by:
resolve
in interfacejava.nio.file.Path
- See Also:
Path.resolve(java.nio.file.Path)
-
resolve
public java.nio.file.Path resolve(java.lang.String other)
- Specified by:
resolve
in interfacejava.nio.file.Path
- See Also:
Path.resolve(java.lang.String)
-
resolveSibling
public java.nio.file.Path resolveSibling(java.nio.file.Path other)
- Specified by:
resolveSibling
in interfacejava.nio.file.Path
- See Also:
Path.resolveSibling(java.nio.file.Path)
-
resolveSibling
public java.nio.file.Path resolveSibling(java.lang.String other)
- Specified by:
resolveSibling
in interfacejava.nio.file.Path
- See Also:
Path.resolveSibling(java.lang.String)
-
relativize
public java.nio.file.Path relativize(java.nio.file.Path other)
- Specified by:
relativize
in interfacejava.nio.file.Path
- See Also:
Path.relativize(java.nio.file.Path)
-
toUri
public java.net.URI toUri()
- Specified by:
toUri
in interfacejava.nio.file.Path
- See Also:
Path.toUri()
-
toAbsolutePath
public java.nio.file.Path toAbsolutePath()
Resolves relative paths against the root directory, normalizing as well.- Specified by:
toAbsolutePath
in interfacejava.nio.file.Path
- See Also:
Path.toAbsolutePath()
-
toRealPath
public java.nio.file.Path toRealPath(java.nio.file.LinkOption... options) throws java.io.IOException
- Specified by:
toRealPath
in interfacejava.nio.file.Path
- Throws:
java.io.IOException
- See Also:
Path.toRealPath(java.nio.file.LinkOption[])
-
toFile
public java.io.File toFile()
- Specified by:
toFile
in interfacejava.nio.file.Path
- See Also:
Path.toFile()
-
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:
register
in interfacejava.nio.file.Path
- Specified by:
register
in interfacejava.nio.file.Watchable
- Throws:
java.io.IOException
- See Also:
java.nio.file.Path#register(java.nio.file.WatchService, java.nio.file.WatchEvent.Kind>[], java.nio.file.WatchEvent.Modifier[])
-
register
public java.nio.file.WatchKey register(java.nio.file.WatchService watcher, java.nio.file.WatchEvent.Kind<?>... events) throws java.io.IOException
- Specified by:
register
in interfacejava.nio.file.Path
- Specified by:
register
in interfacejava.nio.file.Watchable
- Throws:
java.io.IOException
- See Also:
java.nio.file.Path#register(java.nio.file.WatchService, java.nio.file.WatchEvent.Kind>[])
-
iterator
public java.util.Iterator<java.nio.file.Path> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<java.nio.file.Path>
- Specified by:
iterator
in interfacejava.nio.file.Path
- See Also:
Path.iterator()
-
compareTo
public int compareTo(java.nio.file.Path other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<java.nio.file.Path>
- Specified by:
compareTo
in interfacejava.nio.file.Path
- See Also:
Path.compareTo(java.nio.file.Path)
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfacejava.nio.file.Path
- Overrides:
toString
in classjava.lang.Object
- See Also:
Path.toString()
-
fromString
private java.nio.file.Path fromString(java.lang.String path)
Creates a newShrinkWrapPath
instance from the specified inputString
- Parameters:
path
-- Returns:
-
tokenize
private static java.util.List<java.lang.String> tokenize(ShrinkWrapPath path)
Returns the components of this path in order from root out- Returns:
-
normalize
private static java.lang.String normalize(java.util.List<java.lang.String> path, boolean absolute)
Normalizes the tokenized view of the path- Parameters:
path
-- Returns:
-
relativizeCommonRoot
private static ShrinkWrapPath relativizeCommonRoot(ShrinkWrapPath thisOriginal, java.nio.file.Path thisCurrent, java.nio.file.Path otherOriginal, java.nio.file.Path otherCurrent, int backupCount)
Relativizes the paths recursively- Parameters:
thisOriginal
-thisCurrent
-otherOriginal
-otherCurrent
-backupCount
-- Returns:
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.nio.file.Path
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.nio.file.Path
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
-