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

PrimitiveContentHandler

public final class PrimitiveContentHandler extends DefaultHandler

Fields Summary
private Primitive
mPrimitive
private String
mCurTagName
private boolean
mIsTransContent
private Stack
mContentElementsStack
Constructors Summary
public PrimitiveContentHandler()

        mPrimitive = new Primitive();
        mContentElementsStack = new Stack<PrimitiveElement>();
    
Methods Summary
public voidcharacters(char[] ch, int start, int length)

        String contentStr = ImpsUtils.trim(new String(ch, start, length));
        if (contentStr == null || contentStr.length() == 0) {
            return;
        }
        if (mIsTransContent) {
            if (!ImpsTags.TransactionContent.equals(mCurTagName)) {
                PrimitiveElement curPrimitive = mContentElementsStack.peek();

                curPrimitive.setContents(contentStr);
            }
        } else {
            if (ImpsTags.TransactionID.equals(mCurTagName)) {
                mPrimitive.setTransactionId(contentStr);
            } else if (ImpsTags.TransactionMode.equals(mCurTagName)) {
                mPrimitive.setTransactionMode(TransactionMode.valueOf(contentStr));
            } else if (ImpsTags.SessionID.equals(mCurTagName)) {
                mPrimitive.setSession(contentStr);
            } else if (ImpsTags.Poll.equals(mCurTagName)) {
                mPrimitive.setPoll(contentStr);
            } else if (ImpsTags.CIR.equals(mCurTagName)) {
                mPrimitive.setCir(contentStr);
            }
        }
    
public voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)

        if (ImpsTags.TransactionContent.equals(localName)) {
            mIsTransContent = false;
        }

        if (mIsTransContent) {
            if (!mContentElementsStack.empty()) {
                mContentElementsStack.pop();
            }
        }
        mCurTagName = null;
    
public PrimitivegetPrimitive()

        return mPrimitive;
    
public voidreset()

        mPrimitive = new Primitive();
        mContentElementsStack.clear();

        mIsTransContent = false;
    
public voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)

        if (mIsTransContent) {
            if (mContentElementsStack.empty()) {
                mPrimitive.setContentElement(localName);
                mContentElementsStack.push(mPrimitive.getContentElement());
            } else {
                PrimitiveElement parentPrimitive = mContentElementsStack.peek();
                PrimitiveElement childPrimitive = new PrimitiveElement(
                        localName);

                parentPrimitive.addChild(childPrimitive);
                mContentElementsStack.push(childPrimitive);
            }
        } else {
            if (ImpsTags.TransactionContent.equals(localName)) {
                mIsTransContent = true;
            }
        }

        mCurTagName = localName;