驼峰与下划线之间的转换

更新时间:2023-05-16 03:36:50 阅读: 评论:0

温度计英文驼峰与下划线之间的转换驼峰与下划线之间的转换
/**
*
*/
package com;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;属蛇的最佳配偶
/**
* @author xp test5.java 2018年12⽉27⽇
*/
十二生肖排名
public class test5 {
public static void main(String[] args) {
//underscoreName("abcAbcaBc");
//camelName("abc_abca_bc");
//upcaCamelName("abc_abca_bc");
Map<String, Object> data= new HashMap<String, Object>();
data.put("Abc_Abca_Bc_TEXT", "");
camelMap(data);
//underscopeMap(data);
}
//驼峰转⼤写+下划线,abcAbcaBc->ABC_ABCA_BC
public static String underscoreName(String name) {
StringBuilder result = new StringBuilder();
if ((name != null) && (name.length() > 0)) {
result.append(name.substring(0, 1).toUpperCa());
for (int i = 1; i < name.length(); i++) {
String s = name.substring(i, i + 1);
if ((s.UpperCa())) && (!Character.isDigit(s.charAt(0)))) {
result.append("_");
}
result.UpperCa());
}
}
String();
}
//下划线转驼峰,abc_abca_bc->abcAbcaBc
public static String camelName(String name) {
StringBuilder result = new StringBuilder();
if ((name == null) || (name.isEmpty())) {
return "";
}
if (!ains("_")) {
LowerCa();
}
String[] camels = name.split("_");
for (String camel : camels) {
if (!camel.isEmpty()) {
过油肉
if (result.length() == 0) {
result.LowerCa());
} el {
result.append(camel.substring(0, 1).toUpperCa());
result.append(camel.substring(1).toLowerCa());
}
}
}
String();
}
//下划线转⾸字母⼤写驼峰,abc_abca_bc->AbcAbcaBc
public static String upcaCamelName(String name) {
猪和兔相配婚姻如何StringBuilder result = new StringBuilder();
if ((name == null) || (name.isEmpty())) {
return "";
中秋节小故事}
if (!ains("_")) {
result.append(name.substring(0, 1).toUpperCa());
result.append(name.substring(1).toLowerCa());
String();
}
String[] camels = name.split("_");
for (String camel : camels) {
if (!camel.isEmpty()) {
result.append(camel.substring(0, 1).toUpperCa());
result.append(camel.substring(1).toLowerCa());
}
}
String();
}
public static Map<String, Object> camelMap(Map<String, Object> data) {
if (data == null) {
return null;
}
Map<String, Object> ret = new HashMap<>();
Iterator<String> keyIt = data.keySet().iterator();
while (keyIt.hasNext()) {
String key = (String) ();
ret.put(camelName(key), (key));
if (dsWith("_TEXT")) {
String key1 = key.substring(0, key.lastIndexOf("_"));
ret.put(camelName(key1) + "_Text", (key));
}
}
return ret;
}
public static Map<String, Object> underscopeMap(Map<String, Object> data) {  if (data == null) {
return null;
}
Map<String, Object> ret = new HashMap<>();
Iterator<String> keyIt = data.keySet().iterator();
while (keyIt.hasNext()) {
欠款起诉书
String key = (String) ();
ret.put(underscoreName(key), (key));
}
return ret;
win7图片}
}

本文发布于:2023-05-16 03:36:50,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/902036.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:驼峰   相配   起诉书   婚姻   欠款   温度计
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图