Package com.atlassian.bitbucket.content
Class SimplePath
java.lang.Object
com.atlassian.bitbucket.content.SimplePath
- All Implemented Interfaces:
Path
,Serializable
,Comparable<SimplePath>
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSimplePath
(Path path) SimplePath
(SimplePath aParent, SimplePath aPath) SimplePath
(SimplePath aParent, String aPath) SimplePath
(SimplePath aParent, String... aPath) SimplePath
(SimplePath aParent, String aPath, boolean allowSloshes) SimplePath
(CharSequence path) SimplePath
(CharSequence path, boolean allowSloshes) SimplePath
(String aParent, SimplePath aPath) SimplePath
(List<String> start) -
Method Summary
Modifier and TypeMethodDescriptionabbreviate
(int maxLength) Abbreviates the path by removing path components from the middle until the length of thepath
is not greater thanmaxLength
.abbreviatePathComponents
(int maxLength) Returns a similar result togetPathComponents()
, but abbreviates the result (inserts null at the break point)int
boolean
getCommonRoot
(SimplePath other) getComponent
(int i) String[]
getName()
int
getPath()
getPath
(boolean caseSensitive) getStripTail
(SimplePath other, boolean caseSensitive) if other is an exact tail of this, return the path leading up to that tail otherwise return nullgetSubPath
(int depth) getTail()
int
hashCode()
boolean
determines if this path begins with all ofp
boolean
hasPrefix
(SimplePath p, boolean caseSensitive) boolean
isAncestor
(SimplePath descendant) boolean
isRoot()
static String
Intelligently put a "/" between two strings.simplify()
static String[]
split
(CharSequence aPath) static String[]
split
(CharSequence aPath, boolean allowSloshes) toString()
trimFirst
(int n) trimLast()
-
Field Details
-
EMPTY
-
ROOT
-
-
Constructor Details
-
SimplePath
-
SimplePath
-
SimplePath
-
SimplePath
-
SimplePath
-
SimplePath
-
SimplePath
-
SimplePath
-
SimplePath
-
-
Method Details
-
join
Intelligently put a "/" between two strings.- Parameters:
a
- first path componentb
- second path component- Returns:
- merged path
-
split
-
split
-
abbreviate
Abbreviates the path by removing path components from the middle until the length of thepath
is not greater thanmaxLength
.The first and last path component are always in the returned path. If any path components are removed, an ellipses ("...") will appear in the middle. The returned path may in some cases still be greater than the specified
maxLength
.- Parameters:
maxLength
- maximum number of characters- Returns:
- an abbreviated path
-
abbreviatePathComponents
Returns a similar result togetPathComponents()
, but abbreviates the result (inserts null at the break point)- Parameters:
maxLength
- maximum length- Returns:
- an abbreviated array of path components for the current path
-
compareTo
- Specified by:
compareTo
in interfaceComparable<SimplePath>
-
equals
-
getCommonRoot
-
getComponent
-
getComponents
- Specified by:
getComponents
in interfacePath
- Returns:
- an array of Strings representing the directories followed by a possible file name
-
getExtension
- Specified by:
getExtension
in interfacePath
- Returns:
- the file extension of the path (with no .), or null if there is no file extension
-
getName
-
getNumComponents
public int getNumComponents() -
getParent
-
getParentPath
-
getPath
- Returns:
- the string representation of the path
-
getPath
-
getPathComponents
-
getPathHead
-
getStripTail
if other is an exact tail of this, return the path leading up to that tail otherwise return null- Parameters:
other
- the other pathcaseSensitive
- true if case sensitive- Returns:
- the stripped path, or
null
if the other path is not a tail of this path
-
getSubPath
-
getTail
- Returns:
- a String composed of all the path segments after the first segment
-
getTailPath
-
hasPrefix
determines if this path begins with all ofp
- Parameters:
p
- the prefix to check- Returns:
- true if it has the prefix path
-
hasPrefix
-
hashCode
public int hashCode() -
isAncestor
-
isRoot
public boolean isRoot() -
simplify
-
toString
-
trimFirst
-
trimFirst
- Parameters:
n
- number of components to trim- Returns:
- the trimmed path or same path if the length was 0
-
trimLast
-