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

📄 element.java

📁 短信网关发送接受平台。
💻 JAVA
字号:
package XML;
import Utilities.*;
import java.util.*;

public class Element{
  	private String tag="";
  	private String value="";
  	//private String xmlStr="";
	private Vector attributes=new Vector();

  	public Element(){
  		this.tag="";
  		this.value="";
  		//this.xmlStr="";
  	}

  	public Element(String tag){
  		this.tag=tag;
  		//this.xmlStr="<"+tag;
    	}

    	public Element(String tag,String value){
    		this.tag=tag;
    		this.value=value;
    		//this.xmlStr="<"+tag+">"+value;
    	}

    	public Element(String tag,String value,Attribute attr){
    		this.tag=tag;
    		this.value=value;
    		this.attributes.add(attr);
    	}

    	public void setTag(String tag){
    		this.tag=tag;
    	}

    	public String getTag(){
    		return this.tag;
    	}

    	public void setValue(String value){
    		this.value=value;
    	}

    	public String getValue(){
    		return this.value;
    	}

    	public void addAttribute(Attribute attr){
    		this.attributes.add(attr);
    	}



    	//未做解析
    	//public static void getElement(String elemStr){





    	public String toString(){
    		String result="<"+this.tag;
    		Attribute att;
    		for (int i=0;i<this.attributes.size();i++){
				att=(Attribute)attributes.elementAt(i);
				result=" "+att;
			}
		result+=">"+this.value+"</"+this.tag+">";
    		return result;
    	}

	public static void main(String args[]){
		Element element=new Element("command","submit");
		Attribute attr=new Attribute("msg_fmt",15);
		element.addAttribute(attr);
		attr.setName("tp_udhi");
		attr.setValue(0x40);
		element.addAttribute(attr);
		attr.setName("msg_content");
		attr.setValue("this is a test message");
		element.addAttribute(attr);
			System.out.println(element);
		Vector attributes=Attribute.getAttributes("ip=\"192.168.0.1\" UID=\"dongyu\" PWD=\"hi\" ");
		Attribute atr;
		for (int i=0;i<attributes.size();i++){
			atr=(Attribute)attributes.elementAt(i);
			System.out.println(atr.getName()+ "            "+atr.getValue());
		}
	}
}

⌨️ 快捷键说明

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