com.sas.io
Class FileSystemList

com.sas.io.FileSystemList
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.collection.ContentsChangedSource, StaticCollectionInterface, StaticOrderedCollectionInterface, ComponentInterface, LinkPropertiesInterface, ModelInterface, NodeIconInterface, NodeInterface, SimpleNodeInterface, TreeInterface, com.sas.PublicClonable, com.sas.util.Countable, com.sas.util.Enumerable, IndexedGetInterface, ViewInterface, MultipleValueEventSourceInterface, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class FileSystemList
implements StaticOrderedCollectionInterface, TreeInterface, NodeIconInterface

A class that holds a list of RootDirectories (drives) that are available on the system

Creating a FileSystemList Component

FileSystemList fsl = new FileSystemList();

See Also:
Serialized Form

Field Summary
protected  boolean needRefresh
           
protected static java.lang.String NODENAME
           
protected  OrderedCollection oc
           
 
Constructor Summary
FileSystemList()
          a default constructor which looks in local machine and fills the list with available drives.
 
Method Summary
 void addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
          Add a listener for the com.sas.collection.ContentsChangedEvent event.
 void apply(com.sas.util.ApplyInterface action)
          Applies the 'apply' function in the action to every item in the collection.
 java.lang.Object clone()
          Create a copy of the current model
 boolean contains(java.lang.Object element)
          Test for the presence of an object in the collection
 int count()
          Returns the number of items in the collection
 int countNodeChildren(int maximumChildCount)
          Counts the children of the current node. countNodeChildren differs from getNodeChildCount when the number of children is not readily known.
 boolean equals(StaticOrderedCollectionInterface orderedCollection)
          Compare the current items with those in another collection and tell whether the collections are identical.
 void fireContentsChanged(CollectionChangedInfo event)
          Send a ContentsChangedEvent event to all the contentsChangedListener objects in the listener list.
 java.lang.Object get(int index)
          Fetch an item at a index.
 com.sas.visuals.IconInterface getDefaultIcon()
          Returns the default icon for the current node.
 com.sas.visuals.IconInterface getExpandedIcon()
          Returns the expanded icon for the current node.
 com.sas.visuals.IconInterface getExpandedSelectedIcon()
          Sets the expandedSelected icon for the current node.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
           
 int getIndex(java.lang.Object element, int startIndex)
          Returns the index associated with the item (searches forward)
 java.util.Enumeration getItems()
          Gets the enumeration of the filesystem names.
 java.util.Enumeration getItems(int start, int end)
          Returns an enumeration of a subset of the items from a collection.
 int getLastIndex(java.lang.Object element, int startIndex)
          Returns the index associated with the item (searches backward)
 SimpleNodeInterface getNodeChild(int index)
          Returns the child node at the specified index.
 int getNodeChildCount()
          Returns the number of children available.
 SimpleNodeInterface[] getNodeChildren(int startIndex, int count)
          Returns the specified range of children for the current node.
 java.lang.String getNodeExpandedText()
          Returns the value of the nodeExpandedText property.
 java.lang.String getNodeText()
          Returns the value of the nodeText property.
 java.lang.String getNodeType()
          Returns the value of the nodeType property.
 NodeInterface getRoot()
          Gets the root for the tree implementation of the list
 com.sas.visuals.IconInterface getSelectedIcon()
          Returns the selected icon for the current node.
 void initialize()
          The initialize() method was designed to be a synchronization point after the constructor for the object has completed and a number of methods have been called on the component.
 boolean isLeafNode()
          Indicates whether the current node is a leaf.
 void removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
          Remove a listener for the com.sas.collection.ContentsChangedEvent event.
 java.lang.String toString()
           
 
Methods inherited from class com.sas.Component
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getLinkInfo, getModelInterface, getRequiredInterfaces, getResources, getStringResource, getViewInterfaceSupportInfo, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues, setLinkInfo, setModelInterface, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
 
Methods inherited from interface com.sas.beans.PropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

oc

protected transient OrderedCollection oc

needRefresh

protected transient boolean needRefresh

NODENAME

protected static java.lang.String NODENAME
Constructor Detail

FileSystemList

public FileSystemList()
a default constructor which looks in local machine and fills the list with available drives.

Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Create a copy of the current model

Specified by:
clone in interface StaticCollectionInterface
Specified by:
clone in interface StaticOrderedCollectionInterface
Specified by:
clone in interface com.sas.PublicClonable
Overrides:
clone in class Component
Returns:
a clone of the object.
Throws:
java.lang.CloneNotSupportedException - if the model attached to the component being cloned will not allow the clone to attach.

initialize

public void initialize()
Description copied from interface: ComponentInterface
The initialize() method was designed to be a synchronization point after the constructor for the object has completed and a number of methods have been called on the component. This allows components with "expensive" set method calls to delay processing until all the sets have occurred.

