Interface XmlAdapter<V,B>
- Type Parameters:
V- the XML value type (usually String) | XML 值类型(通常是 String)B- the bound Java type | 绑定的 Java 类型
- All Known Implementing Classes:
DateAdapter.DurationAdapter, DateAdapter.InstantAdapter, DateAdapter.LegacyDateAdapter, DateAdapter.LocalDateAdapter, DateAdapter.LocalDateTimeAdapter, DateAdapter.LocalTimeAdapter, DateAdapter.PeriodAdapter, DateAdapter.ZonedDateTimeAdapter
public interface XmlAdapter<V,B>
XML Adapter Interface - Converts between XML representation and Java types
XML 适配器接口 - 在 XML 表示和 Java 类型之间转换
This interface defines methods for marshalling and unmarshalling custom types that cannot be directly represented in XML.
此接口定义用于编组和解组无法直接在 XML 中表示的自定义类型的方法。
Features | 主要功能:
- Bidirectional type conversion (marshal/unmarshal) - 双向类型转换(编组/解组)
- Pluggable adapter registration with XmlBinder - 可插拔适配器注册到 XmlBinder
- Optional type introspection via getBoundType/getValueType - 通过 getBoundType/getValueType 进行可选类型内省
Usage Examples | 使用示例:
public class LocalDateAdapter implements XmlAdapter<String, LocalDate> {
@Override
public LocalDate unmarshal(String value) {
return LocalDate.parse(value);
}
@Override
public String marshal(LocalDate value) {
return value.toString();
}
}
Security | 安全性:
- Thread-safe: Depends on implementation - 线程安全: 取决于实现
- Null-safe: Depends on implementation - 空值安全: 取决于实现
- Since:
- JDK 25, opencode-base-xml V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
-
Method Details
-
unmarshal
-
marshal
-
getBoundType
-
getValueType
-