net.kano.joscar.rvcmd
Class SegmentedFilename

java.lang.Object
  extended bySegmentedFilename

public final class SegmentedFilename
extends java.lang.Object

A data structure containing a series of directory and file names ("segments") that form a system-independent representation of a "file path." This structure is used in file transfers to accommodate for sharing files between operating systems.


Constructor Summary
SegmentedFilename(SegmentedFilename parent, SegmentedFilename child)
          Creates a new SegmentedFilename that consists of the segments in parent followed by the segments in child.
SegmentedFilename(SegmentedFilename parent, java.lang.String file)
          Creates a new SegmentedFilename with the given segmented filename as its "parent" and the given file or directory name as the last "segment."
SegmentedFilename(java.lang.String[] parts)
          Creates a SegmentedFilename containing the given list of segments.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
static SegmentedFilename fromFTFilename(java.lang.String ftFilename)
          Creates a SegmentedFilename from the given "file transfer filename."
static SegmentedFilename fromNativeFilename(java.lang.String nativeFilename)
          Creates a SegmentedFilename from the given native filename.
 java.lang.String[] getSegments()
          Returns an array containing the "segments" of which this segmented filename consists.
 int hashCode()
           
 java.lang.String toFTFilename()
          Converts this segmented filename to a string, separating segments in the returned string with the "file transfer filename" separator (character \001).
 java.lang.String toNativeFilename()
          Converts this segmented filename to a string, separating segments in the returned string with the system's native file separator.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SegmentedFilename

public SegmentedFilename(SegmentedFilename parent,
                         java.lang.String file)
Creates a new SegmentedFilename with the given segmented filename as its "parent" and the given file or directory name as the last "segment." Using this constructor is equivalent to using new SegmentedFilename(parent, new SegmentedFilename(new String[] { file ))}.

Note that if parent is null, this method is equivalent to using new SegmentedFilename(new String[] { file )}. Also note that file cannot be null.

Parameters:
parent - the "parent" SegmentedFilename
file - a filename to be the last segment of the created segmented filename

SegmentedFilename

public SegmentedFilename(SegmentedFilename parent,
                         SegmentedFilename child)
Creates a new SegmentedFilename that consists of the segments in parent followed by the segments in child. Note that if parent is null, the created segmented filename will simply be a clone of child.

Parameters:
parent - the "parent" segmented filename, or null for none
child - the "child" segmented filename

SegmentedFilename

public SegmentedFilename(java.lang.String[] parts)
Creates a SegmentedFilename containing the given list of segments.

Parameters:
parts - the list of filename "segments" of which the created segmented filename should consist
Method Detail

fromNativeFilename

public static SegmentedFilename fromNativeFilename(java.lang.String nativeFilename)
Creates a SegmentedFilename from the given native filename. Note that this method will only produce a valid SegmentedFilename for filenames on the platform on which the JVM is currently running, as it uses the JVM's file.separator system propery.

Parameters:
nativeFilename - a native filename to be converted to a SegmentedFilename
Returns:
a SegmentedFilename generated from the given native filename

fromFTFilename

public static SegmentedFilename fromFTFilename(java.lang.String ftFilename)
Creates a SegmentedFilename from the given "file transfer filename." A "file transfer filename" is simply a filename in the format "\001home\001keith\001dev\001joust\001Joust.ipr", where \001 is the ASCII character with the value 0x01.

Parameters:
ftFilename - a "file transfer filename" to convert to a SegmentedFilename
Returns:
a SegmentedFilename generated from the given "file transfer filename"

getSegments

public final java.lang.String[] getSegments()
Returns an array containing the "segments" of which this segmented filename consists.

Returns:
an array containing this segmented filename's component "segments"

toNativeFilename

public final java.lang.String toNativeFilename()
Converts this segmented filename to a string, separating segments in the returned string with the system's native file separator.

Returns:
a String containing the filename as a native filename

toFTFilename

public final java.lang.String toFTFilename()
Converts this segmented filename to a string, separating segments in the returned string with the "file transfer filename" separator (character \001).

Returns:
a String containing the filename as a "file transfer filename"

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object obj)

toString

public java.lang.String toString()