当前位置:网站首页>解析小结—自用
解析小结—自用
2022-07-31 03:00:00 【杰拉德·皮克·谢】
解析小结
- 解析流程
- 知识点
- [基于java Files类和Paths类的用法(详解)](https://www.jb51.net/article/129130.htm)
- [files.lines()方法以 :Stream流的形式读取文件的所有行](https://blog.csdn.net/JewaveOxford/article/details/108404857)
- Pattern.compile()Pattern.compile函数提取字符串中指定的字符
- [replaceAll() 方法使用给定的参数 replacement 替换字符串所有匹配给定的正则表达式的子字符串](https://www.runoob.com/java/java-string-replaceall.html )
- [substring() substring() 方法用于提取字符串中介于两个指定下标之间的字符。](https://www.w3school.com.cn/js/jsref_substring.asp)
- Character.isUpperCase()
- Java反射技术详解
- XML解析
- BigInteger bigInteger = new BigInteger(substring,2);转化超大二进制
- Document对象
- 代码
解析流程
1 拿到文件
// RedisUtils 见详情
byte[] o = (byte[]) redisUtils.get("128.0.1.13_5005:TCC:50:46:1618883189519");
RedisUtils
2 转化进制
// ByteToObjectUtils 见详情
String binaryStr = ByteToObjectUtils.bytes16toBinaryStr(o);
进入解析流程
1.解析XML
2.获取XML标签内容(解xml文件成想要的数据格式)
getChildNode()
知识点
基于java Files类和Paths类的用法(详解)
Path用于来表示文件路径和文件。可以有多种方法来构造一个Path对象来表示一个文件路径,或者一个文件
files.lines()方法以 :Stream流的形式读取文件的所有行
Pattern.compile()Pattern.compile函数提取字符串中指定的字符
replaceAll() 方法使用给定的参数 replacement 替换字符串所有匹配给定的正则表达式的子字符串
substring() substring() 方法用于提取字符串中介于两个指定下标之间的字符。
Character.isUpperCase()
Java反射技术详解
XML解析
BigInteger bigInteger = new BigInteger(substring,2);转化超大二进制
Document对象
代码
package com.xx.project.common.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.xx.project.common.XmlConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.io.ClassPathResource;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
;
@Slf4j
public class XmlToData {
public static Object getXmlFile(String resourcePath, String binaryStr) {
if (StringUtils.isBlank(binaryStr)) {
return null;
}
JSONArray childNode = new JSONArray();
// 解析xml文件
// 1、获取InputStream输入流
try (InputStream in = new ClassPathResource(resourcePath).getInputStream()) {
// 2、获取DocumentBuilderFactory实例
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// 3、获取DocumentBuilder实例
DocumentBuilder docBuilder = factory.newDocumentBuilder();
// 4、将docBuilder转换为Document
Document doc = docBuilder.parse(in);
// 5、获取节点并循环输出节点值 根节点
Element element = doc.getDocumentElement();
//将xml标签从对象中取出 子节点
NodeList childNodes = element.getChildNodes();
if (childNodes != null) {
//递归读取节点列表中子节点包括内容数据
childNode = getChildNode(childNodes);
}
} catch (Exception e) {
log.error("loadXmlFile is error", e);
}
int bigSet = 0;
// 公共包头解析
JSONArray titleArray = getTitleArray("title.xml");
Map<String, Object> headerData = getStationData(titleArray, binaryStr, bigSet);
if (Objects.nonNull(headerData.get("bigSet"))) {
bigSet = Integer.parseInt(headerData.get("bigSet").toString());
}
if (Objects.isNull(headerData.get("Herder"))) {
return null;
}
Object header = headerData.get("Herder");
JSONObject object = JSONObject.parseObject(JSON.toJSONString(header));
if (Objects.isNull(object.get("length")) || object.getIntValue("length") == 0) {
return null;
}
Map<String, Object> stationData = null;
Map<String, Object> queryMap = new HashMap<>();
switch (object.getIntValue("Type")) {
case XmlConstant.BP:
stationData = getStationData(childNode, binaryStr, bigSet);
System.out.println(stationData);
break;
case XmlConstant.W:
stationData = getStationData(childNode, binaryStr, bigSet);
break;
default:
queryMap = getData(childNode, queryMap, null, binaryStr, bigSet, null, false);
break;
}
if (MapUtils.isNotEmpty(queryMap)) {
return queryMap;
} else {
return stationData;
}
}
private static JSONArray getTitleArray(String resourcePath) {
JSONArray childNode = new JSONArray();
// 解析xml文件
// 1、获取InputStream输入流
try (InputStream in = new ClassPathResource(resourcePath).getInputStream()) {
// 2、获取DocumentBuilderFactory实例
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// 3、获取DocumentBuilder实例
DocumentBuilder docBuilder = factory.newDocumentBuilder();
// 4、将docBuilder转换为Document
Document doc = docBuilder.parse(in);
// 5、获取节点并循环输出节点值
Element element = doc.getDocumentElement();
//将xml标签从对象中取出
NodeList childNodes = element.getChildNodes();
if (childNodes != null) {
//递归读取节点列表中子节点包括内容数据
childNode = getChildNode(childNodes);
}
} catch (Exception e) {
log.error("loadXmlFile is error", e);
}
return childNode;
}
private static JSONArray getChildNode(NodeList childNodes) {
JSONArray resArray = new JSONArray();
try {
for (int i = 0; i < childNodes.getLength(); i++) {
JSONObject resObj = new JSONObject();
/** * 返回节点列表中指定索引号的节点。 * https://www.w3cschool.cn/xmldom/dom-nodelist.html(nodeList) * https://www.runoob.com/dom/dom-node.html(node) */
Node node = childNodes.item(i);
/** * NamedNodeMap * getNamedItem(name) 返回nodeName属性等于name的节点 */
NamedNodeMap attributes = node.getAttributes();
if (attributes != null) {
/** * 当前节点名字 *<category></category> * <segment></segment> * ... */
switch (node.getNodeName()) {
/** * 当前节点下的内容放在PUT中 */
case "category":
if (attributes.getNamedItem("name_CN") != null) {
/** * name_CN 的内容 */
resObj.put("name", attributes.getNamedItem("name_CN").getTextContent());
}
resObj.put("label", "category");
if (attributes.getNamedItem("type") != null) {
resObj.put("type", attributes.getNamedItem("type").getTextContent());
}
if (attributes.getNamedItem("name_EN") != null) {
resObj.put("name_e", attributes.getNamedItem("name_EN").getTextContent());
}
/** * 得到getChildNodes()每一个节点的子节点 */
NodeList categoryNodes = node.getChildNodes();
if (categoryNodes != null) {
//递归调用
JSONArray child = getChildNode(categoryNodes);
if (child.size() > 0) {
resObj.put("categoryChild", child);
}
break;
}
case "segment":
if (attributes.getNamedItem("name_CN") != null) {
resObj.put("name", attributes.getNamedItem("name_CN").getTextContent());
}
if (attributes.getNamedItem("name_EN") != null) {
resObj.put("name_e", attributes.getNamedItem("name_EN").getTextContent());
}
if (attributes.getNamedItem("length") != null) {
resObj.put("length", attributes.getNamedItem("length").getTextContent());
} else if (attributes.getNamedItem("length") != null && attributes.getNamedItem("name_CN") != null) {
resObj.put("name", "预留");
}
if (!resObj.isEmpty()) {
resObj.put("label", "segment");
}
if (attributes.getNamedItem("relateloop") != null) {
resObj.put("relateloop", attributes.getNamedItem("relateloop").getTextContent());
resObj.put("name", "loopRelation");
}
NodeList resNodes = node.getChildNodes();
if (resNodes != null) {
JSONArray child = getChildNode(resNodes);
if (child.size() > 0) {
resObj.put("segmentChild", child);
}
}
break;
case "group":
if (attributes.getNamedItem("name_CN") != null) {
resObj.put("name", attributes.getNamedItem("name_CN").getTextContent());
}
if (attributes.getNamedItem("name_EN") != null) {
resObj.put("name_e", attributes.getNamedItem("name_EN").getTextContent());
}
resObj.put("label", "group");
if (attributes.getNamedItem("length") != null) {
resObj.put("length", attributes.getNamedItem("length").getTextContent());
}
NodeList groupNodes = node.getChildNodes();
if (groupNodes != null) {
JSONArray child = getChildNode(groupNodes);
if (child.size() > 0) {
resObj.put("groupChild", child);
}
}
break;
case "branch":
if (attributes.getNamedItem("name_CN") != null) {
resObj.put("name", attributes.getNamedItem("name_CN").getTextContent());
}
if (attributes.getNamedItem("name_EN") != null) {
resObj.put("name_e", attributes.getNamedItem("name_EN").getTextContent());
}
resObj.put("label", "branch");
if (attributes.getNamedItem("position") != null) {
resObj.put("position", attributes.getNamedItem("position").getTextContent());
}
NodeList branchNodes = node.getChildNodes();
if (branchNodes != null) {
//递归调用
JSONArray child = getChildNode(branchNodes);
if (child.size() > 0) {
resObj.put("branchChild", child);
}
}
break;
case "loop":
resObj.put("label", "loop");
if (attributes.getNamedItem("looptime") != null) {
resObj.put("looptime", attributes.getNamedItem("looptime").getTextContent());
}
if (attributes.getNamedItem("relateloop") != null) {
resObj.put("relateloop", attributes.getNamedItem("relateloop").getTextContent());
}
if (attributes.getNamedItem("name_CN") != null) {
resObj.put("name", attributes.getNamedItem("name_CN").getTextContent());
}
//是否需要排序
if (attributes.getNamedItem("order") != null) {
resObj.put("order", attributes.getNamedItem("order").getTextContent());
}
//是否需要除以单位
if (attributes.getNamedItem("isRemoved") != null) {
resObj.put("isRemoved", attributes.getNamedItem("isRemoved").getTextContent());
}
if (attributes.getNamedItem("name_EN") != null) {
resObj.put("name_e", attributes.getNamedItem("name_EN").getTextContent());
}
//是否需要索引
if (attributes.getNamedItem("isIndex") != null) {
resObj.put("isIndex", attributes.getNamedItem("isIndex").getTextContent());
}
NodeList loopNodes = node.getChildNodes();
if (loopNodes != null) {
//递归调用
JSONArray child = getChildNode(loopNodes);
if (child.size() > 0) {
resObj.put("loopChild", child);
}
}
break;
case "value":
//提取xml文件中type内容 需要什么值直接在这里添加就ok
//只需要xml添加的字段和 下面的key一样就可以
resObj.put("label", "value");
if (attributes.getNamedItem("name_CN") != null) {
resObj.put("name", attributes.getNamedItem("name_CN").getTextContent());
}
if (attributes.getNamedItem("name_EN") != null) {
resObj.put("name_e", attributes.getNamedItem("name_EN").getTextContent());
}
if (attributes.getNamedItem("number") != null) {
resObj.put("number", attributes.getNamedItem("number").getTextContent());
}
if (attributes.getNamedItem("other") != null) {
resObj.put("number", attributes.getNamedItem("other").getTextContent());
}
if (attributes.getNamedItem("isUnit") != null) {
resObj.put("isUnit", attributes.getNamedItem("isUnit").getTextContent());
}
if (attributes.getNamedItem("unit") != null) {
resObj.put("unit", attributes.getNamedItem("unit").getTextContent());
}
NodeList valueNodes = node.getChildNodes();
if (valueNodes != null) {
//递归调用
JSONArray child = getChildNode(valueNodes);
if (child.size() > 0) {
resObj.put("valueChild", child);
}
}
break;
default:
}
}
}
} catch (Exception e) {
log.error("loadXmlFile: getChildNode is error", e);
throw e;
}
return resArray;
}
private static Map<String, Object> getStationData(JSONArray childNode, String binaryStr, int bigSet) {
Map<String, Object> queryMap = new HashMap<>();
for (int j = 0; j < childNode.size(); j++) {
/** * JSON.toJSONString(childNode.get(j)) 转 String * JSONObject.parseObject(String str)转对象 */
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(childNode.get(j)));
if (StringUtils.isEmpty(jsonObject.getString("name_e"))) {
continue;
}
String enName = jsonObject.getString("name_e");
String length = "";
if (Objects.nonNull(jsonObject.getString("length"))) {
length = jsonObject.getString("length");
}
if (Objects.nonNull(jsonObject.get("label")) && CollectionUtils.isNotEmpty(jsonObject.getJSONArray(jsonObject.getString("label") + "Child"))) {
StringBuilder value = new StringBuilder("");
// 子标签集合内容
JSONArray childList = jsonObject.getJSONArray(jsonObject.getString("label") + "Child");
if (jsonObject.getString("label").equals("group")) {
String[] groupSp;
/** * 条件过滤 */
List<Object> collect = childList.stream().filter(s -> Objects.nonNull(JSONObject.parseObject(JSON.toJSONString(s)).get("position")) &&
JSONObject.parseObject(JSON.toJSONString(s)).get("position").equals("true")).collect(Collectors.toList());
boolean flag = true;
/** * 循环子节点 */
for (Object item : childList) {
JSONObject branchObject = JSONObject.parseObject(JSON.toJSONString(item));
groupSp = length.split(",");
if (CollectionUtils.isNotEmpty(collect) && flag) {
/** * 字符串连接 */
value.append(branchObject.getString("name"));
flag = false;
} else if (CollectionUtils.isNotEmpty(collect) && Integer.parseInt(JSONObject.parseObject(JSON.toJSONString(item)).getString("position")) > 1) {
int branchLength = Integer.parseInt(groupSp[branchObject.getInteger("position") - 2]);
if (bigSet >= binaryStr.length()) {
return queryMap;
}
/** * 第一个int为开始的索引,对应String数字中的开始位置, * 第二个是截止的索引位置,对应String中的结束位置 */
String substring = binaryStr.substring(bigSet, bigSet + branchLength);
/** * 转化进制 */
BigInteger num = new BigInteger(substring, 2);
value.append(num).append(branchObject.getString("name"));
bigSet += branchLength;
} else {
int branchLength = Integer.parseInt(groupSp[branchObject.getInteger("position") - 1]);
if (bigSet >= binaryStr.length()) {
return queryMap;
}
String substring = binaryStr.substring(bigSet, bigSet + branchLength);
BigInteger num = new BigInteger(substring, 2);
value.append(num).append(branchObject.getString("name"));
bigSet += branchLength;
}
}
queryMap.put("bigSet", bigSet);
queryMap.put(enName, value.toString());
} else if (jsonObject.getString("label").equals("segment")) {
int longLength = Integer.parseInt(length);
if (bigSet >= binaryStr.length()) {
return queryMap;
}
String substring = binaryStr.substring(bigSet, bigSet + longLength);
for (Object segmentObj : childList) {
JSONObject valueObject = JSONObject.parseObject(JSON.toJSONString(segmentObj));
String number = valueObject.getString("number");
if (number.contains("0x")) {
number = number.replace("0x", "");
BigInteger tenValue = new BigInteger(number, 16);
BigInteger twoToTen = new BigInteger(substring, 2);
if (tenValue.equals(twoToTen)) {
if (StringUtils.isBlank(value)) {
value.append(tenValue);
}
}
}
}
if (StringUtils.isBlank(value.toString())) {
List<Object> collect = childList.stream().filter(s -> Objects.nonNull(JSONObject.parseObject(JSON.toJSONString(s)).get("number")) && JSONObject.parseObject(JSON.toJSONString(s)).get("number").equals("true")).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
value = new StringBuilder(JSONObject.parseObject(JSON.toJSONString(collect.get(0))).getString("name"));
}
}
if (StringUtils.isNotEmpty(jsonObject.getString("relateloop"))) {
int loopNum = Integer.parseInt(substring, 2);
queryMap.put("relateNum", loopNum);
queryMap.put("relateName", jsonObject.getString("relateloop"));
}
bigSet += longLength;
queryMap.put(enName, value);
queryMap.put("bigSet", bigSet);
} else if (jsonObject.getString("label").equals("loop")) {
Integer loopTime = 0;
if (Objects.nonNull(jsonObject.get("relateloop")) && jsonObject.getString("relateloop").equals("true")) {
if (Objects.nonNull(queryMap.get("relateName")) && Objects.nonNull(queryMap.get("relateName"))) {
loopTime = Integer.valueOf(queryMap.get("relateNum").toString());
}
} else {
loopTime = jsonObject.getInteger("looptime");
}
if (Objects.nonNull(jsonObject.get("isRemoved"))) {
Integer isRemoved = jsonObject.getInteger("isRemoved");
loopTime = loopTime / isRemoved;
}
List<Map<String, Object>> dataList = new ArrayList<>();
for (int i = 0; i < loopTime; i++) {
Map<String, Object> stationData = getStationData(childList, binaryStr, bigSet);
if (Objects.nonNull(stationData.get("bigSet"))) {
bigSet = Integer.parseInt(stationData.get("bigSet").toString());
}
stationData.remove("relateNum");
stationData.remove("relateName");
dataList.add(stationData);
}
queryMap.put(enName, dataList);
queryMap.put("bigSet", bigSet);
} else {
// 迭代
Map<String, Object> label = getStationData(jsonObject.getJSONArray(jsonObject.getString("label") + "Child"), binaryStr, bigSet);
if (Objects.nonNull(label.get("bigSet"))) {
bigSet = Integer.parseInt(label.get("bigSet").toString());
}
label.remove("relateNum");
label.remove("relateName");
queryMap.put(enName, label);
queryMap.put("bigSet", bigSet);
}
} else {
if (bigSet >= binaryStr.length()) {
return queryMap;
}
int longLength = Integer.parseInt(length);
String substring = binaryStr.substring(bigSet, bigSet + longLength);
bigSet += longLength;
BigInteger bigInteger = new BigInteger(substring, 2);
if (StringUtils.isNotEmpty(jsonObject.getString("relateloop"))) {
queryMap.put("relateNum", bigInteger);
queryMap.put("relateName", jsonObject.getString("relateloop"));
}
queryMap.put(enName, bigInteger);
queryMap.put("bigSet", bigSet);
}
}
queryMap.remove("relateNum");
queryMap.remove("relateName");
return queryMap;
}
/** * byte数组->xml对应解析 * * @param childNode * @param queryMap * @param numList * @return */
private static Map<String, Object> getData(JSONArray childNode, Map<String, Object> queryMap, List<Integer> numList, String binaryStr, int bigSet, String order, boolean idIndex) {
List<String> suffixList = new LinkedList<>();
if (CollectionUtils.isNotEmpty(numList)) {
if (numList.size() == 1) {
suffixList.add(String.valueOf(numList.get(0)));
} else {
for (Integer num : numList) {
suffixList.add(String.valueOf(num));
}
}
}
for (int j = 0; j < childNode.size(); j++) {
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(childNode.get(j)));
String length = "";
if (Objects.nonNull(jsonObject.getString("length"))) {
length = jsonObject.getString("length");
}
if (StringUtils.isEmpty(jsonObject.getString("name")) && StringUtils.isNotBlank(length)) {
bigSet += Integer.parseInt(length);
continue;
}
String englishName = "";
if ((CollectionUtils.isNotEmpty(suffixList) && idIndex) && childNode.size() == suffixList.size()) {
englishName = jsonObject.getString("name_e") + suffixList.get(j);
} else {
englishName = jsonObject.getString("name_e");
}
if (CollectionUtils.isNotEmpty(jsonObject.getJSONArray(jsonObject.getString("label") + "Child"))) {
JSONArray groupList = jsonObject.getJSONArray(jsonObject.getString("label") + "Child");
StringBuilder value = new StringBuilder();
if (jsonObject.getString("label").equals("group")) {
String[] groupSp;
List<Object> collect = groupList.stream().filter(s -> Objects.nonNull(JSONObject.parseObject(JSON.toJSONString(s)).get("position")) && JSONObject.parseObject(JSON.toJSONString(s)).get("position").equals("true")).collect(Collectors.toList());
boolean flag = true;
for (Object item : groupList) {
JSONObject branchObject = JSONObject.parseObject(JSON.toJSONString(item));
groupSp = length.split(",");
if (CollectionUtils.isNotEmpty(collect) && flag) {
value = new StringBuilder(branchObject.getString("name"));
flag = false;
} else if (CollectionUtils.isNotEmpty(collect) && Integer.parseInt(JSONObject.parseObject(JSON.toJSONString(item)).getString("position")) > 1) {
int branchLength = Integer.parseInt(groupSp[branchObject.getInteger("position") - 2]);
if (bigSet >= binaryStr.length()) {
return queryMap;
}
String substring = binaryStr.substring(bigSet, bigSet + branchLength);
BigInteger num = new BigInteger(substring, 2);
value.append(num).append(branchObject.getString("name"));
bigSet += branchLength;
} else {
int branchLength = Integer.parseInt(groupSp[branchObject.getInteger("position") - 1]);
if (bigSet >= binaryStr.length()) {
return queryMap;
}
String substring = binaryStr.substring(bigSet, bigSet + branchLength);
BigInteger num = new BigInteger(substring, 2);
value.append(num).append(branchObject.getString("name"));
bigSet += branchLength;
}
}
queryMap.put(englishName, value.toString());
} else if (jsonObject.getString("label").equals("segment")) {
int longLength = Integer.parseInt(length);
if (bigSet >= binaryStr.length()) {
return queryMap;
}
String substring = binaryStr.substring(bigSet, bigSet + longLength);
for (Object segmentObj : groupList) {
JSONObject valueObject = JSONObject.parseObject(JSON.toJSONString(segmentObj));
String number = valueObject.getString("number");
if (number.contains("0x")) {
number = number.replace("0x", "");
BigInteger tenValue = new BigInteger(number, 16);
BigInteger twoToTen = new BigInteger(substring, 2);
if (tenValue.equals(twoToTen)) {
value.append(valueObject.getString("name"));
}
}
}
if (StringUtils.isBlank(value.toString())) {
List<Object> collect = groupList.stream().filter(s -> Objects.nonNull(JSONObject.parseObject(JSON.toJSONString(s)).get("number")) && JSONObject.parseObject(JSON.toJSONString(s)).get("number").equals("true")).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
value.append(JSONObject.parseObject(JSON.toJSONString(collect.get(0))).getString("name"));
}
}
queryMap.put(englishName, value);
if (StringUtils.isNotEmpty(jsonObject.getString("relateloop"))) {
BigInteger loopNum = new BigInteger(substring, 2);
queryMap.put("relateNum", loopNum);
queryMap.put("relateName", jsonObject.getString("relateloop"));
}
bigSet += longLength;
} else if (jsonObject.getString("label").equals("loop")) {
Integer loopTime = 0;
if (Objects.nonNull(jsonObject.get("relateloop")) && jsonObject.getString("relateloop").equals("true")) {
Object name = queryMap.get(jsonObject.getString("name"));
if (Objects.nonNull(name)) {
loopTime = Integer.valueOf(queryMap.get("relateNum").toString());
}
} else {
loopTime = jsonObject.getInteger("looptime");
}
if (Objects.nonNull(jsonObject.get("isRemoved"))) {
Integer isRemoved = jsonObject.getInteger("isRemoved");
loopTime = loopTime / isRemoved;
}
boolean isIndex = false;
if (Objects.nonNull(jsonObject.get("isIndex"))) {
isIndex = jsonObject.getBoolean("isIndex");
}
int count = 1;
JSONArray label = jsonObject.getJSONArray(jsonObject.getString("label") + "Child");
List<Object> list = new LinkedList<>();
if ((Objects.nonNull(jsonObject.get("order")) && jsonObject.getString("order").equals("desc"))) {
if (label.size() == 2) {
for (int i = 0; i < loopTime; i++) {
Map<String, Object> loopMap = new HashMap<>();
List<Integer> countList = new LinkedList<>();
countList.add(count * 2);
countList.add(count * 2 - 1);
Map<String, Object> desc = getData(label, loopMap, countList, binaryStr, bigSet, "desc", isIndex);
bigSet = Integer.parseInt(desc.get("bigSet").toString());
desc.remove("bigSet");
list.add(desc);
count++;
}
} else if (label.size() == 4) {
for (int i = 0; i < loopTime; i++) {
Map<String, Object> loopMap = new HashMap<>();
List<Integer> countList = new LinkedList<>();
countList.add(count * 4);
countList.add(count * 4 - 1);
countList.add(count * 4 - 2);
countList.add(count * 4 - 3);
Map<String, Object> desc = getData(label, loopMap, countList, binaryStr, bigSet, "desc", isIndex);
bigSet = Integer.parseInt(desc.get("bigSet").toString());
desc.remove("bigSet");
list.add(desc);
count++;
}
}
} else {
for (int i = 0; i < loopTime; i++) {
Map<String, Object> loopMap = new HashMap<>();
List<Integer> countList = new LinkedList<>();
countList.add(count);
Map<String, Object> data = getData(label, loopMap, countList, binaryStr, bigSet, null, isIndex);
bigSet = Integer.parseInt(data.get("bigSet").toString());
data.remove("bigSet");
list.add(data);
count++;
}
}
queryMap.put(englishName, list);
} else {
Map<String, Object> label = getData(jsonObject.getJSONArray(jsonObject.getString("label") + "Child"), queryMap, null, binaryStr, bigSet, null, false);
if (label.get("bigSet") != null) {
bigSet = Integer.parseInt(label.get("bigSet").toString());
label.remove("bigSet");
}
queryMap.put(englishName, label);
}
} else {
if (bigSet >= binaryStr.length()) {
return queryMap;
}
int longLength = Integer.parseInt(length);
String substring = binaryStr.substring(bigSet, bigSet + longLength);
bigSet += longLength;
BigInteger bigInteger = new BigInteger(substring, 2);
if (CollectionUtils.isNotEmpty(suffixList)) {
queryMap.put(englishName + suffixList.get(j), bigInteger);
} else {
queryMap.put(englishName, bigInteger);
}
}
}
queryMap.put("bigSet", bigSet);
return queryMap;
}
}
边栏推荐
- golang GUI for nuxui — HelloWorld
- 什么是分布式锁?实现分布式锁的三种方式
- CorelDRAW2022精简亚太新增功能详细介绍
- 8. Unified exception handling (controller notifies @ControllerAdvice global configuration class, @ExceptionHandler handles exceptions uniformly)
- 19.支持向量机-优化目标和大间距直观理解
- 【Android】Room —— SQLite的替代品
- 多线程下类对象的服务承诺探讨
- 你们程序员为什么不靠自己的项目谋生?而必须为其他人打工?
- Chapter 9 SVM Practice
- 【shell基础】判断目录是否为空
猜你喜欢

