本文整理汇总了Java中com.google.gdata.data.sites.CommentEntry类的典型用法代码示例。如果您正苦于以下问题:Java CommentEntry类的具体用法?Java CommentEntry怎么用?Java CommentEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommentEntry类属于com.google.gdata.data.sites包,在下文中一共展示了CommentEntry类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderComments
import com.google.gdata.data.sites.CommentEntry; //导入依赖的package包/类
@Override
public XmlElement renderComments(List<CommentEntry> comments) {
XmlElement div = new XmlElement("div");
XmlElement bold = new XmlElement("b");
bold.addText("Comments (" + comments.size() + ")");
div.addElement(bold).addElement(new XmlElement("br"));
for (BaseContentEntry<?> comment : comments) {
XmlElement commentDiv = RendererUtils.getEntryElement(comment, "div");
XmlElement author = RendererUtils.getAuthorElement(comment);
XmlElement updated = RendererUtils.getUpdatedElement(comment);
XmlElement revision = RendererUtils.getRevisionElement(comment);
XmlElement content = RendererUtils.getXhtmlContentElement(comment);
commentDiv.addElement(author).addText(" - ").addElement(updated);
commentDiv.addText(" (Version ").addElement(revision).addText(")");
commentDiv.addElement(new XmlElement("br")).addElement(content);
div.addElement(new XmlElement("br")).addElement(commentDiv);
}
return div;
}
示例2: testGetType
import com.google.gdata.data.sites.CommentEntry; //导入依赖的package包/类
@Test
public void testGetType() {
assertEquals(EntryType.getType(new AnnouncementEntry()),
EntryType.ANNOUNCEMENT);
assertEquals(EntryType.getType(new AnnouncementsPageEntry()),
EntryType.ANNOUNCEMENTS_PAGE);
assertEquals(EntryType.getType(new AttachmentEntry()),
EntryType.ATTACHMENT);
assertEquals(EntryType.getType(new CommentEntry()),
EntryType.COMMENT);
assertEquals(EntryType.getType(new FileCabinetPageEntry()),
EntryType.FILE_CABINET_PAGE);
assertEquals(EntryType.getType(new ListItemEntry()),
EntryType.LIST_ITEM);
assertEquals(EntryType.getType(new ListPageEntry()),
EntryType.LIST_PAGE);
assertEquals(EntryType.getType(new WebAttachmentEntry()),
EntryType.WEB_ATTACHMENT);
assertEquals(EntryType.getType(new WebPageEntry()),
EntryType.WEB_PAGE);
}
示例3: declareExtensions
import com.google.gdata.data.sites.CommentEntry; //导入依赖的package包/类
/**
* Declare the extensions of the feeds for the Google Sites Data API.
*/
private void declareExtensions() {
new AclFeed().declareExtensions(extProfile);
new SiteFeed().declareExtensions(extProfile);
/* Declarations for extensions that need to be handled as specific type
* should be done before call to {@see ExtensionProfile#setAutoExtending}.
* Order of declaration is important. */
extProfile.setAutoExtending(true);
new ActivityFeed().declareExtensions(extProfile);
new AnnouncementEntry().declareExtensions(extProfile);
new AnnouncementsPageEntry().declareExtensions(extProfile);
new AttachmentEntry().declareExtensions(extProfile);
new CommentEntry().declareExtensions(extProfile);
new ContentFeed().declareExtensions(extProfile);
new CreationActivityEntry().declareExtensions(extProfile);
new DeletionActivityEntry().declareExtensions(extProfile);
new EditActivityEntry().declareExtensions(extProfile);
new FileCabinetPageEntry().declareExtensions(extProfile);
new ListItemEntry().declareExtensions(extProfile);
new ListPageEntry().declareExtensions(extProfile);
new MoveActivityEntry().declareExtensions(extProfile);
new RecoveryActivityEntry().declareExtensions(extProfile);
new RevisionFeed().declareExtensions(extProfile);
new WebAttachmentEntry().declareExtensions(extProfile);
new WebPageEntry().declareExtensions(extProfile);
BatchUtils.declareExtensions(extProfile);
}
示例4: setParent
import com.google.gdata.data.sites.CommentEntry; //导入依赖的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);
}
}
}
示例5: testIsPage
import com.google.gdata.data.sites.CommentEntry; //导入依赖的package包/类
@Test
public void testIsPage() {
assertTrue(EntryType.isPage(new AnnouncementEntry()));
assertTrue(EntryType.isPage(new AnnouncementsPageEntry()));
assertTrue(EntryType.isPage(new FileCabinetPageEntry()));
assertTrue(EntryType.isPage(new ListPageEntry()));
assertTrue(EntryType.isPage(new WebPageEntry()));
assertFalse(EntryType.isPage(new AttachmentEntry()));
assertFalse(EntryType.isPage(new CommentEntry()));
assertFalse(EntryType.isPage(new ListItemEntry()));
}
示例6: uploadEntry
import com.google.gdata.data.sites.CommentEntry; //导入依赖的package包/类
@Override
public BaseContentEntry<?> uploadEntry(BaseContentEntry<?> entry,
List<BasePageEntry<?>> ancestors, URL feedUrl, SitesService sitesService) {
checkNotNull(entry);
checkNotNull(ancestors);
checkNotNull(feedUrl);
checkNotNull(sitesService);
BaseContentEntry<?> returnedEntry = null;
if (entry.getId() != null) {
if (entry.getId().startsWith(feedUrl.toExternalForm() + "/")) {
returnedEntry = getEntryById(entry, sitesService);
} else {
entry.setId(null);
}
}
if (returnedEntry == null) {
if (isPage(entry) ||
getType(entry) == ATTACHMENT ||
getType(entry) == WEB_ATTACHMENT) {
returnedEntry = getEntryByPath(entry, ancestors, feedUrl, sitesService);
} else if (getType(entry) == COMMENT) {
// TODO(gk5885): remove extra cast for
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214
if (commentExists((CommentEntry) (BaseContentEntry) entry, feedUrl, sitesService)) {
return entry;
}
} else if (getType(entry) == LIST_ITEM) {
// TODO(gk5885): remove extra cast for
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214
if (listItemExists((ListItemEntry) (BaseContentEntry) entry, feedUrl, sitesService)) {
return entry;
}
}
}
if (returnedEntry == null) {
return entryInserter.insertEntry(entry, feedUrl, sitesService);
} else {
return entryUpdater.updateEntry(returnedEntry, entry,
sitesService);
}
}
示例7: testNormalExport
import com.google.gdata.data.sites.CommentEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testNormalExport() throws IOException {
final BasePageEntry<?> grandparent = new WebPageEntry();
grandparent.setId("grandparent");
grandparent.setTitle(new PlainTextConstruct("grandparent"));
grandparent.setPageName(new PageName("grandparent"));
final BasePageEntry<?> parent = new WebPageEntry();
parent.setId("parent");
EntryUtils.setParentId(parent, grandparent.getId());
final BasePageEntry<?> entry = new WebPageEntry();
entry.setId("entry");
entry.setTitle(new PlainTextConstruct("entry"));
EntryUtils.setParentId(entry, parent.getId());
final BasePageEntry<?> subpage1 = new WebPageEntry();
subpage1.setId("subpage1");
subpage1.setTitle(new PlainTextConstruct("subpage1"));
EntryUtils.setParentId(subpage1, entry.getId());
final BasePageEntry<?> subpage2 = new WebPageEntry();
subpage2.setId("subpage2");
subpage2.setTitle(new PlainTextConstruct("subpage2"));
EntryUtils.setParentId(subpage2, entry.getId());
final AttachmentEntry attachment1 = new AttachmentEntry();
attachment1.setId("attachment1");
attachment1.setUpdated(DateTime.parseDateTime("2009-08-06T16:08:12.107Z"));
EntryUtils.setParentId(attachment1, entry.getId());
final AttachmentEntry attachment2 = new AttachmentEntry();
attachment2.setId("attachment2");
attachment2.setUpdated(DateTime.parseDateTime("2009-08-06T16:26:57.019Z"));
EntryUtils.setParentId(attachment2, entry.getId());
final CommentEntry comment1 = new CommentEntry();
comment1.setId("comment1");
comment1.setUpdated(DateTime.parseDateTime("2009-08-06T16:08:12.107Z"));
EntryUtils.setParentId(comment1, entry.getId());
final CommentEntry comment2 = new CommentEntry();
comment2.setId("comment2");
comment2.setUpdated(DateTime.parseDateTime("2009-08-06T16:26:57.019Z"));
EntryUtils.setParentId(comment2, entry.getId());
entryStore.addEntry(grandparent);
entryStore.addEntry(parent);
entryStore.addEntry(entry);
entryStore.addEntry(subpage1);
entryStore.addEntry(subpage2);
entryStore.addEntry(attachment1);
entryStore.addEntry(attachment2);
entryStore.addEntry(comment1);
entryStore.addEntry(comment2);
final List<BasePageEntry<?>> ancestors = Lists.newArrayList();
ancestors.add(grandparent);
ancestors.add(parent);
final List<BasePageEntry<?>> subpages = Lists.newArrayList();
subpages.add(subpage1);
subpages.add(subpage2);
final List<BaseContentEntry<?>> attachments = Lists.newArrayList();
attachments.add(attachment2);
attachments.add(attachment1);
final List<CommentEntry> comments = Lists.newArrayList();
comments.add(comment2);
comments.add(comment1);
context.checking(new Expectations() {{
oneOf (ancestorLinksRenderer).renderAncestorLinks(
with(equal(ancestors)));
will(returnValue(new XmlElement("div")));
oneOf (titleRenderer).renderTitle(entry);
will(returnValue(new XmlElement("div")));
oneOf (contentRenderer).renderContent(entry, false);
will(returnValue(new XmlElement("div")));
oneOf (subpageLinksRenderer).renderSubpageLinks(with(equal(subpages)));
will(returnValue(new XmlElement("div")));
oneOf (attachmentsRenderer).renderAttachments(with(equal(attachments)));
will(returnValue(new XmlElement("div")));
oneOf (commentsRenderer).renderComments(with(equal(comments)));
will(returnValue(new XmlElement("div")));
}});
exporter.exportPage(entry, entryStore, out, false);
}
示例8: renderComments
import com.google.gdata.data.sites.CommentEntry; //导入依赖的package包/类
/**
* Returns an XmlElement containing the given comments, in the same order as
* they appear in the list.
*/
XmlElement renderComments(List<CommentEntry> comments);