当前位置: 首页>>代码示例>>Java>>正文


Java WireFeedInput类代码示例

本文整理汇总了Java中com.sun.syndication.io.WireFeedInput的典型用法代码示例。如果您正苦于以下问题:Java WireFeedInput类的具体用法?Java WireFeedInput怎么用?Java WireFeedInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WireFeedInput类属于com.sun.syndication.io包,在下文中一共展示了WireFeedInput类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readInternal

import com.sun.syndication.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;
	if (contentType != null && contentType.getCharSet() != null) {
		charset = contentType.getCharSet();
	} else {
		charset = 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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AbstractWireFeedHttpMessageConverter.java

示例2: main

import com.sun.syndication.io.WireFeedInput; //导入依赖的package包/类
public static void main(String[] args) {
    boolean ok = false;
    if (args.length==1) {
        try {
            URL feedUrl = new URL(args[0]);
            WireFeedInput input = new WireFeedInput();

            WireFeed feed = input.build(new XmlReader(feedUrl));

            System.out.println(feed);

            ok = true;
        }
        catch (Exception ex) {
            ex.printStackTrace();
            System.out.println("ERROR: "+ex.getMessage());
        }
    }

    if (!ok) {
        System.out.println();
        System.out.println("WireFeedReader reads and prints any RSS/Atom feed type.");
        System.out.println("The first parameter must be the URL of the feed to read.");
        System.out.println();
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:WireFeedReader.java

示例3: parseEntry

import com.sun.syndication.io.WireFeedInput; //导入依赖的package包/类
/**
 * Parse entry from reader.
 */
public static Entry parseEntry(Reader rd, String baseURI)
    throws JDOMException, IOException, IllegalArgumentException, FeedException {
    // Parse entry into JDOM tree
    SAXBuilder builder = new SAXBuilder();
    Document entryDoc = builder.build(rd);
    Element fetchedEntryElement = entryDoc.getRootElement();
    fetchedEntryElement.detach();

    // Put entry into a JDOM document with 'feed' root so that Rome can handle it
    Feed feed = new Feed();
    feed.setFeedType("atom_1.0");
    WireFeedOutput wireFeedOutput = new WireFeedOutput();
    Document feedDoc = wireFeedOutput.outputJDom(feed);
    feedDoc.getRootElement().addContent(fetchedEntryElement);
    
    if (baseURI != null) {
        feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE);
    }
    
    WireFeedInput input = new WireFeedInput();
    Feed parsedFeed = (Feed)input.build(feedDoc);
    return (Entry)parsedFeed.getEntries().get(0);
}
 
开发者ID:4thline,项目名称:feeds,代码行数:27,代码来源:Atom10Parser.java

示例4: parse

import com.sun.syndication.io.WireFeedInput; //导入依赖的package包/类
/**
 * Parses the data from the supplied InputStream, using the supplied baseURI
 * to resolve any relative URI references.
 *
 * @param in      The InputStream from which to read the data.
 * @param baseURI The URI associated with the data in the InputStream.
 * @throws java.io.IOException If an I/O error occurred while data was read from the InputStream.
 * @throws org.openrdf.rio.RDFParseException
 *                             If the parser has found an unrecoverable parse error.
 * @throws org.openrdf.rio.RDFHandlerException
 *                             If the configured statement handler has encountered an
 *                             unrecoverable error.
 */
@Override
public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
    Preconditions.checkNotNull(baseURI);

    setBaseURI(baseURI);

    WireFeedInput input = new WireFeedInput();
    try {
        WireFeed feed = input.build(new InputSource(in));
        if(feed instanceof Channel) {
            parseFeed((Channel) feed);
        } else {
            throw new RDFParseException("data stream is not an RSS feed");
        }
    } catch (FeedException e) {
        throw new RDFParseException(e);
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:32,代码来源:RSSParser.java

示例5: parse

import com.sun.syndication.io.WireFeedInput; //导入依赖的package包/类
/**
 * Parses the data from the supplied InputStream, using the supplied baseURI
 * to resolve any relative URI references.
 *
 * @param in      The InputStream from which to read the data.
 * @param baseURI The URI associated with the data in the InputStream.
 * @throws java.io.IOException If an I/O error occurred while data was read from the InputStream.
 * @throws org.openrdf.rio.RDFParseException
 *                             If the parser has found an unrecoverable parse error.
 * @throws org.openrdf.rio.RDFHandlerException
 *                             If the configured statement handler has encountered an
 *                             unrecoverable error.
 */
@Override
public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
    Preconditions.checkNotNull(baseURI);

    setBaseURI(baseURI);

    WireFeedInput input = new WireFeedInput();
    try {
        WireFeed feed = input.build(new InputSource(in));
        if(feed instanceof Feed) {
            parseFeed((Feed) feed);
        } else {
            throw new RDFParseException("data stream is not an RSS feed");
        }
    } catch (FeedException e) {
        throw new RDFParseException(e);
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:32,代码来源:AtomParser.java

示例6: getWireFeed

import com.sun.syndication.io.WireFeedInput; //导入依赖的package包/类
protected WireFeed getWireFeed() throws Exception {
    WireFeedInput in = new WireFeedInput();
    return in.build(getFeedReader());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:5,代码来源:FeedTest.java


注:本文中的com.sun.syndication.io.WireFeedInput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。