gpt4 book ai didi

org.apache.commons.io.input.XmlStreamReaderException.getContentTypeEncoding()方法的使用及代码示例

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

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

XmlStreamReaderException.getContentTypeEncoding介绍

[英]Returns the encoding in the content-type used to attempt determining the encoding.
[中]返回用于尝试确定编码的内容类型中的编码。

代码示例

代码示例来源: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

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: 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: 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: 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: 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: 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;
}

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