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

WbxmlPrimitiveSerializer

public class WbxmlPrimitiveSerializer extends Object implements PrimitiveSerializer

Fields Summary
private String
mVersionNs
private String
mTransacNs
private WbxmlSerializer
mWbxmlSerializer
Constructors Summary
public WbxmlPrimitiveSerializer(com.android.im.imps.ImpsConstants.ImpsVersion impsVersion, String versionNs, String transacNs)

        mVersionNs = versionNs;
        mTransacNs = transacNs;
        mWbxmlSerializer = new WbxmlSerializer(impsVersion);
    
Methods Summary
public voidserialize(Primitive primitive, java.io.OutputStream out)

        mWbxmlSerializer.reset();
        mWbxmlSerializer.setOutput(out);
        PrimitiveElement elem = primitive.createMessage(mVersionNs, mTransacNs);
        writeElement(elem);
    
private voidwriteElement(PrimitiveElement element)

        String name = element.getTagName();
        String[] atts = null;
        Map<String, String> attrMap = element.getAttributes();
        if(attrMap != null && attrMap.size() > 0) {
            atts = new String[attrMap.size() * 2];
            int index = 0;
            for (Map.Entry<String, String> entry : attrMap.entrySet()) {
                atts[index++] = entry.getKey();
                atts[index++] = entry.getValue();
            }
        }

        mWbxmlSerializer.startElement(name, atts);

        String contents = element.getContents();
        if(contents != null) {
            mWbxmlSerializer.characters(contents);
        }
        if(element.getChildCount() > 0) {
            for(PrimitiveElement child : element.getChildren()) {
                writeElement(child);
            }
        }
        mWbxmlSerializer.endElement();