FileDocCategorySizeDatePackage
BluetoothMapBmessageBuilder.javaAPI DocAndroid 5.1 API5543Thu Mar 12 22:22:50 GMT 2015android.bluetooth.client.map

BluetoothMapBmessageBuilder

public class BluetoothMapBmessageBuilder extends Object

Fields Summary
private static final String
CRLF
private static final String
BMSG_BEGIN
private static final String
BMSG_VERSION
private static final String
BMSG_STATUS
private static final String
BMSG_TYPE
private static final String
BMSG_FOLDER
private static final String
BMSG_END
private static final String
BENV_BEGIN
private static final String
BENV_END
private static final String
BBODY_BEGIN
private static final String
BBODY_ENCODING
private static final String
BBODY_CHARSET
private static final String
BBODY_LANGUAGE
private static final String
BBODY_LENGTH
private static final String
BBODY_END
private static final String
MSG_BEGIN
private static final String
MSG_END
private static final String
VCARD_BEGIN
private static final String
VCARD_VERSION
private static final String
VCARD_N
private static final String
VCARD_EMAIL
private static final String
VCARD_TEL
private static final String
VCARD_END
private final StringBuilder
mBmsg
Constructors Summary
private BluetoothMapBmessageBuilder()


      
        mBmsg = new StringBuilder();
    
Methods Summary
private voidbuild(BluetoothMapBmessage bmsg)

        int bodyLen = MSG_BEGIN.length() + MSG_END.length() + 3 * CRLF.length()
                + bmsg.mMessage.getBytes().length;

        mBmsg.append(BMSG_BEGIN).append(CRLF);

        mBmsg.append(BMSG_VERSION).append(CRLF);
        mBmsg.append(BMSG_STATUS).append(bmsg.mBmsgStatus).append(CRLF);
        mBmsg.append(BMSG_TYPE).append(bmsg.mBmsgType).append(CRLF);
        mBmsg.append(BMSG_FOLDER).append(bmsg.mBmsgFolder).append(CRLF);

        for (VCardEntry vcard : bmsg.mOriginators) {
            buildVcard(vcard);
        }

        {
            mBmsg.append(BENV_BEGIN).append(CRLF);

            for (VCardEntry vcard : bmsg.mRecipients) {
                buildVcard(vcard);
            }

            {
                mBmsg.append(BBODY_BEGIN).append(CRLF);

                if (bmsg.mBbodyEncoding != null) {
                    mBmsg.append(BBODY_ENCODING).append(bmsg.mBbodyEncoding).append(CRLF);
                }

                if (bmsg.mBbodyCharset != null) {
                    mBmsg.append(BBODY_CHARSET).append(bmsg.mBbodyCharset).append(CRLF);
                }

                if (bmsg.mBbodyLanguage != null) {
                    mBmsg.append(BBODY_LANGUAGE).append(bmsg.mBbodyLanguage).append(CRLF);
                }

                mBmsg.append(BBODY_LENGTH).append(bodyLen).append(CRLF);

                {
                    mBmsg.append(MSG_BEGIN).append(CRLF);

                    mBmsg.append(bmsg.mMessage).append(CRLF);

                    mBmsg.append(MSG_END).append(CRLF);
                }

                mBmsg.append(BBODY_END).append(CRLF);
            }

            mBmsg.append(BENV_END).append(CRLF);
        }

        mBmsg.append(BMSG_END).append(CRLF);
    
private voidbuildVcard(com.android.vcard.VCardEntry vcard)

        String n = buildVcardN(vcard);
        List<PhoneData> tel = vcard.getPhoneList();
        List<EmailData> email = vcard.getEmailList();

        mBmsg.append(VCARD_BEGIN).append(CRLF);

        mBmsg.append(VCARD_VERSION).append(CRLF);

        mBmsg.append(VCARD_N).append(n).append(CRLF);

        if (tel != null && tel.size() > 0) {
            mBmsg.append(VCARD_TEL).append(tel.get(0).getNumber()).append(CRLF);
        }

        if (email != null && email.size() > 0) {
            mBmsg.append(VCARD_EMAIL).append(email.get(0).getAddress()).append(CRLF);
        }

        mBmsg.append(VCARD_END).append(CRLF);
    
private java.lang.StringbuildVcardN(com.android.vcard.VCardEntry vcard)

        NameData nd = vcard.getNameData();
        StringBuilder sb = new StringBuilder();

        sb.append(nd.getFamily()).append(";");
        sb.append(nd.getGiven() == null ? "" : nd.getGiven()).append(";");
        sb.append(nd.getMiddle() == null ? "" : nd.getMiddle()).append(";");
        sb.append(nd.getPrefix() == null ? "" : nd.getPrefix()).append(";");
        sb.append(nd.getSuffix() == null ? "" : nd.getSuffix());

        return sb.toString();
    
public static java.lang.StringcreateBmessage(BluetoothMapBmessage bmsg)

        BluetoothMapBmessageBuilder b = new BluetoothMapBmessageBuilder();

        b.build(bmsg);

        return b.mBmsg.toString();