com.tivoli.twg.filetransfer
Class FSTObject

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended bycom.tivoli.twg.guilibs.UFTreeListViewObject
          extended bycom.tivoli.twg.filetransfer.FSTObject
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode

public class FSTObject
extends com.tivoli.twg.guilibs.UFTreeListViewObject
implements java.io.Serializable

This is a class to represent file system objects in the tree and in the list of files. It is more versitle than the simple string representation.

See Also:
Serialized Form

Field Summary
static int DIRECTORY
          constant to indicate the type of FSTObject is a Directory
static int DRIVE
          constant to indicate the type of FSTObject is a Drive
static int DRIVE_TYPE_CD_ROM
           
static int DRIVE_TYPE_FLOPPY
           
static int DRIVE_TYPE_HARDFILE
           
static int DRIVE_TYPE_NETWORK
           
static int DRIVE_TYPE_NOT_REPORTED
           
static int DRIVE_TYPE_RAMDRIVE
           
static int FILE
          constant to indicate the type of FSTObject is a File
 
Fields inherited from class com.tivoli.twg.guilibs.UFTreeListViewObject
DEFAULT_SORT_WEIGHT
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
FSTObject(java.lang.String name, java.lang.String path)
          Constructor for an FSTObject of type FILE.
FSTObject(java.lang.String name, java.lang.String path, int type)
          Constructor for an FSTObject of any type
FSTObject(java.lang.String name, java.lang.String path, int type, java.lang.String driveLabel, int driveType)
          Constructor for an FSTObject of any type
 
Method Summary
 void add(javax.swing.tree.MutableTreeNode toAdd)
          Add a child node to this parent node.
 java.lang.Object clone()
          Overides clone so it "remembers" its children.
static int compare(FSTObject o1, FSTObject o2)
          Compare two FSTObjects.
 boolean equals(java.lang.Object obj)
          Checks to see if the passed in Object is an FSTObject and whether it has the same path and name as this one.
 java.lang.String getDriveLabel()
          Returns the object's drive label.
 int getDriveType()
          Returns the object's drive type.
 javax.swing.ImageIcon getExpandedImage()
          Returns the image used to represent the node.
 FileAttrs getFileAttributes()
          Get the file attributes belonging to this object.
 java.lang.String getFileSystemPath()
          Returns a string representation of the objects location on the file system
 javax.swing.ImageIcon getImage()
          Returns the image used to represent the node.
 java.lang.String getName()
          Returns the object name.
 int getType()
          Returns the object type,
 void insert(javax.swing.tree.MutableTreeNode newChild, int childIndex)
          Removes newChild from its present parent (if it has a parent), sets the child's parent to this node, and then adds the child to this node's child array at index childIndex.
 boolean isEmpty()
          Test whether or not this directory is empty.
 void remove(int childIndex)
           
 void remove(javax.swing.tree.MutableTreeNode aChild)
           
 void removeAllChildren()
           
