com.sun.syndication.io.WireFeedInput类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(71)

本文整理了Java中com.sun.syndication.io.WireFeedInput类的一些代码示例,展示了WireFeedInput类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WireFeedInput类的具体详情如下:
包路径:com.sun.syndication.io.WireFeedInput
类名称:WireFeedInput

WireFeedInput介绍

[英]Parses an XML document (File, InputStream, Reader, W3C SAX InputSource, W3C DOM Document or JDom DOcument) into an WireFeed (RSS/Atom).

It accepts all flavors of RSS (0.90, 0.91, 0.92, 0.93, 0.94, 1.0 and 2.0) and Atom 0.3 feeds. Parsers are plugable (they must implement the WireFeedParser interface).

The WireFeedInput useds liberal parsers.
[中]将XML文档(文件、InputStream、Reader、W3C SAX InputSource、W3C DOM文档或JDom文档)解析为WireFeed(RSS/Atom)。
它接受各种风格的RSS(0.90、0.91、0.92、0.93、0.94、1.0和2.0)和Atom 0.3订阅源。解析器是可插入的(它们必须实现WireFeedParser接口)。
WireFeedInput使用自由的解析器。

代码示例

代码示例来源:origin: rome/rome

/**
 * Creates a SyndFeedInput instance.
 * <p>
 * @param validate indicates if the input should be validated. NOT IMPLEMENTED YET (validation does not happen)
 *
 */
public SyndFeedInput(boolean validate) {
  _feedInput = new WireFeedInput(validate);
}

代码示例来源:origin: rome/rome

/**
 * Builds SyndFeedImpl from an W3C SAX InputSource.
 * <p>
 * @param is W3C SAX InputSource to read to create the SyndFeedImpl.
 * @return the SyndFeedImpl read from the W3C SAX InputSource.
 * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers.
 * @throws FeedException if the feed could not be parsed
 *
 */
public SyndFeed build(InputSource is) throws IllegalArgumentException,FeedException {
  return new SyndFeedImpl(_feedInput.build(is), preserveWireFeed);
}

代码示例来源:origin: rome/rome

/**
 * Returns the list of supported input feed types.
 * <p>
 * @see WireFeed for details on the format of these strings.
 * <p>
 * @return a list of String elements with the supported input feed types.
 *
 */
public static List getSupportedFeedTypes() {
  return getFeedParsers().getSupportedFeedTypes();
}

代码示例来源:origin: com.sun.jersey/jersey-bundle

public Feed readFrom(
    Class<Feed> type, 
    Type genericType, 
    Annotation annotations[],
    MediaType mediaType, 
    MultivaluedMap<String, String> httpHeaders, 
    InputStream entityStream) throws IOException {
  try {
    WireFeedInput input = new WireFeedInput();                      
    WireFeed wireFeed = input.build(new InputStreamReader(entityStream));    
    if (!(wireFeed instanceof Feed)) {
      throw new IOException(ImplMessages.ERROR_NOT_ATOM_FEED(type));
    }
    return (Feed)wireFeed;
  } catch (FeedException cause) {
    IOException effect = new IOException(ImplMessages.ERROR_MARSHALLING_ATOM(type));
    effect.initCause(cause);
    throw effect;
  }
}

代码示例来源:origin: rome/rome

/**
 * Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource.
 * <p>
 * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom.Document)'.
 * <p>
 * @param is W3C SAX InputSource to read to create the WireFeed.
 * @return the WireFeed read from the W3C SAX InputSource.
 * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers.
 * @throws FeedException if the feed could not be parsed
 *
 */
public WireFeed build(InputSource is) throws IllegalArgumentException,FeedException {
  SAXBuilder saxBuilder = createSAXBuilder();
  try {
    Document document = saxBuilder.build(is);
    return build(document);
  }
  catch (JDOMParseException ex) {
    throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex);
  }
  catch (IllegalArgumentException ex) {
    throw ex;
  }
  catch (Exception ex) {
    throw new ParsingFeedException("Invalid XML",ex);
  }
}

代码示例来源:origin: rome/rome

/**
 * Enables XML healing in the WiredFeedInput instance.
 * <p>
 * Healing trims leading chars from the stream (empty spaces and comments) until the XML prolog.
 * <p>
 * Healing resolves HTML entities (from literal to code number) in the reader.
 * <p>
 * The healing is done only with the build(File) and build(Reader) signatures.
 * <p>
 * By default is TRUE.
 * <p>
 * @param heals TRUE enables stream healing, FALSE disables it.
 *
 */
public void setXmlHealerOn(boolean heals) {
  _feedInput.setXmlHealerOn(heals);
}

