本文整理汇总了Java中com.rometools.rome.io.WireFeedInput.build方法的典型用法代码示例。如果您正苦于以下问题:Java WireFeedInput.build方法的具体用法?Java WireFeedInput.build怎么用?Java WireFeedInput.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.io.WireFeedInput
的用法示例。
在下文中一共展示了WireFeedInput.build方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readInternal
import com.rometools.rome.io.WireFeedInput; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException {
WireFeedInput feedInput = new WireFeedInput();
MediaType contentType = inputMessage.getHeaders().getContentType();
Charset charset =
(contentType != null && contentType.getCharSet() != null? contentType.getCharSet() : DEFAULT_CHARSET);
try {
Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
return (T) feedInput.build(reader);
}
catch (FeedException ex) {
throw new HttpMessageNotReadableException("Could not read WireFeed: " + ex.getMessage(), ex);
}
}
示例2: parseEntry
import com.rometools.rome.io.WireFeedInput; //导入方法依赖的package包/类
/**
* Parse entry from reader.
*/
public static Entry parseEntry(final Reader rd, final String baseURI, final Locale locale) throws JDOMException, IOException, IllegalArgumentException,
FeedException {
// Parse entry into JDOM tree
final SAXBuilder builder = new SAXBuilder();
final Document entryDoc = builder.build(rd);
final Element fetchedEntryElement = entryDoc.getRootElement();
fetchedEntryElement.detach();
// Put entry into a JDOM document with 'feed' root so that Rome can
// handle it
final Feed feed = new Feed();
feed.setFeedType("atom_1.0");
final WireFeedOutput wireFeedOutput = new WireFeedOutput();
final Document feedDoc = wireFeedOutput.outputJDom(feed);
feedDoc.getRootElement().addContent(fetchedEntryElement);
if (baseURI != null) {
feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE);
}
final WireFeedInput input = new WireFeedInput(false, locale);
final Feed parsedFeed = (Feed) input.build(feedDoc);
return parsedFeed.getEntries().get(0);
}
示例3: getFeedDocument
import com.rometools.rome.io.WireFeedInput; //导入方法依赖的package包/类
/**
* Get feed document representing collection.
*
* @throws com.rometools.rome.propono.atom.server.AtomException On error retrieving feed file.
* @return Atom Feed representing collection.
*/
public Feed getFeedDocument() throws AtomException {
InputStream in = null;
synchronized (FileStore.getFileStore()) {
in = FileStore.getFileStore().getFileInputStream(getFeedPath());
if (in == null) {
in = createDefaultFeedDocument(contextURI + servletPath + "/" + handle + "/" + collection);
}
}
try {
final WireFeedInput input = new WireFeedInput();
final WireFeed wireFeed = input.build(new InputStreamReader(in, "UTF-8"));
return (Feed) wireFeed;
} catch (final Exception ex) {
throw new AtomException(ex);
}
}
示例4: testXmlBomb
import com.rometools.rome.io.WireFeedInput; //导入方法依赖的package包/类
public void testXmlBomb() throws Exception {
// https://en.wikipedia.org/wiki/Billion_laughs
// https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
String content = "<?xml version=\"1.0\"?>\n" +
"<!DOCTYPE lolz [\n" +
" <!ENTITY lol \"lol\">\n" +
" <!ELEMENT lolz (#PCDATA)>\n" +
" <!ENTITY lol1 \"&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;\">\n" +
" <!ENTITY lol2 \"&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;\">\n" +
" <!ENTITY lol3 \"&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;\">\n" +
" <!ENTITY lol4 \"&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;\">\n" +
" <!ENTITY lol5 \"&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;\">\n" +
" <!ENTITY lol6 \"&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;\">\n" +
" <!ENTITY lol7 \"&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;\">\n" +
" <!ENTITY lol8 \"&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;\">\n" +
" <!ENTITY lol9 \"&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;\">\n" +
"]>\n" +
"<feed>\n" +
" <title>&lol9;</title>\n" +
" <subtitle>subtitle</subtitle>\n" +
" <entry>\n" +
" <id>id1</id>\n" +
" <title>title1</title>\n" +
" </entry>\n" +
"</feed>";
InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
WireFeedInput feedInput = new WireFeedInput();
Reader reader = new InputStreamReader(is, Charset.forName("UTF-8"));
try {
feedInput.build(reader);
fail("Expected exception");
}
catch (ParsingFeedException ex) {
}
}
示例5: testTemp
import com.rometools.rome.io.WireFeedInput; //导入方法依赖的package包/类
public void testTemp() throws Exception {
final WireFeedInput input = new WireFeedInput();
final WireFeed wf = input.build(TestUtil.loadFile("/opml_1.0_links.xml"));
final WireFeedOutput output = new WireFeedOutput();
final SyndFeedImpl sf = new SyndFeedImpl(wf);
sf.setFeedType("rss_2.0");
sf.setDescription("");
sf.setLink("http://foo.com");
sf.setFeedType("opml_1.0");
output.output(sf.createWireFeed(), new NullWriter());
}
示例6: getNextEntries
import com.rometools.rome.io.WireFeedInput; //导入方法依赖的package包/类
private void getNextEntries() throws ProponoException {
if (nextURI == null) {
return;
}
final GetMethod colGet = new GetMethod(collection.getHrefResolved(nextURI));
collection.addAuthentication(colGet);
try {
collection.getHttpClient().executeMethod(colGet);
final SAXBuilder builder = new SAXBuilder();
final Document doc = builder.build(colGet.getResponseBodyAsStream());
final WireFeedInput feedInput = new WireFeedInput();
col = (Feed) feedInput.build(doc);
} catch (final Exception e) {
throw new ProponoException("ERROR: fetching or parsing next entries, HTTP code: " + (colGet != null ? colGet.getStatusCode() : -1), e);
} finally {
colGet.releaseConnection();
}
members = col.getEntries().iterator();
col.getEntries().size();
nextURI = null;
final List<Link> altLinks = col.getOtherLinks();
if (altLinks != null) {
for (final Link link : altLinks) {
if ("next".equals(link.getRel())) {
nextURI = link.getHref();
}
}
}
}
示例7: importOpml
import com.rometools.rome.io.WireFeedInput; //导入方法依赖的package包/类
public void importOpml(User user, String xml) {
xml = xml.substring(xml.indexOf('<'));
WireFeedInput input = new WireFeedInput();
try {
Opml feed = (Opml) input.build(new StringReader(xml));
List<Outline> outlines = feed.getOutlines();
for (int i = 0; i < outlines.size(); i++) {
handleOutline(user, outlines.get(i), null, i);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
示例8: getWireFeed
import com.rometools.rome.io.WireFeedInput; //导入方法依赖的package包/类
protected WireFeed getWireFeed() throws Exception {
final WireFeedInput in = new WireFeedInput();
in.setAllowDoctypes(allowDoctypes);
return in.build(getFeedReader());
}
示例9: getWireFeed
import com.rometools.rome.io.WireFeedInput; //导入方法依赖的package包/类
protected WireFeed getWireFeed() throws Exception {
final WireFeedInput in = new WireFeedInput();
return in.build(getFeedReader());
}