高手请进!!!
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;
}
}
这是一段实用程序的代码。上面打问号的两个问题,以及这段程序一般用在什么地方,有什么作用,怎么用?
分数给的不多,但望高手指点,小弟初学。