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

XmlCellsGDataParser

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

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

param
is the stream from which to read the data
param
xmlParser the XMLPullParser to use for parsing 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 CellEntry();
    
protected com.google.wireless.gdata.data.FeedcreateFeed()

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

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

        String name = parser.getName();
        // cells can only have row, col, inputValue, & numericValue attrs
        if ("cell".equals(name)) {
            int count = parser.getAttributeCount();
            String attrName = null;
            for (int i = 0; i < count; ++i) {
                attrName = parser.getAttributeName(i);
                if ("row".equals(attrName)) {
                    row.setRow(StringUtils.parseInt(parser
                            .getAttributeValue(i), 0));
                } else if ("col".equals(attrName)) {
                    row.setCol(StringUtils.parseInt(parser
                            .getAttributeValue(i), 0));
                } else if ("numericValue".equals(attrName)) {
                    row.setNumericValue(parser.getAttributeValue(i));
                } else if ("inputValue".equals(attrName)) {
                    row.setInputValue(parser.getAttributeValue(i));
                }
            }

            // also need the data stored in the child text node
            row.setValue(XmlUtils.extractChildText(parser));
        }
    
protected voidhandleExtraElementInFeed(com.google.wireless.gdata.data.Feed feed)

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

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

        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 (CELL_FEED_POST_REL.equals(rel)) {
                cellFeed.setEditUri(href);
            }
        }