import java.io.Serializable;
import java.util.List;
public
abstract
class
Node
implements
Serializable,INodeAction{
private
static
final
long serialVersionUID = 3858789701720999153L;
protected
Element father;
protected
Document domFather;
@Override
public
Integer getBeifen(){
Integer n;
if
(father==null){
n = 0;
return
n;
}
Node node = this;
n = 0;
while
(node.father!=null){
n++;
node = node.father;
if
(node.father==null){
return
n;
}
}
if
(!(node.father==null)){
return
null;
}
return
n;
}
public
Element getFather() {
return
father;
}
@Override
public
String printSpace() {
StringBuffer sb =
new
StringBuffer();
Integer n = getBeifen();
if
(n == null) {
return
sb.toString();
}
for
(int i = 0; i nodeList = domFather.getNodeList();
int idx = nodeList.indexOf(this);
return
idx==0?null:nodeList.get(idx-1);
}
}
List<node> nodeList = father.getNodeList();
int idx = nodeList.indexOf(this);
return
idx==0?null:nodeList.get(idx-1);
}
@Override
public
Node getNextSibling() {
if
(father==null){
if
(domFather==null){
DocumentUtil.throwException(
"节点还没添加到文档!"
);
}
else
{
List<node> nodeList = domFather.getNodeList();
int idx = nodeList.indexOf(this);
return
idx==nodeList.size()-1?null:nodeList.get(idx+1);
}
}
List<node> nodeList = father.getNodeList();
int idx = nodeList.indexOf(this);
return
idx==nodeList.size()-1?null:nodeList.get(idx+1);
}
}</node></node></node>