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

BluetoothMapMessagesListing

public class BluetoothMapMessagesListing extends Object

Fields Summary
private static final String
TAG
private final ArrayList
mMessages
Constructors Summary
public BluetoothMapMessagesListing(InputStream in)


       
        mMessages = new ArrayList<BluetoothMapMessage>();

        parse(in);
    
Methods Summary
public java.util.ArrayListgetList()

        return mMessages;
    
public voidparse(java.io.InputStream in)


        try {
            XmlPullParser xpp = XmlPullParserFactory.newInstance().newPullParser();
            xpp.setInput(in, "utf-8");

            int event = xpp.getEventType();
            while (event != XmlPullParser.END_DOCUMENT) {
                switch (event) {
                    case XmlPullParser.START_TAG:
                        if (xpp.getName().equals("msg")) {

                            HashMap<String, String> attrs = new HashMap<String, String>();

                            for (int i = 0; i < xpp.getAttributeCount(); i++) {
                                attrs.put(xpp.getAttributeName(i), xpp.getAttributeValue(i));
                            }

                            try {
                                BluetoothMapMessage msg = new BluetoothMapMessage(attrs);
                                mMessages.add(msg);
                            } catch (IllegalArgumentException e) {
                                /* TODO: provide something more useful here */
                                Log.w(TAG, "Invalid <msg/>");
                            }
                        }
                        break;
                }

                event = xpp.next();
            }

        } catch (XmlPullParserException e) {
            Log.e(TAG, "XML parser error when parsing XML", e);
        } catch (IOException e) {
            Log.e(TAG, "I/O error when parsing XML", e);
        }