com.atlassian.jira.issue.attachment
Class Path

java.lang.Object
  extended by com.atlassian.jira.issue.attachment.Path
All Implemented Interfaces:
Serializable, Comparable<Path>

public class Path
extends Object
implements Serializable, Comparable<Path>

Copied from FECRU

./java/com/cenqua/fisheye/Path.java r54145

See Also:
Serialized Form

Constructor Summary
Path()
           
Path(CharSequence path)
           
Path(CharSequence path, boolean allowSloshes)
           
Path(List<String> start)
           
Path(Path path)
           
Path(Path aParent, Path aPath)
           
Path(Path aParent, String aPath)
           
Path(Path aParent, String aPath, boolean allowSloshes)
           
Path(String aParent, Path aPath)
           
 
Method Summary
 Path abbreviate(int maxLength)
          abbreviate a path by removing path components from the middle until the length of the path (as via .getPath()) is not greater then maxLength.
 Path[] abbreviatePathComponents(int maxLength)
          Returns a similar result to getPathComponents(), but abbreviates the result (inserts null at the break point)
 int compareTo(Path o)
           
 boolean equals(Object o)
           
 Path getCommonRoot(Path other)
           
 String getComponent(int i)
           
 String[] getComponents()
           
 String getExtension()
           
 String getName()
           
 int getNumComponents()
           
 Path getParent()
           
 String getPath()
           
 String getPath(boolean caseSensitive)
           
 Path[] getPathComponents()
           
 Path getPathHead()
           
 Path getRelativePath(Path aStartPath)
          returns a path relative to aStartPath.
 Path getRelativePath(Path aStartPath, boolean caseSensitive)
           
 Path getStripTail(Path other)
          if other is an exact tail of this, return the path leading up to that tail otherwise return null
 Path getSubPath(int depth)
           
 String getTail()
           
 Path getTailPath()
           
 int hashCode()
           
 boolean hasPrefix(Path p)
          determines if this path begins with all of p
 boolean hasPrefix(Path p, boolean caseSensitive)
           
 boolean isAbove()
          Indicates this path points to a locatio above the notional root.
 boolean isAncestor(Path descendant)
           
 boolean isRoot()
           
static String join(String a, String b)
          Intelligently Put a "/" between two strings.
 Path normalize()
           
 int numComponents()
           
static String parseDir(String p)
           
static String parseName(String p)
           
 Path simplify()
           
static String[] split(CharSequence aPath)
           
static String[] split(CharSequence aPath, boolean allowSloshes)
           
 void toLowerCase()
           
 String toString()
           
 Path trimFirst()
           
 Path trimFirst(int n)
           
 Path trimLast()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Path

public Path()

Path

public Path(CharSequence path)

Path

public Path(CharSequence path,
            boolean allowSloshes)

Path

public Path(Path path)

Path

public Path(Path aParent,
            String aPath)

Path

public Path(Path aParent,
            Path aPath)

Path

public Path(Path aParent,
            String aPath,
            boolean allowSloshes)

Path

public Path(String aParent,
            Path aPath)

Path

public Path(List<String> start)
Method Detail

getParent

public Path getParent()

getPath

public String getPath()
Returns:
the string representation of the path

getComponents

public String[] getComponents()

getPathComponents

public Path[] getPathComponents()

isAncestor

public boolean isAncestor(Path descendant)

getCommonRoot

public Path getCommonRoot(Path other)

getStripTail

public Path getStripTail(Path other)
if other is an exact tail of this, return the path leading up to that tail otherwise return null


getRelativePath

public Path getRelativePath(Path aStartPath)
returns a path relative to aStartPath. If the paths have no common prefix, then null object is returned.

TODO revisit this method, it's meaning and where it is used


getRelativePath

public Path getRelativePath(Path aStartPath,
                            boolean caseSensitive)

getName

public String getName()

toString

public String toString()
Overrides:
toString in class Object

simplify

public Path simplify()

isAbove

public boolean isAbove()
Indicates this path points to a locatio above the notional root.

Returns:
true if the path is above the root.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

join

public static String join(String a,
                          String b)
Intelligently Put a "/" between two strings.


split

public static String[] split(CharSequence aPath)

split

public static String[] split(CharSequence aPath,
                             boolean allowSloshes)

isRoot

public boolean isRoot()

trimFirst

public Path trimFirst()

trimFirst

public Path trimFirst(int n)
Parameters:
n - number of components to trim

trimLast

public Path trimLast()

getComponent

public String getComponent(int i)

numComponents

public int numComponents()

getNumComponents

public int getNumComponents()

compareTo

public int compareTo(Path o)
Specified by:
compareTo in interface Comparable<Path>

parseName

public static String parseName(String p)

parseDir

public static String parseDir(String p)

abbreviate

public Path abbreviate(int maxLength)
abbreviate a path by removing path components from the middle until the length of the path (as via .getPath()) is not greater then maxLength.

The first and last path component are always in the returned path.

If any path components were removed, an ellippses "..." will appear in the middle

The returned path may in some cases still be greater.


abbreviatePathComponents

public Path[] abbreviatePathComponents(int maxLength)
Returns a similar result to getPathComponents(), but abbreviates the result (inserts null at the break point)


hasPrefix

public boolean hasPrefix(Path p)
determines if this path begins with all of p


hasPrefix

public boolean hasPrefix(Path p,
                         boolean caseSensitive)

normalize

public Path normalize()

getPath

public String getPath(boolean caseSensitive)

toLowerCase

public void toLowerCase()

getSubPath

public Path getSubPath(int depth)

getPathHead

public Path getPathHead()

getTail

public String getTail()
Returns:
a String composed of all the path segments after the first segment

getTailPath

public Path getTailPath()

getExtension

public String getExtension()
Returns:
the file extension of the path (with no .), or null if there is no file extension


Copyright © 2002-2012 Atlassian. All Rights Reserved.