为了显示项目树,我编写了引用自身的类:
CTree
{
String name;
CGroupOfItems[] groups
CGroupOfItems[] getGroups();
//... and more getter and setter methods
}
CGroupOfItems
{
String name;
CItem[] items;
CItems[] getItems();
//... and more getter and setter methods
}
CItem
{
String name;
CItem[] childItems;
CItems[] getChildItems();
//... and more getter and setter methods
}
有了这个,我管理树,如:
tree
-group 1
- item 1.1
- item 1.1.1
- item 1.1.1.1
- item 1.1.2
- item 1.2
- group 2
- item 2.1
.....
现在对于其他一些功能,我想管理其成员提供更多数据的树:
CTreeBig
{
String name;
int id;
String additionalData;
CGroupOfItemsBig[] groups
CGroupOfItemsBig[] getGroups();
//... and more getter and setter methods
}
CGroupOfItemsBig
{
String name;
int id;
String additionalData;
CItemBig[] items;
CItemBig[] getItems();
//... and more getter and setter methods
}
CItemBig
{
String name;
int id;
String additionalData;
CItemBig[] childItems;
CItemBig[] getChildItems();
//... and more getter and setter methods
}
现在我想从 CTree 扩展 CTreeBig。但这是不可能的,因为我无法覆盖
CGroupOfItems[] getGroups();
和:
CGroupOfItemsBig[] getGroups();
谁能给我一个提示,我可以如何使用 Java-Extension 来解决这个问题。至少有必要从 Object CTreeBig 获取 Object CTree。
当然我可以手动编码,但我现实我的类更复杂,我不仅有两个类 CTree,而且可能有 4 个或 5 个......
提前致谢
焦