diff options
author | Debajit Ghosh <debajit@google.com> | 2009-09-16 17:07:29 -0700 |
---|---|---|
committer | Debajit Ghosh <debajit@google.com> | 2009-09-16 17:07:29 -0700 |
commit | 5ba0fd82db3c177f2c47308ab4f9d4f751f25369 (patch) | |
tree | ae3643e57275525e593fa1ec370b77afcab08de1 | |
parent | 5c870410d46b91ba56e131b7e5937121e52a9444 (diff) | |
download | gdata-5ba0fd82db3c177f2c47308ab4f9d4f751f25369.tar.gz |
delete unused gdata2 code.
34 files changed, 0 insertions, 2559 deletions
diff --git a/src/com/google/wireless/gdata2/calendar/client/CalendarClient.java b/src/com/google/wireless/gdata2/calendar/client/CalendarClient.java deleted file mode 100644 index faf4bed..0000000 --- a/src/com/google/wireless/gdata2/calendar/client/CalendarClient.java +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.client; - -import com.google.wireless.gdata2.calendar.data.CalendarEntry; -import com.google.wireless.gdata2.client.GDataClient; -import com.google.wireless.gdata2.client.GDataParserFactory; -import com.google.wireless.gdata2.client.GDataServiceClient; -import com.google.wireless.gdata2.client.HttpException; -import com.google.wireless.gdata2.client.QueryParams; -import com.google.wireless.gdata2.parser.GDataParser; -import com.google.wireless.gdata2.parser.ParseException; - -import java.io.IOException; -import java.io.InputStream; - -/** - * GDataServiceClient for accessing Google Calendar. This client can access and - * parse both the meta feed (list of calendars for a user) and events feeds - * (calendar entries for a specific user). The parsers this class uses handle - * the XML version of feeds. - */ -// TODO: add a method that applies projections such as cutting the attendees. -public class CalendarClient extends GDataServiceClient { - /** Service value for calendar. */ - public static final String SERVICE = "cl"; - - public static final String PROJECTION_PRIVATE_FULL = "/private/full"; - public static final String PROJECTION_PRIVATE_SELF_ATTENDANCE = "/private/full-selfattendance"; - - /** Standard base url for a calendar feed. */ - private static final String CALENDAR_BASE_FEED_URL = - "http://www.google.com/calendar/feeds/"; - - /** - * Create a new CalendarClient. Uses the standard base URL for calendar feeds. - * @param client The GDataClient that should be used to authenticate - * requests, retrieve feeds, etc. - * @param factory The factory that should be used to obtain {@link GDataParser}s used by this - * client. - */ - public CalendarClient(GDataClient client, GDataParserFactory factory) { - super(client, factory); - } - - /* (non-Javadoc) - * @see GDataServiceClient#getServiceName - */ - public String getServiceName() { - return SERVICE; - } - - /** - * Returns the protocol version used by this GDataServiceClient, - * in the form of a "2.1" string. For Calendar, we use the - * default - * - * @return String - */ - public String getProtocolVersion() { - return DEFAULT_GDATA_VERSION; - } - - - - /** - * Returns the url for the default feed for a user, after applying the - * provided QueryParams. - * @param username The username for this user. - * @param projection the projection to use - * @param params The QueryParams that should be applied to the default feed. - * @return The url that should be used to retrieve a user's default feed. - */ - public String getDefaultCalendarUrl(String username, String projection, QueryParams params) { - String feedUrl = CALENDAR_BASE_FEED_URL + getGDataClient().encodeUri(username); - feedUrl += projection; - if (params == null) { - return feedUrl; - } - return params.generateQueryUrl(feedUrl); - } - - /** - * Returns the url for the metafeed for user, which contains the information about - * the user's calendars. - * @param username The username for this user. - * @return The url that should be used to retrieve a user's default feed. - */ - public String getUserCalendarsUrl(String username) { - return CALENDAR_BASE_FEED_URL + getGDataClient().encodeUri(username); - } - - /** - * Fetches the meta feed containing the list of calendars for a user. The - * caller is responsible for closing the returned {@link GDataParser}. - * - * @param feedUrl the URL of the user calendars feed - * @param authToken The authentication token for this user - * @return A GDataParser with the meta feed containing the list of - * calendars for this user. - * @throws ParseException Thrown if the feed could not be fetched. - */ - public GDataParser getParserForUserCalendars(String feedUrl, String authToken) - throws ParseException, IOException, HttpException { - GDataClient gDataClient = getGDataClient(); - InputStream is = gDataClient.getFeedAsStream(feedUrl, authToken, null /* etag */, getProtocolVersion()); - return getGDataParserFactory().createParser(CalendarEntry.class, is); - } -} diff --git a/src/com/google/wireless/gdata2/calendar/client/package.html b/src/com/google/wireless/gdata2/calendar/client/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/calendar/client/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/calendar/data/CalendarEntry.java b/src/com/google/wireless/gdata2/calendar/data/CalendarEntry.java deleted file mode 100644 index 069d0af..0000000 --- a/src/com/google/wireless/gdata2/calendar/data/CalendarEntry.java +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.data; - -import com.google.wireless.gdata2.data.Entry; - -/** - * Entry containing information about a calendar. - */ -public class CalendarEntry extends Entry { - - /** - * Access level constant indicating the user has no access to a calendar. - */ - public static final byte ACCESS_NONE = 0; - - /** - * Access level constant indicating the user can read (but not write) to - * a calendar. - */ - public static final byte ACCESS_READ = 1; - - /** - * Access level constant indicating the user can only view free-busy - * information for a calendar. - */ - public static final byte ACCESS_FREEBUSY = 2; - - /** - * Access level constant indicating the user can edit this calendar. - */ - public static final byte ACCESS_EDITOR = 3; - - /** - * Access level constant indicating the user owns this calendar. - */ - public static final byte ACCESS_OWNER = 4; - - private byte accessLevel = ACCESS_READ; - // TODO: rename to feed Url? - private String alternateLink = null; - private String color = null; - private boolean hidden = false; - private boolean selected = true; - private String timezone = null; - - /** - * Creates a new, empty calendar entry. - */ - public CalendarEntry() { - } - - public void clear() { - super.clear(); - accessLevel = ACCESS_READ; - alternateLink = null; - color = null; - hidden = false; - selected = true; - timezone = null; - } - - /** - * @return the accessLevel - */ - public byte getAccessLevel() { - return accessLevel; - } - - /** - * @param accessLevel the accessLevel to set - */ - public void setAccessLevel(byte accessLevel) { - this.accessLevel = accessLevel; - } - - /** - * @return the alternateLink - */ - public String getAlternateLink() { - return alternateLink; - } - - /** - * @param alternateLink the alternateLink to set - */ - public void setAlternateLink(String alternateLink) { - this.alternateLink = alternateLink; - } - - /** - * @return the color - */ - public String getColor() { - return color; - } - - /** - * @param color the color to set - */ - public void setColor(String color) { - this.color = color; - } - - /** - * @return the hidden - */ - public boolean isHidden() { - return hidden; - } - - /** - * @param hidden the hidden to set - */ - public void setHidden(boolean hidden) { - this.hidden = hidden; - } - - /** - * @return the selected - */ - public boolean isSelected() { - return selected; - } - - /** - * @param selected the selected to set - */ - public void setSelected(boolean selected) { - this.selected = selected; - } - - /** - * @return the timezone - */ - public String getTimezone() { - return timezone; - } - - /** - * @param timezone the timezone to set - */ - public void setTimezone(String timezone) { - this.timezone = timezone; - } - - public void toString(StringBuffer sb) { - sb.append("ACCESS LEVEL: "); - sb.append(accessLevel); - sb.append('\n'); - appendIfNotNull(sb, "ALTERNATE LINK", alternateLink); - appendIfNotNull(sb, "COLOR", color); - sb.append("HIDDEN: "); - sb.append(hidden); - sb.append('\n'); - sb.append("SELECTED: "); - sb.append(selected); - sb.append('\n'); - appendIfNotNull(sb, "TIMEZONE", timezone); - } -} diff --git a/src/com/google/wireless/gdata2/calendar/data/CalendarsFeed.java b/src/com/google/wireless/gdata2/calendar/data/CalendarsFeed.java deleted file mode 100644 index b2b4669..0000000 --- a/src/com/google/wireless/gdata2/calendar/data/CalendarsFeed.java +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.data; - -import com.google.wireless.gdata2.data.Feed; - -/** - * Meta feed containing the list of calendars for a user. - */ -public class CalendarsFeed extends Feed { - - /** - * Creates a new empty calendars feed. - */ - public CalendarsFeed() { - } - -} diff --git a/src/com/google/wireless/gdata2/calendar/data/EventEntry.java b/src/com/google/wireless/gdata2/calendar/data/EventEntry.java deleted file mode 100644 index e5a5f9c..0000000 --- a/src/com/google/wireless/gdata2/calendar/data/EventEntry.java +++ /dev/null @@ -1,327 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.data; - -import com.google.wireless.gdata2.data.Entry; - -import java.util.Hashtable; -import java.util.Vector; -import java.util.Enumeration; - -/** - * Entry containing information about an event in a calendar. - */ -public class EventEntry extends Entry { - - // TODO: pack all of these enums into an int - - /** - * Status constant indicating that a user's attendance at an event is - * tentative. - */ - public static final byte STATUS_TENTATIVE = 0; - - /** - * Status constant indicating that a user's attendance at an event is - * confirmed. - */ - public static final byte STATUS_CONFIRMED = 1; - - /** - * Status constant indicating that an event has been cancelled. - */ - public static final byte STATUS_CANCELED = 2; - - /** - * Visibility constant indicating that an event uses the user's default - * visibility. - */ - public static final byte VISIBILITY_DEFAULT = 0; - - /** - * Visibility constant indicating that an event has been marked - * confidential. - */ - public static final byte VISIBILITY_CONFIDENTIAL = 1; - - /** - * Visibility constant indicating that an event has been marked private. - */ - public static final byte VISIBILITY_PRIVATE = 2; - - /** - * Visibility constant indicating that an event has been marked public. - */ - public static final byte VISIBILITY_PUBLIC = 3; - - /** - * Transparency constant indicating that an event has been marked opaque. - */ - public static final byte TRANSPARENCY_OPAQUE = 0; - - /** - * Transparency constant indicating that an event has been marked - * transparent. - */ - public static final byte TRANSPARENCY_TRANSPARENT = 1; - - private byte status = STATUS_TENTATIVE; - private String recurrence = null; - private byte visibility = VISIBILITY_DEFAULT; - private byte transparency = TRANSPARENCY_OPAQUE; - private Vector attendees = new Vector(); - private Vector whens = new Vector(); - private Vector reminders = null; - private String originalEventId = null; - private String originalEventStartTime = null; - private String where = null; - private String commentsUri = null; - private Hashtable extendedProperties = null; - private boolean quickAdd = false; - - /** - * Creates a new empty event entry. - */ - public EventEntry() { - } - - /* - * (non-Javadoc) - * @see com.google.wireless.gdata2.data.Entry#clear() - */ - public void clear() { - super.clear(); - status = STATUS_TENTATIVE; - recurrence = null; - visibility = VISIBILITY_DEFAULT; - transparency = TRANSPARENCY_OPAQUE; - attendees.removeAllElements(); - whens.removeAllElements(); - reminders = null; - originalEventId = null; - originalEventStartTime = null; - where = null; - commentsUri = null; - extendedProperties = null; - quickAdd = false; - } - - /** - * @return the recurrence - */ - public String getRecurrence() { - return recurrence; - } - - /** - * @param recurrence the recurrence to set - */ - public void setRecurrence(String recurrence) { - this.recurrence = recurrence; - } - - /** - * @return the status - */ - public byte getStatus() { - return status; - } - - /** - * @param status the status to set - */ - public void setStatus(byte status) { - this.status = status; - } - - /** - * @return the transparency - */ - public byte getTransparency() { - return transparency; - } - - /** - * @param transparency the transparency to set - */ - public void setTransparency(byte transparency) { - this.transparency = transparency; - } - - /** - * @return the visibility - */ - public byte getVisibility() { - return visibility; - } - - /** - * @param visibility the visibility to set - */ - public void setVisibility(byte visibility) { - this.visibility = visibility; - } - - public void clearAttendees() { - attendees.removeAllElements(); - } - - public void addAttendee(Who attendee) { - attendees.addElement(attendee); - } - - public Vector getAttendees() { - return attendees; - } - - public void clearWhens() { - whens.removeAllElements(); - } - - public void addWhen(When when) { - whens.addElement(when); - } - - public Vector getWhens() { - return whens; - } - - public When getFirstWhen() { - if (whens.isEmpty()) { - return null; - } - return (When) whens.elementAt(0); - } - - public Vector getReminders() { - return reminders; - } - - public void addReminder(Reminder reminder) { - if (reminders == null) { - reminders = new Vector(); - } - reminders.addElement(reminder); - } - - public void clearReminders() { - reminders = null; - } - - public String getOriginalEventId() { - return originalEventId; - } - - public void setOriginalEventId(String originalEventId) { - this.originalEventId = originalEventId; - } - - public String getOriginalEventStartTime() { - return originalEventStartTime; - } - - public void setOriginalEventStartTime(String originalEventStartTime) { - this.originalEventStartTime = originalEventStartTime; - } - - /** - * @return the where - */ - public String getWhere() { - return where; - } - - /** - * @param where the where to set - */ - public void setWhere(String where) { - this.where = where; - } - - public Hashtable getExtendedProperties() { - return extendedProperties; - } - - public String getExtendedProperty(String name) { - if (extendedProperties == null) { - return null; - } - String value = null; - if (extendedProperties.containsKey(name)) { - value = (String) extendedProperties.get(name); - } - return value; - } - - public void addExtendedProperty(String name, String value) { - if (extendedProperties == null) { - extendedProperties = new Hashtable(); - } - extendedProperties.put(name, value); - } - - public void clearExtendedProperties() { - extendedProperties = null; - } - - public String getCommentsUri() { - return commentsUri; - } - - public void setCommentsUri(String commentsUri) { - this.commentsUri = commentsUri; - } - - public boolean isQuickAdd() { - return quickAdd; - } - - public void setQuickAdd(boolean quickAdd) { - this.quickAdd = quickAdd; - } - - public void toString(StringBuffer sb) { - super.toString(sb); - sb.append("STATUS: " + status + "\n"); - appendIfNotNull(sb, "RECURRENCE", recurrence); - sb.append("VISIBILITY: " + visibility + "\n"); - sb.append("TRANSPARENCY: " + transparency + "\n"); - - appendIfNotNull(sb, "ORIGINAL_EVENT_ID", originalEventId); - appendIfNotNull(sb, "ORIGINAL_START_TIME", originalEventStartTime); - - sb.append("QUICK_ADD: " + (quickAdd ? "true" : "false")); - - Enumeration whos = this.attendees.elements(); - while (whos.hasMoreElements()) { - Who who = (Who) whos.nextElement(); - who.toString(sb); - } - - Enumeration times = this.whens.elements(); - while (times.hasMoreElements()) { - When when = (When) times.nextElement(); - when.toString(sb); - } - if (reminders != null) { - Enumeration alarms = reminders.elements(); - while (alarms.hasMoreElements()) { - Reminder reminder = (Reminder) alarms.nextElement(); - reminder.toString(sb); - } - } - appendIfNotNull(sb, "WHERE", where); - appendIfNotNull(sb, "COMMENTS", commentsUri); - if (extendedProperties != null) { - Enumeration entryNames = extendedProperties.keys(); - while (entryNames.hasMoreElements()) { - String name = (String) entryNames.nextElement(); - String value = (String) extendedProperties.get(name); - sb.append(name); - sb.append(':'); - sb.append(value); - sb.append('\n'); - } - } - } -} diff --git a/src/com/google/wireless/gdata2/calendar/data/EventsFeed.java b/src/com/google/wireless/gdata2/calendar/data/EventsFeed.java deleted file mode 100644 index b524e26..0000000 --- a/src/com/google/wireless/gdata2/calendar/data/EventsFeed.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.data; - -import com.google.wireless.gdata2.data.Feed; - -/** - * Feed containing events in a calendar. - */ -public class EventsFeed extends Feed { - - private String timezone = null; - - /** - * Creates a new empty events feed. - */ - public EventsFeed() { - } - - /** - * @return the timezone - */ - public String getTimezone() { - return timezone; - } - - /** - * @param timezone the timezone to set - */ - public void setTimezone(String timezone) { - this.timezone = timezone; - } -} diff --git a/src/com/google/wireless/gdata2/calendar/data/Recurrence.java b/src/com/google/wireless/gdata2/calendar/data/Recurrence.java deleted file mode 100644 index 17a0a49..0000000 --- a/src/com/google/wireless/gdata2/calendar/data/Recurrence.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.data; - -/** - * Container for information about a Recurrence. - */ -// TODO: get rid of this? -public class Recurrence { - - private final String recurrence; - - /** - * Creates a new recurrence for the provide recurrence string. - * @param recurrence The recurrence string that should be parsed. - */ - public Recurrence(String recurrence) { - this.recurrence = recurrence; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - return recurrence; - } -} diff --git a/src/com/google/wireless/gdata2/calendar/data/Reminder.java b/src/com/google/wireless/gdata2/calendar/data/Reminder.java deleted file mode 100644 index 9672123..0000000 --- a/src/com/google/wireless/gdata2/calendar/data/Reminder.java +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2007 The Android Open Source Project -package com.google.wireless.gdata2.calendar.data; - -/** - * Contains information about a reminder for an event. - */ -public class Reminder { - /** - * Default reminder method as defined on the calendar server. - */ - public static final byte METHOD_DEFAULT = 0; - - /** - * Reminder that uses e-mail for notification. - */ - public static final byte METHOD_EMAIL = 1; - - /** - * Reminder that uses sms for notification. - */ - public static final byte METHOD_SMS = 2; - - /** - * Reminder that uses a local alert for notification. - */ - public static final byte METHOD_ALERT = 3; - - /** - * Reminder that uses a calendar-wide default time for the alarm. - */ - public static final int MINUTES_DEFAULT = -1; - - // do absolute times work with recurrences? - // private String absoluteTime; - private int minutes = MINUTES_DEFAULT; - private byte method = METHOD_DEFAULT; - - /** - * Creates a new empty reminder. - */ - public Reminder() { - } - - /** - * Returns the method of the reminder. - * @return The method of the reminder. - */ - public byte getMethod() { - return method; - } - - /** - * Sets the method of the reminder. - * @param method The method of the reminder. - */ - public void setMethod(byte method) { - this.method = method; - } - - /** - * Gets how many minutes before an event that the reminder should be - * triggered. - * @return How many minutes before an event that the reminder should be - * triggered. - */ - public int getMinutes() { - return minutes; - } - - /** - * Sets how many minutes before an event that the reminder should be - * triggered. - * @param minutes How many minutes before an event that the reminder should - * be triggered. - */ - public void setMinutes(int minutes) { - this.minutes = minutes; - } - - public void toString(StringBuffer sb) { - sb.append("REMINDER MINUTES: " + minutes); - sb.append("\n"); - sb.append("REMINDER METHOD: " + method); - sb.append("\n"); - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - toString(sb); - return sb.toString(); - } -} diff --git a/src/com/google/wireless/gdata2/calendar/data/When.java b/src/com/google/wireless/gdata2/calendar/data/When.java deleted file mode 100644 index a2b1975..0000000 --- a/src/com/google/wireless/gdata2/calendar/data/When.java +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2007 The Android Open Source Project -package com.google.wireless.gdata2.calendar.data; - -import com.google.wireless.gdata2.data.StringUtils; - -/** - * Contains information about the start and end of an instance of an event. - */ -public class When { - private final String startTime; - private final String endTime; - - /** - * Creates a new When. - * @param startTime The start of the event. - * @param endTime The end of the event. - */ - public When(String startTime, String endTime) { - this.startTime = startTime; - this.endTime = endTime; - } - - /** - * Returns the start time for the event. - * @return The start time for the event. - */ - public String getStartTime() { - return startTime; - } - - /** - * Returns the end time for the event. - * @return The end time for the event. - */ - public String getEndTime() { - return endTime; - } - - public void toString(StringBuffer sb) { - if (!StringUtils.isEmpty(startTime)) { - sb.append("START TIME: " + startTime + "\n"); - } - if (!StringUtils.isEmpty(endTime)) { - sb.append("END TIME: " + endTime + "\n"); - } - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - toString(sb); - return sb.toString(); - } -} diff --git a/src/com/google/wireless/gdata2/calendar/data/Who.java b/src/com/google/wireless/gdata2/calendar/data/Who.java deleted file mode 100644 index 8a21dfa..0000000 --- a/src/com/google/wireless/gdata2/calendar/data/Who.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.google.wireless.gdata2.calendar.data; - -import com.google.wireless.gdata2.data.StringUtils; - -/** - * Contains information about a event attendee. - */ -public class Who { - - /** - * No attendee relationhip set. Used in {@link #setRelationship} - * and {@link #getRelationship}. - */ - public static final byte RELATIONSHIP_NONE = 0; - - /** - * A general meeting/event attendee. Used in {@link #setRelationship} - * and {@link #getRelationship}. - */ - public static final byte RELATIONSHIP_ATTENDEE = 1; - - /** - * Event organizer. An organizer is not necessary an attendee. - * Used in {@link #setRelationship} and {@link #getRelationship}. - */ - public static final byte RELATIONSHIP_ORGANIZER = 2; - - /** - * Performer. Similar to {@link #RELATIONSHIP_SPEAKER}, but with more emphasis on art than - * speech delivery. - * Used in {@link #setRelationship} and {@link #getRelationship}. - */ - public static final byte RELATIONSHIP_PERFORMER = 3; - - /** - * Speaker. Used in {@link #setRelationship} and {@link #getRelationship}. - */ - public static final byte RELATIONSHIP_SPEAKER = 4; - - /** - * No attendee type set. Used in {@link #setType} and {@link #getType}. - */ - public static final byte TYPE_NONE = 0; - - /** - * Optional attendee. Used in {@link #setType} and {@link #getType}. - */ - public static final byte TYPE_OPTIONAL = 1; - - /** - * Required attendee. Used in {@link #setType} and {@link #getType}. - */ - public static final byte TYPE_REQUIRED = 2; - - /** - * No attendee status set. Used in {@link #setStatus} and {@link #getStatus}. - */ - public static final byte STATUS_NONE = 0; - - - /** - * Attendee has accepted. Used in {@link #setStatus} and {@link #getStatus}. - */ - public static final byte STATUS_ACCEPTED = 1; - - /** - * Attendee has declined. Used in {@link #setStatus} and {@link #getStatus}. - */ - public static final byte STATUS_DECLINED = 2; - - /** - * Invitation has been sent, but the person has not accepted. - * Used in {@link #setStatus} and {@link #getStatus}. - */ - public static final byte STATUS_INVITED = 3; - - /** - * Attendee has accepted tentatively. Used in {@link #setStatus} and {@link #getStatus}. - */ - public static final byte STATUS_TENTATIVE = 4; - - private String email; - private String value; - private byte relationship = RELATIONSHIP_NONE; - private byte type = TYPE_NONE; - private byte status = STATUS_NONE; - - /** - * Creates a new Who, representing event attendee information. - */ - public Who() { - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public byte getRelationship() { - return relationship; - } - - public void setRelationship(byte relationship) { - this.relationship = relationship; - } - - public byte getType() { - return type; - } - - public void setType(byte type) { - this.type = type; - } - - public byte getStatus() { - return status; - } - - public void setStatus(byte status) { - this.status = status; - } - - protected void toString(StringBuffer sb) { - if (!StringUtils.isEmpty(email)) { - sb.append("EMAIL: " + email + "\n"); - } - - if (!StringUtils.isEmpty(value)) { - sb.append("VALUE: " + value + "\n"); - } - - sb.append("RELATIONSHIP: " + relationship + "\n"); - sb.append("TYPE: " + type + "\n"); - sb.append("STATUS: " + status + "\n"); - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - toString(sb); - return sb.toString(); - } -} diff --git a/src/com/google/wireless/gdata2/calendar/data/package.html b/src/com/google/wireless/gdata2/calendar/data/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/calendar/data/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/calendar/package.html b/src/com/google/wireless/gdata2/calendar/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/calendar/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/calendar/parser/package.html b/src/com/google/wireless/gdata2/calendar/parser/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/calendar/parser/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarGDataParserFactory.java b/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarGDataParserFactory.java deleted file mode 100644 index 6146ad1..0000000 --- a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarGDataParserFactory.java +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.parser.xml; - -import com.google.wireless.gdata2.calendar.data.CalendarEntry; -import com.google.wireless.gdata2.calendar.data.EventEntry; -import com.google.wireless.gdata2.calendar.serializer.xml.XmlEventEntryGDataSerializer; -import com.google.wireless.gdata2.client.GDataParserFactory; -import com.google.wireless.gdata2.data.Entry; -import com.google.wireless.gdata2.parser.GDataParser; -import com.google.wireless.gdata2.parser.ParseException; -import com.google.wireless.gdata2.parser.xml.XmlParserFactory; -import com.google.wireless.gdata2.serializer.GDataSerializer; -import com.google.wireless.gdata2.serializer.xml.XmlBatchGDataSerializer; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.InputStream; -import java.util.Enumeration; - -/** - * GDataParserFactory that creates XML GDataParsers and GDataSerializers for - * Google Calendar. - */ -public class XmlCalendarGDataParserFactory implements GDataParserFactory { - - private final XmlParserFactory xmlFactory; - - public XmlCalendarGDataParserFactory(XmlParserFactory xmlFactory) { - this.xmlFactory = xmlFactory; - } - - /** - * Returns a parser for a calendars meta-feed. - * - * @param is The input stream to be parsed. - * @return A parser for the stream. - */ - public GDataParser createCalendarsFeedParser(InputStream is) - throws ParseException { - XmlPullParser xmlParser; - try { - xmlParser = xmlFactory.createParser(); - } catch (XmlPullParserException xppe) { - throw new ParseException("Could not create XmlPullParser", xppe); - } - return new XmlCalendarsGDataParser(is, xmlParser); - } - - /* - * (non-javadoc) - * - * @see GDataParserFactory#createParser - */ - public GDataParser createParser(InputStream is) throws ParseException { - XmlPullParser xmlParser; - try { - xmlParser = xmlFactory.createParser(); - } catch (XmlPullParserException xppe) { - throw new ParseException("Could not create XmlPullParser", xppe); - } - return new XmlEventsGDataParser(is, xmlParser); - } - - /* - * (non-Javadoc) - * - * @see com.google.wireless.gdata2.client.GDataParserFactory#createParser( - * int, java.io.InputStream) - */ - public GDataParser createParser(Class entryClass, InputStream is) - throws ParseException { - if (entryClass == CalendarEntry.class) { - return createCalendarsFeedParser(is); - } else if (entryClass == EventEntry.class) { - return createParser(is); - } - throw new IllegalArgumentException("Unknown entry class '" + entryClass.getName() - + "' specified."); - } - - /** - * Creates a new {@link GDataSerializer} for the provided entry. The entry - * <strong>must</strong> be an instance of {@link EventEntry}. - * - * @param entry The {@link EventEntry} that should be serialized. - * @return The {@link GDataSerializer} that will serialize this entry. - * @throws IllegalArgumentException Thrown if entry is not an - * {@link EventEntry}. - * @see GDataParserFactory#createSerializer - */ - public GDataSerializer createSerializer(Entry entry) { - if (!(entry instanceof EventEntry)) { - throw new IllegalArgumentException("Expected EventEntry!"); - } - EventEntry eventEntry = (EventEntry) entry; - return new XmlEventEntryGDataSerializer(xmlFactory, eventEntry); - } - - /** - * Creates a new {@link GDataSerializer} for the given batch. - * - * @param batch the {@link Enumeration} of entries in the batch. - * @return The {@link GDataSerializer} that will serialize this batch. - */ - public GDataSerializer createSerializer(Enumeration batch) { - return new XmlBatchGDataSerializer(this, xmlFactory, batch); - } -} diff --git a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarsGDataParser.java b/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarsGDataParser.java deleted file mode 100644 index 6a8d2c4..0000000 --- a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlCalendarsGDataParser.java +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.parser.xml; - -import com.google.wireless.gdata2.calendar.data.CalendarEntry; -import com.google.wireless.gdata2.calendar.data.CalendarsFeed; -import com.google.wireless.gdata2.data.Entry; -import com.google.wireless.gdata2.data.Feed; -import com.google.wireless.gdata2.parser.ParseException; -import com.google.wireless.gdata2.parser.xml.XmlGDataParser; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.IOException; -import java.io.InputStream; - -/** - * GDataParser for the meta feed listing a user's calendars. - */ -public class XmlCalendarsGDataParser extends XmlGDataParser { - - /** - * Creates a new XmlCalendarsGDataParser. - * @param is The InputStream containing the calendars feed. - * @throws ParseException Thrown if an XmlPullParser could not be created. - */ - public XmlCalendarsGDataParser(InputStream is, XmlPullParser parser) - throws ParseException { - super(is, parser); - } - - /* - * (non-Javadoc) - * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createFeed() - */ - protected Feed createFeed() { - return new CalendarsFeed(); - } - - /* - * (non-Javadoc) - * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createEntry() - */ - protected Entry createEntry() { - return new CalendarEntry(); - } - - /* - * (non-Javadoc) - * @see XmlGDataParser#handleExtraElementInEntry - */ - protected void handleExtraElementInEntry(Entry entry) - throws XmlPullParserException, IOException { - - 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); - } - } - - /* - * (non-Javadoc) - * @see XmlGDataParser#handleExtraLinkInEntry - */ - protected void handleExtraLinkInEntry(String rel, - String type, - String href, - Entry entry) - throws XmlPullParserException, IOException { - if (("alternate".equals(rel)) && - ("application/atom+xml".equals(type))) { - CalendarEntry calendarEntry = (CalendarEntry) entry; - calendarEntry.setAlternateLink(href); - } - } -} diff --git a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlEventsGDataParser.java b/src/com/google/wireless/gdata2/calendar/parser/xml/XmlEventsGDataParser.java deleted file mode 100644 index 38f8272..0000000 --- a/src/com/google/wireless/gdata2/calendar/parser/xml/XmlEventsGDataParser.java +++ /dev/null @@ -1,425 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.parser.xml; - -import com.google.wireless.gdata2.calendar.data.EventEntry; -import com.google.wireless.gdata2.calendar.data.EventsFeed; -import com.google.wireless.gdata2.calendar.data.When; -import com.google.wireless.gdata2.calendar.data.Reminder; -import com.google.wireless.gdata2.calendar.data.Who; -import com.google.wireless.gdata2.data.Entry; -import com.google.wireless.gdata2.data.Feed; -import com.google.wireless.gdata2.data.StringUtils; -import com.google.wireless.gdata2.data.XmlUtils; -import com.google.wireless.gdata2.parser.ParseException; -import com.google.wireless.gdata2.parser.xml.XmlGDataParser; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.IOException; -import java.io.InputStream; - -/** - * GDataParser for an events feed containing events in a calendar. - */ -public class XmlEventsGDataParser extends XmlGDataParser { - - // whether or not we've seen reminders directly under the entry. - // the calendar feed sends duplicate <reminder> entries in case of - // recurrences, if the recurrences are expanded. - // if the <reminder> elements precede the <when> elements, we'll only - // process the <reminder> elements directly under the entry and ignore - // the <reminder> elements within a <when>. - // if the <when> elements precede the <reminder> elements, we'll first - // process reminders under the when, and then we'll clear them and process - // the reminders directly under the entry (which should take precedence). - // if we only see <reminder> as direct children of the entry or only see - // <reminder> as children of <when> elements, there is no conflict. - private boolean hasSeenReminder = false; - - /** - * Creates a new XmlEventsGDataParser. - * @param is The InputStream that should be parsed. - * @throws ParseException Thrown if a parser cannot be created. - */ - public XmlEventsGDataParser(InputStream is, XmlPullParser parser) - throws ParseException { - super(is, parser); - } - - /* - * (non-Javadoc) - * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createFeed() - */ - protected Feed createFeed() { - return new EventsFeed(); - } - - /* - * (non-Javadoc) - * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createEntry() - */ - protected Entry createEntry() { - return new EventEntry(); - } - - protected void handleEntry(Entry entry) throws XmlPullParserException, - IOException, ParseException { - hasSeenReminder = false; // Reset the state for the new entry - super.handleEntry(entry); - } - - protected void handleExtraElementInFeed(Feed feed) - throws XmlPullParserException, IOException { - XmlPullParser parser = getParser(); - if (!(feed instanceof EventsFeed)) { - throw new IllegalArgumentException("Expected EventsFeed!"); - } - EventsFeed eventsFeed = (EventsFeed) feed; - String name = parser.getName(); - if ("timezone".equals(name)) { - String timezone = parser.getAttributeValue(null /* ns */, "value"); - if (!StringUtils.isEmpty(timezone)) { - eventsFeed.setTimezone(timezone); - } - } - } - - /* - * (non-Javadoc) - * @see XmlGDataParser#handleExtraElementInEntry - */ - protected void handleExtraElementInEntry(Entry entry) - throws XmlPullParserException, IOException, ParseException { - - XmlPullParser parser = getParser(); - - if (!(entry instanceof EventEntry)) { - throw new IllegalArgumentException("Expected EventEntry!"); - } - EventEntry eventEntry = (EventEntry) entry; - - // NOTE: all of these names are assumed to be in the "gd" namespace. - // we do not bother checking that here. - - String name = parser.getName(); - if ("eventStatus".equals(name)) { - String eventStatusStr = parser.getAttributeValue(null, "value"); - byte eventStatus = EventEntry.STATUS_TENTATIVE; - if ("http://schemas.google.com/g/2005#event.canceled". - equals(eventStatusStr)) { - eventStatus = EventEntry.STATUS_CANCELED; - } else if ("http://schemas.google.com/g/2005#event.confirmed". - equals(eventStatusStr)) { - eventStatus = EventEntry.STATUS_CONFIRMED; - } else if ("http://schemas.google.com/g/2005#event.tentative". - equals(eventStatusStr)) { - eventStatus = EventEntry.STATUS_TENTATIVE; - } - eventEntry.setStatus(eventStatus); - } else if ("recurrence".equals(name)) { - String recurrence = XmlUtils.extractChildText(parser); - eventEntry.setRecurrence(recurrence); - } else if ("transparency".equals(name)) { - String transparencyStr = parser.getAttributeValue(null, "value"); - byte transparency = EventEntry.TRANSPARENCY_OPAQUE; - if ("http://schemas.google.com/g/2005#event.opaque". - equals(transparencyStr)) { - transparency = EventEntry.TRANSPARENCY_OPAQUE; - } else if ("http://schemas.google.com/g/2005#event.transparent". - equals(transparencyStr)) { - transparency = EventEntry.TRANSPARENCY_TRANSPARENT; - } - eventEntry.setTransparency(transparency); - } else if ("visibility".equals(name)) { - String visibilityStr = parser.getAttributeValue(null, "value"); - byte visibility = EventEntry.VISIBILITY_DEFAULT; - if ("http://schemas.google.com/g/2005#event.confidential". - equals(visibilityStr)) { - visibility = EventEntry.VISIBILITY_CONFIDENTIAL; - } else if ("http://schemas.google.com/g/2005#event.default" - .equals(visibilityStr)) { - visibility = EventEntry.VISIBILITY_DEFAULT; - } else if ("http://schemas.google.com/g/2005#event.private" - .equals(visibilityStr)) { - visibility = EventEntry.VISIBILITY_PRIVATE; - } else if ("http://schemas.google.com/g/2005#event.public" - .equals(visibilityStr)) { - visibility = EventEntry.VISIBILITY_PUBLIC; - } - eventEntry.setVisibility(visibility); - } else if ("who".equals(name)) { - handleWho(eventEntry); - } else if ("when".equals(name)) { - handleWhen(eventEntry); - } else if ("reminder".equals(name)) { - if (!hasSeenReminder) { - // if this is the first <reminder> we've seen directly under the - // entry, clear any previously seen reminders (under <when>s) - eventEntry.clearReminders(); - hasSeenReminder = true; - } - handleReminder(eventEntry); - } else if ("originalEvent".equals(name)) { - handleOriginalEvent(eventEntry); - } else if ("where".equals(name)) { - String where = parser.getAttributeValue(null /* ns */, - "valueString"); - String rel = parser.getAttributeValue(null /* ns */, - "rel"); - if (StringUtils.isEmpty(rel) || - "http://schemas.google.com/g/2005#event".equals(rel)) { - eventEntry.setWhere(where); - } - // TODO: handle entryLink? - } else if ("feedLink".equals(name)) { - // TODO: check that the parent is a gd:comments - String commentsUri = parser.getAttributeValue(null /* ns */, "href"); - eventEntry.setCommentsUri(commentsUri); - } else if ("extendedProperty".equals(name)) { - String propertyName = parser.getAttributeValue(null /* ns */, "name"); - String propertyValue = parser.getAttributeValue(null /* ns */, "value"); - eventEntry.addExtendedProperty(propertyName, propertyValue); - } - } - - private void handleWho(EventEntry eventEntry) - throws XmlPullParserException, IOException, ParseException { - - XmlPullParser parser = getParser(); - - int eventType = parser.getEventType(); - String name = parser.getName(); - - if (eventType != XmlPullParser.START_TAG || - (!"who".equals(parser.getName()))) { - // should not happen. - throw new - IllegalStateException("Expected <who>: Actual " - + "element: <" - + name + ">"); - } - - String email = - parser.getAttributeValue(null /* ns */, "email"); - String relString = - parser.getAttributeValue(null /* ns */, "rel"); - String value = - parser.getAttributeValue(null /* ns */, "valueString"); - - Who who = new Who(); - who.setEmail(email); - who.setValue(value); - byte rel = Who.RELATIONSHIP_NONE; - if ("http://schemas.google.com/g/2005#event.attendee".equals(relString)) { - rel = Who.RELATIONSHIP_ATTENDEE; - } else if ("http://schemas.google.com/g/2005#event.organizer".equals(relString)) { - rel = Who.RELATIONSHIP_ORGANIZER; - } else if ("http://schemas.google.com/g/2005#event.performer".equals(relString)) { - rel = Who.RELATIONSHIP_PERFORMER; - } else if ("http://schemas.google.com/g/2005#event.speaker".equals(relString)) { - rel = Who.RELATIONSHIP_SPEAKER; - } else if (StringUtils.isEmpty(relString)) { - rel = Who.RELATIONSHIP_ATTENDEE; - } else { - throw new ParseException("Unexpected rel: " + relString); - } - who.setRelationship(rel); - - eventEntry.addAttendee(who); - - while (eventType != XmlPullParser.END_DOCUMENT) { - switch (eventType) { - case XmlPullParser.START_TAG: - name = parser.getName(); - if ("attendeeStatus".equals(name)) { - String statusString = - parser.getAttributeValue(null /* ns */, "value"); - byte status = Who.STATUS_NONE; - if ("http://schemas.google.com/g/2005#event.accepted". - equals(statusString)) { - status = Who.STATUS_ACCEPTED; - } else if ("http://schemas.google.com/g/2005#event.declined". - equals(statusString)) { - status = Who.STATUS_DECLINED; - } else if ("http://schemas.google.com/g/2005#event.invited". - equals(statusString)) { - status = Who.STATUS_INVITED; - } else if ("http://schemas.google.com/g/2005#event.tentative". - equals(statusString)) { - status = Who.STATUS_TENTATIVE; - } else if (StringUtils.isEmpty(statusString)) { - status = Who.STATUS_TENTATIVE; - } else { - throw new ParseException("Unexpected status: " + statusString); - } - who.setStatus(status); - } else if ("attendeeType".equals(name)) { - String typeString= XmlUtils.extractChildText(parser); - byte type = Who.TYPE_NONE; - if ("http://schemas.google.com/g/2005#event.optional".equals(typeString)) { - type = Who.TYPE_OPTIONAL; - } else if ("http://schemas.google.com/g/2005#event.required". - equals(typeString)) { - type = Who.TYPE_REQUIRED; - } else if (StringUtils.isEmpty(typeString)) { - type = Who.TYPE_REQUIRED; - } else { - throw new ParseException("Unexpected type: " + typeString); - } - who.setType(type); - } - break; - case XmlPullParser.END_TAG: - name = parser.getName(); - if ("who".equals(name)) { - return; - } - default: - // ignore - } - - eventType = parser.next(); - } - } - - private void handleWhen(EventEntry eventEntry) - throws XmlPullParserException, IOException { - - XmlPullParser parser = getParser(); - - int eventType = parser.getEventType(); - String name = parser.getName(); - - if (eventType != XmlPullParser.START_TAG || - (!"when".equals(parser.getName()))) { - // should not happen. - throw new - IllegalStateException("Expected <when>: Actual " - + "element: <" - + name + ">"); - } - - String startTime = - parser.getAttributeValue(null /* ns */, "startTime"); - String endTime = - parser.getAttributeValue(null /* ns */, "endTime"); - - When when = new When(startTime, endTime); - eventEntry.addWhen(when); - boolean firstWhen = eventEntry.getWhens().size() == 1; - // we only parse reminders under the when if reminders have not already - // been handled (directly under the entry, or in a previous when for - // this entry) - boolean handleReminders = firstWhen && !hasSeenReminder; - - eventType = parser.next(); - while (eventType != XmlPullParser.END_DOCUMENT) { - switch (eventType) { - case XmlPullParser.START_TAG: - name = parser.getName(); - if ("reminder".equals(name)) { - // only want to store reminders on the first when. they - // should have the same values for all other instances. - if (handleReminders) { - handleReminder(eventEntry); - } - } - break; - case XmlPullParser.END_TAG: - name = parser.getName(); - if ("when".equals(name)) { - return; - } - default: - // ignore - } - - eventType = parser.next(); - } - } - - private void handleReminder(EventEntry eventEntry) { - XmlPullParser parser = getParser(); - - Reminder reminder = new Reminder(); - eventEntry.addReminder(reminder); - - String methodStr = parser.getAttributeValue(null /* ns */, - "method"); - String minutesStr = parser.getAttributeValue(null /* ns */, - "minutes"); - String hoursStr = parser.getAttributeValue(null /* ns */, - "hours"); - String daysStr = parser.getAttributeValue(null /* ns */, - "days"); - - if (!StringUtils.isEmpty(methodStr)) { - if ("alert".equals(methodStr)) { - reminder.setMethod(Reminder.METHOD_ALERT); - } else if ("email".equals(methodStr)) { - reminder.setMethod(Reminder.METHOD_EMAIL); - } else if ("sms".equals(methodStr)) { - reminder.setMethod(Reminder.METHOD_SMS); - } - } - - int minutes = Reminder.MINUTES_DEFAULT; - if (!StringUtils.isEmpty(minutesStr)) { - minutes = StringUtils.parseInt(minutesStr, minutes); - } else if (!StringUtils.isEmpty(hoursStr)) { - minutes = 60*StringUtils.parseInt(hoursStr, minutes); - } else if (!StringUtils.isEmpty(daysStr)) { - minutes = 24*60*StringUtils.parseInt(daysStr, minutes); - } - // TODO: support absolute times? - if (minutes < 0) { - minutes = Reminder.MINUTES_DEFAULT; - } - reminder.setMinutes(minutes); - } - - private void handleOriginalEvent(EventEntry eventEntry) - throws XmlPullParserException, IOException { - - XmlPullParser parser = getParser(); - - int eventType = parser.getEventType(); - String name = parser.getName(); - - if (eventType != XmlPullParser.START_TAG || - (!"originalEvent".equals(parser.getName()))) { - // should not happen. - throw new - IllegalStateException("Expected <originalEvent>: Actual " - + "element: <" - + name + ">"); - } - - eventEntry.setOriginalEventId( - parser.getAttributeValue(null /* ns */, "href")); - - eventType = parser.next(); - while (eventType != XmlPullParser.END_DOCUMENT) { - switch (eventType) { - case XmlPullParser.START_TAG: - name = parser.getName(); - if ("when".equals(name)) { - eventEntry.setOriginalEventStartTime( - parser.getAttributeValue(null/*ns*/, "startTime")); - } - break; - case XmlPullParser.END_TAG: - name = parser.getName(); - if ("originalEvent".equals(name)) { - return; - } - default: - // ignore - } - - eventType = parser.next(); - } - } -} diff --git a/src/com/google/wireless/gdata2/calendar/parser/xml/package.html b/src/com/google/wireless/gdata2/calendar/parser/xml/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/calendar/parser/xml/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/calendar/serializer/package.html b/src/com/google/wireless/gdata2/calendar/serializer/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/calendar/serializer/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/calendar/serializer/xml/XmlEventEntryGDataSerializer.java b/src/com/google/wireless/gdata2/calendar/serializer/xml/XmlEventEntryGDataSerializer.java deleted file mode 100644 index ce16a77..0000000 --- a/src/com/google/wireless/gdata2/calendar/serializer/xml/XmlEventEntryGDataSerializer.java +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.calendar.serializer.xml; - -import com.google.wireless.gdata2.calendar.data.EventEntry; -import com.google.wireless.gdata2.calendar.data.When; -import com.google.wireless.gdata2.calendar.data.Reminder; -import com.google.wireless.gdata2.calendar.data.Who; -import com.google.wireless.gdata2.data.StringUtils; -import com.google.wireless.gdata2.parser.xml.XmlGDataParser; -import com.google.wireless.gdata2.parser.xml.XmlParserFactory; -import com.google.wireless.gdata2.parser.ParseException; -import com.google.wireless.gdata2.serializer.xml.XmlEntryGDataSerializer; - -import org.xmlpull.v1.XmlSerializer; - -import java.io.IOException; -import java.util.Enumeration; -import java.util.Hashtable; - - -/** - * Serializes Google Calendar event entries into the Atom XML format. - */ -// TODO: move all strings into constants. share with parser? -public class XmlEventEntryGDataSerializer extends XmlEntryGDataSerializer { - - public static final String NAMESPACE_GCAL = "gCal"; - public static final String NAMESPACE_GCAL_URI = - "http://schemas.google.com/gCal/2005"; - - public XmlEventEntryGDataSerializer(XmlParserFactory factory, - EventEntry entry) { - super(factory, entry); - } - - protected EventEntry getEventEntry() { - return (EventEntry) getEntry(); - } - - protected void declareExtraEntryNamespaces(XmlSerializer serializer) - throws IOException { - serializer.setPrefix(NAMESPACE_GCAL, NAMESPACE_GCAL_URI); - } - - /* (non-Javadoc) - * @see XmlEntryGDataSerializer#serializeExtraEntryContents - */ - protected void serializeExtraEntryContents(XmlSerializer serializer, - int format) - throws IOException, ParseException { - EventEntry entry = getEventEntry(); - - serializeEventStatus(serializer, entry.getStatus()); - serializeTransparency(serializer, entry.getTransparency()); - serializeVisibility(serializer, entry.getVisibility()); - Enumeration attendees = entry.getAttendees().elements(); - while (attendees.hasMoreElements()) { - Who attendee = (Who) attendees.nextElement(); - serializeWho(serializer, entry, attendee); - } - - serializeRecurrence(serializer, entry.getRecurrence()); - // either serialize reminders directly under the entry, or serialize - // whens (with reminders within the whens) -- should be just one. - if (entry.getRecurrence() != null) { - if (entry.getReminders() != null) { - Enumeration reminders = entry.getReminders().elements(); - while (reminders.hasMoreElements()) { - Reminder reminder = (Reminder) reminders.nextElement(); - serializeReminder(serializer, reminder); - } - } - } else { - Enumeration whens = entry.getWhens().elements(); - while (whens.hasMoreElements()) { - When when = (When) whens.nextElement(); - serializeWhen(serializer, entry, when); - } - } - serializeOriginalEvent(serializer, - entry.getOriginalEventId(), - entry.getOriginalEventStartTime()); - serializeWhere(serializer, entry.getWhere()); - - serializeCommentsUri(serializer, entry.getCommentsUri()); - - Hashtable extendedProperties = entry.getExtendedProperties(); - if (extendedProperties != null) { - Enumeration propertyNames = extendedProperties.keys(); - while (propertyNames.hasMoreElements()) { - String propertyName = (String) propertyNames.nextElement(); - String propertyValue = (String) extendedProperties.get(propertyName); - serializeExtendedProperty(serializer, propertyName, propertyValue); - } - } - - serializeQuickAdd(serializer, entry.isQuickAdd()); - } - - private static void serializeEventStatus(XmlSerializer serializer, - byte status) - throws IOException { - - String statusString; - - switch (status) { - case EventEntry.STATUS_TENTATIVE: - statusString = "http://schemas.google.com/g/2005#event.tentative"; - break; - case EventEntry.STATUS_CANCELED: - statusString = "http://schemas.google.com/g/2005#event.canceled"; - break; - case EventEntry.STATUS_CONFIRMED: - statusString = "http://schemas.google.com/g/2005#event.confirmed"; - break; - default: - // should not happen - // TODO: log this - statusString = "http://schemas.google.com/g/2005#event.tentative"; - } - - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "eventStatus"); - serializer.attribute(null /* ns */, "value", statusString); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "eventStatus"); - } - - private static void serializeRecurrence(XmlSerializer serializer, - String recurrence) - throws IOException { - if (StringUtils.isEmpty(recurrence)) { - return; - } - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "recurrence"); - serializer.text(recurrence); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "recurrence"); - } - - private static void serializeTransparency(XmlSerializer serializer, - byte transparency) - throws IOException { - - String transparencyString; - - switch (transparency) { - case EventEntry.TRANSPARENCY_OPAQUE: - transparencyString = - "http://schemas.google.com/g/2005#event.opaque"; - break; - case EventEntry.TRANSPARENCY_TRANSPARENT: - transparencyString = - "http://schemas.google.com/g/2005#event.transparent"; - break; - default: - // should not happen - // TODO: log this - transparencyString = - "http://schemas.google.com/g/2005#event.transparent"; - } - - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "transparency"); - serializer.attribute(null /* ns */, "value", transparencyString); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "transparency"); - } - - - private static void serializeVisibility(XmlSerializer serializer, - byte visibility) - throws IOException { - - String visibilityString; - - switch (visibility) { - case EventEntry.VISIBILITY_DEFAULT: - visibilityString = "http://schemas.google.com/g/2005#event.default"; - break; - case EventEntry.VISIBILITY_CONFIDENTIAL: - visibilityString = - "http://schemas.google.com/g/2005#event.confidential"; - break; - case EventEntry.VISIBILITY_PRIVATE: - visibilityString = "http://schemas.google.com/g/2005#event.private"; - break; - case EventEntry.VISIBILITY_PUBLIC: - visibilityString = "http://schemas.google.com/g/2005#event.public"; - break; - default: - // should not happen - // TODO: log this - visibilityString = "http://schemas.google.com/g/2005#event.default"; - } - - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "visibility"); - serializer.attribute(null /* ns */, "value", visibilityString); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "visibility"); - } - - private static void serializeWho(XmlSerializer serializer, - EventEntry entry, - Who who) - throws IOException, ParseException { - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "who"); - String email = who.getEmail(); - if (!StringUtils.isEmpty(email)) { - serializer.attribute(null /* ns */, "email", email); - } - - String value = who.getValue(); - if (!StringUtils.isEmpty(value)) { - serializer.attribute(null /* ns */, "valueString", value); - } - - String rel = null; - switch (who.getRelationship()) { - case Who.RELATIONSHIP_NONE: - break; - case Who.RELATIONSHIP_ATTENDEE: - rel = "http://schemas.google.com/g/2005#event.attendee"; - break; - case Who.RELATIONSHIP_ORGANIZER: - rel = "http://schemas.google.com/g/2005#event.organizer"; - break; - case Who.RELATIONSHIP_PERFORMER: - rel = "http://schemas.google.com/g/2005#event.performer"; - break; - case Who.RELATIONSHIP_SPEAKER: - rel = "http://schemas.google.com/g/2005#event.speaker"; - break; - default: - throw new ParseException("Unexpected rel: " + who.getRelationship()); - } - if (!StringUtils.isEmpty(rel)) { - serializer.attribute(null /* ns */, "rel", rel); - } - - String status = null; - switch (who.getStatus()) { - case Who.STATUS_NONE: - break; - case Who.STATUS_ACCEPTED: - status = "http://schemas.google.com/g/2005#event.accepted"; - break; - case Who.STATUS_DECLINED: - status = "http://schemas.google.com/g/2005#event.declined"; - break; - case Who.STATUS_INVITED: - status = "http://schemas.google.com/g/2005#event.invited"; - break; - case Who.STATUS_TENTATIVE: - status = "http://schemas.google.com/g/2005#event.tentative"; - break; - default: - throw new ParseException("Unexpected status: " + who.getStatus()); - } - if (!StringUtils.isEmpty(status)) { - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, - "attendeeStatus"); - serializer.attribute(null /* ns */, "value", status); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, - "attendeeStatus"); - } - - String type = null; - switch (who.getType()) { - case Who.TYPE_NONE: - break; - case Who.TYPE_REQUIRED: - type = "http://schemas.google.com/g/2005#event.required"; - break; - case Who.TYPE_OPTIONAL: - type = "http://schemas.google.com/g/2005#event.optional"; - break; - default: - throw new ParseException("Unexpected type: " + who.getType()); - } - if (!StringUtils.isEmpty(type)) { - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, - "attendeeType"); - serializer.attribute(null /* ns */, "value", type); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "attendeeType"); - } - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "who"); - } - - private static void serializeWhen(XmlSerializer serializer, - EventEntry entry, - When when) - throws IOException { - // TODO: throw exn if startTime is empty but endTime is not? - String startTime = when.getStartTime(); - String endTime = when.getEndTime(); - if (StringUtils.isEmpty(when.getStartTime())) { - return; - } - - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "when"); - serializer.attribute(null /* ns */, "startTime", startTime); - if (!StringUtils.isEmpty(endTime)) { - serializer.attribute(null /* ns */, "endTime", endTime); - } - if (entry.getReminders() != null) { - Enumeration reminders = entry.getReminders().elements(); - while (reminders.hasMoreElements()) { - Reminder reminder = (Reminder) reminders.nextElement(); - serializeReminder(serializer, reminder); - } - } - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "when"); - } - - private static void serializeReminder(XmlSerializer serializer, - Reminder reminder) - throws IOException { - - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "reminder"); - byte method = reminder.getMethod(); - String methodStr = null; - switch (method) { - case Reminder.METHOD_ALERT: - methodStr = "alert"; - break; - case Reminder.METHOD_EMAIL: - methodStr = "email"; - break; - case Reminder.METHOD_SMS: - methodStr = "sms"; - break; - } - if (methodStr != null) { - serializer.attribute(null /* ns */, "method", methodStr); - } - - int minutes = reminder.getMinutes(); - if (minutes != Reminder.MINUTES_DEFAULT) { - serializer.attribute(null /* ns */, "minutes", - Integer.toString(minutes)); - } - - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "reminder"); - } - - private static void serializeOriginalEvent(XmlSerializer serializer, - String originalEventId, - String originalEventTime) - throws IOException { - if (StringUtils.isEmpty(originalEventId) || - StringUtils.isEmpty(originalEventTime)) { - return; - } - - - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "originalEvent"); - int index = originalEventId.lastIndexOf('/'); - if (index != -1) { - String id = originalEventId.substring(index + 1); - if (!StringUtils.isEmpty(id)) { - serializer.attribute(null /* ns */, "id", id); - } - } - serializer.attribute(null /* ns */, "href", originalEventId); - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "when"); - serializer.attribute(null /* ns */, "startTime", originalEventTime); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "when"); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "originalEvent"); - } - - - private static void serializeWhere(XmlSerializer serializer, - String where) - throws IOException { - if (StringUtils.isEmpty(where)) { - return; - } - - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "where"); - serializer.attribute(null /* ns */, "valueString", where); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "where"); - } - - private static void serializeCommentsUri(XmlSerializer serializer, - String commentsUri) - throws IOException { - if (commentsUri == null) { - return; - } - - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "feedLink"); - serializer.attribute(null /* ns */, "href", commentsUri); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "feedLink"); - } - - private static void serializeExtendedProperty(XmlSerializer serializer, - String name, - String value) - throws IOException { - serializer.startTag(XmlGDataParser.NAMESPACE_GD_URI, "extendedProperty"); - serializer.attribute(null /* ns */, "name", name); - serializer.attribute(null /* ns */, "value", value); - serializer.endTag(XmlGDataParser.NAMESPACE_GD_URI, "extendedProperty"); - } - - private static void serializeQuickAdd(XmlSerializer serializer, - boolean quickAdd) throws IOException { - if (quickAdd) { - serializer.startTag(NAMESPACE_GCAL, "quickadd"); - serializer.attribute(null /* ns */, "value", "true"); - serializer.endTag(NAMESPACE_GCAL, "quickadd"); - } - } -} diff --git a/src/com/google/wireless/gdata2/calendar/serializer/xml/package.html b/src/com/google/wireless/gdata2/calendar/serializer/xml/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/calendar/serializer/xml/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/client/SubscribedFeedsClient.java b/src/com/google/wireless/gdata2/subscribedfeeds/client/SubscribedFeedsClient.java deleted file mode 100644 index 734f185..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/client/SubscribedFeedsClient.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2007 The Android Open Source Project - -package com.google.wireless.gdata2.subscribedfeeds.client; - -import com.google.wireless.gdata2.client.GDataClient; -import com.google.wireless.gdata2.client.GDataParserFactory; -import com.google.wireless.gdata2.client.GDataServiceClient; - -/** - * GDataServiceClient for accessing Subscribed Feeds. This client can access - * subscribed feeds for specific users. The parser this class uses handles - * the XML version of feeds. - */ -public class SubscribedFeedsClient extends GDataServiceClient { - - /** Service value for contacts. This is only used for downloads; uploads - * are done using the service that corresponds to the subscribed feed. */ - public static final String SERVICE = "mail"; - - /** - * Create a new SubscribedFeedsClient. - * @param client The GDataClient that should be used to authenticate - * requests, retrieve feeds, etc. - */ - public SubscribedFeedsClient(GDataClient client, GDataParserFactory factory) { - super(client, factory); - } - - /* - * (non-Javadoc) - * @see GDataServiceClient#getServiceName() - */ - public String getServiceName() { - return SERVICE; - } - - /** - * Returns the protocol version used by this GDataServiceClient, - * in the form of a string. Subscribed feeds is using the default - * - * @return protocolVersion - */ - public String getProtocolVersion() { - return DEFAULT_GDATA_VERSION; - } -} diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/client/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/client/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/client/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/data/FeedUrl.java b/src/com/google/wireless/gdata2/subscribedfeeds/data/FeedUrl.java deleted file mode 100644 index 523f8ea..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/data/FeedUrl.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -** Copyright 2006, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** See the License for the specific language governing permissions and -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** limitations under the License. -*/ - -package com.google.wireless.gdata2.subscribedfeeds.data; - -/** - * The FeedUrl GData type. - */ -public class FeedUrl { - private String feed; - private String service; - private String authToken; - - public FeedUrl() { - } - - public FeedUrl(String feed, String service, String authToken) { - setFeed(feed); - setService(service); - setAuthToken(authToken); - } - - public String getFeed() { - return feed; - } - - public void setFeed(String feed) { - this.feed = feed; - } - - public String getService() { - return service; - } - - public void setService(String service) { - this.service = service; - } - - public String getAuthToken() { - return authToken; - } - - public void setAuthToken(String authToken) { - this.authToken = authToken; - } - - public void toString(StringBuffer sb) { - sb.append("FeedUrl"); - sb.append(" url:").append(getFeed()); - sb.append(" service:").append(getService()); - sb.append(" authToken:").append(getAuthToken()); - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - toString(sb); - return sb.toString(); - } -} diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsEntry.java b/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsEntry.java deleted file mode 100644 index 319d6fd..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsEntry.java +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2007 The Android Open Source Project -package com.google.wireless.gdata2.subscribedfeeds.data; - -import com.google.wireless.gdata2.data.Entry; - -/** - * Entry containing information about a contact. - */ -public class SubscribedFeedsEntry extends Entry { - private FeedUrl feedUrl; - private String routingInfo; - private String clientToken; - - public String getClientToken() { - return clientToken; - } - - public void setClientToken(String clientToken) { - this.clientToken = clientToken; - } - - public SubscribedFeedsEntry() { - super(); - } - - public FeedUrl getSubscribedFeed() { - return feedUrl; - } - - public void setSubscribedFeed(FeedUrl feedUrl) { - this.feedUrl = feedUrl; - } - - public String getRoutingInfo() { - return routingInfo; - } - - public void setRoutingInfo(String routingInfo) { - this.routingInfo = routingInfo; - } - - /* - * (non-Javadoc) - * @see com.google.wireless.gdata2.data.Entry#clear() - */ - public void clear() { - super.clear(); - } - - public void toString(StringBuffer sb) { - super.toString(sb); - } -} diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsFeed.java b/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsFeed.java deleted file mode 100644 index 6eb600e..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/data/SubscribedFeedsFeed.java +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2007 The Android Open Source Project -package com.google.wireless.gdata2.subscribedfeeds.data; - -import com.google.wireless.gdata2.data.Feed; - -/** - * Feed containing contacts. - */ -public class SubscribedFeedsFeed extends Feed { - /** - * Creates a new empty events feed. - */ - public SubscribedFeedsFeed() { - } -} diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/data/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/data/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/data/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/parser/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/parser/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/parser/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParser.java b/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParser.java deleted file mode 100644 index 5f5cb6d..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParser.java +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2007 The Android Open Source Project -package com.google.wireless.gdata2.subscribedfeeds.parser.xml; - -import com.google.wireless.gdata2.data.Entry; -import com.google.wireless.gdata2.data.Feed; -import com.google.wireless.gdata2.data.XmlUtils; -import com.google.wireless.gdata2.parser.ParseException; -import com.google.wireless.gdata2.parser.xml.XmlGDataParser; -import com.google.wireless.gdata2.subscribedfeeds.data.FeedUrl; -import com.google.wireless.gdata2.subscribedfeeds.data.SubscribedFeedsEntry; -import com.google.wireless.gdata2.subscribedfeeds.data.SubscribedFeedsFeed; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.IOException; -import java.io.InputStream; - -/** - * GDataParser for a subscribed feeds feed. - */ -public class XmlSubscribedFeedsGDataParser extends XmlGDataParser { - /** - * Creates a new XmlSubscribedFeedsGDataParser. - * @param is The InputStream that should be parsed. - * @throws ParseException Thrown if a parser cannot be created. - */ - public XmlSubscribedFeedsGDataParser(InputStream is, XmlPullParser parser) - throws ParseException { - super(is, parser); - } - - /* - * (non-Javadoc) - * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createFeed() - */ - protected Feed createFeed() { - return new SubscribedFeedsFeed(); - } - - /* - * (non-Javadoc) - * @see com.google.wireless.gdata2.parser.xml.XmlGDataParser#createEntry() - */ - protected Entry createEntry() { - return new SubscribedFeedsEntry(); - } - - protected void handleExtraElementInEntry(Entry entry) - throws XmlPullParserException, IOException { - XmlPullParser parser = getParser(); - - if (!(entry instanceof SubscribedFeedsEntry)) { - throw new IllegalArgumentException("Expected SubscribedFeedsEntry!"); - } - SubscribedFeedsEntry subscribedFeedsEntry = - (SubscribedFeedsEntry) entry; - String name = parser.getName(); - if ("feedurl".equals(name)) { - FeedUrl feedUrl = new FeedUrl(); - feedUrl.setFeed(parser.getAttributeValue(null /* ns */, "value")); - feedUrl.setService(parser.getAttributeValue(null /* ns */, "service")); - feedUrl.setAuthToken(parser.getAttributeValue(null /* ns */, "authtoken")); - subscribedFeedsEntry.setSubscribedFeed(feedUrl); - } - if ("routingInfo".equals(name)) { - subscribedFeedsEntry.setRoutingInfo( - XmlUtils.extractChildText(parser)); - } - if ("clientToken".equals(name)) { - subscribedFeedsEntry.setClientToken( - XmlUtils.extractChildText(parser)); - } - } -} diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParserFactory.java b/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParserFactory.java deleted file mode 100644 index 2e606dd..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/XmlSubscribedFeedsGDataParserFactory.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.google.wireless.gdata2.subscribedfeeds.parser.xml; - -import com.google.wireless.gdata2.client.GDataParserFactory; -import com.google.wireless.gdata2.data.Entry; -import com.google.wireless.gdata2.parser.GDataParser; -import com.google.wireless.gdata2.parser.ParseException; -import com.google.wireless.gdata2.parser.xml.XmlParserFactory; -import com.google.wireless.gdata2.serializer.GDataSerializer; -import com.google.wireless.gdata2.serializer.xml.XmlBatchGDataSerializer; -import com.google.wireless.gdata2.subscribedfeeds.data.SubscribedFeedsEntry; -import com.google.wireless.gdata2.subscribedfeeds.serializer.xml.XmlSubscribedFeedsEntryGDataSerializer; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.InputStream; -import java.util.Enumeration; - -/** - * GDataParserFactory that creates XML GDataParsers and GDataSerializers for - * Subscribed Feeds. - */ -public class XmlSubscribedFeedsGDataParserFactory implements - GDataParserFactory { - private final XmlParserFactory xmlFactory; - - public XmlSubscribedFeedsGDataParserFactory(XmlParserFactory xmlFactory) { - this.xmlFactory = xmlFactory; - } - - /* - * (non-javadoc) - * - * @see GDataParserFactory#createParser - */ - public GDataParser createParser(InputStream is) throws ParseException { - XmlPullParser xmlParser; - try { - xmlParser = xmlFactory.createParser(); - } catch (XmlPullParserException xppe) { - throw new ParseException("Could not create XmlPullParser", xppe); - } - return new XmlSubscribedFeedsGDataParser(is, xmlParser); - } - - /* - * (non-Javadoc) - * - * @see GDataParserFactory#createMetaFeedParser(int, java.io.InputStream) - */ - public GDataParser createParser(Class entryClass, InputStream is) - throws ParseException { - if (entryClass != SubscribedFeedsEntry.class) { - throw new IllegalArgumentException( - "SubscribedFeeds supports only a single feed type"); - } - // we don't have feed sub-types, so just return the default - return createParser(is); - } - - - /** - * Creates a new {@link GDataSerializer} for the provided entry. The entry - * <strong>must</strong> be an instance of {@link SubscribedFeedsEntry}. - * - * @param entry The {@link SubscribedFeedsEntry} that should be - * serialized. - * @return The {@link GDataSerializer} that will serialize this entry. - * @throws IllegalArgumentException Thrown if entry is not a - * {@link SubscribedFeedsEntry}. - * @see com.google.wireless.gdata2.client.GDataParserFactory#createSerializer - */ - public GDataSerializer createSerializer(Entry entry) { - if (!(entry instanceof SubscribedFeedsEntry)) { - throw new IllegalArgumentException( - "Expected SubscribedFeedsEntry!"); - } - SubscribedFeedsEntry subscribedFeedsEntry = - (SubscribedFeedsEntry) entry; - return new XmlSubscribedFeedsEntryGDataSerializer(xmlFactory, - subscribedFeedsEntry); - } - - /** - * Creates a new {@link GDataSerializer} for the given batch. - * - * @param batch the {@link Enumeration} of entries in the batch. - * @return The {@link GDataSerializer} that will serialize this batch. - */ - public GDataSerializer createSerializer(Enumeration batch) { - return new XmlBatchGDataSerializer(this, xmlFactory, batch); - } -} diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/parser/xml/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/serializer/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/XmlSubscribedFeedsEntryGDataSerializer.java b/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/XmlSubscribedFeedsEntryGDataSerializer.java deleted file mode 100644 index ed018b2..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/XmlSubscribedFeedsEntryGDataSerializer.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.google.wireless.gdata2.subscribedfeeds.serializer.xml; - -import com.google.wireless.gdata2.data.StringUtils; -import com.google.wireless.gdata2.serializer.xml.XmlEntryGDataSerializer; -import com.google.wireless.gdata2.subscribedfeeds.data.FeedUrl; -import com.google.wireless.gdata2.subscribedfeeds.data.SubscribedFeedsEntry; -import com.google.wireless.gdata2.parser.xml.XmlParserFactory; - -import org.xmlpull.v1.XmlSerializer; - -import java.io.IOException; - -/** - * Serializes the SubscribedFeedEntry into the Atom XML format. - */ -public class XmlSubscribedFeedsEntryGDataSerializer extends - XmlEntryGDataSerializer { - public static final String NAMESPACE_GSYNC = "gsync"; - public static final String NAMESPACE_GSYNC_URI = - "http://schemas.google.com/gsync/data"; - - public XmlSubscribedFeedsEntryGDataSerializer(XmlParserFactory factory, - SubscribedFeedsEntry entry) { - super(factory, entry); - } - - protected SubscribedFeedsEntry getSubscribedFeedsEntry() { - return (SubscribedFeedsEntry) getEntry(); - } - - protected void declareExtraEntryNamespaces(XmlSerializer serializer) - throws IOException { - serializer.setPrefix(NAMESPACE_GSYNC, NAMESPACE_GSYNC_URI); - } - - /* (non-Javadoc) - * @see XmlEntryGDataSerializer#serializeExtraEntryContents - */ - protected void serializeExtraEntryContents(XmlSerializer serializer, - int format) - throws IOException { - SubscribedFeedsEntry entry = getSubscribedFeedsEntry(); - - serializeFeedUrl(serializer, entry.getSubscribedFeed()); - serializeClientToken(serializer, entry.getClientToken()); - serializeRoutingInfo(serializer, entry.getRoutingInfo()); - } - - private static void serializeFeedUrl(XmlSerializer serializer, - FeedUrl feedUrl) - throws IOException { - serializer.startTag(NAMESPACE_GSYNC_URI, "feedurl"); - serializer.attribute(null /* ns */, "value", feedUrl.getFeed()); - serializer.attribute(null /* ns */, "service", feedUrl.getService()); - serializer.attribute(null /* ns */, "authtoken", feedUrl.getAuthToken()); - serializer.endTag(NAMESPACE_GSYNC_URI, "feedurl"); - } - - private static void serializeClientToken(XmlSerializer serializer, - String clientToken) - throws IOException { - if (StringUtils.isEmpty(clientToken)) { - clientToken = ""; - } - serializer.startTag(NAMESPACE_GSYNC_URI, "clientToken"); - serializer.text(clientToken); - serializer.endTag(NAMESPACE_GSYNC_URI, "clientToken"); - } - - private static void serializeRoutingInfo(XmlSerializer serializer, - String routingInfo) - throws IOException { - if (StringUtils.isEmpty(routingInfo)) { - routingInfo = ""; - } - serializer.startTag(NAMESPACE_GSYNC_URI, "routingInfo"); - serializer.text(routingInfo); - serializer.endTag(NAMESPACE_GSYNC_URI, "routingInfo"); - } -} diff --git a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/package.html b/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/package.html deleted file mode 100644 index 1c9bf9d..0000000 --- a/src/com/google/wireless/gdata2/subscribedfeeds/serializer/xml/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> - {@hide} -</body> -</html> |