com.atlassian.jira.issue.attachment
Class Path

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

public class Path
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<Path>

Copied from FECRU

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

See Also:
Serialized Form

Constructor Summary
Path()
           
Path(java.lang.CharSequence path)
           
Path(java.lang.CharSequence path, boolean allowSloshes)
           
Path(java.util.List<java.lang.String> start)
           
Path(Path path)
           
Path(Path aParent, Path aPath)
           
Path(Path aParent, java.lang.String aPath)
           
Path(Path aParent, java.lang.String aPath, boolean allowSloshes)
           
Path(java.lang.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(java.lang.Object o)
           
 Path getCommonRoot(Path other)
           
 java.lang.String getComponent(int i)
           
 java.lang.String[] getComponents()
           
 java.lang.String getExtension()
           
 java.lang.String getName()
           
 int getNumComponents()
           
 Path getParent()
           
 java.lang.String getPath()
           
 java.lang.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)
           
 java.lang.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 java.lang.String join(java.lang.String a, java.lang.String b)
          Intelligently Put a "/" between two strings.
 Path normalize()
           
 int numComponents()
           
static java.lang.String parseDir(java.lang.String p)
           
static java.lang.String parseName(java.lang.String p)
           
 Path simplify()
           
static java.lang.String[] split(java.lang.CharSequence aPath)
           
static java.lang.String[] split(java.lang.CharSequence aPath, boolean allowSloshes)
           
 void toLowerCase()
           
 java.lang.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(java.lang.CharSequence path)

Path

public Path(java.lang.CharSequence path,
            boolean allowSloshes)

Path

public Path(Path path)

Path

public Path(Path aParent,
            java.lang.String aPath)

Path

public Path(Path aParent,
            Path aPath)

Path

public Path(Path aParent,
            java.lang.String aPath,
            boolean allowSloshes)

Path

public Path(java.lang.String aParent,
            Path aPath)

Path

public Path(java.util.List<java.lang.String> start)
Method Detail

getParent

public Path getParent()

getPath

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

getComponents

public java.lang.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 java.lang.String getName()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.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(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

join

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


split

public static java.lang.String[] split(java.lang.CharSequence aPath)

split

public static java.lang.String[] split(java.lang.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 java.lang.String getComponent(int i)

numComponents

public int numComponents()

getNumComponents

public int getNumComponents()

compareTo

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

parseName

public static java.lang.String parseName(java.lang.String p)

parseDir

public static java.lang.String parseDir(java.lang.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 java.lang.String getPath(boolean caseSensitive)

toLowerCase

public void toLowerCase()

getSubPath

public Path getSubPath(int depth)

getPathHead

public Path getPathHead()

getTail

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

getTailPath

public Path getTailPath()

getExtension

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


Copyright © 2002-2010 Atlassian. All Rights Reserved.