代码示例来源:origin: rome/rome

/**
 * Indicates if the WiredFeedInput instance will XML heal (if necessary) the character stream.
 * <p>
 * Healing trims leading chars from the stream (empty spaces and comments) until the XML prolog.
 * <p>
 * Healing resolves HTML entities (from literal to code number) in the reader.
 * <p>
 * The healing is done only with the build(File) and build(Reader) signatures.
 * <p>
 * By default is TRUE.
 * <p>
 * @return TRUE if healing is enabled, FALSE if not.
 *
 */
public boolean getXmlHealerOn() {
  return _feedInput.getXmlHealerOn();
}

代码示例来源:origin: com.sun.jersey/jersey-atom

public Feed readFrom(
    Class<Feed> type, 
    Type genericType, 
    Annotation annotations[],
    MediaType mediaType, 
    MultivaluedMap<String, String> httpHeaders, 
    InputStream entityStream) throws IOException {
  try {
    WireFeedInput input = new WireFeedInput();                      
    WireFeed wireFeed = input.build(new InputStreamReader(entityStream));    
    if (!(wireFeed instanceof Feed)) {
      throw new IOException(ImplMessages.ERROR_NOT_ATOM_FEED(type));
    }
    return (Feed)wireFeed;
  } catch (FeedException cause) {
    IOException effect = new IOException(ImplMessages.ERROR_MARSHALLING_ATOM(type));
    effect.initCause(cause);
    throw effect;
  }
}

代码示例来源:origin: org.apache.marmotta/sesame-tools-rio-rss

/**
 * Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource.
 * <p>
 * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
 * <p>
 * @param is W3C SAX InputSource to read to create the WireFeed.
 * @return the WireFeed read from the W3C SAX InputSource.
 * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers.
 * @throws FeedException if the feed could not be parsed
 *
 */
public WireFeed build(InputSource is) throws IllegalArgumentException,FeedException {
  SAXBuilder saxBuilder = createSAXBuilder();
  try {
    Document document = saxBuilder.build(is);
    return build(document);
  }
  catch (JDOMParseException ex) {
    throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex);
  }
  catch (IllegalArgumentException ex) {
    throw ex;
  }
  catch (Exception ex) {
    throw new ParsingFeedException("Invalid XML",ex);
  }
}

代码示例来源:origin: com.sun.syndication/com.springsource.com.sun.syndication

/**
 * Enables XML healing in the WiredFeedInput instance.
 * <p>
 * Healing trims leading chars from the stream (empty spaces and comments) until the XML prolog.
 * <p>
 * Healing resolves HTML entities (from literal to code number) in the reader.
 * <p>
 * The healing is done only with the build(File) and build(Reader) signatures.
 * <p>
 * By default is TRUE.
 * <p>
 * @param heals TRUE enables stream healing, FALSE disables it.
 *
 */
public void setXmlHealerOn(boolean heals) {
  _feedInput.setXmlHealerOn(heals);
}

代码示例来源:origin: org.apache.marmotta/sesame-tools-rio-rss

/**
 * Indicates if the WiredFeedInput instance will XML heal (if necessary) the character stream.
 * <p>
 * Healing trims leading chars from the stream (empty spaces and comments) until the XML prolog.
 * <p>
 * Healing resolves HTML entities (from literal to code number) in the reader.
 * <p>
 * The healing is done only with the build(File) and build(Reader) signatures.
 * <p>
 * By default is TRUE.
 * <p>
 * @return TRUE if healing is enabled, FALSE if not.
 *
 */
public boolean getXmlHealerOn() {
  return _feedInput.getXmlHealerOn();
}

代码示例来源:origin: jersey/jersey-1.x

public Feed readFrom(
    Class<Feed> type, 
    Type genericType, 
    Annotation annotations[],
    MediaType mediaType, 
    MultivaluedMap<String, String> httpHeaders, 
    InputStream entityStream) throws IOException {
  try {
    WireFeedInput input = new WireFeedInput();                      
    WireFeed wireFeed = input.build(new InputStreamReader(entityStream));    
    if (!(wireFeed instanceof Feed)) {
      throw new IOException(ImplMessages.ERROR_NOT_ATOM_FEED(type));
    }
    return (Feed)wireFeed;
  } catch (FeedException cause) {
    IOException effect = new IOException(ImplMessages.ERROR_MARSHALLING_ATOM(type));
    effect.initCause(cause);
    throw effect;
  }
}

代码示例来源:origin: rome/rome

