本文整理汇总了Java中com.google.gdata.data.sites.BaseContentEntry类的典型用法代码示例。如果您正苦于以下问题:Java BaseContentEntry类的具体用法?Java BaseContentEntry怎么用?Java BaseContentEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseContentEntry类属于com.google.gdata.data.sites包,在下文中一共展示了BaseContentEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseElement
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
private void parseElement(Element element, List<BaseContentEntry<?>> entries) {
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 (!child.getTagName().equals("q") &&
!child.getTagName().equals("blockquote")) {
if (hasClass(child, "hentry")) {
entries.add(entryParser.parseEntry(child));
}
parseElement(child, entries);
}
}
}
}
示例2: renderAttachments
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
@Override
public XmlElement renderAttachments(List<BaseContentEntry<?>> attachments) {
XmlElement div = new XmlElement("div");
XmlElement bold = new XmlElement("b");
bold.addText("Attachments (" + attachments.size() + ")");
div.addElement(bold).addElement(new XmlElement("br"));
for (BaseContentEntry<?> attachment : attachments) {
EntryType type = getType(attachment);
if (type == ATTACHMENT || type == WEB_ATTACHMENT) {
XmlElement attachmentDiv = RendererUtils.getEntryElement(attachment,
"div");
XmlElement link = RendererUtils.getOutOfLineContentElement(attachment);
XmlElement updated = RendererUtils.getUpdatedElement(attachment);
XmlElement author = RendererUtils.getAuthorElement(attachment);
XmlElement revision = RendererUtils.getRevisionElement(attachment);
attachmentDiv.addElement(link).addText(" - on ").addElement(updated)
.addText(" by ").addElement(author).addText(" (Version ")
.addElement(revision).addText(")");
div.addElement(new XmlElement("br")).addElement(attachmentDiv);
} else {
LOGGER.log(Level.WARNING, "Invalid Attachment Type!");
}
}
return div;
}
示例3: getOutOfLineContentElement
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
/**
* Creates a new hAtom "entry-content entry-title" anchor, containing the
* given entry's out of line content link in the href attribute, and title as
* its text.
*/
static XmlElement getOutOfLineContentElement(BaseContentEntry<?> entry) {
checkNotNull(entry);
XmlElement element = new XmlElement("a");
element.setAttribute("class", "entry-content entry-title");
String title = entry.getTitle().getPlainText();
String href;
if (getType(entry) == ATTACHMENT) {
href = title;
} else if (getType(entry) == WEB_ATTACHMENT) {
href = ((OutOfLineContent) entry.getContent()).getUri();
} else {
LOGGER.log(Level.WARNING, "Only attachments have out of line content!");
href = "";
}
element.setAttribute("href", href);
element.addText(title);
return element;
}
示例4: renderFileCabinet
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
@Override
public XmlElement renderFileCabinet(
List<BaseContentEntry<?>> attachments) {
XmlElement table = new XmlElement("table");
for (BaseContentEntry<?> attachment : attachments) {
XmlElement row = RendererUtils.getEntryElement(attachment, "tr");
XmlElement link = RendererUtils.getOutOfLineContentElement(attachment);
row.addElement(new XmlElement("td").addElement(link));
XmlElement summary = RendererUtils.getSummaryElement(attachment);
row.addElement(new XmlElement("td").addElement(summary));
XmlElement updated = RendererUtils.getUpdatedElement(attachment);
row.addElement(new XmlElement("td").addElement(updated));
XmlElement author = RendererUtils.getAuthorElement(attachment);
row.addElement(new XmlElement("td").addElement(author));
XmlElement revision = RendererUtils.getRevisionElement(attachment);
row.addElement(new XmlElement("td").addText("(Version ")
.addElement(revision).addText(")"));
table.addElement(row);
}
return table;
}
示例5: renderAncestorLinks
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
@Override
public XmlElement renderAncestorLinks(List<BasePageEntry<?>> ancestors) {
XmlElement div = new XmlElement("div");
for (int i = 0; i < ancestors.size(); i++) {
BaseContentEntry<?> ancestor = ancestors.get(i);
String path = "";
for (int j = 0; j < ancestors.size() - i; j++) {
path += "../";
}
XmlElement link = RendererUtils.getHyperLink(path + "index.html",
ancestor.getTitle().getPlainText());
div.addElement(link);
div.addText(" > ");
}
return div;
}
示例6: renderComments
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的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;
}
示例7: renderContent
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
@Override
public XmlElement renderContent(BaseContentEntry<?> entry,
boolean revisionsExported) {
XmlElement div = new XmlElement("div");
div.addElement(RendererUtils.getXhtmlContentElement(entry));
div.addElement(new XmlElement("br"));
XmlElement info = new XmlElement("small");
info.addText("Updated on ");
info.addElement(RendererUtils.getUpdatedElement(entry));
info.addText(" by ");
info.addElement(RendererUtils.getAuthorElement(entry));
if (revisionsExported) {
info.addText(" (");
XmlElement historyLink = new XmlElement("a");
historyLink.addText("Version ").addElement(
RendererUtils.getRevisionElement(entry));
historyLink.setAttribute("href", "history.html");
info.addElement(historyLink).addText(")");
} else {
info.addText(" (Version ")
.addElement(RendererUtils.getRevisionElement(entry)).addText(")");
}
div.addElement(info);
div.addElement(new XmlElement("br")).addElement(new XmlElement("br"));
return div;
}
示例8: addEntry
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
@Override
public void addEntry(BaseContentEntry<?> entry) {
checkNotNull(entry);
String id = entry.getId();
if (id != null && entries.get(id) == null) {
entries.put(id, entry);
String parentId = EntryUtils.getParentId(entry);
if (parentId == null) {
if (isPage(entry)) {
topLevelEntries.add((BasePageEntry<?>) entry);
} else {
LOGGER.log(Level.WARNING, "All non-page entries must have a parent!");
}
} else {
children.put(parentId, entry);
}
} else {
LOGGER.log(Level.WARNING, "All entries should have a unique non-null id!");
}
}
示例9: convertLinks
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
private void convertLinks(BaseContentEntry<?> entry, EntryStore entryStore,
URL siteUrl, boolean isRevision, String prefix, String suffix) {
String content = getXhtmlContent(entry);
String url = siteUrl.toExternalForm();
String siteRoot = getSiteRoot(entry, entryStore);
if (isRevision) {
siteRoot += "../";
}
int index = content.indexOf(prefix + url);
while (index != -1) {
int startIndex = index + prefix.length();
int endIndex = content.indexOf(suffix, startIndex + 1);
String beforeLink = content.substring(0, startIndex);
String link = "";
int beginIndex = startIndex + url.length() + 1;
if(beginIndex < endIndex){
link = content.substring(beginIndex, endIndex);
}
String afterLink = content.substring(endIndex);
content = beforeLink + siteRoot + link + "/index.html" + afterLink;
index = content.indexOf(prefix + url);
}
setContent(entry, content);
}
示例10: getSideBar
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
private XmlElement getSideBar(BaseContentEntry<?> entry, EntryStore entryStore) {
XmlElement table = new XmlElement("table");
table.addElement(new XmlElement("tr").addElement(new XmlElement("th")
.addText("Navigation").setAttribute("align", "left")));
Set<BasePageEntry<?>> pages = Sets.newTreeSet(titleComparator);
pages.addAll(entryStore.getTopLevelEntries());
String pathToRoot = getPathToRoot(entry, entryStore);
for (BasePageEntry<?> page : pages) {
String text = page.getTitle().getPlainText();
if (page.equals(entry)) {
table.addElement(new XmlElement("tr").addElement(new XmlElement("td")
.addElement(new XmlElement("small").addText(text))));
} else {
String href = pathToRoot + page.getPageName().getValue() + "/index.html";
XmlElement link = new XmlElement("a").addText(text)
.setAttribute("href", href);
table.addElement(new XmlElement("tr").addElement(new XmlElement("td")
.addElement(new XmlElement("small").addElement(link))));
}
}
return table;
}
示例11: testUpdateById
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
@Test
public void testUpdateById() throws IOException, ServiceException {
final String id = feedUrl.toExternalForm() + "/entry";
final BaseContentEntry<?> newEntry = new WebPageEntry();
newEntry.setId(id);
final BaseContentEntry<?> oldEntry = new WebPageEntry();
oldEntry.setId(id);
oldEntry.addLink(ILink.Rel.ENTRY_EDIT, ILink.Type.ATOM, id);
final BaseContentEntry<?> returnedEntry = new WebPageEntry();
returnedEntry.setId(id);
context.checking(new Expectations() {{
oneOf (sitesService).getEntry(new URL(id), WebPageEntry.class);
will(returnValue(oldEntry));
oneOf (entryUpdater).updateEntry(oldEntry, newEntry, sitesService);
will(returnValue(returnedEntry));
}});
assertEquals(returnedEntry, entryUploader.uploadEntry(newEntry,
new LinkedList<BasePageEntry<?>>(), feedUrl, sitesService));
}
示例12: testUpdateByPath
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testUpdateByPath() throws IOException, ServiceException {
final BasePageEntry<?> parent = new WebPageEntry();
parent.setPageName(new PageName("parent"));
final BasePageEntry<?> newEntry = new WebPageEntry();
newEntry.setPageName(new PageName("entry"));
final List<BasePageEntry<?>> ancestors = Lists.newLinkedList();
ancestors.add(parent);
final BasePageEntry<?> oldEntry = new WebPageEntry();
final String id = feedUrl.toExternalForm() + "/entry";
oldEntry.setId(id);
oldEntry.addLink(ILink.Rel.ENTRY_EDIT, ILink.Type.ATOM, id);
final BaseContentEntry<?> returnedEntry = new WebPageEntry();
context.checking(new Expectations() {{
allowing (entryProvider).getEntries(with(any(ContentQuery.class)),
with(sitesService));
will(returnValue(Lists.newArrayList(oldEntry)));
oneOf (entryUpdater).updateEntry(oldEntry, newEntry, sitesService);
will(returnValue(returnedEntry));
}});
assertEquals(returnedEntry, entryUploader.uploadEntry(newEntry, ancestors,
feedUrl, sitesService));
}
示例13: testInsert
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
@Test
public void testInsert() throws IOException, ServiceException {
final BasePageEntry<?> parent = new WebPageEntry();
parent.setPageName(new PageName("parent"));
final BasePageEntry<?> newEntry = new WebPageEntry();
newEntry.setPageName(new PageName("entry"));
final List<BasePageEntry<?>> ancestors = Lists.newLinkedList();
ancestors.add(parent);
final BasePageEntry<?> oldEntry = new WebPageEntry();
final String id = feedUrl.toExternalForm() + "/entry";
oldEntry.setId(id);
oldEntry.addLink(ILink.Rel.ENTRY_EDIT, ILink.Type.ATOM, id);
final BaseContentEntry<?> returnedEntry = new WebPageEntry();
context.checking(new Expectations() {{
allowing (entryProvider).getEntries(with(any(ContentQuery.class)),
with(sitesService));
will(returnValue(Lists.newArrayList()));
oneOf (entryInserter).insertEntry(newEntry, feedUrl, sitesService);
will(returnValue(returnedEntry));
}});
assertEquals(returnedEntry, entryUploader.uploadEntry(newEntry, ancestors,
feedUrl, sitesService));
}
示例14: testDataParsing
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的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());
}
示例15: testWithChildren
import com.google.gdata.data.sites.BaseContentEntry; //导入依赖的package包/类
@Test
public void testWithChildren() {
final Element entryElement = document.createElement("div");
entryElement.setAttribute("class", "hentry listpage");
final Element attachmentElement1 = document.createElement("span");
attachmentElement1.setAttribute("class", "hentry attachment");
entryElement.appendChild(attachmentElement1);
final Element attachmentElement2 = document.createElement("p");
attachmentElement2.setAttribute("class", "hentry attachment");
entryElement.appendChild(attachmentElement2);
final Element commentItemElement = document.createElement("tr");
commentItemElement.setAttribute("class", "hentry comment");
entryElement.appendChild(commentItemElement);
final Element listItemElement = document.createElement("tr");
listItemElement.setAttribute("class", "hentry listitem");
entryElement.appendChild(listItemElement);
BaseContentEntry<?> entry = entryParser.parseEntry(entryElement);
assertEquals(EntryType.getType(entry), EntryType.LIST_PAGE);
}