mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-30 18:19:04 +08:00
#517 将XStreamTransformer的register方法设为public,方便用户自定义扩展
This commit is contained in:
@ -1,12 +1,16 @@
|
||||
package me.chanjar.weixin.open.util.xml;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
|
||||
import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/007gzs">007</a>
|
||||
*/
|
||||
@ -18,7 +22,7 @@ public class XStreamTransformer {
|
||||
}
|
||||
|
||||
/**
|
||||
* xml -> pojo
|
||||
* xml -> pojo.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T fromXml(Class<T> clazz, String xml) {
|
||||
@ -33,24 +37,24 @@ public class XStreamTransformer {
|
||||
}
|
||||
|
||||
/**
|
||||
* pojo -> xml
|
||||
* pojo -> xml.
|
||||
*/
|
||||
public static <T> String toXml(Class<T> clazz, T object) {
|
||||
return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册扩展消息的解析器
|
||||
* 注册扩展消息的解析器.
|
||||
*
|
||||
* @param clz 类型
|
||||
* @param xStream xml解析器
|
||||
*/
|
||||
private static void register(Class<?> clz, XStream xStream) {
|
||||
public static void register(Class<?> clz, XStream xStream) {
|
||||
CLASS_2_XSTREAM_INSTANCE.put(clz, xStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会自动注册该类及其子类
|
||||
* 会自动注册该类及其子类.
|
||||
*
|
||||
* @param clz 要注册的类
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user