Lines 49-54
Link Here
|
49 |
import java.lang.ref.Reference; |
49 |
import java.lang.ref.Reference; |
50 |
import java.lang.ref.WeakReference; |
50 |
import java.lang.ref.WeakReference; |
51 |
import java.util.*; |
51 |
import java.util.*; |
|
|
52 |
import java.util.logging.Logger; |
52 |
import org.netbeans.modules.masterfs.providers.ProvidedExtensions; |
53 |
import org.netbeans.modules.masterfs.providers.ProvidedExtensions; |
53 |
|
54 |
|
54 |
/** |
55 |
/** |
Lines 56-61
Link Here
|
56 |
*/ |
57 |
*/ |
57 |
public final class NamingFactory { |
58 |
public final class NamingFactory { |
58 |
private static final Map nameMap = new WeakHashMap(); |
59 |
private static final Map nameMap = new WeakHashMap(); |
|
|
60 |
private static final Logger LOG = Logger.getLogger(NamingFactory.class.getName()); |
59 |
|
61 |
|
60 |
public static synchronized FileNaming fromFile(final File file) { |
62 |
public static synchronized FileNaming fromFile(final File file) { |
61 |
final LinkedList<File> list = new LinkedList<File>(); |
63 |
final LinkedList<File> list = new LinkedList<File>(); |
Lines 233-268
Link Here
|
233 |
|
235 |
|
234 |
private static List collectChildren(FileName parent) { |
236 |
private static List collectChildren(FileName parent) { |
235 |
assert Thread.holdsLock(NamingFactory.class); |
237 |
assert Thread.holdsLock(NamingFactory.class); |
|
|
238 |
long now = System.currentTimeMillis(); |
236 |
List retval = new ArrayList(); |
239 |
List retval = new ArrayList(); |
|
|
240 |
Object isChild = new Object(); |
241 |
Object isNotChild = new Object(); |
237 |
for (Object value : nameMap.values()) { |
242 |
for (Object value : nameMap.values()) { |
238 |
if (value instanceof List) { |
243 |
if (value instanceof List) { |
239 |
for (Object item : (List) value) { |
244 |
for (Object item : (List) value) { |
240 |
Reference ref = (Reference) item; |
245 |
Reference ref = (Reference) item; |
241 |
FileNaming naming = (FileNaming) ref.get(); |
246 |
FileName naming = (FileName) ref.get(); |
242 |
if (isChild(parent, naming)) { |
247 |
if (isChild(parent, naming, isChild, isNotChild)) { |
243 |
retval.add(naming); |
248 |
retval.add(naming); |
244 |
} |
249 |
} |
245 |
} |
250 |
} |
246 |
} else { |
251 |
} else { |
247 |
Reference ref = (Reference) value; |
252 |
Reference ref = (Reference) value; |
248 |
FileNaming naming = (FileNaming) ref.get(); |
253 |
FileName naming = (FileName) ref.get(); |
249 |
if (isChild(parent, naming)) { |
254 |
if (isChild(parent, naming, isChild, isNotChild)) { |
250 |
retval.add(naming); |
255 |
retval.add(naming); |
251 |
} |
256 |
} |
252 |
} |
257 |
} |
253 |
} |
258 |
} |
|
|
259 |
LOG.info(retval.size() + " children for " + parent + " took " + (System.currentTimeMillis() - now + " all names: " + nameMap.size())); |
254 |
return retval; |
260 |
return retval; |
255 |
} |
261 |
} |
256 |
|
262 |
|
257 |
private static boolean isChild(FileName parent, FileNaming naming) { |
263 |
private static boolean isChild( |
258 |
FileNaming temp = naming; |
264 |
FileName parent, FileName naming, Object isChild, Object isNotChild |
|
|
265 |
) { |
266 |
FileName temp = naming; |
267 |
boolean found = false; |
259 |
while (temp != null) { |
268 |
while (temp != null) { |
260 |
if (temp == parent) { |
269 |
if (temp == parent) { |
261 |
return true; |
270 |
found = true; |
|
|
271 |
break; |
262 |
} |
272 |
} |
263 |
temp = temp.getParent(); |
273 |
if (temp.status == isChild) { |
|
|
274 |
found = true; |
275 |
break; |
276 |
} |
277 |
if (temp.status == isNotChild) { |
278 |
break; |
279 |
} |
280 |
temp = (FileName)temp.getParent(); |
264 |
} |
281 |
} |
265 |
return false; |
282 |
FileName again = naming; |
|
|
283 |
while (again != temp) { |
284 |
again.status = found ? isChild : isNotChild; |
285 |
again = (FileName)again.getParent(); |
286 |
} |
287 |
return found; |
266 |
} |
288 |
} |
267 |
|
289 |
|
268 |
private static Reference getReference(final List list, final File f) { |
290 |
private static Reference getReference(final List list, final File f) { |