📄 jsubnode.java
字号:
package ast;
public abstract class JSubNode implements IJSubNode {
protected IJSubNode parent;
protected java.util.Vector children;
public JSubNode() {
children = new java.util.Vector (2, 2);
}
public JSubNode(IJSubNode n) {
children = new java.util.Vector (2, 2);
children.addElement (n);
n.setParent (this);
}
public void setParent(IJSubNode n) {
parent = n;
}
public IJSubNode getParent() {
return parent;
}
public void addChild(IJSubNode n) {
children.addElement (n);
}
public IJSubNode getChild(int i) {
return (IJSubNode)children.elementAt (i);
}
public int getNumChildren() {
return children.size ();
}
public java.util.Enumeration elements () {
return children.elements ();
}
public String toString(String prefix) {
return prefix + toString();
}
public int getDepth () {
int depth = 0;
for (int i = 0; i < children.size(); i++) {
IJSubNode n = (IJSubNode)children.elementAt(i);
int ndepth = n.getDepth() + 1;
if (depth < ndepth)
depth = ndepth;
}
return depth;
}
/**
* display with insert.
* this may be transacted in this class.
*
* prefix that String to insert that display.
*/
public void dump(String prefix) {
System.out.println(prefix + toString());
for (int i = 0; i < children.size(); ++i) {
IJSubNode n = (IJSubNode)children.elementAt(i);
n.dump(prefix + " ");
}
}
/**
* XML-display.
* the XML-display may be transacted in that class.
* they need detail of Sub-class only about unified XML-Type
* Callback (getXMLType ().
*
* @param p that display current for print as the case: println
* @param prefix that String to the insert of the display
*/
public void genXML (java.io.PrintStream p, String prefix) {
p.println (prefix + "<" + getXMLType () + ">");
for (int i = 0; i < children.size(); ++i) {
IJSubNode n = (IJSubNode)children.elementAt(i);
n.genXML (p, prefix + " ");
}
p.println (prefix + "</" + getXMLType () + ">");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -