Class XmlBindException

All Implemented Interfaces:
Serializable

public class XmlBindException extends OpenXmlException
XML Bind Exception - Thrown when XML-to-Bean binding fails XML 绑定异常 - 当 XML 到 Bean 绑定失败时抛出

This exception is thrown when the binder cannot convert XML to a Java object or vice versa, due to type mismatches, missing annotations, or other issues.

当绑定器由于类型不匹配、缺少注解或其他问题而无法将 XML 转换为 Java 对象(或反之)时抛出此异常。

Features | 主要功能:

  • Exception for XML-to-Bean binding failures - XML 到 Bean 绑定失败的异常
  • Extends OpenXmlException with specific context - 继承 OpenXmlException,带特定上下文

Usage Examples | 使用示例:

// Catch specific exception
try {
    // XML operation
} catch (XmlBindException e) {
    System.err.println(e.getMessage());
}

Security | 安全性:

  • Thread-safe: Yes (immutable exception) - 线程安全: 是(不可变异常)
  • Null-safe: No (message must not be null) - 空值安全: 否(消息不能为 null)
Since:
JDK 25, opencode-base-xml V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • XmlBindException

      public XmlBindException(Class<?> targetType, String message)
      Constructs a bind exception with target type and message. 构造带目标类型和消息的绑定异常。
      Parameters:
      targetType - the target type | 目标类型
      message - the detail message | 详细消息
    • XmlBindException

      public XmlBindException(Class<?> targetType, String message, Throwable cause)
      Constructs a bind exception with target type, message and cause. 构造带目标类型、消息和原因的绑定异常。
      Parameters:
      targetType - the target type | 目标类型
      message - the detail message | 详细消息
      cause - the cause | 原因
    • XmlBindException

      public XmlBindException(String message)
      Constructs a bind exception with message only. 构造仅带消息的绑定异常。
      Parameters:
      message - the detail message | 详细消息
    • XmlBindException

      public XmlBindException(String message, Throwable cause)
      Constructs a bind exception with message and cause. 构造带消息和原因的绑定异常。
      Parameters:
      message - the detail message | 详细消息
      cause - the cause | 原因
  • Method Details

    • getTargetType

      public Class<?> getTargetType()
      Returns the target type that failed to bind. 返回绑定失败的目标类型。
      Returns:
      the target type, or null if not applicable | 目标类型,如果不适用则返回 null