FileDocCategorySizeDatePackage
XmlCalendarsGDataParser.javaAPI DocAndroid 1.5 API5105Wed May 06 22:41:16 BST 2009com.google.wireless.gdata.calendar.parser.xml

XmlCalendarsGDataParser

public class XmlCalendarsGDataParser extends com.google.wireless.gdata.parser.xml.XmlGDataParser
GDataParser for the meta feed listing a user's calendars.

Fields Summary
Constructors Summary
public XmlCalendarsGDataParser(InputStream is, XmlPullParser parser)
Creates a new XmlCalendarsGDataParser.

param
is The InputStream containing the calendars feed.
throws
ParseException Thrown if an XmlPullParser could not be created.

        super(is, parser);
    
Methods Summary
protected com.google.wireless.gdata.data.EntrycreateEntry()

        return new CalendarEntry();
    
protected com.google.wireless.gdata.data.FeedcreateFeed()

        return new CalendarsFeed();
    
protected voidhandleExtraElementInEntry(com.google.wireless.gdata.data.Entry entry)


        XmlPullParser parser = getParser();

        if (!(entry instanceof CalendarEntry)) {
            throw new IllegalArgumentException("Expected CalendarEntry!");
        }
        CalendarEntry calendarEntry = (CalendarEntry) entry;

        // NOTE: all of these names are assumed to be in the "gcal" namespace.
        // we do not bother checking that here.
        String name = parser.getName();
        if ("accesslevel".equals(name)) {
            String accesslevelStr = parser.getAttributeValue(null /* ns */,
                    "value");
            byte accesslevel = CalendarEntry.ACCESS_READ;
            if ("none".equals(accesslevelStr)) {
                accesslevel = CalendarEntry.ACCESS_NONE;
            } else if ("read".equals(accesslevelStr)) {
                accesslevel = CalendarEntry.ACCESS_READ;
            } else if ("freebusy".equals(accesslevelStr)) {
                accesslevel = CalendarEntry.ACCESS_FREEBUSY;
            } else if ("contributor".equals(accesslevelStr)) {
                // contributor is the access level that used to be used, but it seems to have
                // been deprecated in favor of "editor".
                accesslevel = CalendarEntry.ACCESS_EDITOR;
            } else if ("editor".equals(accesslevelStr)) {
                accesslevel = CalendarEntry.ACCESS_EDITOR;
            } else if ("owner".equals(accesslevelStr)) {
                accesslevel = CalendarEntry.ACCESS_OWNER;
            }
            calendarEntry.setAccessLevel(accesslevel);
        } else if ("color".equals(name)) {
            String color =
                parser.getAttributeValue(null /* ns */, "value");
            calendarEntry.setColor(color);
        } else if ("hidden".equals(name)) {
            String hiddenStr =
                parser.getAttributeValue(null /* ns */, "value");
            boolean hidden = false;
            if ("false".equals(hiddenStr)) {
                hidden = false;
            } else if ("true".equals(hiddenStr)) {
                hidden = true;
            }
            calendarEntry.setHidden(hidden);
            // if the calendar is hidden, it cannot be selected.
            if (hidden) {
                calendarEntry.setSelected(false);
            }
        } else if ("selected".equals(name)) {
            String selectedStr =
                parser.getAttributeValue(null /* ns */, "value");
            boolean selected = false;
            if ("false".equals(selectedStr)) {
                selected = false;
            } else if ("true".equals(selectedStr)) {
                selected = true;
            }
            calendarEntry.setSelected(selected);
        } else if ("timezone".equals(name)) {
            String timezone =
                parser.getAttributeValue(null /* ns */, "value");
            calendarEntry.setTimezone(timezone);
        }
    
protected voidhandleExtraLinkInEntry(java.lang.String rel, java.lang.String type, java.lang.String href, com.google.wireless.gdata.data.Entry entry)

        if (("alternate".equals(rel)) &&
            ("application/atom+xml".equals(type))) {
            CalendarEntry calendarEntry = (CalendarEntry) entry;
            calendarEntry.setAlternateLink(href);
        }