Package com.google.gdata.data.spreadsheet

Examples of com.google.gdata.data.spreadsheet.TableEntry


    FeedURLFactory factory = FeedURLFactory.getDefault();
    URL tableFeedUrl = factory.getTableFeedUrl(ssKey);

    // Check if already exists.
    TableEntry tableEntry = null;
    TableFeed feed = ss.getFeed(tableFeedUrl, TableFeed.class);
    for (TableEntry entry : feed.getEntries()) {
      if (entry.getTitle().getPlainText().equals(kind)) {
        tableEntry = entry;
        logger.info("TableFeed:" + kind + " already exists.");
        break;
      }
    }

    // Add TableFeed
    if (tableEntry == null) {
      tableEntry = new TableEntry();
      tableEntry.setTitle(new PlainTextConstruct(kind));
      tableEntry.setWorksheet(new Worksheet(kind));
      tableEntry.setHeader(new Header(1));

      Data tableData = new Data();
      tableData.setNumberOfRows(0);
      tableData.setStartIndex(2);
      tableData.setInsertionMode(InsertionMode.INSERT);

      // Create a title row
      tableData.addColumn(new Column("A", Entity.KEY_RESERVED_PROPERTY));
      for (int i = 0; i < properties.size(); i++) {
        String index = number2columnName(i + 1);
        String columnName = properties.get(i).getName();
        tableData.addColumn(new Column(index, columnName));
      }
      tableEntry.setData(tableData);
      tableEntry = ss.insert(tableFeedUrl, tableEntry);
      logger.info("Craeted tableFeed:" + kind);
    }
    String[] split = tableEntry.getId().split("/");
    final String tableId = split[split.length - 1];

    // Add a "valueType" row (the cells are filled with "*" to be replaced)
    int numberOfRows = tableEntry.getData().getNumberOfRows();
    if (numberOfRows == 0) {
      RecordEntry newEntry = new RecordEntry();
      newEntry.addField(new Field(null, Entity.KEY_RESERVED_PROPERTY, VALUE_TYPE));
      for (int i = 0; i < properties.size(); i++) {
        GbProperty gbProperty = properties.get(i);
View Full Code Here


   * @throws IOException when an error occurs in communication with the Google
   *         Spreadsheets service.
   */
  public void addNewEntry(String nameValuePairs) throws IOException,
      ServiceException {
    TableEntry newEntry = setEntryContentsFromString(new TableEntry(),
        nameValuePairs);
    service.insert(tablesFeedUrl, newEntry);
    out.println("Added table!");
  }
View Full Code Here

   *         Spreadsheets service.
   * @throws IOException when an error occurs in communication with the Google
   *         Spreadsheets service.
   */
  public void delete(String idToDelete) throws IOException, ServiceException {
    TableEntry entry = entriesCached.get(idToDelete); // Find the entry to
    // delete

    if (entry != null) {
      entry.delete(); // This deletes the existing entry.
      out.println("Deleted!");
    } else {
      out.println("I don't know that ID.");
      out.println("In GData, you must get an entry before deleting it,");
      out.println("so that you have the version ID.");
View Full Code Here

  public void update(String id, String nameValuePairs) throws IOException,
      ServiceException {

    // The next line of code finds the entry to update.
    // See the javadoc on entriesCached.
    TableEntry entry = entriesCached.get(id);

    setEntryContentsFromString(entry, nameValuePairs);

    if (entry != null) {
      entry.update(); // This updates the existing entry.
      out.println("Updated!");
    } else {
      out.println("I don't know that ID.");
      out.println("In GData, you must get an entry before deleting it.");
      out.println("You might have to 'list' first.");
View Full Code Here

TOP

Related Classes of com.google.gdata.data.spreadsheet.TableEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.