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

Primitive

public final class Primitive extends Object
A primitive is the basic packet sent between the IMPS server and the IMPS client. Note that this class is not thread-safe.

Fields Summary
private TransactionMode
mTransactionMode
private String
mTransactionId
private String
mSessionId
private String
mPoll
private String
mCir
private PrimitiveElement
mContentElement
Constructors Summary
public Primitive()
Constructs a new Primitive with default value.


                
      
    
public Primitive(String type)
Constructs a new Primitive with a type.

param
type the type of the primitive.

        mContentElement = new PrimitiveElement(type);
    
Methods Summary
public PrimitiveElementaddElement(java.lang.String tag)

        return mContentElement.addChild(tag);
    
public voidaddElement(java.lang.String tag, java.lang.String value)

        mContentElement.addChild(tag, value);
    
public voidaddElement(java.lang.String tag, boolean value)

        mContentElement.addChild(tag, value);
    
public voidaddElement(PrimitiveElement elem)

        mContentElement.addChild(elem);
    
PrimitiveElementcreateMessage(java.lang.String versionUri, java.lang.String transactUri)

        PrimitiveElement root = new PrimitiveElement(ImpsTags.WV_CSP_Message);

        root.setAttribute(ImpsTags.XMLNS, versionUri);
        PrimitiveElement sessionElem = root.addChild(ImpsTags.Session);

        PrimitiveElement sessionDescElem = sessionElem.addChild(
                ImpsTags.SessionDescriptor);
        sessionDescElem.addChild(ImpsTags.SessionType,
                getSessionType().toString());
        if (getSessionId() != null) {
            sessionDescElem.addChild(ImpsTags.SessionID, getSessionId());
        }

        PrimitiveElement transElem = sessionElem.addChild(ImpsTags.Transaction);

        PrimitiveElement transDescElem = transElem.addChild(
                ImpsTags.TransactionDescriptor);
        transDescElem.addChild(ImpsTags.TransactionMode,
                getTransactionMode().toString());
        if (getTransactionID() != null) {
            transDescElem.addChild(ImpsTags.TransactionID, getTransactionID());
        }

        PrimitiveElement transContentElem = transElem.addChild(
                ImpsTags.TransactionContent);
        transContentElem.setAttribute(ImpsTags.XMLNS, transactUri);
        transContentElem.addChild(getContentElement());

        return root;
    
public java.lang.StringgetCir()

        return mCir;
    
public PrimitiveElementgetContentElement()

        return mContentElement;
    
public PrimitiveElementgetElement(java.lang.String tag)

        return mContentElement.getChild(tag);
    
public java.lang.StringgetElementContents(java.lang.String tag)

        PrimitiveElement elem = getElement(tag);
        return elem == null ? null : elem.getContents();
    
public java.lang.StringgetPoll()

        return mPoll;
    
public java.lang.StringgetSessionId()
Gets the session ID of this primitive.

return
the session ID.

        return mSessionId;
    
public com.android.im.imps.Primitive$SessionTypegetSessionType()
Gets the session type of this primitive.

return
the session type .

        return mSessionId == null ? SessionType.Outband : SessionType.Inband;
    
public java.lang.StringgetTransactionID()
Gets the transaction ID of this primitive.

return
the transaction ID.

        return mTransactionId;
    
public com.android.im.imps.Primitive$TransactionModegetTransactionMode()
Gets the transaction mode of this primitive.

return
the transaction mode.

        return mTransactionMode;
    
public java.lang.StringgetType()

        return (mContentElement == null) ? null : mContentElement.getTagName();
    
public voidsetCir(java.lang.String cir)

        this.mCir = cir;
    
public voidsetContentElement(java.lang.String type)

        mContentElement = new PrimitiveElement(type);
    
public voidsetPoll(java.lang.String poll)

        this.mPoll = poll;
    
public voidsetSession(java.lang.String sessionId)
Sets the session ID of this primitive.

param
sessionId the session ID.

        this.mSessionId = sessionId;
    
public voidsetTransaction(ImpsTransaction transaction)

        this.mTransactionId = transaction.getId();
    
public voidsetTransactionId(java.lang.String transId)
Sets the transaction ID of this primitive.

param
transId the transaction ID.

        this.mTransactionId = transId;
    
public voidsetTransactionMode(com.android.im.imps.Primitive$TransactionMode mode)
Sets the transaction mode of this primitive.

param
mode the transaction mode.

        this.mTransactionMode = mode;