weixin4j-qy: 新增userid与openid互换接口

This commit is contained in:
jinyu
2015-06-24 20:57:24 +08:00
parent bb79042d4e
commit f6b1f76210
23 changed files with 255 additions and 195 deletions
@@ -4,7 +4,6 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.regex.Pattern;
/**
* 对$n结尾的节点注解
@@ -18,9 +17,5 @@ import java.util.regex.Pattern;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ListsuffixResult {
String[] value() default { DEFAULT_REGEX };
public final static String DEFAULT_REGEX = "(_\\d)$";
public final static Pattern DEFAULT_PATTERN = Pattern
.compile(DEFAULT_REGEX);
String[] value() default { "(_\\d)$" };
}
@@ -42,6 +42,26 @@ import com.foxinmy.weixin4j.util.StringUtil;
*/
public class ListsuffixResultDeserializer {
private static Pattern DEFAULT_PATTERN;
static {
String regex = null;
try {
Object value = ListsuffixResult.class.getMethod("value")
.getDefaultValue();
if (value instanceof String) {
regex = (String) value;
} else if (value instanceof String[]) {
regex = ((String[]) value)[0];
}
} catch (NoSuchMethodException e) {
;
}
if (StringUtil.isBlank(regex)) {
regex = "(_\\d)$";
}
DEFAULT_PATTERN = Pattern.compile(regex);
}
/**
* 对包含$n节点的xml序列化
*
@@ -109,9 +129,8 @@ public class ListsuffixResultDeserializer {
} else if (event == XMLStreamConstants.CHARACTERS) {
String key = matcher.group();
if (!pattern.pattern().equals(
ListsuffixResult.DEFAULT_REGEX)) {
matcher = ListsuffixResult.DEFAULT_PATTERN
.matcher(name);
DEFAULT_PATTERN.pattern())) {
matcher = DEFAULT_PATTERN.matcher(name);
matcher.find();
key = matcher.group();
}
@@ -146,7 +165,7 @@ public class ListsuffixResultDeserializer {
.getDefaultValue().toString())) {
itemName = rootElement.name();
}
} catch (Exception e) {
} catch (NoSuchMethodException e) {
;
}
}