高手请进!!!

afunx 2009-11-25 11:44:56
import java.util.ArrayList;

/**
*
* @author bminten
*/
public abstract class Descriptor {

public enum Quantity {
ONE, ZERO_OR_MORE, ONE_OR_MORE
};

private Class describedClass;//???这里的CLASS类,如何运用的,或者它是什么意思,为什么要用这个类定义。

/**
* Holds value of property quantity.
*/
private Quantity quantity;

private ArrayList<Descriptor> children;//???ArrayList<E>这里的E代表什么?

/** Creates a new instance of Descriptor */
public Descriptor(Class describedClass) {
this(describedClass, Quantity.ONE);
}

/** Creates a new instance of Descriptor */
public Descriptor(Class describedClass, Quantity quantity) {
this.quantity = quantity;
}

/**
* Getter for property quantity.
* @return Value of property quantity.
*/
public Quantity getQuantity() {
return this.quantity;
}

/**
* Setter for property quantity.
* @param quantity New value of property quantity.
*/
public void setQuantity(Quantity quantity) {
this.quantity = quantity;
}

protected void addChild(Descriptor child) {
if (children == null) {
children = new ArrayList<Descriptor>();
}
children.add(child);
}

protected void addChildren(Descriptor[] children) {
for (Descriptor child : children) {
addChild(child);
}
}

public Descriptor[] getChildren() {
return children.toArray(new Descriptor[0]);
}

/**
* Holds value of property name.
*/
private String name;

/**
* Getter for property name.
* @return Value of property name.
*/
public String getName() {
if (this.name == null) {
return getCanonicalName();
}
return this.name;
}

/**
* Setter for property name.
* @param name New value of property name.
*/
public void setName(String name) {
this.name = name;
}

public String getCanonicalName() {
return describedClass.getCanonicalName();
}

/**
* Holds value of property comment.
*/
private String comment;

/**
* Getter for property comment.
* @return Value of property comment.
*/
public String getComment() {

return this.comment;
}

/**
* Setter for property comment.
* @param comment New value of property comment.
*/
public void setComment(String comment) {

this.comment = comment;
}

/**
* Holds value of property parent.
*/
private Descriptor parent;

/**
* Getter for property parent.
* @return Value of property parent.
*/
public Descriptor getParent() {
return this.parent;
}

/**
* Setter for property parent.
* @param parent New value of property parent.
*/
public void setParent(Descriptor parent) {
this.parent = parent;
}
}
这是一段实用程序的代码。上面打问号的两个问题,以及这段程序一般用在什么地方,有什么作用,怎么用?
分数给的不多,但望高手指点,小弟初学。
...全文
46 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
一头头 2009-11-25
  • 打赏
  • 举报
回复
你代码不全 应该还有一个 describedClass 的东西

E是泛型的意思 google it.
knightzhuwei 2009-11-25
  • 打赏
  • 举报
回复
private Class describedClass;//???这里的CLASS类,如何运用的,或者它是什么意思,为什么要用这个类定义。
反射
private ArrayList <Descriptor> children;//???ArrayList <E>这里的E代表什么?
泛型

具体可以google

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