Lines 51-64
Link Here
|
51 |
/** just for testing purposes |
51 |
/** just for testing purposes |
52 |
*/ |
52 |
*/ |
53 |
static final void fastCache(boolean fast) { |
53 |
static final void fastCache(boolean fast) { |
54 |
if (fast) { |
54 |
//do nothing - children map was unused - leaving this call |
55 |
POOL.children = null; |
55 |
//for now for the unit test that depends on it |
56 |
} else { |
|
|
57 |
POOL.children = new HashMap<FileObject, List<Item>>(); |
58 |
} |
56 |
} |
59 |
} |
|
|
60 |
/** map that assigns to each folder list of Items created for its children */ |
61 |
private Map<FileObject,List<Item>> children = new HashMap<FileObject, List<Item>>(); |
62 |
|
57 |
|
63 |
/** covers all FileSystems we're listening on */ |
58 |
/** covers all FileSystems we're listening on */ |
64 |
private Set<FileSystem> knownFileSystems = new WeakSet<FileSystem>(); |
59 |
private Set<FileSystem> knownFileSystems = new WeakSet<FileSystem>(); |
Lines 559-573
Link Here
|
559 |
if (itm != null) { // the file was someones' primary |
554 |
if (itm != null) { // the file was someones' primary |
560 |
return Collections.singleton(itm); // so notify only owner |
555 |
return Collections.singleton(itm); // so notify only owner |
561 |
} else { // unknown file or someone secondary |
556 |
} else { // unknown file or someone secondary |
562 |
List<Item> arr = children.get(fo.getParent()); |
557 |
// List<Item> arr = children.get(fo.getParent()); |
563 |
if (arr != null) { |
558 |
// if (arr != null) { |
564 |
return new ArrayList<Item>(arr); |
559 |
// return new ArrayList<Item>(arr); |
565 |
} else { |
560 |
// } else { |
566 |
return Collections.emptyList(); |
561 |
return Collections.emptyList(); |
|
|
562 |
// } |
567 |
} |
563 |
} |
568 |
} |
564 |
} |
569 |
} |
565 |
} |
570 |
} |
|
|
571 |
|
566 |
|
572 |
public void fileChanged(FileEvent fe) { |
567 |
public void fileChanged(FileEvent fe) { |
573 |
if (LISTENER.isLoggable(Level.FINE)) { |
568 |
if (LISTENER.isLoggable(Level.FINE)) { |
Lines 1224-1266
Link Here
|
1224 |
super(512); |
1219 |
super(512); |
1225 |
} |
1220 |
} |
1226 |
|
1221 |
|
1227 |
public Item put(FileObject obj, Item item) { |
|
|
1228 |
Item prev = super.put(obj, item); |
1229 |
if (children == null) { |
1230 |
return prev; |
1231 |
} |
1232 |
|
1233 |
FileObject parent = obj.getParent(); |
1234 |
if (parent == null) { |
1235 |
return prev; |
1236 |
} |
1237 |
List<Item> arr = children.get(parent); |
1238 |
if (arr == null) { |
1239 |
arr = new ArrayList<Item>(); |
1240 |
} |
1241 |
arr.add(item); |
1242 |
return prev; |
1243 |
} |
1244 |
public Item remove(Object obj) { |
1222 |
public Item remove(Object obj) { |
|
|
1223 |
//WTF is this? |
1245 |
Item prev = super.remove(obj); |
1224 |
Item prev = super.remove(obj); |
1246 |
if (! (obj instanceof FileObject)) { |
1225 |
if (! (obj instanceof FileObject)) { |
1247 |
return prev; |
1226 |
return prev; |
1248 |
} |
1227 |
} |
1249 |
if (children == null) { |
|
|
1250 |
return prev; |
1251 |
} |
1252 |
|
1253 |
FileObject parent = ((FileObject)obj).getParent(); |
1228 |
FileObject parent = ((FileObject)obj).getParent(); |
1254 |
if (parent == null) { |
1229 |
if (parent == null) { |
1255 |
return prev; |
1230 |
return prev; |
1256 |
} |
1231 |
} |
1257 |
List<Item> arr = children.get(parent); |
|
|
1258 |
if (arr != null) { |
1259 |
arr.remove(obj); |
1260 |
if (arr.isEmpty()) { |
1261 |
children.remove(parent); |
1262 |
} |
1263 |
} |
1264 |
return prev; |
1232 |
return prev; |
1265 |
} |
1233 |
} |
1266 |
} // end of DoubleHashMap |
1234 |
} // end of DoubleHashMap |