⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node.java

📁 开发框架。 一.说明: 此框架的意图是解决手机软件开发中常遇到
💻 JAVA
字号:
package org.gggeye.easymf.xml;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;


/** *//**
 * @author shizhongqin
 * @date 2006-5-1
 * mail:shizhongqin@gmail.com
 */

public class Node {
    private String name;
    private Node parent;
    private String value;
    private String description;
    private Hashtable attributes=new Hashtable();
    private Vector childNodes=new Vector();
    public Node(String name){
        this.name=name;
    }
    
    public String getName(){
        return this.name;
    }
    public void setName(String name){
        this.name=name;
    }
    public String getValue(){
        return this.value;
    }
    public void setValue(String value){
        this.value=value;
    }
    public void setAttribute(String name,String value){
        this.attributes.put(name,value);
    }
    public String getAttribute(String attributeName){
        return (String)attributes.get(attributeName);
    }
    public void setDescription(String desc){
        this.description=desc;
    }
    public String getDescription(){
        return this.description;
    }
    public void setParent(Node parent){
        this.parent=parent;
    }
    public Node getParent(){
        return this.parent;
    }
    public void addChild(Node childNode){
        this.childNodes.addElement(childNode);
        childNode.setParent(this); 
    }
    
    public String toString(){
        StringBuffer xml=new StringBuffer();
        if ((this.getDescription()!=null)&&(this.getDescription().length()>0))
           xml.append("<!--"+this.getDescription()+"--> ");
        xml.append("<");
        xml.append(this.getName());
        
        Enumeration keys=this.attributes.elements();
        while(keys.hasMoreElements()){
            String key=(String)keys.nextElement();
            String value=(String)this.attributes.get(key);
            xml.append(" "+ key+ "=" + value + " ");
        }
        if (((this.getValue()==null)||(this.getValue().length()==0))&&(this.childNodes.size()==0)){
           xml.append(" /> ");
        }else{
           xml.append(" >");
           if ((this.getValue()!=null)&&(this.getValue().length()>0)){
                   xml.append(this.getValue());
           }        
           for(int i=0;i<this.childNodes.size();i++)
             xml.append(((Node)this.childNodes.elementAt(i)).toString());
           xml.append("</"+this.getName()+"> ");         
        }
        return xml.toString();
    }

	public Hashtable getAttributes() {
		return attributes;
	}

	public Vector getChildNodes() {
		return childNodes;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -