当前位置: 首页>>代码示例>>Java>>正文


Java Data类代码示例

本文整理汇总了Java中com.google.gdata.data.spreadsheet.Data的典型用法代码示例。如果您正苦于以下问题:Java Data类的具体用法?Java Data怎么用?Java Data使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Data类属于com.google.gdata.data.spreadsheet包,在下文中一共展示了Data类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printTable

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
/**
 * Prints a table entry in a format that looks vaguely like the xml. 
 * 
 * @param table entry to print.
 */
public void printTable(TableEntry entry) {
  out.println("-- id: " + entry.getId() 
      + "  title: " + entry.getTitle().getPlainText());
  out.println("<title>" + entry.getTitle().getPlainText() + "</title>");
  out.println("<summary>" + entry.getSummary().getPlainText() + "</summary>");
  out.println("<worksheet>" + entry.getWorksheet().getName()
      + "</worksheet>");
  out.println("<header>" + entry.getHeader().getRow() + "</header>");
  Data data = entry.getData();
  out.println("<data> insertionMode=" + data.getInsertionMode().name()
      + " startRow=" + data.getStartIndex() 
      + " numRows=" + data.getNumberOfRows());
  for (Column col: data.getColumns()) {
    out.println("     <column>" + col.getIndex() + " " + col.getName()
        + "</column>");
  }
  out.println("</data>");
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:24,代码来源:RecordDemo.java

示例2: printAndCacheEntry

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
/**
 * Prints the entire table entry, in a way that mildly resembles what the
 * actual XML looks like.
 * 
 * In addition, all printed entries are cached here. This way, they can be
 * updated or deleted, without having to retrieve the version identifier again
 * from the server.
 * 
 * @param entry the list entry to print
 */
public void printAndCacheEntry(TableEntry entry) {

  // We only care about the entry id, chop off the leftmost part.
  // I.E., this turns http://spreadsheets.google.com/..../cpzh6 into cpzh6.
  String id = entry.getId().substring(entry.getId().lastIndexOf('/') + 1);

  // Cache all displayed entries so that they can be updated later.
  entriesCached.put(id, entry);

  out.println("-- id: " + id + "  title: " + entry.getTitle().getPlainText());
  out.println("<title>" + entry.getTitle().getPlainText() + "</title>");
  out.println("<summary>" + entry.getSummary().getPlainText() + "</summary>");
  out.println("<worksheet>" + entry.getWorksheet().getName()
      + "</worksheet>");
  out.println("<header>" + entry.getHeader().getRow() + "</header>");
  Data data = entry.getData();
  out.println("<data> insertionMode=" + data.getInsertionMode().name()
      + " startRow=" + data.getStartIndex() 
      + " numRows=" + data.getNumberOfRows());
  for (Column col: data.getColumns()) {
    out.println("     <column>" + col.getIndex() + " " + col.getName()
        + "</column>");
  }
  out.println("</data>");
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:36,代码来源:TableDemo.java

示例3: declareExtensions

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
@Override
public void declareExtensions(ExtensionProfile extProfile) {
  if (extProfile.isDeclared(ListPageEntry.class)) {
    return;
  }
  super.declareExtensions(extProfile);
  extProfile.declare(ListPageEntry.class, Data.getDefaultDescription(true,
      false));
  new Data().declareExtensions(extProfile);
  extProfile.declare(ListPageEntry.class,
      new ExtensionDescription(FeedLink.class, new XmlNamespace("gd",
      "http://schemas.google.com/g/2005"), "feedLink", true, false, false));
  new FeedLink().declareExtensions(extProfile);
  extProfile.declare(ListPageEntry.class, Header.getDefaultDescription(true,
      false));
  extProfile.declare(ListPageEntry.class,
      Worksheet.getDefaultDescription(true, false));
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:19,代码来源:ListPageEntry.java

示例4: parseElement

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
/**
 * Populates the given Data object with information from the given element.
 */
private void parseElement(Element element, Data data) {
  NodeList nodeList = element.getChildNodes();
  for (int i = 0; i < nodeList.getLength(); i++) {
    Node node = nodeList.item(i);
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      Element child = (Element) node;
      if (hasClass(child, "gs:column")) {
        Column column = new Column();
        column.setIndex(child.getAttribute("title"));
        column.setName(child.getTextContent());
        data.addColumn(column);
      } else {
        parseElement(child, data);
      }
    }
  }
}
 
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:21,代码来源:DataParserImpl.java

示例5: testDataParsing

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
@Test
public void testDataParsing() {
  final Element entryElement = document.createElement("div");
  entryElement.setAttribute("class", "hentry listpage");
  final Element dataElement = document.createElement("tr");
  dataElement.setAttribute("class", "gs:data");
  entryElement.appendChild(dataElement);
  
  final Data data = new Data();
  
  context.checking(new Expectations() {{
    oneOf (dataParser).parseData(dataElement); 
      will(returnValue(data));
  }});
  
  BaseContentEntry<?> entry = entryParser.parseEntry(entryElement);
  assertTrue(EntryType.getType(entry) == EntryType.LIST_PAGE);
  // TODO(gk5885): remove extra cast for
  // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214
  assertEquals(data, ((ListPageEntry) (BaseContentEntry) entry).getData());
}
 
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:22,代码来源:EntryParserImplTest.java

示例6: setData

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
/**
 * Sets the data region of a table.
 *
 * @param data data region of a table or <code>null</code> to reset
 */
public void setData(Data data) {
  if (data == null) {
    removeExtension(Data.class);
  } else {
    setExtension(data);
  }
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:13,代码来源:ListPageEntry.java

示例7: parseData

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
@Override
public Data parseData(Element element) {
  checkNotNull(element);
  Data data = new Data();
  //This line is needed for the spreadsheet API
  data.setStartIndex(2);
  parseElement(element, data);
  return data;
}
 
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:10,代码来源:DataParserImpl.java

示例8: setParent

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
/**
 * Sets all parent-related fields in the given entry for the given parent. 
 */
public static void setParent(BaseContentEntry<?> entry, 
    BasePageEntry<?> parent) {
  entry.addLink(SitesLink.Rel.PARENT, ILink.Type.ATOM, parent.getId());
  if (getType(entry) == COMMENT) {
    InReplyTo inReplyTo = new InReplyTo();
    inReplyTo.setHref(
        parent.getLink(ILink.Rel.ALTERNATE, "text/html").getHref()); 
    inReplyTo.setRef(parent.getId());
    // TODO(gk5885): remove extra cast for
    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214
    ((CommentEntry) (BaseContentEntry) entry).setInReplyTo(inReplyTo);
  } else if (getType(entry) == LIST_ITEM) {
    if (getType(parent) != LIST_PAGE) {
      throw new IllegalStateException("List items can only be descendents of " 
          + "list pages!");
    }
    // TODO(gk5885): remove extra casts for
    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214
    ListItemEntry listItem = (ListItemEntry) (BaseContentEntry) entry;
    ListPageEntry listPage = (ListPageEntry) (BasePageEntry) parent;
    Data data = listPage.getData();
    Map<String, String> names = Maps.newHashMap();
    for (Column column : data.getColumns()) {
      names.put(column.getIndex(), column.getName());
    }
    for (Field field : listItem.getFields()) {
      String name = names.get(field.getIndex());
      field.setName(name);
    }
  }
}
 
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:35,代码来源:EntryUtils.java

示例9: testComplicatedStructure

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
@Test
public void testComplicatedStructure() {
  String html = "<div class=\"gs:data\">" +
                  "<table>" +
                    "<tr class=\"gs:column\" title=\"A\">" +
                      "<td>Column <b>1</b></td>" + 
                    "</tr>" +
                    "<tr class=\"gs:column\" title=\"B\">" +
                      "<td><i>Column</i> 2</td>" +
                    "</tr>" +
                  "</table>" +
                  "<div class=\"gs:column\" title=\"C\">" +
                    "<a href=\"website.com\">Column</a> 3" +
                  "</div>" +
                  "<span class=\"gs:column\" title=\"D\">" +
                    "Column 4" +
                  "</span>" +
                "</div>";
  Element element = getElement(html);
  Data data = parser.parseData(element);
  int index = 0;
  for(Column col : data.getColumns()) {
    assertEquals(columns.get(index).getIndex(), col.getIndex());
    assertEquals(columns.get(index).getName(), col.getName());
    index++;
  }
}
 
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:28,代码来源:DataParserImplTest.java

示例10: setEntryContentsFromString

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
/**
 * Parses the command line arguments given in the format 
 * "title=Table1,summary=This is a test", and sets the corresponding values 
 * on the given TableEntry.
 *
 * Values that are not specified are left alone. That is, if the entry already
 * contains "title=Table1", then setting summary will retain
 * the title as Table1.
 * 
 * @param entryToUpdate the entry to change based on the parameters
 * @param nameValuePairs the list of name/value pairs, containing the name of
 *        the title.
 */
public TableEntry setEntryContentsFromString(TableEntry entryToUpdate, 
    String nameValuePairs) {
  Map<String, String> dataParams = Maps.newHashMap();
  Map<String, String> dataCols = Maps.newHashMap();

  // Split first by the commas between the different fields.
  for (String nameValuePair : nameValuePairs.split(",")) {

    // Then, split by the equal sign.  Attributes are specified as key=value.
    String[] parts = nameValuePair.split("=", 2);
    if (parts.length < 2) {
      System.out.println("Attributes are specified as key=value, " 
          + "for example, title=Table1");
    } 
    
    String tag = parts[0].trim(); // such as "name"
    String value = parts[1].trim(); // such as "Fred"
    
    if (tag.equals("title")) {
      entryToUpdate.setTitle(new PlainTextConstruct(value));
    } else if (tag.equals("summary")) {
      entryToUpdate.setSummary(new PlainTextConstruct(value));
    } else if (tag.equals("worksheet")) {
      entryToUpdate.setWorksheet(new Worksheet(value));
    } else if (tag.equals("header")) {
      entryToUpdate.setHeader(new Header(Integer.parseInt(value)));
    } else if (tag.equals("startrow") || tag.equals("insertionmode") 
          || tag.equals("numrows")) {
      dataParams.put(tag, value);
    } else if (tag.equals("columns")) {
      String[] columns = value.split(";");
      for (int i = 0; i < columns.length; i++) {
        String[] colInfo = columns[i].split(":");
        if (colInfo.length < 2) {
          System.out.println("Columns are specified as column:value, for " 
              + " example, B:UpdatedPhone");
        }
        String index = colInfo[0];
        String name = colInfo[1];
        dataCols.put(index, name);
      }
    }
  }
 
  // Update table data.
  Data data = getDataFromParams(
      entryToUpdate.getData(), dataParams, dataCols);
  entryToUpdate.setData(data);

  return entryToUpdate;
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:65,代码来源:TableDemo.java

示例11: getData

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
/**
 * Returns the data region of a table.
 *
 * @return data region of a table
 */
public Data getData() {
  return getExtension(Data.class);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:9,代码来源:ListPageEntry.java

示例12: hasData

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
/**
 * Returns whether it has the data region of a table.
 *
 * @return whether it has the data region of a table
 */
public boolean hasData() {
  return hasExtension(Data.class);
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:9,代码来源:ListPageEntry.java

示例13: parseData

import com.google.gdata.data.spreadsheet.Data; //导入依赖的package包/类
/**
 * Returns a Data object containing any data information in the given element.
 */
Data parseData(Element element);
 
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:5,代码来源:DataParser.java


注:本文中的com.google.gdata.data.spreadsheet.Data类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。