/**
 * Builds SyndFeedImpl from an JDOM document.
 * <p>
 * @param document JDOM document to read to create the SyndFeedImpl.
 * @return the SyndFeedImpl read from the JDOM document.
 * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers.
 * @throws FeedException if the feed could not be parsed
 *
 */
public SyndFeed build(Document document) throws IllegalArgumentException,FeedException {
  return new SyndFeedImpl(_feedInput.build(document), preserveWireFeed);
}

代码示例来源:origin: com.sun.syndication/com.springsource.com.sun.syndication

/**
 * Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource.
 * <p>
 * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom.Document)'.
 * <p>
 * @param is W3C SAX InputSource to read to create the WireFeed.
 * @return the WireFeed read from the W3C SAX InputSource.
 * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers.
 * @throws FeedException if the feed could not be parsed
 *
 */
public WireFeed build(InputSource is) throws IllegalArgumentException,FeedException {
  SAXBuilder saxBuilder = createSAXBuilder();
  try {
    Document document = saxBuilder.build(is);
    return build(document);
  }
  catch (JDOMParseException ex) {
    throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex);
  }
  catch (IllegalArgumentException ex) {
    throw ex;
  }
  catch (Exception ex) {
    throw new ParsingFeedException("Invalid XML",ex);
  }
}

代码示例来源:origin: com.sun.syndication/com.springsource.com.sun.syndication

/**
 * Creates a SyndFeedInput instance.
 * <p>
 * @param validate indicates if the input should be validated. NOT IMPLEMENTED YET (validation does not happen)
 *
 */
public SyndFeedInput(boolean validate) {
  _feedInput = new WireFeedInput(validate);
}

代码示例来源:origin: com.sun.syndication/com.springsource.com.sun.syndication

/**
 * Returns the list of supported input feed types.
 * <p>
 * @see WireFeed for details on the format of these strings.
 * <p>
 * @return a list of String elements with the supported input feed types.
 *
 */
public static List getSupportedFeedTypes() {
  return getFeedParsers().getSupportedFeedTypes();
}

代码示例来源:origin: org.apache.marmotta/sesame-tools-rio-rss

/**
 * Enables XML healing in the WiredFeedInput instance.
 * <p>
 * Healing trims leading chars from the stream (empty spaces and comments) until the XML prolog.
 * <p>
 * Healing resolves HTML entities (from literal to code number) in the reader.
 * <p>
 * The healing is done only with the build(File) and build(Reader) signatures.
 * <p>
 * By default is TRUE.
 * <p>
 * @param heals TRUE enables stream healing, FALSE disables it.
 *
 */
public void setXmlHealerOn(boolean heals) {
  _feedInput.setXmlHealerOn(heals);
}

代码示例来源:origin: com.sun.syndication/com.springsource.com.sun.syndication

/**
 * Indicates if the WiredFeedInput instance will XML heal (if necessary) the character stream.
 * <p>
 * Healing trims leading chars from the stream (empty spaces and comments) until the XML prolog.
 * <p>
 * Healing resolves HTML entities (from literal to code number) in the reader.
 * <p>
 * The healing is done only with the build(File) and build(Reader) signatures.
 * <p>
 * By default is TRUE.
 * <p>
 * @return TRUE if healing is enabled, FALSE if not.
 *
 */
public boolean getXmlHealerOn() {
  return _feedInput.getXmlHealerOn();
}

代码示例来源:origin: com.sun.jersey/jersey-bundle

/**
 * Parse entry from InputStream.
 */
private static Entry parseEntry(InputStream in) 
throws JDOMException, IOException, IllegalArgumentException, FeedException {
  // Parse entry into JDOM tree
  SAXBuilder builder = new SAXBuilder();
  Document entryDoc = builder.build(in);
  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(FEED_TYPE);
  WireFeedOutput wireFeedOutput = new WireFeedOutput();
  Document feedDoc = wireFeedOutput.outputJDom(feed);
  feedDoc.getRootElement().addContent(fetchedEntryElement);
      
  WireFeedInput input = new WireFeedInput();
  Feed parsedFeed = (Feed)input.build(feedDoc);
  return (Entry)parsedFeed.getEntries().get(0);
}

代码示例来源:origin: rome/rome

/**
 * Builds SyndFeedImpl from an Reader.
 * <p>
 * @param reader Reader to read to create the SyndFeedImpl.
 * @return the SyndFeedImpl read from the Reader.
 * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers.
 * @throws FeedException if the feed could not be parsed
 *
 */
public SyndFeed build(Reader reader) throws IllegalArgumentException,FeedException {
  return new SyndFeedImpl(_feedInput.build(reader), preserveWireFeed);
}

相关文章