什么是系统?

php 网站的多语言设置(IP地址区分国内国外)

CMOS和TTL的区别?

Basic learning about Redis related content

11、Redis实现关注、取消关注以及关注和粉丝列表

Crypto Firms Offer Offer To Theft Hackers: Keep A Little, Give The Rest

接口测试关键技术

CentOS7下mysql5.7.37的安装【完美方案】

Intel's software and hardware optimization empowers Neusoft to accelerate the arrival of the era of smart medical care

Moxa NPort 设备缺陷可能使关键基础设施遭受破坏性攻击
随机推荐
Multilingual settings of php website (IP address distinguishes domestic and foreign)
Installation of mysql5.7.37 under CentOS7 [perfect solution]
工程(五)——小目标检测tph-yolov5
JetPack component Databinding
SonarQube的BUG定义
Uninstallation of mysql5.7.37 under CentOS7 [perfect solution]
Clustering index, and what is the difference between a clustering index
观察者模式
10、Redis实现点赞(Set)和获取总点赞数
Hanyuan Hi-Tech 8-channel HDMI integrated multi-service high-definition video optical transceiver 8-channel HDMI video + 8-channel two-way audio + 8-channel 485 data + 8-channel E1 + 32-channel teleph
SQL注入 Less54(限制次数的SQL注入+union注入)
execsnoop 工具
SQL注入 Less47(报错注入) 和Less49(时间盲注)
The simulation application of common mode inductance is here, full of dry goods for everyone
开题报告之论文框架
Pythagorean tuple od js
测试中的误报和漏报同样的值得反复修正
AI software development process in medical imaging field
JS function this context runtime syntax parentheses array IIFE timer delay self.backup context call apply
php 网站的多语言设置(IP地址区分国内国外)