From cd93b3f1992cad3f2940e201fc7d3236fac9d7c0 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 11 八月 2020 15:30:26 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/utils/Struct.java |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/zy/common/utils/Struct.java b/src/main/java/com/zy/common/utils/Struct.java
index 9f960a0..0ee0939 100644
--- a/src/main/java/com/zy/common/utils/Struct.java
+++ b/src/main/java/com/zy/common/utils/Struct.java
@@ -24,6 +24,7 @@
 	
 	private transient Map<String,byte[]> decodeByteMapping = new HashMap<>();
 	private transient Map<String,byte[]> encodeByteMapping = new HashMap<>();
+	// 瑙g爜鍓嶇殑鍘熺敓瀛楄妭鏁扮粍
 	private transient byte[] dataBytes = null;
 	private transient byte[] decodeBytes = null;
 	private transient byte[] encodeBytes = null;
@@ -247,6 +248,9 @@
 		return instance.decode(bytes);
 	}
 
+	/**
+	 * 瑙g爜锛� 瀛楄妭鏁扮粍 ====>> java瀵硅薄
+	 */
 	@SuppressWarnings({ "unchecked", "rawtypes" })
 	public <T extends Struct> T decode(byte[] bytes) throws Exception{
 		this.dataBytes = bytes;
@@ -254,6 +258,7 @@
 		Class<? extends Struct> cls = this.getClass();
 		Field[] fields = cls.getFields();
 		if(this.decodeByteMapping==null)instance.decodeByteMapping=new HashMap();
+		// spring el琛ㄨ揪寮�
 		EvaluationContext context = new StandardEvaluationContext();
 		context.setVariable("_", bytes.length);
 		int bited = 0;//宸茶浣嶆暟
@@ -262,9 +267,9 @@
 			bit bit = field.getAnnotation(bit.class);
 			expr expr = field.getAnnotation(expr.class);
 			flag flag = field.getAnnotation(flag.class);
+			// 娌℃湁size銆乥it銆乪xpr娉ㄨВ鐨勫彉閲忎笉杩涜瑙f瀽
 			if(size==null && bit==null && expr==null){
 				continue;
-				//throw new RuntimeException(cls.getSimpleName()+"瀛楁"+field.getName()+"鏈爣璁癅size|@bit|@expr");
 			}
 			String name = field.getName();
 			Class<?> type = field.getType();
@@ -365,10 +370,12 @@
 		instance.unusedBytes = unusedBytes;
 		return (T) instance;
 	}
+
+	// 瀛楄妭鏁扮粍 ===>> 杞负鍗佸叚杩涘埗瀛楃涓�
 	public static String toHex(byte[] bytes) {
         StringBuilder buf = new StringBuilder(bytes.length * 2);
         for(byte b : bytes) { // 浣跨敤String鐨刦ormat鏂规硶杩涜杞崲
-            buf.append(String.format("%02x", new Integer(b & 0xff)));
+            buf.append(String.format("%02x", b & 0xff));
         }
         return buf.toString().toUpperCase();
     }
@@ -439,7 +446,6 @@
 		}
 		return bbt;
 	}
-    
     
     public static class TestMessage {
 		public @size(1) byte begin = 0x7e;//璧峰绗�

--
Gitblit v1.9.1