mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-21 02:57:37 +08:00
🐛 #1169 修复企业微信更新成员事件消息解析问题
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package me.chanjar.weixin.common.util.xml;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.thoughtworks.xstream.converters.basic.StringConverter;
|
||||
|
||||
/**
|
||||
* Integer型数组转换器.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2019-08-22
|
||||
*/
|
||||
public class IntegerArrayConverter extends StringConverter {
|
||||
@Override
|
||||
public boolean canConvert(Class type) {
|
||||
return type == Integer[].class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Object obj) {
|
||||
return "<![CDATA[" + Joiner.on(",").join((Integer[]) obj) + "]]>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fromString(String str) {
|
||||
final Iterable<String> iterable = Splitter.on(",").split(str);
|
||||
final String[] strings = Iterables.toArray(iterable, String.class);
|
||||
Integer[] result = new Integer[strings.length];
|
||||
int index = 0;
|
||||
for (String string : strings) {
|
||||
result[index++] = Integer.parseInt(string);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package me.chanjar.weixin.common.util.xml;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.thoughtworks.xstream.converters.basic.StringConverter;
|
||||
|
||||
/**
|
||||
* Long型数组转换器.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2019-08-22
|
||||
*/
|
||||
public class LongArrayConverter extends StringConverter {
|
||||
@Override
|
||||
public boolean canConvert(Class type) {
|
||||
return type == Long[].class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Object obj) {
|
||||
return "<![CDATA[" + Joiner.on(",").join((Long[]) obj) + "]]>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fromString(String str) {
|
||||
final Iterable<String> iterable = Splitter.on(",").split(str);
|
||||
final String[] strings = Iterables.toArray(iterable, String.class);
|
||||
Long[] result = new Long[strings.length];
|
||||
int index = 0;
|
||||
for (String string : strings) {
|
||||
result[index++] = Long.parseLong(string);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -2,6 +2,11 @@ package me.chanjar.weixin.common.util.xml;
|
||||
|
||||
import com.thoughtworks.xstream.converters.basic.StringConverter;
|
||||
|
||||
/**
|
||||
* CDATA 内容转换器,加上CDATA标签.
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*/
|
||||
public class XStreamCDataConverter extends StringConverter {
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user