|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.io.FileList
public class FileList
A class that holds a list of File and Directory names that are available in a Directory on a specified FileSystem.
Creating a FileList Component
A FileList object can be used as a model for ListBox, ComboBox or Tree. Create a FileList object, set its property - startingDirectories and filterPredicates and include directories. If the properties are not set, then a list of fileSystems (drives) are displayed in a tree and list of files in the listbox. Specify the options - recursive. To create a FileList Object FileList fl = new FileList("*", "*.gif", true) will create a list of all the files that are gif files. The flag set to true in above constructor will affect the list if it is displayed in a tree, otherwise it is ignored. To use this class to search the directories recursively, use it by dropping it on a tree. A call to getitem() method will only return the files in the starting directories that match the file filter, it will not do a recursive search.
| Field Summary | |
|---|---|
protected static OrderedCollection |
coc
|
protected static OrderedCollection |
driveCollection
|
protected static java.lang.String |
environmentVariable
|
protected StringCollection |
fileNameList
|
protected com.sas.collection.ContentsChangedListener[] |
listenerList
|
protected static OrderedCollection |
newPathCollection
|
protected OrderedCollection |
oc
|
protected static OrderedCollection |
pathCollection
|
protected static java.lang.String |
RB_KEY
|
protected static boolean |
showDirectories
|
protected static boolean |
showFiles
|
protected static boolean |
sortSelected
|
| Constructor Summary | |
|---|---|
FileList()
A default constructor initilaizes the list with the fileSystem names (drive names). |
|
FileList(java.lang.String startingDirs,
java.lang.String filters,
boolean recursive)
A constructor that takes the directory name and filter and fills this list based on the file filter. |
|
| 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(absolute path name of file) in the collection (StaticOrderedCollection implementation) |
int |
count()
Returns the number of files and directories in the current collection (StaticOrderedCollection implementation) |
int |
countNodeChildren(int maximumChildCount)
Counts the children of the current node. |
boolean |
equals(StaticOrderedCollectionInterface orderedCollection)
Compare the current collection of absolute file name strings with those in another collection and tell whether the collections are identical. |
void |
fireContentsChanged(com.sas.collection.ContentsChangedEvent event)
Send a ChangedEvent event to all the ChangedListener objects in the listener list. |
java.lang.Object |
get(int index)
Fetch an item (absolute path name of file) at an 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()
|
java.lang.String |
getFilters()
Gets the file filters seperated by semicolon. |
int |
getIndex(java.lang.Object element,
int startIndex)
Returns the index associated with the item (searches forward) (StaticOrderedCollection implementation) |
java.util.Enumeration |
getItems()
Returns list of file name Strings as an enumeration. |
java.util.Enumeration |
getItems(int start,
int end)
Returns an enumeration of a subset of the items (an absolute path name of files) from a collection. |
int |
getLastIndex(java.lang.Object element,
int startIndex)
Returns the index associated with the item (searches backward) (StaticOrderedCollection implementation) |
SimpleNodeInterface |
getNodeChild(int index)
Returns the child node at the specified index. |
int |
getNodeChildCount()
Returns the number of children. |
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. |
java.lang.String |
getStartingDirectories()
get the starting direcotry property for this filelist. |
boolean |
isLeafNode()
Indicates whether the current node is a leaf. |
boolean |
isRecursive()
return a flag indicating whether to show directories or not |
com.sas.util.PredicateInterface |
newFilterPredicate(java.lang.Object predicateString)
Create a new predicate and return it. |
void |
refresh()
Adds the names to the filenames only if the list is not filled |
void |
refreshAlways()
Add the filenames to the list again. |
void |
removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Remove a listener for the com.sas.collection.ContentsChangedEvent event. |
void |
setDefaultValues()
This method sets the initial property values to their default values. |
void |
setFilters(java.lang.String fils)
Sets the file filterPredicates to match the filenames to add to this list. |
void |
setPredicates(com.sas.util.PredicateInterface[] predicates)
Sets the filterPredicates property to the the predicates passed in. |
void |
setRecursive(boolean recursive)
Set the flag to show directories or not |
void |
setStartingDirectories(java.lang.String startingDirs)
Set the starting directories property for this list. |
protected void |
sort(com.sas.util.Comparator comparator)
|
void |
sort(com.sas.util.Comparator comparator,
int start,
int end)
Sorts a range of items from the current collection using the provided comparison function. |
java.lang.String |
toString()
Returns the list as filenames seperated by comma |
| Methods inherited from interface com.sas.beans.PropertyChangeSource |
|---|
addPropertyChangeListener, removePropertyChangeListener |
| Field Detail |
|---|
protected static java.lang.String environmentVariable
protected static OrderedCollection coc
protected static OrderedCollection driveCollection
protected static OrderedCollection pathCollection
protected static OrderedCollection newPathCollection
protected static boolean showFiles
protected static boolean showDirectories
protected static boolean sortSelected
protected static final java.lang.String RB_KEY
protected transient OrderedCollection oc
protected transient StringCollection fileNameList
protected com.sas.collection.ContentsChangedListener[] listenerList
| Constructor Detail |
|---|
public FileList()
public FileList(java.lang.String startingDirs,
java.lang.String filters,
boolean recursive)
startingDirectories - a semicolon seperated list of directories
to start the search from.filters - a semicolon seperated list of file filters to match the
filenames against.recursive - indicated whether the list should contain directories
or not.| Method Detail |
|---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void setDefaultValues()
ComponentInterfaceNote that the designTime property is not initialized when setDefaultValues is called, so initialization which depends on the value of designTime should take place in initializeComponent.
setDefaultValues in interface ComponentInterfacesetDefaultValues in class ComponentComponentInterface.setDefaultValues()public void setStartingDirectories(java.lang.String startingDirs)
a - semicolon separated directory names.public java.lang.String getStartingDirectories()
public void setFilters(java.lang.String fils)
a - semicolon or coma seperated list of file filterPredicates.public java.lang.String getFilters()
public com.sas.util.PredicateInterface newFilterPredicate(java.lang.Object predicateString)
predicateString - to be converted to predicate
public void setPredicates(com.sas.util.PredicateInterface[] predicates)
preicates - to be set for this listpublic java.util.Enumeration getItems()
getItems in interface com.sas.util.Enumerablepublic NodeInterface getRoot()
FileList fl = new FileList("d:\\images", "*")
- will create a root node called FileList(d:\\images\\*) and
set its children to (d:\\images\\*) and its children to the files
and directories in images directories..
(TreeInterface implementation)
getRoot in interface TreeInterfacepublic boolean isRecursive()
public void setRecursive(boolean recursive)
recursive - flag shows directories if true.public void addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
addContentsChangedListener in interface com.sas.collection.ContentsChangedSourcelistener - an object which handles ChangedEvent events
the listener is not added a second time if it already exists
in the list of listeners for this event.ContentsChangedSourcepublic void removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
removeContentsChangedListener in interface com.sas.collection.ContentsChangedSourcelistener - an object which handles ContentsChangedEvent eventsContentsChangedSourcepublic void fireContentsChanged(com.sas.collection.ContentsChangedEvent event)
event - the event to send
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface StaticCollectionInterfaceclone in interface StaticOrderedCollectionInterfaceclone in interface com.sas.PublicClonableclone in class Componentjava.lang.CloneNotSupportedException - if the model attached to the component being cloned
will not allow the clone to attach.public java.lang.String getNodeExpandedText()
getNodeExpandedText in interface NodeInterfacepublic java.lang.String getNodeText()
getNodeText in interface NodeInterfacepublic java.lang.String getNodeType()
getNodeType in interface NodeInterfacepublic int countNodeChildren(int maximumChildCount)
countNodeChildren is an instruction to determine the number of children even though that number is not readily known. To limit the potential overhead of this determination, the maximum number of children to read may be specified.
countNodeChildren in interface SimpleNodeInterfacemaxCount - Maximum number of children to read, or 0 to read indefinitely.
Implementations where the number of children is always known should
ignore this parameter. In cases where the total number of children
is unknown, but the number known so far is greater than maxCount
should return the larger known number. Thus maxCount is only used as
a limiting factor when the implementation has to actually do
computation (e.g. fetch observations).
public int getNodeChildCount()
getNodeChildCount in interface SimpleNodeInterfacepublic boolean isLeafNode()
isLeafNode in interface SimpleNodeInterfacepublic SimpleNodeInterface getNodeChild(int index)
getNodeChild in interface SimpleNodeInterfaceindex - the 0-based index of the child node to retrieve
true.
public SimpleNodeInterface[] getNodeChildren(int startIndex,
int count)
getNodeChildren in interface SimpleNodeInterfacestartIndex - 0-based index which identifies the start of the rangecount - the amount of children to get
true.public com.sas.visuals.IconInterface getDefaultIcon()
getDefaultIcon in interface NodeIconInterfacepublic com.sas.visuals.IconInterface getExpandedIcon()
getExpandedIcon in interface NodeIconInterfacepublic com.sas.visuals.IconInterface getSelectedIcon()
getSelectedIcon in interface NodeIconInterfacepublic com.sas.visuals.IconInterface getExpandedSelectedIcon()
getExpandedSelectedIcon in interface NodeIconInterfacepublic boolean equals(StaticOrderedCollectionInterface orderedCollection)
equals in interface StaticOrderedCollectionInterfaceorderedCollection - Another ordered collection of absolute file name strings
to be compared to.
public java.lang.Object get(int index)
get in interface IndexedGetInterfaceindex - the position of the item, zero-based indexing.
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()-1].
public int getIndex(java.lang.Object element,
int startIndex)
getIndex in interface StaticOrderedCollectionInterfaceelement - item (an absolute path name of file) to search forstartIndex - the position where the search should start
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)
public java.util.Enumeration getItems(int start,
int end)
getItems in interface StaticOrderedCollectionInterfacestart - 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.
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()]
public int getLastIndex(java.lang.Object element,
int startIndex)
getLastIndex in interface StaticOrderedCollectionInterfaceelement - the item(absolute path name of file) to search forstartIndex - the position where the search should start
java.lang.IndexOutOfBoundsException - if the index is
not in the range [0..count()-1]
com.sas.util.InvalidElementTypeException - when the object is
not of type String (a RuntimeException) (a RuntimeException)public boolean contains(java.lang.Object element)
contains in interface StaticCollectionInterfaceelement - The item(absolute file name) to search for
com.sas.util.InvalidElementTypeException - when the object is not of type String (a RuntimeException)public int count()
count in interface com.sas.util.Countablepublic void apply(com.sas.util.ApplyInterface action)
apply in interface StaticCollectionInterfaceaction - An object that provides a function which takes
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
public void sort(com.sas.util.Comparator comparator,
int start,
int end)
comparator - An instance of a subclass of Comparator which provides a
compare(Object,Object) function.start - the index of the first item in the range to sortend - sort the items between start and (end-1)Comparatorpublic java.lang.String toString()
toString in class java.lang.Objectpublic void refresh()
public void refreshAlways()
protected void sort(com.sas.util.Comparator comparator)
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||