FileDocCategorySizeDatePackage
XmlListGDataParser.javaAPI DocAndroid 1.5 API3729Wed May 06 22:41:16 BST 2009com.google.wireless.gdata.spreadsheets.parser.xml

XmlListGDataParser

public class XmlListGDataParser extends com.google.wireless.gdata.parser.xml.XmlGDataParser
Parser for non-Atom data in a GData Spreadsheets List-based feed.

Fields Summary
private static final String
LIST_FEED_POST_REL
The rel ID used by the server to identify the URLs for List POSTs (updates)
Constructors Summary
public XmlListGDataParser(InputStream is, XmlPullParser xmlParser)
Creates a new XmlListGDataParser.

param
is the stream from which to read the data
param
xmlParser the XmlPullParser to use to parse the raw XML
throws
ParseException if the super-class throws one


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

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

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

        XmlPullParser parser = getParser();
        if (!(entry instanceof ListEntry)) {
            throw new IllegalArgumentException("Expected ListEntry!");
        }
        ListEntry row = (ListEntry) entry;

        String name = parser.getName();
        row.setValue(name, XmlUtils.extractChildText(parser));
    
protected voidhandleExtraElementInFeed(com.google.wireless.gdata.data.Feed feed)

        XmlPullParser parser = getParser();
        if (!(feed instanceof ListFeed)) {
            throw new IllegalArgumentException("Expected ListFeed!");
        }
        ListFeed listFeed = (ListFeed) feed;

        String name = parser.getName();
        if (!"link".equals(name)) {
            return;
        }

        // lists store column data in the gsx namespace:
        // <gsx:columnheader>data</gsx:columnheader>
        // The columnheader tag names are the scrubbed values of the first row.
        // We extract them all and store them as keys in a Map.
        int numAttrs = parser.getAttributeCount();
        String rel = null;
        String href = null;
        String attrName = null;
        for (int i = 0; i < numAttrs; ++i) {
            attrName = parser.getAttributeName(i);
            if ("rel".equals(attrName)) {
                rel = parser.getAttributeValue(i);
            } else if ("href".equals(attrName)) {
                href = parser.getAttributeValue(i);
            }
        }
        if (!(StringUtils.isEmpty(rel) || StringUtils.isEmpty(href))) {
            if (LIST_FEED_POST_REL.equals(rel)) {
                listFeed.setEditUri(href);
            }
        }