static java.lang.String removeDuplicateChars(java.lang.String str, char c)
          Replaces all double occurrences of c (eg.
 void setDirectoryEmpty(boolean b)
          Sets the directory empty flag.
 void setDriveLabel(java.lang.String driveLabel)
          Sets the object's drive label.
 void setDriveType(int driveType)
          Sets the object's drive type.
 void setFileAttributes(FileAttrs attrs)
          Set the file attributes belonging to this object.
 void setFileSystemPath(java.lang.String path)
          Sets the file system path.
 void setName(java.lang.String name)
          Sets the name of this object.
 void setType(int type)
          Sets the object type,
static java.lang.String toDisplay(FileSource source, java.lang.String filename)
          Always display paths separated by the local default path delimiter.
static java.lang.String toDisplay(java.lang.String filename)
          Always display paths separated by the local default path delimiter.
static java.lang.String toSend(FileSource source, java.lang.String filename)
          Always send paths separated by backslashes.
static java.lang.String toSend(java.lang.String filename)
          Always send paths separated by backslashes.
static java.lang.String toStore(FileSource source, java.lang.String filename)
          Always store paths separated by forward slashes.
static java.lang.String toStore(java.lang.String filename)
          Always store paths separated by forward slashes.
 java.lang.String toString()
          Returns tha path plus the file name separated by forward slashes.
 
Methods inherited from class com.tivoli.twg.guilibs.UFTreeListViewObject
compareCaption, getCaption, getCaptionBackgroundColor, getCaptionFont, getCaptionForegroundColor, getLargeExpandedImage, getLargeImage, getSortWeight, getStatusDefinitions, isASource, isATarget, isEnabled, isTargetable, resetViewProperties, setAsSource, setAsTarget, setAsTargetable, setCaption, setCaptionBackgroundColor, setCaptionFont, setCaptionForegroundColor, setEnabled, setExpandedImage, setImage, setLargeExpandedImage, setLargeImage, setSortWeight, setStatusDefinitions, useExpandImage
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
breadthFirstEnumeration, children, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FILE

public static final int FILE
constant to indicate the type of FSTObject is a File

See Also:
Constant Field Values

DIRECTORY

public static final int DIRECTORY
constant to indicate the type of FSTObject is a Directory

See Also:
Constant Field Values

DRIVE

public static final int DRIVE
constant to indicate the type of FSTObject is a Drive

See Also:
Constant Field Values

DRIVE_TYPE_NOT_REPORTED

public static final int DRIVE_TYPE_NOT_REPORTED
See Also:
Constant Field Values

DRIVE_TYPE_FLOPPY

public static final int DRIVE_TYPE_FLOPPY
See Also:
Constant Field Values

DRIVE_TYPE_HARDFILE

public static final int DRIVE_TYPE_HARDFILE
See Also:
Constant Field Values

DRIVE_TYPE_CD_ROM

public static final int DRIVE_TYPE_CD_ROM
See Also:
Constant Field Values

DRIVE_TYPE_NETWORK

public static final int DRIVE_TYPE_NETWORK
See Also:
Constant Field Values

DRIVE_TYPE_RAMDRIVE

public static final int DRIVE_TYPE_RAMDRIVE
See Also:
Constant Field Values
Constructor Detail

FSTObject

public FSTObject(java.lang.String name,
                 java.lang.String path)
Constructor for an FSTObject of type FILE.


FSTObject

public FSTObject(java.lang.String name,
                 java.lang.String path,
                 int type)
Constructor for an FSTObject of any type


FSTObject

public FSTObject(java.lang.String name,
                 java.lang.String path,
                 int type,
                 java.lang.String driveLabel,
                 int driveType)
Constructor for an FSTObject of any type

Method Detail

insert

public void insert(javax.swing.tree.MutableTreeNode newChild,
                   int childIndex)
Removes newChild from its present parent (if it has a parent), sets the child's parent to this node, and then adds the child to this node's child array at index childIndex. newChild must not be null and must not be an ancestor of this node.

Specified by:
insert in interface javax.swing.tree.MutableTreeNode
Parameters:
newChild - the MutableTreeNode to insert under this node
childIndex - the index in this node's child array where this node is to be inserted
Throws:
java.lang.ArrayIndexOutOfBoundsException - if childIndex is out of bounds
java.lang.IllegalArgumentException - if newChild is null or is an ancestor of this node
java.lang.IllegalStateException - if this node does not allow children
See Also:
DefaultMutableTreeNode.isNodeDescendant(javax.swing.tree.DefaultMutableTreeNode)

add

public void add(javax.swing.tree.MutableTreeNode toAdd)
Add a child node to this parent node.


removeAllChildren

public void removeAllChildren()

remove

public void remove(javax.swing.tree.MutableTreeNode aChild)
Specified by:
remove in interface javax.swing.tree.MutableTreeNode

remove

public void remove(int childIndex)
Specified by:
remove in interface javax.swing.tree.MutableTreeNode

compare

public static int compare(FSTObject o1,
                          FSTObject o2)
Compare two FSTObjects.

Returns:
int - less than 0 if o2 is bigger, more than 0 if o1 is bigger and 0 if they are equal.

clone

public java.lang.Object clone()
Overides clone so it "remembers" its children.

Returns:
Object - a copy of this object.

getImage

public javax.swing.ImageIcon getImage()
Returns the image used to represent the node.


getExpandedImage

public javax.swing.ImageIcon getExpandedImage()
Returns the image used to represent the node.


getName

public java.lang.String getName()
Returns the object name.

Returns:
String - the file name.

setName

public void setName(java.lang.String name)
Sets the name of this object.


getType

public int getType()
Returns the object type,

Returns:
int - one of: DRIVE, DIRECTORY, FILE.

setType

public void setType(int type)
Sets the object type,


getDriveType

public int getDriveType()
Returns the object's drive type. Only meaningful if the object type is DRIVE.

Returns:
int - one of: DRIVE_TYPE_NOT_REPORTED, DRIVE_TYPE_FLOPPY, DRIVE_TYPE_HARDFILE, DRIVE_TYPE_CD_ROM, DRIVE_TYPE_NETWORK, DRIVE_TYPE_RAMDRIVE

setDriveType

public void setDriveType(int driveType)
Sets the object's drive type. Only meaningful if the object type is DRIVE.


getDriveLabel

public java.lang.String getDriveLabel()
Returns the object's drive label. Only meaningful if the object type is DRIVE.

Returns:
String - this object's drive label

setDriveLabel

public void setDriveLabel(java.lang.String driveLabel)
Sets the object's drive label. Only meaningful if the object type is DRIVE.


getFileSystemPath

public java.lang.String getFileSystemPath()
Returns a string representation of the objects location on the file system

Returns:
String - the path to this file.

setFileSystemPath

public void setFileSystemPath(java.lang.String path)
Sets the file system path.


toString

public java.lang.String toString()
Returns tha path plus the file name separated by forward slashes. Use the toDisplay, and toSend methods to convert the path delimiters as appropriate.

Returns:
String - internal String representation of this object.

equals

public boolean equals(java.lang.Object obj)
Checks to see if the passed in Object is an FSTObject and whether it has the same path and name as this one.

Parameters:
obj - the FSTobject to compare against.

setDirectoryEmpty

public void setDirectoryEmpty(boolean b)
Sets the directory empty flag. Used to take care of problem with endless update attempts.


isEmpty

public boolean isEmpty()
Test whether or not this directory is empty. Useful for testing whether or not the directory has been retrieved from a file source.

Returns:
boolean - true if this is an empty directory.

setFileAttributes

public void setFileAttributes(FileAttrs attrs)
Set the file attributes belonging to this object. This should be done during every refresh.


getFileAttributes

public FileAttrs getFileAttributes()
Get the file attributes belonging to this object.

Returns:
FileAttrs - the attributes object.

toDisplay

public static java.lang.String toDisplay(java.lang.String filename)
Always display paths separated by the local default path delimiter.

Returns:
String - path formatted with local seperator char.

toStore

public static java.lang.String toStore(java.lang.String filename)
Always store paths separated by forward slashes.

Returns:
String - path formatted with forward slashes.

toSend

public static java.lang.String toSend(java.lang.String filename)
Always send paths separated by backslashes.

Returns:
String - path formatted with backslashes.

toDisplay

public static java.lang.String toDisplay(FileSource source,
                                         java.lang.String filename)
Always display paths separated by the local default path delimiter.

Returns:
String - path formatted with local seperator char.

toStore

public static java.lang.String toStore(FileSource source,
                                       java.lang.String filename)
Always store paths separated by forward slashes.

Returns:
String - path formatted with forward slashes.

toSend

public static java.lang.String toSend(FileSource source,
                                      java.lang.String filename)
Always send paths separated by backslashes.

Returns:
String - path formatted with backslashes.

removeDuplicateChars

public static java.lang.String removeDuplicateChars(java.lang.String str,
                                                    char c)
Replaces all double occurrences of c (eg. c + c becomes just c).

Returns:
String new string with duplicate chars stripped.