Lines 60-69
Link Here
|
60 |
FileNaming retVal = null; |
60 |
FileNaming retVal = null; |
61 |
switch (status) { |
61 |
switch (status) { |
62 |
case ChildrenSupport.ALL_CHILDREN_CACHED: |
62 |
case ChildrenSupport.ALL_CHILDREN_CACHED: |
63 |
retVal = lookupChildInCache(childName); |
63 |
retVal = lookupChildInCache(folderName, childName); |
64 |
if (!rescan) break; |
64 |
if (!rescan) break; |
65 |
case ChildrenSupport.SOME_CHILDREN_CACHED: |
65 |
case ChildrenSupport.SOME_CHILDREN_CACHED: |
66 |
if (status != ChildrenSupport.ALL_CHILDREN_CACHED) retVal = lookupChildInCache(childName); |
66 |
if (status != ChildrenSupport.ALL_CHILDREN_CACHED) retVal = lookupChildInCache(folderName, childName); |
67 |
case ChildrenSupport.NO_CHILDREN_CACHED: |
67 |
case ChildrenSupport.NO_CHILDREN_CACHED: |
68 |
if (retVal == null || rescan) { |
68 |
if (retVal == null || rescan) { |
69 |
final FileNaming original = retVal; |
69 |
final FileNaming original = retVal; |
Lines 83-99
Link Here
|
83 |
return retVal; |
83 |
return retVal; |
84 |
} |
84 |
} |
85 |
|
85 |
|
86 |
private FileName lookupChildInCache(final String childName) { |
86 |
private FileName lookupChildInCache(final FileNaming folder, final String childName) { |
87 |
FileName retVal = null; |
87 |
final File f = new File (folder.getFile (), childName); |
88 |
final Set cache = getChildrenCache(); |
88 |
final Integer id = NamingFactory.createID (f); |
89 |
for (Iterator iterator = cache.iterator(); iterator.hasNext();) { |
89 |
|
90 |
final FileName item = (FileName) iterator.next(); |
90 |
class FakeNaming implements FileNaming { |
91 |
if (item.getName().equals(childName)) { |
91 |
public FileName lastEqual; |
92 |
retVal = item; |
92 |
|
93 |
break; |
93 |
public String getName() { |
|
|
94 |
return childName; |
95 |
} |
96 |
public FileNaming getParent() { |
97 |
return folder; |
98 |
} |
99 |
public boolean isRoot() { |
100 |
return false; |
101 |
} |
102 |
|
103 |
public File getFile() { |
104 |
return f; |
105 |
} |
106 |
|
107 |
public Integer getId() { |
108 |
return id; |
109 |
} |
110 |
public boolean rename(String name) { |
111 |
// not implemented, as it will not be called |
112 |
throw new IllegalStateException (); |
113 |
} |
114 |
|
115 |
public boolean equals (Object obj) { |
116 |
if (hashCode () == obj.hashCode ()) { |
117 |
assert lastEqual == null : "Just one can be there"; // NOI18N |
118 |
lastEqual = (FileName)obj; |
119 |
return true; |
120 |
} |
121 |
return false; |
122 |
} |
123 |
|
124 |
public int hashCode () { |
125 |
return id.intValue (); |
94 |
} |
126 |
} |
95 |
} |
127 |
} |
96 |
return retVal; |
128 |
FakeNaming fake = new FakeNaming (); |
|
|
129 |
|
130 |
final Set cache = getChildrenCache(); |
131 |
if (cache.contains (fake)) { |
132 |
assert fake.lastEqual != null : "If cache contains the object, we set lastEqual"; // NOI18N |
133 |
return fake.lastEqual; |
134 |
} else { |
135 |
return null; |
136 |
} |
97 |
} |
137 |
} |
98 |
|
138 |
|
99 |
private static FileNaming rescanChild(final FileNaming folderName, final String childName) { |
139 |
private static FileNaming rescanChild(final FileNaming folderName, final String childName) { |