Commit 1170a55d by s_guodong

init

parents
HELP.md
target/
out/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea/*
!.idea/artifacts
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.brilliance</groupId>
<artifactId>be-rmb-report</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>rmb-report-bean</module>
<module>rmb-report</module>
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<jdk15on.version>1.62</jdk15on.version>
<fastjson.version>1.2.83</fastjson.version>
<gjson.version>2.2.4</gjson.version>
<commons.io.version>2.4</commons.io.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcpkix-jdk15on -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>${jdk15on.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>${jdk15on.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gjson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>${pom.artifactId}</finalName>
</build>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>be-rmb-report</artifactId>
<groupId>com.brilliance</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rmb-report-bean</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
package com.brilliance.rmb.report.model;
import java.lang.annotation.*;
/**
* Created by cjh on 2019/9/5 0005.
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Desc {
String value() ;
String typeName() default "";
}
package com.brilliance.rmb.report.model;
/**
* @Description
* @Author s_guodong
* @Date 2023/5/11
*/
public class HEAD {
private String sendBic;
public String getSendBic() {
return sendBic;
}
public void setSendBic(String sendBic) {
this.sendBic = sendBic;
}
}
package com.brilliance.rmb.report.model;
import java.lang.annotation.*;
/**
* Created by cjh on 2019/9/5 0005.
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Len {
int size() default 0;
int min() default 0;
int max() default 0;
}
package com.brilliance.rmb.report.model;
import java.lang.annotation.*;
/**
* Created by cjh on 2019/9/5 0005.
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Need {
String value() default "";
}
package com.brilliance.rmb.report.model;
import java.lang.annotation.*;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD})
public @interface UnSig {
Class<?>[] filter() default {};
String regex() default "";
int[] num() default {};//满足域序号的进行加签
}
package com.brilliance.rmb.report.model;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Xmlns {
String value() default "";
}
package com.brilliance.rmb.report.model.cfx2101;
import com.brilliance.rmb.report.model.Desc;
import com.brilliance.rmb.report.model.Len;
import com.brilliance.rmb.report.model.Need;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlType(propOrder = { "SendOrgCode", "EntrustDate", "PackNo", "AllNum"})
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "BatchHead2101")
public class BatchHead2101 {
@Len(size =12)
@Desc("发起机构代码")
@Need
public String SendOrgCode;
/**
* 请求发起日期
*/
@Desc("委托日期")
@Need
public String EntrustDate;
/**
* 用于发起方唯一标识一个包的流水号,由发起方自定义
*/
@Desc("包流水号")
@Need
@Len(size =8)
public String PackNo;
/**
* 当前包中包含的交易总数,要求总笔数不大于1000
*/
@Desc("总笔数")
@Need
public Integer AllNum;
public BatchHead2101 () {
}
public BatchHead2101 (String SendOrgCode ,String EntrustDate ,String PackNo ,Integer AllNum ){
this.SendOrgCode=SendOrgCode;
this.EntrustDate=EntrustDate;
this.PackNo=PackNo;
this.AllNum=AllNum;
}
}
\ No newline at end of file
package com.brilliance.rmb.report.model.cfx2101;
import com.brilliance.rmb.report.model.Desc;
import com.brilliance.rmb.report.model.HEAD;
import com.brilliance.rmb.report.model.Need;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlType(propOrder = { "HEAD", "MSG"})
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "CFX")
public class Cfx2101 {
@Desc("报文头")
@Need
public HEAD HEAD;
@Desc("报文体")
@Need
public MSG MSG;
public Cfx2101 () {
}
public Cfx2101 (HEAD HEAD ,MSG MSG ){
this.HEAD=HEAD;
this.MSG=MSG;
}
}
\ No newline at end of file
package com.brilliance.rmb.report.model.cfx2101;
import com.brilliance.rmb.report.model.Desc;
import com.brilliance.rmb.report.model.Len;
import com.brilliance.rmb.report.model.Need;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlType(propOrder = { "LevyNo", "OperType", "ActionDesc", "BankOrgCode", "PayeeName", "PayeeAttr", "PayeeOrgCode", "PayerName", "PayBankCode", "AllAmt", "PayeeDate", "BalanceMode", "PayeeCNY", "BankTraNo", "Reserve1", "Reserve2", "Reserve3", "Reserve4", "Reserve5", "Reserve6"})
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Income2101")
public class Income2101 {
/**
* 编制规则详见附录A6
*/
@Len(size =24)
@Desc("申报号码")
@Need
public String LevyNo;
/**
* 详见附录A1 操作类型
*/
@Desc("操作类型")
@Len(size =1)
@Need
public String OperType;
/**
* 操作类型为2变更、3撤销时必填
*/
@Desc("变更/撤销原因")
@Len(min = 1,max =128 )
public String ActionDesc;
/**
* 境内结算银行
*/
@Len(size =12)
@Desc("银行机构代码")
@Need
public String BankOrgCode;
/**
* 境内收款主体
*/
@Desc("收款人名称")
@Need
@Len(min = 1,max =128 )
public String PayeeName;
/**
* 详见附录A1 收付款人属性
*/
@Desc("收款人属性")
@Len(size =4)
@Need
public String PayeeAttr;
/**
* 机构填写统一社会信用代码,个人填写身份证件号码
*/
@Desc("收款人机构代码或身份证件号码")
@Len(min = 1,max =30 )
@Need
public String PayeeOrgCode;
/**
* 境外付款主体
*/
@Len(min = 1,max =200 )
@Need
@Desc("付款人名称")
public String PayerName;
/**
* 银行根据报文实际情况填写11位SWIFT BIC或12位支付行号
*/
@Desc("付款行行号")
@Need
@Len(min = 11,max =12 )
public String PayBankCode;
@Desc("总金额")
@Need
public String AllAmt;
@Desc("收款日期")
@Need
public String PayeeDate;
/**
* 详见附录A1 结算方式
*/
@Desc("结算方式")
@Len(size =2)
@Need
public String BalanceMode;
/**
* 详见附录A1 币种
*/
@Desc("收款币种")
@Len(size =3)
@Need
public String PayeeCNY;
/**
* 指该笔业务在银行的业务编号
*/
@Len(min = 1,max =22 )
@Need
@Desc("银行业务编号")
public String BankTraNo;
/**
* 预留
*/
@Len(min = 1,max =200 )
@Desc("预留字段1")
public String Reserve1;
/**
* 预留
*/
@Len(min = 1,max =200 )
@Desc("预留字段2")
public String Reserve2;
/**
* 预留
*/
@Len(min = 1,max =200 )
@Desc("预留字段3")
public String Reserve3;
/**
* 预留
*/
@Len(min = 1,max =200 )
@Desc("预留字段4")
public String Reserve4;
/**
* 预留
*/
@Len(min = 1,max =200 )
@Desc("预留字段5")
public String Reserve5;
/**
* 预留
*/
@Len(min = 1,max =200 )
@Desc("预留字段6")
public String Reserve6;
public Income2101 () {
}
public Income2101 (String LevyNo ,String OperType ,String ActionDesc ,String BankOrgCode ,String PayeeName ,String PayeeAttr ,String PayeeOrgCode ,String PayerName ,String PayBankCode ,String AllAmt ,String PayeeDate ,String BalanceMode ,String PayeeCNY ,String BankTraNo ,String Reserve1 ,String Reserve2 ,String Reserve3 ,String Reserve4 ,String Reserve5 ,String Reserve6 ){
this.LevyNo=LevyNo;
this.OperType=OperType;
this.ActionDesc=ActionDesc;
this.BankOrgCode=BankOrgCode;
this.PayeeName=PayeeName;
this.PayeeAttr=PayeeAttr;
this.PayeeOrgCode=PayeeOrgCode;
this.PayerName=PayerName;
this.PayBankCode=PayBankCode;
this.AllAmt=AllAmt;
this.PayeeDate=PayeeDate;
this.BalanceMode=BalanceMode;
this.PayeeCNY=PayeeCNY;
this.BankTraNo=BankTraNo;
this.Reserve1=Reserve1;
this.Reserve2=Reserve2;
this.Reserve3=Reserve3;
this.Reserve4=Reserve4;
this.Reserve5=Reserve5;
this.Reserve6=Reserve6;
}
}
\ No newline at end of file
package com.brilliance.rmb.report.model.cfx2101;
import com.brilliance.rmb.report.model.Desc;
import com.brilliance.rmb.report.model.Need;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.List;
@XmlType(propOrder = { "BatchHead2101", "Income2101"})
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "MSG")
public class MSG {
@Desc("批量头")
@Need
public BatchHead2101 BatchHead2101;
@Desc("收入基本信息")
@Need
public List<Income2101> Income2101;
public MSG () {
}
public MSG (BatchHead2101 BatchHead2101 ,List<Income2101> Income2101 ){
this.BatchHead2101=BatchHead2101;
this.Income2101=Income2101;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>be-rmb-report</artifactId>
<groupId>com.brilliance</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rmb-report</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.brilliance</groupId>
<artifactId>rmb-report-bean</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.infosec</groupId>
<artifactId>netsignapi</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/../lib/netsignapi.jar</systemPath>
</dependency>
<dependency>
<groupId>cn.com.infosec</groupId>
<artifactId>ISFJ_v2_0_139_20_BAISC_JDK15</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/../lib/ISFJ_v2_0_139_20_BAISC_JDK15.jar</systemPath>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package rmb.report.framework.annotation;
import java.lang.annotation.*;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Activate {
//分组(过滤)
String[] group() default {};
//排序
int order() default 0;
}
package rmb.report.framework.annotation;
import java.util.Comparator;
public class ActivateComparator implements Comparator<Object>{
public static final Comparator<Object> COMPARATOR = new ActivateComparator();
@Override
public int compare(Object o1, Object o2) {
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return -1;
}
if (o2 == null) {
return 1;
}
if (o1.equals(o2)) {
return 0;
}
Activate a1 = o1.getClass().getAnnotation(Activate.class);
Activate a2 = o2.getClass().getAnnotation(Activate.class);
int n1 = a1 == null ? 0 : a1.order();
int n2 = a2 == null ? 0 : a2.order();
return n1 > n2 ? 1 : -1;
}
}
package rmb.report.framework.annotation;
import java.lang.annotation.*;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Fixed {
//长度
int length();
//位置
int order();
//值不足时填充方向,默认右填充
String direct() default "right";
//填充字符,默认空格
String fill() default " ";
}
\ No newline at end of file
package rmb.report.framework.annotation;
import java.lang.reflect.Field;
import java.util.Comparator;
public class FixedComparator implements Comparator<Object>{
public static final Comparator<Object> COMPARATOR = new FixedComparator();
@Override
public int compare(Object o1, Object o2) {
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return -1;
}
if (o2 == null) {
return 1;
}
if (o1.equals(o2)) {
return 0;
}
Fixed a1 = ((Field)o1).getAnnotation(Fixed.class);
Fixed a2 = ((Field)o2).getAnnotation(Fixed.class);
int n1 = a1 == null ? 0 : a1.order();
int n2 = a2 == null ? 0 : a2.order();
return n1 > n2 ? 1 : -1;
}
}
package rmb.report.framework.exception;
public class ConstructException extends RuntimeException{
/**
*
*/
private static final long serialVersionUID = -339780892224228969L;
public ConstructException() {
super();
}
public ConstructException(String msg) {
super(msg);
}
public ConstructException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
public ConstructException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
}
package rmb.report.framework.exception;
public class PacketException extends RuntimeException{
private static final long serialVersionUID = -1536190313303327147L;
public PacketException() {
super();
}
public PacketException(String msg) {
super(msg);
}
public PacketException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
public PacketException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
}
package rmb.report.framework.exception;
public class SignException extends RuntimeException{
private static final long serialVersionUID = -1536190313303327147L;
public SignException() {
super();
}
public SignException(String msg) {
super(msg);
}
public SignException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
public SignException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
}
package rmb.report.utils;
public abstract class Assert {
protected Assert() {
}
public static void notNull(Object obj, String message) {
if (obj == null) {
throw new IllegalArgumentException(message);
}
}
public static void notNullByArray(Object[] obj, String message) {
if (obj == null || obj.length == 0) {
throw new IllegalArgumentException(message);
}
}
public static void state(boolean expression, String message) {
if (!expression) {
throw new IllegalStateException(message);
}
}
}
package rmb.report.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import java.util.List;
public class FastJsonUtil {
private static final SerializeConfig config;
static {
config = new SerializeConfig();
}
private static final SerializerFeature[] features = {
SerializerFeature.WriteMapNullValue, // 输出空置字段
SerializerFeature.WriteNullListAsEmpty, // list字段如果为null,输出为[],而不是null
SerializerFeature.WriteNullNumberAsZero, // 数值字段如果为null,输出为0,而不是null
SerializerFeature.WriteNullBooleanAsFalse, // Boolean字段如果为null,输出为false,而不是null
SerializerFeature.WriteNullStringAsEmpty // 字符类型字段如果为null,输出为"",而不是null
};
/**
* 转换成字符串
*
* @param object
* @return
*/
public static String toJSONString(Object object) {
return JSON.toJSONString(object, config);
}
/**
* 转换成字符串
*
* @param object
* @return
*/
public static String toJSONString(Object object,SimplePropertyPreFilter filter) {
return JSON.toJSONString(object, filter, new SerializerFeature[]{});
}
/**
* 转换成字符串 ,带有过滤器
*
* @param object
* @return
*/
public static String toJSONWithFeatures(Object object) {
return JSON.toJSONString(object, config, features);
}
/**
* 转成bean对象
*
* @param text
* @return
*/
public static Object toBean(String text) {
return JSON.parseObject(text);
}
/**
* 转成具体的泛型bean对象
*
* @param text
* @param clazz
* @param <T>
* @return
*/
public static <T> T toBean(String text, Class<T> clazz) {
return JSON.parseObject(text, clazz);
}
/**
* 转换为数组Array
*
* @param text
* @param <T>
* @return
*/
public static <T> Object[] toArray(String text) {
return JSON.parseArray(text).toArray();
}
/**
* 转换为具体的泛型数组Array
*
* @param text
* @param clazz
* @param <T>
* @return
*/
public static <T> Object[] toArray(String text, Class<T> clazz) {
return JSON.parseArray(text, clazz).toArray();
}
/**
* 转换为具体的泛型List
* @param text
* @param clazz
* @param <T>
* @return
*/
public static <T> List<T> toList(String text, Class<T> clazz) {
return JSON.parseArray(text, clazz);
}
}
package rmb.report.utils;
import org.bouncycastle.util.encoders.Base64;
import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class StringUtil {
private static final char[] DIGITS_LOWER = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
private static final int Max = Integer.MAX_VALUE;
public static boolean isEmpty(String str) {
return str == null || str.length() == 0;
}
public static boolean isNotEmpty(String str) {
return !isEmpty(str);
}
public static String file2Base64Str(String FilePath, String charset) throws UnsupportedEncodingException {
byte[] fileBytes = file2Bytes(FilePath);
String fileStr = null;
if (fileBytes != null) {
fileStr = new String(Base64.encode(fileBytes), charset);
}
return fileStr;
}
public static void base64Str2File(String base64Str, String FilePath) {
byte[] fileBytes = Base64.decode(base64Str);
writeBytes2File(fileBytes, FilePath, false);
}
private static void writeBytes2File(byte[] fileBytes, String filePath, boolean isAppend) {
File file = createFile(filePath);
FileOutputStream out = null;
try {
out = new FileOutputStream(file, isAppend);
out.write(fileBytes, 0, fileBytes.length);
out.flush();
} catch (IOException e1) {
throw new RuntimeException(e1);
} finally {
if (null != out) {
try {
out.close();
} catch (Exception e2) {
}
}
}
}
private static byte[] file2Bytes(String filePath) {
File file = createFile(filePath);
long len = file.length();
if (len >= Max) {
throw new RuntimeException("File is larger then max array size");
} else {
byte[] bytes = new byte[(int) len];
FileInputStream in = null;
try {
in = new FileInputStream(file);
int readLength = in.read(bytes);
if ((long) readLength < len) {
throw new IOException(String.format("File length is [%d] but read [%d]!", new Object[]{len, readLength}));
}
} catch (Exception e1) {
throw new RuntimeException(e1);
} finally {
if (null != in) {
try {
in.close();
} catch (Exception e2) {
}
}
}
return bytes;
}
}
private static File createFile(String filePath) {
File file = new File(filePath);
if (!file.exists()) {
File parentFile = file.getParentFile();
if (null != parentFile && !parentFile.exists()) {
parentFile.mkdirs();
}
try {
file.createNewFile();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return file;
}
public static String md5Hex(String data, String charset) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(data.getBytes(charset));
byte[] md5Bytes = md5.digest();
return encodeHexStr(md5Bytes);
}
public static String encodeHexStr(byte[] data) {
return new String(encodeHex(data));
}
public static char[] encodeHex(byte[] data) {
int len = data.length;
char[] out = new char[len << 1];
int i = 0;
for (int j = 0; i < len; ++i) {
out[j++] = DIGITS_LOWER[(data[i] >>> 4) & 0xF];
out[j++] = DIGITS_LOWER[0xF & data[i]];
}
return out;
}
}
package rmb.report.utils;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.SchemaOutputResolver;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.io.IOException;
public class XsdUtil {
public CustomSchemaOutputResolver resolver;
public void createXSD(Class<?>[] classes) {
try {
JAXBContext context = JAXBContext.newInstance(classes);
context.generateSchema(resolver);
} catch (JAXBException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public class CustomSchemaOutputResolver extends SchemaOutputResolver {
private File file;
public CustomSchemaOutputResolver(String dir, String fileName) {
try {
file = new File(dir, fileName);
if (!file.exists()) {
file.createNewFile();
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
return new StreamResult(file);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment