gpt4 book ai didi

org.apache.commons.io.input.XmlStreamReaderException类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 17:05:40 25 4
gpt4 key购买 nike

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

XmlStreamReaderException介绍

[英]The XmlStreamReaderException is thrown by the XmlStreamReader constructors if the charset encoding can not be determined according to the XML 1.0 specification and RFC 3023.

The exception returns the unconsumed InputStream to allow the application to do an alternate processing with the stream. Note that the original InputStream given to the XmlStreamReader cannot be used as that one has been already read.
[中]如果无法根据XML 1.0规范和RFC 3023确定字符集编码,XmlStreamReader构造函数将引发XmlStreamReaderException。
该异常返回未使用的InputStream,以允许应用程序对该流进行替代处理。请注意,无法使用提供给XmlStreamReader的原始InputStream,因为该InputStream已被读取。

代码示例

代码示例来源:origin: commons-io/commons-io

/**
 * Do lenient detection.
 *
 * @param httpContentType content-type header to use for the resolution of
 *        the charset encoding.
 * @param ex The thrown exception
 * @return the encoding
 * @throws IOException thrown if there is a problem reading the stream.
 */
private String doLenientDetection(String httpContentType,
    XmlStreamReaderException ex) throws IOException {
  if (httpContentType != null && httpContentType.startsWith("text/html")) {
    httpContentType = httpContentType.substring("text/html".length());
    httpContentType = "text/xml" + httpContentType;
    try {
      return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
          ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
    } catch (final XmlStreamReaderException ex2) {
      ex = ex2;
    }
  }
  String encoding = ex.getXmlEncoding();
  if (encoding == null) {
    encoding = ex.getContentTypeEncoding();
  }
  if (encoding == null) {
    encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
  }
  return encoding;
}

代码示例来源:origin: commons-io/commons-io

if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) {
    final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
  if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
    final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
  if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
    final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);

代码示例来源:origin: commons-io/commons-io

private void checkRawError(final String msgSuffix,
    final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final String defaultEncoding) {
  try {
    checkRawEncoding("XmlStreamReaderException", bomEnc, xmlGuessEnc, xmlEnc, defaultEncoding);
    fail("Expected XmlStreamReaderException");
  } catch (final XmlStreamReaderException e) {
    assertTrue("Msg Start: " + e.getMessage(), e.getMessage().startsWith("Invalid encoding"));
    assertTrue("Msg End: "   + e.getMessage(), e.getMessage().endsWith(msgSuffix));
    assertEquals("bomEnc",      bomEnc,      e.getBomEncoding());
    assertEquals("xmlGuessEnc", xmlGuessEnc, e.getXmlGuessEncoding());
    assertEquals("xmlEnc",      xmlEnc,      e.getXmlEncoding());
    assertNull("ContentTypeEncoding", e.getContentTypeEncoding());
    assertNull("ContentTypeMime",     e.getContentTypeMime());
  } catch (final Exception e) {
    fail("Expected XmlStreamReaderException, but threw " + e);
  }
}

代码示例来源:origin: Nextdoor/bender

/**
 * Do lenient detection.
 *
 * @param httpContentType content-type header to use for the resolution of
 *        the charset encoding.
 * @param ex The thrown exception
 * @return the encoding
 * @throws IOException thrown if there is a problem reading the stream.
 */
private String doLenientDetection(String httpContentType,
    XmlStreamReaderException ex) throws IOException {
  if (httpContentType != null && httpContentType.startsWith("text/html")) {
    httpContentType = httpContentType.substring("text/html".length());
    httpContentType = "text/xml" + httpContentType;
    try {
      return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
          ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
    } catch (XmlStreamReaderException ex2) {
      ex = ex2;
    }
  }
  String encoding = ex.getXmlEncoding();
  if (encoding == null) {
    encoding = ex.getContentTypeEncoding();
  }
  if (encoding == null) {
    encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
  }
  return encoding;
}

代码示例来源:origin: commons-io/commons-io

private void checkHttpError(final String msgSuffix, final boolean lenient, final String httpContentType,
    final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final String defaultEncoding) {
  try {
    checkHttpEncoding("XmlStreamReaderException", lenient, httpContentType, bomEnc, xmlGuessEnc, xmlEnc, defaultEncoding);
    fail("Expected XmlStreamReaderException");
  } catch (final XmlStreamReaderException e) {
    assertTrue("Msg Start: " + e.getMessage(), e.getMessage().startsWith("Invalid encoding"));
    assertTrue("Msg End: "   + e.getMessage(), e.getMessage().endsWith(msgSuffix));
    assertEquals("bomEnc",      bomEnc,      e.getBomEncoding());
    assertEquals("xmlGuessEnc", xmlGuessEnc, e.getXmlGuessEncoding());
    assertEquals("xmlEnc",      xmlEnc,      e.getXmlEncoding());
    assertEquals("ContentTypeEncoding", XmlStreamReader.getContentTypeEncoding(httpContentType),
                      e.getContentTypeEncoding());
    assertEquals("ContentTypeMime", XmlStreamReader.getContentTypeMime(httpContentType),
                    e.getContentTypeMime());
  } catch (final Exception e) {
    fail("Expected XmlStreamReaderException, but threw " + e);
  }
}

代码示例来源:origin: commons-io/commons-io

throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
if (bomEnc != null) {
  final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
  throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
if (bomEnc != null) {
  final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
  throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Do lenient detection.
 *
 * @param httpContentType content-type header to use for the resolution of
 *        the charset encoding.
 * @param ex The thrown exception
 * @return the encoding
 * @throws IOException thrown if there is a problem reading the stream.
 */
private String doLenientDetection(String httpContentType,
    XmlStreamReaderException ex) throws IOException {
  if (httpContentType != null && httpContentType.startsWith("text/html")) {
    httpContentType = httpContentType.substring("text/html".length());
    httpContentType = "text/xml" + httpContentType;
    try {
      return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
          ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
    } catch (final XmlStreamReaderException ex2) {
      ex = ex2;
    }
  }
  String encoding = ex.getXmlEncoding();
  if (encoding == null) {
    encoding = ex.getContentTypeEncoding();
  }
  if (encoding == null) {
    encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
  }
  return encoding;
}

代码示例来源:origin: Nextdoor/bender

if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) {
    String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
  if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
    String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);

代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded

/**
 * Do lenient detection.
 *
 * @param httpContentType content-type header to use for the resolution of
 *        the charset encoding.
 * @param ex The thrown exception
 * @return the encoding
 * @throws IOException thrown if there is a problem reading the stream.
 */
private String doLenientDetection(String httpContentType,
    XmlStreamReaderException ex) throws IOException {
  if (httpContentType != null && httpContentType.startsWith("text/html")) {
    httpContentType = httpContentType.substring("text/html".length());
    httpContentType = "text/xml" + httpContentType;
    try {
      return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
          ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
    } catch (final XmlStreamReaderException ex2) {
      ex = ex2;
    }
  }
  String encoding = ex.getXmlEncoding();
  if (encoding == null) {
    encoding = ex.getContentTypeEncoding();
  }
  if (encoding == null) {
    encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
  }
  return encoding;
}

代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded

if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) {
    final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
  if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
    final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
  if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
    final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * Do lenient detection.
 *
 * @param httpContentType content-type header to use for the resolution of
 *        the charset encoding.
 * @param ex The thrown exception
 * @return the encoding
 * @throws IOException thrown if there is a problem reading the stream.
 */
private String doLenientDetection(String httpContentType,
    XmlStreamReaderException ex) throws IOException {
  if (httpContentType != null && httpContentType.startsWith("text/html")) {
    httpContentType = httpContentType.substring("text/html".length());
    httpContentType = "text/xml" + httpContentType;
    try {
      return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
          ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
    } catch (XmlStreamReaderException ex2) {
      ex = ex2;
    }
  }
  String encoding = ex.getXmlEncoding();
  if (encoding == null) {
    encoding = ex.getContentTypeEncoding();
  }
  if (encoding == null) {
    encoding = defaultEncoding == null ? UTF_8 : defaultEncoding;
  }
  return encoding;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) {
    final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
  if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
    final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
  if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
    final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);

代码示例来源:origin: org.onosproject/onlab-thirdparty

if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) {
    String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
  if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
    String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
  if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
    String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
    throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);

代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded

throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
if (bomEnc != null) {
  final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
  throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
if (bomEnc != null) {
  final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
  throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
if (bomEnc != null) {
  final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
  throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
if (bomEnc != null) {
  final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
  throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);

代码示例来源:origin: org.onosproject/onlab-thirdparty

throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
if (bomEnc != null) {
  String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
  throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
if (bomEnc != null) {
  String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
  throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);

代码示例来源:origin: Nextdoor/bender

throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
if (bomEnc != null) {
  String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
  throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com