Lines 48-63
Link Here
|
48 |
import java.util.NoSuchElementException; |
48 |
import java.util.NoSuchElementException; |
49 |
import org.openide.filesystems.FileObject; |
49 |
import org.openide.filesystems.FileObject; |
50 |
import org.openide.loaders.DataFolder; |
50 |
import org.openide.loaders.DataFolder; |
51 |
import org.openide.loaders.DataObject; |
|
|
52 |
|
51 |
|
53 |
/** |
52 |
/** |
54 |
* |
53 |
* |
55 |
* @author Marian Petras |
54 |
* @author Marian Petras |
56 |
*/ |
55 |
*/ |
57 |
class SimpleSearchIterator implements Iterator<DataObject> { |
56 |
class SimpleSearchIterator implements Iterator<FileObject> { |
58 |
|
57 |
|
59 |
/** current enumeration of children */ |
58 |
/** current enumeration of children */ |
60 |
private Enumeration<DataObject> childrenEnum; |
59 |
private Enumeration<? extends FileObject> childrenEnum; |
61 |
/** |
60 |
/** |
62 |
* filters to be applied on the current enumeration of children |
61 |
* filters to be applied on the current enumeration of children |
63 |
* ({@link #childrenEnum}) |
62 |
* ({@link #childrenEnum}) |
Lines 70-77
Link Here
|
70 |
/** */ |
69 |
/** */ |
71 |
private final boolean recursive; |
70 |
private final boolean recursive; |
72 |
/** stack of the ancestor folders' children enumerations */ |
71 |
/** stack of the ancestor folders' children enumerations */ |
73 |
private final List<Enumeration<DataObject>> enums |
72 |
private final List<Enumeration<? extends FileObject>> enums |
74 |
= new ArrayList<Enumeration<DataObject>>(); //unsynced stack |
73 |
= new ArrayList<Enumeration<? extends FileObject>>(); //unsynced stack |
75 |
/** |
74 |
/** |
76 |
* stack of filter lists to be applied on children of the ancestor folders |
75 |
* stack of filter lists to be applied on children of the ancestor folders |
77 |
* ({@link #enums}) |
76 |
* ({@link #enums}) |
Lines 84-97
Link Here
|
84 |
* <code>DataObject</code> to be returned the next time method |
83 |
* <code>DataObject</code> to be returned the next time method |
85 |
* {@link #next()} is called |
84 |
* {@link #next()} is called |
86 |
*/ |
85 |
*/ |
87 |
private DataObject nextObject; |
86 |
private FileObject nextObject; |
88 |
|
87 |
|
89 |
/** |
88 |
/** |
90 |
*/ |
89 |
*/ |
91 |
SimpleSearchIterator(DataFolder folder, |
90 |
SimpleSearchIterator(DataFolder folder, |
92 |
boolean recursive, |
91 |
boolean recursive, |
93 |
List<FileObjectFilter> filters) { |
92 |
List<FileObjectFilter> filters) { |
94 |
this.childrenEnum = folder.children(false); |
93 |
this.childrenEnum = folder.getPrimaryFile().getChildren(false); |
95 |
this.recursive = recursive; |
94 |
this.recursive = recursive; |
96 |
this.filters = (filters != null) ? new ArrayList<FileObjectFilter>(filters) |
95 |
this.filters = (filters != null) ? new ArrayList<FileObjectFilter>(filters) |
97 |
: null; |
96 |
: null; |
Lines 108-114
Link Here
|
108 |
|
107 |
|
109 |
/** |
108 |
/** |
110 |
*/ |
109 |
*/ |
111 |
public DataObject next() { |
110 |
public FileObject next() { |
112 |
if (!hasNext()) { |
111 |
if (!hasNext()) { |
113 |
throw new NoSuchElementException(); |
112 |
throw new NoSuchElementException(); |
114 |
} |
113 |
} |
Lines 124-131
Link Here
|
124 |
assert childrenEnum != null; |
123 |
assert childrenEnum != null; |
125 |
do { |
124 |
do { |
126 |
if (childrenEnum.hasMoreElements()) { |
125 |
if (childrenEnum.hasMoreElements()) { |
127 |
DataObject dataObject = childrenEnum.nextElement(); |
126 |
FileObject file = childrenEnum.nextElement(); |
128 |
FileObject file = dataObject.getPrimaryFile(); |
|
|
129 |
if (file.isFolder()) { |
127 |
if (file.isFolder()) { |
130 |
if (!recursive) { |
128 |
if (!recursive) { |
131 |
continue; |
129 |
continue; |
Lines 147-159
Link Here
|
147 |
filterLists.add(null); |
145 |
filterLists.add(null); |
148 |
} |
146 |
} |
149 |
enums.add(childrenEnum); |
147 |
enums.add(childrenEnum); |
150 |
childrenEnum = ((DataFolder) dataObject).children(false); |
148 |
childrenEnum = file.getChildren(false); |
151 |
} else { |
149 |
} else { |
152 |
if ((filters != null) && !checkFileFilters(file)) { |
150 |
if ((filters != null) && !checkFileFilters(file)) { |
153 |
continue; |
151 |
continue; |
154 |
} |
152 |
} |
155 |
|
153 |
|
156 |
nextObject = dataObject; |
154 |
nextObject = file; |
157 |
break; |
155 |
break; |
158 |
} |
156 |
} |
159 |
} else { |
157 |
} else { |