当前位置: 首页 > news >正文

部落冲突做弊器网站网站排名怎么做上去

部落冲突做弊器网站,网站排名怎么做上去,怎么用word做一个网站,动漫制作与设计专业目前搜索到的大部分代码都存在以下问题: 复杂结构解析丢失解析后顺序错乱 所以自己写了一个,经过不充分测试,基本满足使用。可以直接在线使用 在线地址 除了yml和properties互转之外,还可以生成代码、sql转json等,可…

目前搜索到的大部分代码都存在以下问题:

  • 复杂结构解析丢失
  • 解析后顺序错乱

所以自己写了一个,经过不充分测试,基本满足使用。可以直接在线使用 在线地址
除了yml和properties互转之外,还可以生成代码、sql转json等,可以去用一下,用爱发电,感谢支持!
在这里插入图片描述
源码:

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.yaml.snakeyaml.Yaml;import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;/*** @author Deng.Weiping* @since 2023/11/28 13:57*/
@Slf4j
public class PropertiesUtil {/*** yaml 转 Properties** @param input* @return*/public static String castToProperties(String input) {Map<String, Object> propertiesMap = new LinkedHashMap<>();Map<String, Object> yamlMap = new Yaml().load(input);flattenMap("", yamlMap, propertiesMap);StringBuffer strBuff = new StringBuffer();propertiesMap.forEach((key, value) -> strBuff.append(key).append("=").append(value).append(StrUtil.LF));return strBuff.toString();}/*** Properties 转 Yaml** @param input* @return*/public static String castToYaml(String input) {try {Map<String, Object> properties = readProperties(input);return properties2Yaml(properties);} catch (Exception e) {log.error("property 转 Yaml 转换失败", e);}return null;}private static Map<String, Object> readProperties(String input) throws IOException {Map<String, Object> propertiesMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 保证顺序for (String line : input.split(StrUtil.LF)) {if (StrUtil.isNotBlank(line)) {// 使用正则表达式解析每一行中的键值对Pattern pattern = Pattern.compile("\\s*([^=\\s]*)\\s*=\\s*(.*)\\s*");Matcher matcher = pattern.matcher(line);if (matcher.matches()) {String key = matcher.group(1);String value = matcher.group(2);propertiesMap.put(key, value);}}}return propertiesMap;}/*** 递归 Map 集合,转为 Properties集合** @param prefix* @param yamlMap* @param treeMap*/private static void flattenMap(String prefix, Map<String, Object> yamlMap, Map<String, Object> treeMap) {yamlMap.forEach((key, value) -> {String fullKey = prefix + key;if (value instanceof LinkedHashMap) {flattenMap(fullKey + ".", (LinkedHashMap) value, treeMap);} else if (value instanceof ArrayList) {List values = (ArrayList) value;for (int i = 0; i < values.size(); i++) {String itemKey = String.format("%s[%d]", fullKey, i);Object itemValue = values.get(i);if (itemValue instanceof String) {treeMap.put(itemKey, itemValue);} else {flattenMap(itemKey + ".", (LinkedHashMap) itemValue, treeMap);}}} else {treeMap.put(fullKey, value.toString());}});}/*** properties 格式转化为 yaml 格式字符串** @param properties* @return*/private static String properties2Yaml(Map<String, Object> properties) {if (CollUtil.isEmpty(properties)) {return null;}Map<String, Object> map = parseToMap(properties);StringBuffer stringBuffer = map2Yaml(map);return stringBuffer.toString();}/*** 递归解析为 LinkedHashMap** @param propMap* @return*/private static Map<String, Object> parseToMap(Map<String, Object> propMap) {Map<String, Object> resultMap = new LinkedHashMap<>();try {if (CollectionUtils.isEmpty(propMap)) {return resultMap;}propMap.forEach((key, value) -> {if (key.contains(".")) {String currentKey = key.substring(0, key.indexOf("."));if (resultMap.get(currentKey) != null) {return;}Map<String, Object> childMap = getChildMap(propMap, currentKey);Map<String, Object> map = parseToMap(childMap);resultMap.put(currentKey, map);} else {resultMap.put(key, value);}});} catch (Exception e) {e.printStackTrace();}return resultMap;}/*** 获取拥有相同父级节点的子节点** @param propMap* @param currentKey* @return*/private static Map<String, Object> getChildMap(Map<String, Object> propMap, String currentKey) {Map<String, Object> childMap = new LinkedHashMap<>();try {propMap.forEach((key, value) -> {if (key.contains(currentKey + ".")) {key = key.substring(key.indexOf(".") + 1);childMap.put(key, value);}});} catch (Exception e) {e.printStackTrace();}return childMap;}/*** map集合转化为yaml格式字符串** @param map* @return*/public static StringBuffer map2Yaml(Map<String, Object> map) {//默认deep 为零,表示不空格,deep 每加一层,缩进两个空格return map2Yaml(map, 0);}/*** 把Map集合转化为yaml格式 String字符串** @param propMap map格式配置文件* @param deep    树的层级,默认deep 为零,表示不空格,deep 每加一层,缩进两个空格* @return*/private static StringBuffer map2Yaml(Map<String, Object> propMap, int deep) {StringBuffer yamlBuffer = new StringBuffer();try {if (CollectionUtils.isEmpty(propMap)) {return yamlBuffer;}String space = getSpace(deep);for (Map.Entry<String, Object> entry : propMap.entrySet()) {Object valObj = entry.getValue();if (entry.getKey().contains("[") && entry.getKey().contains("]")) {String key = entry.getKey().substring(0, entry.getKey().indexOf("[")) + ":";yamlBuffer.append(space + key + "\n");propMap.forEach((itemKey, itemValue) -> {if (itemKey.startsWith(key.substring(0, entry.getKey().indexOf("[")))) {yamlBuffer.append(getSpace(deep + 1) + "- ");if (itemValue instanceof Map) {StringBuffer valStr = map2Yaml((Map<String, Object>) itemValue, 0);String[] split = valStr.toString().split(StrUtil.LF);for (int i = 0; i < split.length; i++) {if (i > 0) {yamlBuffer.append(getSpace(deep + 2));}yamlBuffer.append(split[i]).append(StrUtil.LF);}} else {yamlBuffer.append(itemValue + "\n");}}});break;} else {String key = space + entry.getKey() + ":";if (valObj instanceof String) { //值为value 类型,不用再继续遍历yamlBuffer.append(key + " " + valObj + "\n");} else if (valObj instanceof List) { //yaml List 集合格式yamlBuffer.append(key + "\n");List<String> list = (List<String>) entry.getValue();String lSpace = getSpace(deep + 1);for (String str : list) {yamlBuffer.append(lSpace + "- " + str + "\n");}} else if (valObj instanceof Map) { //继续递归遍历Map<String, Object> valMap = (Map<String, Object>) valObj;yamlBuffer.append(key + "\n");StringBuffer valStr = map2Yaml(valMap, deep + 1);yamlBuffer.append(valStr.toString());} else {yamlBuffer.append(key + " " + valObj + "\n");}}}} catch (Exception e) {e.printStackTrace();}return yamlBuffer;}/*** 获取缩进空格** @param deep* @return*/private static String getSpace(int deep) {StringBuffer buffer = new StringBuffer();if (deep == 0) {return "";}for (int i = 0; i < deep; i++) {buffer.append("  ");}return buffer.toString();}}
http://www.hkea.cn/news/462444/

相关文章:

