org.codehaus.plexus.util.xml.XmlStreamReader类的使用及代码示例

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

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

XmlStreamReader介绍

[英]Character stream that handles (or at least attemtps to) all the necessary Voodo to figure out the charset encoding of the XML document within the stream.

IMPORTANT: This class is not related in any way to the org.xml.sax.XMLReader. This one IS a character stream.

All this has to be done without consuming characters from the stream, if not the XML parser will not recognized the document as a valid XML. This is not 100% true, but it's close enough (UTF-8 BOM is not handled by all parsers right now, XmlReader handles it and things work in all parsers).

The XmlReader class handles the charset encoding of XML documents in Files, raw streams and HTTP streams by offering a wide set of constructors.

By default the charset encoding detection is lenient, the constructor with the lenient flag can be used for an script (following HTTP MIME and XML specifications). All this is nicely explained by Mark Pilgrim in his blog, Determining the character encoding of a feed.
[中]字符流,它处理(或至少尝试)所有必要的巫术,以确定流中XML文档的字符集编码。
重要提示:该类与组织没有任何关系。xml。萨克斯。XMLReader。这是一个字符流。
所有这些都必须在不使用流中的字符的情况下完成,否则XML解析器将无法将文档识别为有效的XML。这并不是100%正确,但已经足够接近了(UTF-8 BOM目前不是由所有解析器处理的,XmlReader处理它,所有解析器都能工作)。
XmlReader类通过提供大量构造函数来处理文件、原始流和HTTP流中XML文档的字符集编码。
默认情况下,字符集编码检测为lenient,带有lenient标志的构造函数可用于脚本(遵循HTTP MIME和XML规范)。Mark Pilgrim在他的博客Determining the character encoding of a feed中很好地解释了这一切。

代码示例

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Create a new Reader with XML encoding detection rules.
 *
 * @param file not null file.
 * @return an XML reader instance for the input file.
 * @throws IOException if any.
 * @see XmlStreamReader
 */
public static XmlStreamReader newXmlReader( File file )
  throws IOException
{
  return new XmlStreamReader( file );
}

代码示例来源:origin: org.sonatype.tycho/tycho-metadata-model

@SuppressWarnings("deprecation")
public static Platform read(File file) throws IOException, XmlPullParserException {
  XmlStreamReader reader = ReaderFactory.newXmlReader(file);
  try {
    return new Platform(Xpp3DomBuilder.build(reader));
  } finally {
    reader.close();
  }
}

代码示例来源:origin: org.apache.maven.doxia/doxia-converter

return ( (XmlStreamReader) reader ).getEncoding();

代码示例来源:origin: org.codehaus.tycho/tycho-osgi-components

@SuppressWarnings("deprecation")
public static Platform read(File file) throws IOException, XmlPullParserException {
  XmlStreamReader reader = ReaderFactory.newXmlReader(file);
  try {
    return new Platform(Xpp3DomBuilder.build(reader));
  } finally {
    reader.close();
  }
}

代码示例来源:origin: org.apache.maven.doxia/doxia-doc-renderer

reader = getVelocityReader( f, ( (XmlStreamReader) reader ).getEncoding(), context );

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Create a new Reader with XML encoding detection rules.
 *
 * @param in not null input stream.
 * @return an XML reader instance for the input stream.
 * @throws IOException if any.
 * @see XmlStreamReader
 */
public static XmlStreamReader newXmlReader( InputStream in )
  throws IOException
{
  return new XmlStreamReader( in );
}

代码示例来源:origin: org.codehaus.tycho/tycho-osgi-components

@SuppressWarnings("deprecation")
public static ProductConfiguration read(File file) throws IOException,
    XmlPullParserException {
  XmlStreamReader reader = ReaderFactory.newXmlReader(file);
  try {
    return new ProductConfiguration(Xpp3DomBuilder.build(reader));
  } finally {
    reader.close();
  }
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Create a new Reader with XML encoding detection rules.
 *
 * @param url not null url.
 * @return an XML reader instance for the input url.
 * @throws IOException if any.
 * @see XmlStreamReader
 */
public static XmlStreamReader newXmlReader( URL url )
  throws IOException
{
  return new XmlStreamReader( url );
}

代码示例来源:origin: org.codehaus.tycho/tycho-osgi-components

@SuppressWarnings("deprecation")
public static ProductConfiguration read(InputStream inputStream)
    throws IOException, XmlPullParserException {
  XmlStreamReader reader = ReaderFactory.newXmlReader(inputStream);
  try {
    return new ProductConfiguration(Xpp3DomBuilder.build(reader));
  } finally {
    reader.close();
  }
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Create a new Reader with XML encoding detection rules.
 * @see XmlStreamReader
 */
public static XmlStreamReader newXmlReader( InputStream in )
throws IOException
{
  return new XmlStreamReader( in );
}

代码示例来源:origin: org.codehaus.tycho/tycho-osgi-components

@SuppressWarnings("deprecation")
public static UpdateSite read(InputStream is)
  throws IOException, XmlPullParserException
{
  XmlStreamReader reader = ReaderFactory.newXmlReader(is);
  try {
    return new UpdateSite(Xpp3DomBuilder.build(reader));
  } finally {
    reader.close();
  }
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Create a new Reader with XML encoding detection rules.
 * @see XmlStreamReader
 */
public static XmlStreamReader newXmlReader( URL url )
throws IOException
{
  return new XmlStreamReader( url );
}

代码示例来源:origin: eclipse/tycho

@SuppressWarnings("deprecation")
public static Platform read(File file) throws IOException, XmlPullParserException {
  XmlStreamReader reader = ReaderFactory.newXmlReader(file);
  try {
    return new Platform(Xpp3DomBuilder.build(reader));
  } finally {
    reader.close();
  }
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Create a new Reader with XML encoding detection rules.
 * @see XmlStreamReader
 */
public static XmlStreamReader newXmlReader( File file )
throws IOException
{
  return new XmlStreamReader( file );
}

代码示例来源:origin: org.codehaus.tycho/tycho-osgi-components

@SuppressWarnings("deprecation")
public static Feature read(InputStream input) throws IOException, XmlPullParserException {
  XmlStreamReader reader = ReaderFactory.newXmlReader(input);
  try {
    return new Feature(Xpp3DomBuilder.build(reader));
  } finally {
    reader.close();
  }
}

代码示例来源:origin: org.sonatype.gshell/gshell-util

/**
 * Create a new Reader with XML encoding detection rules.
 *
 * @param in not null input stream.
 * @return an XML reader instance for the input stream.
 * @throws IOException if any.
 * @see XmlStreamReader
 */
public static XmlStreamReader newXmlReader( InputStream in )
throws IOException
{
  return new XmlStreamReader( in );
}

代码示例来源:origin: org.eclipse.tycho/tycho-metadata-model

@SuppressWarnings("deprecation")
public static Platform read(File file) throws IOException, XmlPullParserException {
  XmlStreamReader reader = ReaderFactory.newXmlReader(file);
  try {
    return new Platform(Xpp3DomBuilder.build(reader));
  } finally {
    reader.close();
  }
}

代码示例来源:origin: org.sonatype.gshell/gshell-util

/**
 * Create a new Reader with XML encoding detection rules.
 *
 * @param file not null file.
 * @return an XML reader instance for the input file.
 * @throws IOException if any.
 * @see XmlStreamReader
 */
public static XmlStreamReader newXmlReader( File file )
throws IOException
{
  return new XmlStreamReader( file );
}

代码示例来源:origin: org.codehaus.tycho/tycho-osgi-components

@SuppressWarnings( "deprecation" )
public static Target read( File file )
  throws IOException, XmlPullParserException
{
  XmlStreamReader reader = ReaderFactory.newXmlReader( file );
  try
  {
    return new Target( Xpp3DomBuilder.build( reader ) );
  }
  finally
  {
    reader.close();
  }
}

代码示例来源:origin: org.sonatype.gshell/gshell-util

/**
 * Create a new Reader with XML encoding detection rules.
 *
 * @param url not null url.
 * @return an XML reader instance for the input url.
 * @throws IOException if any.
 * @see XmlStreamReader
 */
public static XmlStreamReader newXmlReader( URL url )
throws IOException
{
  return new XmlStreamReader( url );
}

相关文章

微信公众号

最新文章

更多