net.sf.jfilesync.util
Class TPathControlBase

java.lang.Object
  extended by net.sf.jfilesync.util.TPathControlBase
All Implemented Interfaces:
TPathControlInterface
Direct Known Subclasses:
TPathUnix, TPathWindows

public abstract class TPathControlBase
extends java.lang.Object
implements TPathControlInterface

This class provides the basic functions for working with directories on different systems. All sub-classes should override system specific methods.


Field Summary
private  java.lang.String fileSeparator
           
protected  java.lang.String root_str
           
 
Constructor Summary
TPathControlBase(java.lang.String fileSep)
           
 
Method Summary
 java.lang.String appendDirectory(java.lang.String absolutePath, java.lang.String path)
           
 java.lang.String basename(java.lang.String path)
          returns the last object in a path like /a/b/c The object <> can be a filename or a name of a directory.
 java.lang.String basepath(java.lang.String rootdir, java.lang.String path, java.lang.String basename)
          returns b if the root dir is /a and path is /a/b/c and basename c
 java.lang.String getFileSeparator()
           
 java.lang.String getNetPath(java.lang.String path)
           
 java.lang.String getPathLevelUp(java.lang.String path)
           
 java.lang.String getRoot(java.lang.String path)
          returns the current root of a given path
 boolean isRoot(java.lang.String path)
           
 java.lang.String netAppendDirectory(java.lang.String absolutePath, java.lang.String path)
           
 java.lang.String netPlainpath(java.lang.String root, java.lang.String path)
          the same functionality as plain path but for network protocols like FTP, SFTP where the folder root is "/"
 java.lang.String normalize(java.lang.String path)
          returns a valid path for a given system, if the path exists is not checked
 java.lang.String plainpath(java.lang.String root, java.lang.String path)
          root = /a path = /a/b/c returns b/c there will be no file separator at the start of the string
 boolean startsWithRoot(java.lang.String path)
           
 java.lang.String trimPathString(java.lang.String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jfilesync.util.TPathControlInterface
getPrintablePath
 

Field Detail

root_str

protected java.lang.String root_str

fileSeparator

private java.lang.String fileSeparator
Constructor Detail

TPathControlBase

public TPathControlBase(java.lang.String fileSep)
Method Detail

getFileSeparator

public java.lang.String getFileSeparator()
Specified by:
getFileSeparator in interface TPathControlInterface

isRoot

public boolean isRoot(java.lang.String path)
Specified by:
isRoot in interface TPathControlInterface

getPathLevelUp

public java.lang.String getPathLevelUp(java.lang.String path)
Specified by:
getPathLevelUp in interface TPathControlInterface

trimPathString

public java.lang.String trimPathString(java.lang.String path)
Specified by:
trimPathString in interface TPathControlInterface

appendDirectory

public java.lang.String appendDirectory(java.lang.String absolutePath,
                                        java.lang.String path)
Specified by:
appendDirectory in interface TPathControlInterface

netAppendDirectory

public java.lang.String netAppendDirectory(java.lang.String absolutePath,
                                           java.lang.String path)
Specified by:
netAppendDirectory in interface TPathControlInterface

getNetPath

public java.lang.String getNetPath(java.lang.String path)
Specified by:
getNetPath in interface TPathControlInterface

startsWithRoot

public boolean startsWithRoot(java.lang.String path)
Specified by:
startsWithRoot in interface TPathControlInterface

basename

public java.lang.String basename(java.lang.String path)
Description copied from interface: TPathControlInterface
returns the last object in a path like /a/b/c The object <> can be a filename or a name of a directory.

Specified by:
basename in interface TPathControlInterface
Returns:
from /a/b/c(/) -> c

basepath

public java.lang.String basepath(java.lang.String rootdir,
                                 java.lang.String path,
                                 java.lang.String basename)
Description copied from interface: TPathControlInterface
returns b if the root dir is /a and path is /a/b/c and basename c

Specified by:
basepath in interface TPathControlInterface
Returns:
basepath

plainpath

public java.lang.String plainpath(java.lang.String root,
                                  java.lang.String path)
Description copied from interface: TPathControlInterface
root = /a path = /a/b/c returns b/c there will be no file separator at the start of the string

Specified by:
plainpath in interface TPathControlInterface
Returns:
path without string that was declared to be root

netPlainpath

public java.lang.String netPlainpath(java.lang.String root,
                                     java.lang.String path)
Description copied from interface: TPathControlInterface
the same functionality as plain path but for network protocols like FTP, SFTP where the folder root is "/"

Specified by:
netPlainpath in interface TPathControlInterface
Returns:
path without string that was passed to be the root

getRoot

public java.lang.String getRoot(java.lang.String path)
Description copied from interface: TPathControlInterface
returns the current root of a given path

Specified by:
getRoot in interface TPathControlInterface
Returns:
the root of path or an empty string if path does not have a root

normalize

public java.lang.String normalize(java.lang.String path)
Description copied from interface: TPathControlInterface
returns a valid path for a given system, if the path exists is not checked

Specified by:
normalize in interface TPathControlInterface