  • 兼容手机的网站百度怎么推广自己的视频
  • 宝安中心医院入职体检跟我学seo
  • 企业网站后端模板石家庄疫情最新情况
  • 沈阳哪家网站做的好网络营销是指什么
  • 我的网站模板网站建设主要推广方式
  • 国外app素材网站seo运营是做什么的
  • 企业网站seo怎么做百度帐号个人中心
  • 郑州网站建设亅汉狮网络百度网盘seo优化
  • 模板型网站seo优化平台
  • 官方网站下载免费软件培训机构有哪些?哪个比较好
  • 网站导航怎么做的惠州seo计费管理
  • 建设公司网站模板全国唯一一个没有疫情的城市
  • 网站怎么做seo_南京百度提升优化
  • 旅游网站开发与设计论文怎么样建网站
  • 北京网站推广排名公司企业网站的搜索引擎推广与优化
  • 动态网站期末设计广告营销策略
  • 山东网站营销推广费用旺道seo推广
  • 邢台网站建设服务周到百度数据分析工具
  • 周口网站建设竞价恶意点击犯法吗
  • 网站建设没有预付款seo快速提升排名
  • 网站开发者的设计构想网络推广平台软件
  • 做立体字的网站重庆seo公司排名
  • 电子商务网站的建设包含哪些流程搜索引擎关键词怎么优化
  • 将自己做的网站发布到谷歌推广新手教程
  • 深圳保障性住房管理办法seo排名优化方法
  • 2022注册公司取名推荐网络营销的优化和推广方式
  • 做网站费是多少贵州二级站seo整站优化排名
  • 做网站潍坊培训课程安排
  • python做网站需要什么seo学习论坛
  • 用手机怎样制作网站网络seo是什么