FileDocCategorySizeDatePackage
PrimitiveElement.javaAPI DocAndroid 1.5 API4490Wed May 06 22:42:46 BST 2009com.android.im.imps

PrimitiveElement

public final class PrimitiveElement extends Object
Represents a XML element of Primitive. Note that this class is not thread-safe.

Fields Summary
private String
mTagName
private HashMap
mAttributes
private ArrayList
mChildren
private String
mContents
Constructors Summary
public PrimitiveElement(String tagName)

        mTagName = tagName;
    
Methods Summary
public com.android.im.imps.PrimitiveElementaddChild(com.android.im.imps.PrimitiveElement child)

        if (child != null) {
            getChildren().add(child);
        }

        return child;
    
public com.android.im.imps.PrimitiveElementaddChild(java.lang.String tagName)

        if (null == tagName) {
            return null;
        }
        PrimitiveElement element = new PrimitiveElement(tagName);
        getChildren().add(element);
        return element;
    
public voidaddChild(java.lang.String tagName, java.lang.String contents)

        PrimitiveElement element = addChild(tagName);
        if (null != contents) {
            element.setContents(contents);
        }
    
public voidaddChild(java.lang.String tagName, boolean value)

        addChild(tagName).setContents(value ?
                ImpsConstants.TRUE : ImpsConstants.FALSE);
    
public voidaddPropertyChild(java.lang.String name, java.lang.String value)

        PrimitiveElement ret = addChild(ImpsTags.Property);
        ret.addChild(ImpsTags.Name, name);
        ret.addChild(ImpsTags.Value, value);
    
public voidaddPropertyChild(java.lang.String name, boolean value)

        PrimitiveElement ret = addChild(ImpsTags.Property);
        ret.addChild(ImpsTags.Name, name);
        ret.addChild(ImpsTags.Value, value);
    
public java.util.MapgetAttributes()

        if (mAttributes == null) {
            return null;
        }
        return Collections.unmodifiableMap(mAttributes);
    
public com.android.im.imps.PrimitiveElementgetChild(java.lang.String tagName)

        for (PrimitiveElement child : getChildren()) {
            if (tagName.equals(child.getTagName())) {
                return child;
            }
        }
        return null;
    
public java.lang.StringgetChildContents(java.lang.String tagName)

        PrimitiveElement child = getChild(tagName);
        return child == null ? null : child.getContents();
    
public intgetChildCount()

        if (mChildren == null || mChildren.isEmpty()) {
            return 0;
        } else {
            return mChildren.size();
        }
    
public java.util.ArrayListgetChildren()

        if (mChildren == null) {
            mChildren = new ArrayList<PrimitiveElement>();
        }
        return mChildren;
    
public java.util.ArrayListgetChildren(java.lang.String tagName)

        ArrayList<PrimitiveElement> children = new ArrayList<PrimitiveElement>();

        for (PrimitiveElement child : getChildren()) {
            if (tagName.equals(child.getTagName())) {
                children.add(child);
            }
        }

        return children;
    
public java.lang.StringgetContents()

        return mContents;
    
public com.android.im.imps.PrimitiveElementgetFirstChild()

        if ((mChildren == null) || mChildren.isEmpty()) {
            return null;
        }
        return mChildren.get(0);
    
public java.lang.StringgetTagName()

        return mTagName;
    
public voidsetAttribute(java.lang.String key, java.lang.String value)

        if (key != null && value != null) {
            if (mAttributes == null) {
                mAttributes = new HashMap<String, String>();
            }
            mAttributes.put(key, value);
        }
    
public voidsetContents(java.lang.String contents)

        mContents = contents;
    
public voidsetTagName(java.lang.String tagName)

        this.mTagName = tagName;