本文整理汇总了Java中com.google.gdata.data.OutOfLineContent类的典型用法代码示例。如果您正苦于以下问题:Java OutOfLineContent类的具体用法?Java OutOfLineContent怎么用?Java OutOfLineContent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OutOfLineContent类属于com.google.gdata.data包,在下文中一共展示了OutOfLineContent类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOutOfLineContentElement
import com.google.gdata.data.OutOfLineContent; //导入依赖的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;
}
示例2: insertSite
import com.google.gdata.data.OutOfLineContent; //导入依赖的package包/类
/**
* Adds a new site for the given user.
*
* @param myService authenticated WebmasterTools Service object
* @param siteUrl URL of site to add to account
* @return a SitesEntry with the newly-created site
* @throws ServiceException if the service is unable to handle the request.
* @throws IOException if there was an error communicating with the server.
*/
public static SitesEntry insertSite(WebmasterToolsService myService,
String siteUrl) throws IOException, ServiceException {
SitesEntry entry = new SitesEntry();
OutOfLineContent content = new OutOfLineContent();
content.setUri(siteUrl);
entry.setContent(content);
System.out.println("Site: " + siteUrl + " now being added.");
return myService.insert(getSitesFeedUrl(), entry);
}
示例3: downloadAttachment
import com.google.gdata.data.OutOfLineContent; //导入依赖的package包/类
/**
* Downloads an attachment.
*
* @param entry The attachment (entry) to download.
* @param entryId The content entry id of the attachment (e.g. 1234567890)
* @throws ServiceException
* @throws IOException
*/
public void downloadAttachment(String entryId, String directory)
throws IOException, ServiceException {
AttachmentEntry attachment = service.getEntry(
new URL(getContentFeedUrl() + entryId), AttachmentEntry.class);
String url = ((OutOfLineContent) attachment.getContent()).getUri();
///*MediaSource mediaSource = service.getMedia((MediaContent) entry.getContent());*/
downloadFile(url, directory + attachment.getTitle().getPlainText());
}
示例4: getWorksheetFeedUrlString
import com.google.gdata.data.OutOfLineContent; //导入依赖的package包/类
/**
* Gets the URL for this spreadseet's worksheets feed as a string.
*
* <p>This checks for version compatibility also.
*
* and call that from here, just like in WorksheetEntry.
*
* @return a string representing the URL for the worksheets feed
*/
private String getWorksheetFeedUrlString() {
Version spreadsheetVersion = state.service.getProtocolVersion();
if (spreadsheetVersion.isCompatible(SpreadsheetService.Versions.V1)) {
Link feedLink = this.getLink(Namespaces.WORKSHEETS_LINK_REL,
Link.Type.ATOM);
return feedLink.getHref();
} else { // must be SpreadsheetService.Versions.V2; only 2 versions for now
return ((OutOfLineContent)(this.getContent())).getUri();
}
}
示例5: getTitleElement
import com.google.gdata.data.OutOfLineContent; //导入依赖的package包/类
/**
* Creates a new hAtom "entry-title" element for the given entry.
*/
static XmlElement getTitleElement(BaseContentEntry<?> entry) {
checkNotNull(entry);
String title = entry.getTitle().getPlainText();
if (getType(entry) == ATTACHMENT) {
return getHyperLink(title, title).setAttribute("class", "entry-title");
} else if (getType(entry) == WEB_ATTACHMENT) {
String href = ((OutOfLineContent) entry.getContent()).getUri();
return getHyperLink(href, title).setAttribute("class", "entry-title");
}
return new XmlElement("span").setAttribute("class", "entry-title")
.addText(title);
}
示例6: importPage
import com.google.gdata.data.OutOfLineContent; //导入依赖的package包/类
@Override
public BasePageEntry<?> importPage(File directory, boolean importRevisions,
List<BasePageEntry<?>> ancestors, URL feedUrl, URL siteUrl,
SitesService sitesService) {
checkNotNull(directory);
File file = new File(directory, "index.html");
if (!file.isFile()) {
LOGGER.log(Level.WARNING, "No valid file in directory: " + directory);
return null;
}
List<BaseContentEntry<?>> entries = pageParser.parsePage(file);
BasePageEntry<?> page = getFirstPageEntry(entries);
if (page == null) {
LOGGER.log(Level.WARNING, "No valid page entry!");
return null;
}
page.setPageName(new PageName(directory.getName()));
linkConverter.convertLinks(page, ancestors, siteUrl, false);
if (!ancestors.isEmpty()) {
EntryUtils.setParent(page, ancestors.get(ancestors.size() - 1));
}
BasePageEntry<?> returnedEntry = null;
if (importRevisions && new File(directory, "_revisions").isDirectory()) {
returnedEntry = revisionsImporter.importRevisions(
directory, ancestors, feedUrl, siteUrl, sitesService);
}
if (returnedEntry == null) {
returnedEntry = (BasePageEntry<?>) entryUploader.uploadEntry(
page, ancestors, feedUrl, sitesService);
} else {
returnedEntry = (BasePageEntry<?>) entryUpdater.updateEntry(
returnedEntry, page, sitesService);
}
List<BasePageEntry<?>> newAncestors = Lists.newLinkedList(ancestors);
newAncestors.add(returnedEntry);
for (BaseContentEntry<?> child : getNonPageEntries(entries)) {
if (getType(child) == ATTACHMENT) {
if (child.getContent() != null) {
String src = ((OutOfLineContent) child.getContent()).getUri();
File attachmentFile = new File(directory, src);
MediaSource mediaSource = new MediaFileSource(attachmentFile,
"application/octet-stream");
child.setContent((Content) null);
child.setMediaSource(mediaSource);
} else {
System.out.println(child.getTitle().getPlainText());
}
}
EntryUtils.setParent(child, returnedEntry);
entryUploader.uploadEntry(child, newAncestors, feedUrl, sitesService);
}
return returnedEntry;
}