📄 xmlnodebuilder.java
字号:
package edu.ou.kmi.buddyspace.xml;
import java.io.Serializable;
import java.util.*;
import org.jabber.jabberbeans.util.*;
import org.jabber.jabberbeans.*;
import org.jabber.jabberbeans.Extension.*;
import org.xml.sax.AttributeList;
import org.xml.sax.helpers.AttributeListImpl;
/*
* An <code>XMLNodeBuilder</code> is used to generate a generic XMLNode
* object.
*/
public class XMLNodeBuilder implements ExtensionBuilder
{
/** XML base element name*/
private String name;
/** XML base element attributes (including namespace) */
private AttributeList attributes;
/** XML subnodes - including text parts (Strings) */
private Vector children;
/*
* Construct a new <code>XMLNodeBuilder</code> object
*/
public XMLNodeBuilder()
{reset();}
/** reset this builder to a default state, for reuse */
public void reset()
{
name = null;
attributes = null;
children = new Vector();
}
/* return the name */
public String getName() {
return name;
}
/* sets name */
public void setName(String name) {
this.name = name;
}
/* return the xmlns */
public String getNamespace() {
return (attributes == null)? null : attributes.getValue("xmlns");
}
/* sets xmlns */
/*public void setNamespace(String xmlns) {
this.xmlns = xmlns;
}*/
/* return the attributes */
public AttributeList getAttributes() {
return attributes;
}
/* sets attributes */
public void setAttributes(AttributeList attributes) {
this.attributes = new AttributeListImpl(attributes);
}
/* returns all text concatenated into one string */
public String getCharacters() {
if (children == null) return null;
StringBuffer characters = new StringBuffer();
Enumeration chEnum = children.elements();
while (chEnum.hasMoreElements()) {
Object o = chEnum.nextElement();
if (o instanceof String) {
characters.append((String)o);
}
}
return characters.toString();
}
/* sets characters */
public void addCharacters(String characters) {
if (characters != null && characters.length() != 0)
children.add(characters);
}
/* return the children */
public Vector getChildren() {
return children;
}
/* adds the child */
public void addChild(XMLData child) {
if (child != null /*&& !children.contains(child)*/)
children.add(child);
}
/* removes the child */
/*public void removeChild(XMLData child) {
children.remove(child);
}*/
/*
* Build a <code>XMLNode</code> based on the current builder
* state.
*
* @return <code>XMLNode</code> based on the current builder
* state.
*/
public Extension build() throws InstantiationException
{return new XMLNode(this);}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -