我是eclipse开发的新手,我正在为Jface树查看器开发自定义namepatternfilter。我在我的过滤器中有以下代码,递归地遍历节点元素的子节点。
public boolean isChildMatch(final Object element) {
boolean value = false;
// Object[] children = this.contentProvider.getChildren(element);
Object[] items = null;
if (((HashMap<Object, String>) getTreeMap().get(element)) == null) {
final Object[] children = this.contentProvider.getChildren(element);
items = children;
new Thread(new Runnable() {
@Override
public void run() {
final HashMap<Object, String> childrenMap = new HashMap<Object, String>();
for (Object object : children) {
childrenMap.put(object, null);
}
NamePatternFilter.this.getTreeMap().put(element, childrenMap);
}
}).start();
}
else {
items = ((HashMap<Object, String>) getTreeMap().get(element)).keySet().toArray();
}
for (Object child : items) {
if (isElementMatch(child)) {
value = true;
break;
}
else if (isChildMatch(child)) {
this.visibleElements.add(child);
value = true;
break;
}
}
return value;
}
当我运行代码时,我得到了stackoverflow异常
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.StackOverflowError)
at org.eclipse.swt.SWT.error(SWT.java:4441)
at org.eclipse.swt.SWT.error(SWT.java:4356)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:139)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4147)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3764)
我在这里缺少什么?