FileDocCategorySizeDatePackage
Element.javaAPI DocAndroid 1.5 API5058Wed May 06 22:41:42 BST 2009org.ccil.cowan.tagsoup

Element

public class Element extends Object
The internal representation of an actual element (not an element type). An Element has an element type, attributes, and a successor Element for use in constructing stacks and queues of Elements.
see
ElementType
see
AttributesImpl

Fields Summary
private ElementType
theType
private AttributesImpl
theAtts
private Element
theNext
private boolean
preclosed
Constructors Summary
public Element(ElementType type, boolean defaultAttributes)
Return an Element from a specified ElementType.

param
type The element type of the newly constructed element
param
defaultAttributes True if default attributes are wanted

		theType = type;
		if (defaultAttributes) theAtts = new AttributesImpl(type.atts());
		else theAtts = new AttributesImpl();
		theNext = null;
		preclosed = false;
		
Methods Summary
public voidanonymize()
Make this element anonymous. Remove any id or name attribute present in the element's attributes.

		for (int i = theAtts.getLength() - 1; i >= 0; i--) {
			if (theAtts.getType(i).equals("ID") ||
			    theAtts.getQName(i).equals("name")) {
				theAtts.removeAttribute(i);
				}
			}
		
public AttributesImplatts()
Return the attributes as an AttributesImpl object. Returning an AttributesImpl makes the attributes mutable.

return
The attributes
see
AttributesImpl

 return theAtts; 
public booleancanContain(org.ccil.cowan.tagsoup.Element other)
Return true if the type of this element can contain the type of another element. Convenience method.

param
other The other element

		return theType.canContain(other.theType);
		
public voidclean()
Clean the attributes of this element. Attributes with null name (the name was ill-formed) or null value (the attribute was present in the element type but not in this actual element) are removed.

		for (int i = theAtts.getLength() - 1; i >= 0; i--) {
			String name = theAtts.getLocalName(i);
			if (theAtts.getValue(i) == null || name == null ||
					name.length() == 0) {
				theAtts.removeAttribute(i);
				continue;
				}
			}
		
public intflags()
Return the flags vector of the element's type. Convenience method.

return
The flags vector

 return theType.flags(); 
public booleanisPreclosed()
Return true if this element has been preclosed.

		return preclosed;
		
public java.lang.StringlocalName()
Return the local name of the element's type. Convenience method.

return
The element type local name

 return theType.localName(); 
public intmemberOf()
Return the member-of vector of the element's type. Convenience method.

return
The member-of vector

 return theType.memberOf(); 
public intmodel()
Return the content model vector of the element's type. Convenience method.

return
The content model vector

 return theType.model(); 
public java.lang.Stringname()
Return the name of the element's type. Convenience method.

return
The element type name

 return theType.name(); 
public java.lang.Stringnamespace()
Return the namespace name of the element's type. Convenience method.

return
The element type namespace name

 return theType.namespace(); 
public org.ccil.cowan.tagsoup.Elementnext()
Return the next element in an element stack or queue.

return
The next element

 return theNext; 
public ElementTypeparent()
Return the parent element type of the element's type. Convenience method.

return
The parent element type

 return theType.parent(); 
public voidpreclose()
Force this element to preclosed status, meaning that an end-tag has been seen but the element cannot yet be closed for structural reasons.

		preclosed = true;
		
public voidsetAttribute(java.lang.String name, java.lang.String type, java.lang.String value)
Set an attribute and its value into this element.

param
name The attribute name (Qname)
param
type The attribute type
param
value The attribute value

		theType.setAttribute(theAtts, name, type, value);
		
public voidsetNext(org.ccil.cowan.tagsoup.Element next)
Change the next element in an element stack or queue.

param
next The new next element

 theNext = next; 
public ElementTypetype()
Return the element type.

return
The element type.

 return theType;