initialize() should be called on a component after is it constructed :

     ListBox listBox = new ListBox();
     listBox.initialize();
     container.add( listBox );
 

Overriding initialize is now discouraged since it is generally better to override setDefaultValues and readObject to perform initialization.

By default (in the ComponentInterface implementation), initialize() does nothing. However, various components override initialize() to perform operations, and it should be called.

Although use of initialize() is now discouraged, initialize() is also called by the validateObject method after a component is deserialized. This allows components which need processing during creation and deserialization to have a common place to perform operations. Adding event handlers to subcomponents is a typical use of the initialize method.

Specified by:
initialize in interface ComponentInterface
Overrides:
initialize in class Component
See Also:
ComponentInterface.initialize()

addContentsChangedListener

public void addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Add a listener for the com.sas.collection.ContentsChangedEvent event.

Specified by:
addContentsChangedListener in interface com.sas.collection.ContentsChangedSource
Parameters:
listener - an object which handles contentsChangedEvent events the listener is not added a second time if it already exists in the list of listeners for this event.
See Also:
ContentsChangedSource

removeContentsChangedListener

public void removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Remove a listener for the com.sas.collection.ContentsChangedEvent event. Nothing happens if the listener is not in the list of listeners for this event.

Specified by:
removeContentsChangedListener in interface com.sas.collection.ContentsChangedSource
Parameters:
listener - an object which handles ContentsChangedEvent events
See Also:
ContentsChangedSource

fireContentsChanged

public void fireContentsChanged(CollectionChangedInfo event)
Send a ContentsChangedEvent event to all the contentsChangedListener objects in the listener list. The listener list is copied first, so the event is sent only to each item which is in the list at the time of this copy, even if adds or removes are performed after the send has started.

Parameters:
event - the event to send

getItems

public java.util.Enumeration getItems()
Gets the enumeration of the filesystem names.

Specified by:
getItems in interface com.sas.util.Enumerable
Returns:
Enumeration of file system names

equals

public boolean equals(StaticOrderedCollectionInterface orderedCollection)
Compare the current items with those in another collection and tell whether the collections are identical. The equals method is used to compare collection items.

Specified by:
equals in interface StaticOrderedCollectionInterface
Parameters:
orderedCollection - Another ordered collection to be compared to.
Returns:
True if identical, False otherwise.

get

public java.lang.Object get(int index)
Fetch an item at a index.

Specified by:
get in interface IndexedGetInterface
Parameters:
index - the position of the item, zero-based indexing.
Returns:
the item associated with the index value
Throws:
java.lang.IndexOutOfBoundsException - if index is not in the range [0, count()-1].

getIndex

public int getIndex(java.lang.Object element,
                    int startIndex)
Returns the index associated with the item (searches forward)

Specified by:
getIndex in interface StaticOrderedCollectionInterface
Parameters:
element - item to search for
startIndex - the position where the search should start
Returns:
the zero-based index corresponding to the list item or -1 if the item is not found.
Throws:
java.lang.IndexOutOfBoundsException - if the index is not in the range [0..count()-1].
com.sas.util.InvalidElementTypeException - In some implementations, the objects that are stored may be restricted to a particular type (such as String). (a RuntimeException)

getItems

public java.util.Enumeration getItems(int start,
                                      int end)
Returns an enumeration of a subset of the items from a collection.

Specified by:
getItems in interface StaticOrderedCollectionInterface
Parameters:
start - the index of the first item, zero based.
end - one past the index of the last item to include in the enumeration, zero based. Note that the range of elements returned in the Enumeration does not include the endthe item; this is consistent with substring(start, end) in java.lang.String, for example.
Returns:
an enumeration of the requested elements.
Throws:
java.lang.IndexOutOfBoundsException - if start is not in the range [0, count()-1], or start>last or end is not in the range [0, count()]

getLastIndex

public int getLastIndex(java.lang.Object element,
                        int startIndex)
Returns the index associated with the item (searches backward)

Specified by:
getLastIndex in interface StaticOrderedCollectionInterface
Parameters:
element - the item to search for
startIndex - the position where the search should start
Returns:
the zero-based index corresponding to the list item or -1 if the item is not found.
Throws:
java.lang.IndexOutOfBoundsException - if the index is not in the range [0..count()-1]
com.sas.util.InvalidElementTypeException - In some implementations, the objects that are stored may be restricted to a particular type (such as String). (a RuntimeException)

contains

public boolean contains(java.lang.Object element)
Test for the presence of an object in the collection

Specified by:
contains in interface StaticCollectionInterface
Parameters:
element - The item to search for
Returns:
True if and only if the item exists
Throws:
com.sas.util.InvalidElementTypeException - In some implementations, the objects that are stored may be restricted to a particular type (such as String). (a RuntimeException)

count

public int count()
Returns the number of items in the collection

Specified by:
count in interface com.sas.util.Countable
Returns:
the number of items in the collection

apply

public void apply(com.sas.util.ApplyInterface action)
Applies the 'apply' function in the action to every item in the collection. This is a general way to modify all the items in a collection. (StaticOrderedCollection implementation)

Specified by:
apply in interface StaticCollectionInterface
Parameters:
action - An object that provides a function which takes an object as an argument and then does something to it. The application of the action continues until all items in the the collection have been operated on, of until a call to the action.apply(Object item) method returns ApplyInterface.ABORT

getRoot

public NodeInterface getRoot()
Gets the root for the tree implementation of the list

Specified by:
getRoot in interface TreeInterface
Returns:
NodeInterface

getNodeExpandedText

public java.lang.String getNodeExpandedText()
Returns the value of the nodeExpandedText property. The expanded text is usually a more descriptive version of the nodeText property. For example, a node that represents a file can return the file name for the nodeText property and the full path name for the nodeExpandedText property.

Specified by:
getNodeExpandedText in interface NodeInterface
Returns:
the nodeExpandedText property

getNodeText

public java.lang.String getNodeText()
Returns the value of the nodeText property.

Specified by:
getNodeText in interface NodeInterface
Returns:
the nodeText property

getNodeType

public java.lang.String getNodeType()
Returns the value of the nodeType property. The type can be used for categorizing nodes.

Specified by:
getNodeType in interface NodeInterface
Returns:
the nodeType property

countNodeChildren

public int countNodeChildren(int maximumChildCount)
Counts the children of the current node. countNodeChildren differs from getNodeChildCount when the number of children is not readily known. In such a case, getNodeChildCount will simply return -1 to indicate that the count is unknown, while countNodeChildren will actually compute the answer; thus countNodeChildren is a potentially expensive operation. To limit this potential overhead, a maximum child count may be passed to this method, such that the implementation will not read more than that many children. If exactly the number of children specified as the maximum count to read exists under the current node then a value equal in magnitude but opposite in sign (-maximumChildCount) should be returned.

Specified by:
countNodeChildren in interface SimpleNodeInterface
Parameters:
maximumChildCount - the maximum number of children to read, or 0 to read indefinitely
Returns:
The number of children known to be available.

getNodeChildCount

public int getNodeChildCount()
Returns the number of children available. If the number of children is unknown, -1 should be returned.

Specified by:
getNodeChildCount in interface SimpleNodeInterface
Returns:
the number of children or -1 if unknown

isLeafNode

public boolean isLeafNode()
Indicates whether the current node is a leaf. A true value indicates that the current node is a leaf and hence will not have any children.

Specified by:
isLeafNode in interface SimpleNodeInterface
Returns:
true if the current node is a leaf, otherwise false

getNodeChild

public SimpleNodeInterface getNodeChild(int index)
Returns the child node at the specified index.

Specified by:
getNodeChild in interface SimpleNodeInterface
Parameters:
index - the 0-based index of the child node to retrieve
Returns:
the child at index or null if the leafNode property value is true.

getNodeChildren

public SimpleNodeInterface[] getNodeChildren(int startIndex,
                                             int count)
Returns the specified range of children for the current node. If there are less children than are queried for, an implementation can return an array whose size if representative of the actual number of children being returned or an array whose size is the same as the number of children asked for. If the resulting array's size is the same as the number asked for and there are fewer children returned than asked for the implementation should assign the unused values in the array to null.

Specified by:
getNodeChildren in interface SimpleNodeInterface
Parameters:
startIndex - 0-based index which identifies the start of the range
count - the amount of children to get
Returns:
an array containing the specified range of children or null if the leafNode property value is true.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getDefaultIcon

public com.sas.visuals.IconInterface getDefaultIcon()
Returns the default icon for the current node.

Specified by:
getDefaultIcon in interface NodeIconInterface
Returns:
the default icon for the current node

getExpandedIcon

public com.sas.visuals.IconInterface getExpandedIcon()
Returns the expanded icon for the current node. If the expanded icon is null then the result of getDefaultIcon should be returned.

Specified by:
getExpandedIcon in interface NodeIconInterface
Returns:
the expanded icon for the current node

getSelectedIcon

public com.sas.visuals.IconInterface getSelectedIcon()
Returns the selected icon for the current node. If the selected icon is null then the result of getDefaultIcon should be returned.

Specified by:
getSelectedIcon in interface NodeIconInterface
Returns:
the selected icon for the current node

getExpandedSelectedIcon

public com.sas.visuals.IconInterface getExpandedSelectedIcon()
Sets the expandedSelected icon for the current node. If the expandedSelected icon is null then the result of getExpandedIcon should be returned.

Specified by:
getExpandedSelectedIcon in interface NodeIconInterface
Returns:
the expandedSelected icon for the current node



Copyright © 2009 SAS Institute Inc. All Rights Reserved.