本文整理汇总了Java中com.rometools.rome.feed.atom.Content.setType方法的典型用法代码示例。如果您正苦于以下问题:Java Content.setType方法的具体用法?Java Content.setType怎么用?Java Content.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.feed.atom.Content
的用法示例。
在下文中一共展示了Content.setType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFeedEntries
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request,
HttpServletResponse response) throws Exception {
List<Entry> entries = new ArrayList<Entry>();
List<Customer> customerlist = (List<Customer>) model.get("customers");
for (Customer o : customerlist) {
Entry entry = new Entry();
entry.setId("https://github.com/mploed/event-driven-spring-boot/customer/" + Long.toString(o.getId()));
entry.setUpdated(o.getUpdated());
entry.setTitle("Customer " + o.getId());
List<Content> contents = new ArrayList<Content>();
Content content = new Content();
content.setSrc(baseUrl(request) + "customer/rest/" + Long.toString(o.getId()));
content.setType("application/json");
contents.add(content);
entry.setContents(contents);
Content summary = new Content();
summary.setValue("This is the customer " + o.getId());
entry.setSummary(summary);
entries.add(entry);
}
return entries;
}
示例2: buildFeedEntries
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request,
HttpServletResponse response) throws Exception {
List<Entry> entries = new ArrayList<Entry>();
List<Order> orderlist = (List<Order>) model.get("orders");
for (Order o : orderlist) {
Entry entry = new Entry();
entry.setId("tag:ewolff.com/microservice-atom/order/" + Long.toString(o.getId()));
entry.setUpdated(o.getUpdated());
entry.setTitle("Order " + o.getId());
List<Content> contents = new ArrayList<Content>();
Content content = new Content();
content.setSrc(baseUrl(request) + "order/" + Long.toString(o.getId()));
content.setType("application/json");
contents.add(content);
entry.setContents(contents);
Content summary = new Content();
summary.setValue("This is the order " + o.getId());
entry.setSummary(summary);
entries.add(entry);
}
return entries;
}
示例3: reduceContent
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
private Content reduceContent(Content first, Content second) {
Content newContent = new Content();
String type = first.getType();
String newValue;
if (type.toLowerCase().contains("html")) {
newValue = first.getValue() + "<br/>" + second.getValue();
} else {
newValue = first.getValue() + "\n " + second.getValue();
}
newContent.setValue(newValue);
newContent.setType(type);
newContent.setSrc(first.getSrc());
return newContent;
}
示例4: parseContent
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
private Content parseContent(final Element e) {
final String value = parseTextConstructToString(e);
final String src = getAttributeValue(e, "src");
final String type = getAttributeValue(e, "type");
final Content content = new Content();
content.setSrc(src);
content.setType(type);
content.setValue(value);
return content;
}
示例5: createFeed
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
private Feed createFeed() {
final Feed feed = new Feed();
final Content content = new Content();
content.setType("application/xml");
content.setValue("<test>Hello Hello</test>");
feed.setTitleEx(content);
feed.setFeedType("atom_1.0");
return feed;
}
示例6: ClientMediaEntry
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
public ClientMediaEntry(final ClientAtomService service, final ClientCollection collection, final String title, final String slug,
final String contentType, final InputStream is) {
this(service, collection);
inputStream = is;
setTitle(title);
setSlug(slug);
final Content content = new Content();
content.setType(contentType);
final List<Content> contents = new ArrayList<Content>();
contents.add(content);
setContents(contents);
}
示例7: setContent
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
/**
* Set content of entry.
*
* @param contentString content string.
* @param type Must be "text" for plain text, "html" for escaped HTML, "xhtml" for XHTML or a
* valid MIME content-type.
*/
public void setContent(final String contentString, final String type) {
final Content newContent = new Content();
newContent.setType(type == null ? Content.HTML : type);
newContent.setValue(contentString);
final ArrayList<Content> contents = new ArrayList<Content>();
contents.add(newContent);
setContents(contents);
}
示例8: createAtomContent
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
protected Content createAtomContent(final SyndContent sContent) {
final Content content = new Content();
content.setType(sContent.getType());
content.setValue(sContent.getValue());
return content;
}
示例9: parseEntry
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
protected Entry parseEntry(final Feed feed, final Element eEntry, final String baseURI, final Locale locale) {
final Entry entry = new Entry();
final String xmlBase = eEntry.getAttributeValue("base", Namespace.XML_NAMESPACE);
if (xmlBase != null) {
entry.setXmlBase(xmlBase);
}
final Element title = eEntry.getChild("title", getAtomNamespace());
if (title != null) {
final Content c = new Content();
c.setValue(parseTextConstructToString(title));
c.setType(getAttributeValue(title, "type"));
entry.setTitleEx(c);
}
final List<Element> links = eEntry.getChildren("link", getAtomNamespace());
entry.setAlternateLinks(parseAlternateLinks(feed, entry, baseURI, links));
entry.setOtherLinks(parseOtherLinks(feed, entry, baseURI, links));
final List<Element> authors = eEntry.getChildren("author", getAtomNamespace());
if (!authors.isEmpty()) {
entry.setAuthors(parsePersons(baseURI, authors, locale));
}
final List<Element> contributors = eEntry.getChildren("contributor", getAtomNamespace());
if (!contributors.isEmpty()) {
entry.setContributors(parsePersons(baseURI, contributors, locale));
}
final Element id = eEntry.getChild("id", getAtomNamespace());
if (id != null) {
entry.setId(id.getText());
}
final Element updated = eEntry.getChild("updated", getAtomNamespace());
if (updated != null) {
entry.setUpdated(DateParser.parseDate(updated.getText(), locale));
}
final Element published = eEntry.getChild("published", getAtomNamespace());
if (published != null) {
entry.setPublished(DateParser.parseDate(published.getText(), locale));
}
final Element summary = eEntry.getChild("summary", getAtomNamespace());
if (summary != null) {
entry.setSummary(parseContent(summary));
}
final Element content = eEntry.getChild("content", getAtomNamespace());
if (content != null) {
final List<Content> contents = new ArrayList<Content>();
contents.add(parseContent(content));
entry.setContents(contents);
}
final Element rights = eEntry.getChild("rights", getAtomNamespace());
if (rights != null) {
entry.setRights(rights.getText());
}
final List<Element> categories = eEntry.getChildren("category", getAtomNamespace());
entry.setCategories(parseCategories(baseURI, categories));
// TODO: SHOULD handle Atom entry source element
final Element source = eEntry.getChild("source", getAtomNamespace());
if (source != null) {
entry.setSource(parseFeedMetadata(baseURI, source, locale));
}
entry.setModules(parseItemModules(eEntry, locale));
final List<Element> foreignMarkup = extractForeignMarkup(eEntry, entry, getAtomNamespace());
if (!foreignMarkup.isEmpty()) {
entry.setForeignMarkup(foreignMarkup);
}
return entry;
}
示例10: testSimpleEntryPostAndRemove
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
/**
* Tests that entries can be posted and removed in all collections that accept entries. Fails if
* no collections found that accept entries.
*/
public void testSimpleEntryPostAndRemove() throws Exception {
assertNotNull(service);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;
assertNotNull(space.getTitle());
for (final Object element2 : space.getCollections()) {
final ClientCollection col = (ClientCollection) element2;
if (col.accepts(Collection.ENTRY_TYPE)) {
// we found a collection that accepts entries, so post one
final ClientEntry m1 = col.createEntry();
m1.setTitle("Test post");
final Content c = new Content();
c.setValue("This is a test post");
c.setType("html");
m1.setContent(c);
col.addEntry(m1);
// entry should now exist on server
final ClientEntry m2 = col.getEntry(m1.getEditURI());
assertNotNull(m2);
// remove entry
m2.remove();
// fetching entry now should result in exception
boolean failed = false;
try {
col.getEntry(m1.getEditURI());
} catch (final ProponoException e) {
failed = true;
}
assertTrue(failed);
count++;
}
}
}
assertTrue(count > 0);
}
示例11: testSimpleEntryPostUpdateAndRemove
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
/**
* Tests that entries can be posted, updated and removed in all collections that accept entries.
* Fails if no collections found that accept entries.
*/
public void testSimpleEntryPostUpdateAndRemove() throws Exception {
assertNotNull(service);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;
assertNotNull(space.getTitle());
for (final Object element2 : space.getCollections()) {
final ClientCollection col = (ClientCollection) element2;
if (col.accepts(Collection.ENTRY_TYPE)) {
// we found a collection that accepts entries, so post one
final ClientEntry m1 = col.createEntry();
m1.setTitle(col.getTitle() + ": Test post");
final Content c = new Content();
c.setValue("This is a test post");
c.setType("html");
m1.setContent(c);
col.addEntry(m1);
// entry should now exist on server
final ClientEntry m2 = col.getEntry(m1.getEditURI());
assertNotNull(m2);
m2.setTitle(col.getTitle() + ": Updated title");
m2.update();
// entry should now be updated on server
final ClientEntry m3 = col.getEntry(m1.getEditURI());
assertEquals(col.getTitle() + ": Updated title", m3.getTitle());
// remove entry
m3.remove();
// fetching entry now should result in exception
boolean failed = false;
try {
col.getEntry(m1.getEditURI());
} catch (final ProponoException e) {
failed = true;
}
assertTrue(failed);
count++;
}
}
}
assertTrue(count > 0);
}
示例12: testSimpleEntryPostAndRemove
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
/**
* Tests that entries can be posted and removed in all collections that accept entries. Fails if
* no collections found that accept entries.
*/
@Test
public void testSimpleEntryPostAndRemove() throws Exception {
assertNotNull(service);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;
assertNotNull(space.getTitle());
for (final Object element2 : space.getCollections()) {
final ClientCollection col = (ClientCollection) element2;
if (col.accepts(Collection.ENTRY_TYPE)) {
// we found a collection that accepts entries, so post one
final ClientEntry m1 = col.createEntry();
m1.setTitle("Test post");
final Content c = new Content();
c.setValue("This is a test post");
c.setType("html");
m1.setContent(c);
col.addEntry(m1);
// entry should now exist on server
final ClientEntry m2 = col.getEntry(m1.getEditURI());
assertNotNull(m2);
// remove entry
m2.remove();
// fetching entry now should result in exception
boolean failed = false;
try {
col.getEntry(m1.getEditURI());
} catch (final ProponoException e) {
failed = true;
}
assertTrue(failed);
count++;
}
}
}
assertTrue(count > 0);
}
示例13: testSimpleEntryPostUpdateAndRemove
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
/**
* Tests that entries can be posted, updated and removed in all collections that accept entries.
* Fails if no collections found that accept entries.
*/
@Test
public void testSimpleEntryPostUpdateAndRemove() throws Exception {
assertNotNull(service);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;
assertNotNull(space.getTitle());
for (final Object element2 : space.getCollections()) {
final ClientCollection col = (ClientCollection) element2;
if (col.accepts(Collection.ENTRY_TYPE)) {
// we found a collection that accepts entries, so post one
final ClientEntry m1 = col.createEntry();
m1.setTitle(col.getTitle() + ": Test post");
final Content c = new Content();
c.setValue("This is a test post");
c.setType("html");
m1.setContent(c);
col.addEntry(m1);
// entry should now exist on server
final ClientEntry m2 = col.getEntry(m1.getEditURI());
assertNotNull(m2);
m2.setTitle(col.getTitle() + ": Updated title");
m2.update();
// entry should now be updated on server
final ClientEntry m3 = col.getEntry(m1.getEditURI());
assertEquals(col.getTitle() + ": Updated title", m3.getTitle());
// remove entry
m3.remove();
// fetching entry now should result in exception
boolean failed = false;
try {
col.getEntry(m1.getEditURI());
} catch (final ProponoException e) {
failed = true;
}
assertTrue(failed);
count++;
}
}
}
assertTrue(count > 0);
}
示例14: setRenderedContent
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
private void setRenderedContent(Post post, Entry entry) {
Content content = new Content();
content.setType(Content.HTML);
content.setValue(post.getRenderedContent());
entry.setContents(Arrays.asList(content));
}