常量按照规范应该大写

项目中有的地方大写有的小写,统一部分为大写
This commit is contained in:
hanshuai 2020-09-27 12:41:12 +08:00
parent 73cd33450a
commit c0d5751a8b
38 changed files with 374 additions and 374 deletions

View File

@ -41,9 +41,9 @@ public class BeanPath implements Serializable{
private static final long serialVersionUID = 1L;
/** 表达式边界符号数组 */
private static final char[] expChars = { CharUtil.DOT, CharUtil.BRACKET_START, CharUtil.BRACKET_END };
private static final char[] EXP_CHARS = { CharUtil.DOT, CharUtil.BRACKET_START, CharUtil.BRACKET_END };
private boolean isStartWith$ = false;
private boolean isStartWith = false;
protected List<String> patternParts;
/**
@ -154,7 +154,7 @@ public class BeanPath implements Serializable{
subBean = getFieldValue(subBean, patternPart);
if (null == subBean) {
// 支持表达式的第一个对象为Bean本身若用户定义表达式$开头则不做此操作
if (isFirst && false == this.isStartWith$ && BeanUtil.isMatchName(bean, patternPart, true)) {
if (isFirst && false == this.isStartWith && BeanUtil.isMatchName(bean, patternPart, true)) {
subBean = bean;
isFirst = false;
} else {
@ -229,11 +229,11 @@ public class BeanPath implements Serializable{
c = expression.charAt(i);
if (0 == i && '$' == c) {
// 忽略开头的$符表示当前对象
isStartWith$ = true;
isStartWith = true;
continue;
}
if (ArrayUtil.contains(expChars, c)) {
if (ArrayUtil.contains(EXP_CHARS, c)) {
// 处理边界符号
if (CharUtil.BRACKET_END == c) {
// 中括号数字下标结束

View File

@ -17,8 +17,8 @@ public class Base32 {
private Base32() {}
private static final String base32Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
private static final int[] base32Lookup = {//
private static final String BASE32_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
private static final int[] BASE32_LOOKUP = {//
0xFF, 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, // '0', '1', '2', '3', '4', '5', '6', '7'
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // '8', '9', ':', ';', '<', '=', '>', '?'
0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G'
@ -68,7 +68,7 @@ public class Base32 {
i++;
}
}
base32.append(base32Chars.charAt(digit));
base32.append(BASE32_CHARS.charAt(digit));
}
return base32.toString();
@ -120,11 +120,11 @@ public class Base32 {
lookup = base32.charAt(i) - '0';
/* Skip chars outside the lookup table */
if (lookup < 0 || lookup >= base32Lookup.length) {
if (lookup < 0 || lookup >= BASE32_LOOKUP.length) {
continue;
}
digit = base32Lookup[lookup];
digit = BASE32_LOOKUP[lookup];
/* If this digit is not in the table, ignore it */
if (digit == 0xFF) {

View File

@ -19,7 +19,7 @@ import cn.hutool.core.util.StrUtil;
public class Base62 {
private static final Charset DEFAULT_CHARSET = CharsetUtil.CHARSET_UTF_8;
private static final Base62Codec codec = Base62Codec.createGmp();
private static final Base62Codec CODEC = Base62Codec.createGmp();
// -------------------------------------------------------------------- encode
/**
@ -50,7 +50,7 @@ public class Base62 {
* @return 被加密后的字符串
*/
public static String encode(byte[] source) {
return new String(codec.encode(source));
return new String(CODEC.encode(source));
}
/**
@ -144,6 +144,6 @@ public class Base62 {
* @return 解码后的bytes
*/
public static byte[] decode(byte[] base62bytes) {
return codec.decode(base62bytes);
return CODEC.decode(base62bytes);
}
}

View File

@ -9,7 +9,7 @@ package cn.hutool.core.codec;
public class Caesar {
// 26个字母表
public static final String table = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz";
public static final String TABLE = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz";
/**
* 传入明文加密得到密文
@ -63,8 +63,8 @@ public class Caesar {
* @return 加密后的字符
*/
private static char encodeChar(char c, int offset) {
int position = (table.indexOf(c) + offset) % 52;
return table.charAt(position);
int position = (TABLE.indexOf(c) + offset) % 52;
return TABLE.charAt(position);
}
@ -75,11 +75,11 @@ public class Caesar {
* @return 解密后的字符
*/
private static char decodeChar(char c, int offset) {
int position = (table.indexOf(c) - offset) % 52;
int position = (TABLE.indexOf(c) - offset) % 52;
if (position < 0) {
position += 52;
}
return table.charAt(position);
return TABLE.charAt(position);
}
// ----------------------------------------------------------------------------------------- Private method end
}

View File

@ -17,8 +17,8 @@ import cn.hutool.core.util.StrUtil;
*/
public class Morse {
private static final Map<Integer, String> alphabets = new HashMap<>(); // code point -> morse
private static final Map<String, Integer> dictionaries = new HashMap<>(); // morse -> code point
private static final Map<Integer, String> ALPHABETS = new HashMap<>(); // code point -> morse
private static final Map<String, Integer> DICTIONARIES = new HashMap<>(); // morse -> code point
/**
* 注册莫尔斯电码表
@ -27,8 +27,8 @@ public class Morse {
* @param dict 二进制
*/
private static void registerMorse(Character abc, String dict) {
alphabets.put(Integer.valueOf(abc), dict);
dictionaries.put(dict, Integer.valueOf(abc));
ALPHABETS.put(Integer.valueOf(abc), dict);
DICTIONARIES.put(dict, Integer.valueOf(abc));
}
static {
@ -129,7 +129,7 @@ public class Morse {
final int len = text.codePointCount(0, text.length());
for (int i = 0; i < len; i++) {
int codePoint = text.codePointAt(i);
String word = alphabets.get(codePoint);
String word = ALPHABETS.get(codePoint);
if (word == null) {
word = Integer.toBinaryString(codePoint);
}
@ -161,7 +161,7 @@ public class Morse {
continue;
}
word = word.replace(dit, '0').replace(dah, '1');
codePoint = dictionaries.get(word);
codePoint = DICTIONARIES.get(word);
if (codePoint == null) {
codePoint = Integer.valueOf(word, 2);
}

View File

@ -12,22 +12,22 @@ public enum BasicType {
BYTE, SHORT, INT, INTEGER, LONG, DOUBLE, FLOAT, BOOLEAN, CHAR, CHARACTER, STRING;
/** 包装类型为Key原始类型为Value例如 Integer.class =》 int.class. */
public static final Map<Class<?>, Class<?>> wrapperPrimitiveMap = new ConcurrentHashMap<>(8);
public static final Map<Class<?>, Class<?>> WRAPPER_PRIMITIVE_MAP = new ConcurrentHashMap<>(8);
/** 原始类型为Key包装类型为Value例如 int.class =》 Integer.class. */
public static final Map<Class<?>, Class<?>> primitiveWrapperMap = new ConcurrentHashMap<>(8);
public static final Map<Class<?>, Class<?>> PRIMITIVE_WRAPPER_MAP = new ConcurrentHashMap<>(8);
static {
wrapperPrimitiveMap.put(Boolean.class, boolean.class);
wrapperPrimitiveMap.put(Byte.class, byte.class);
wrapperPrimitiveMap.put(Character.class, char.class);
wrapperPrimitiveMap.put(Double.class, double.class);
wrapperPrimitiveMap.put(Float.class, float.class);
wrapperPrimitiveMap.put(Integer.class, int.class);
wrapperPrimitiveMap.put(Long.class, long.class);
wrapperPrimitiveMap.put(Short.class, short.class);
WRAPPER_PRIMITIVE_MAP.put(Boolean.class, boolean.class);
WRAPPER_PRIMITIVE_MAP.put(Byte.class, byte.class);
WRAPPER_PRIMITIVE_MAP.put(Character.class, char.class);
WRAPPER_PRIMITIVE_MAP.put(Double.class, double.class);
WRAPPER_PRIMITIVE_MAP.put(Float.class, float.class);
WRAPPER_PRIMITIVE_MAP.put(Integer.class, int.class);
WRAPPER_PRIMITIVE_MAP.put(Long.class, long.class);
WRAPPER_PRIMITIVE_MAP.put(Short.class, short.class);
for (Map.Entry<Class<?>, Class<?>> entry : wrapperPrimitiveMap.entrySet()) {
primitiveWrapperMap.put(entry.getValue(), entry.getKey());
for (Map.Entry<Class<?>, Class<?>> entry : WRAPPER_PRIMITIVE_MAP.entrySet()) {
PRIMITIVE_WRAPPER_MAP.put(entry.getValue(), entry.getKey());
}
}
@ -40,7 +40,7 @@ public enum BasicType {
if(null == clazz || false == clazz.isPrimitive()){
return clazz;
}
Class<?> result = primitiveWrapperMap.get(clazz);
Class<?> result = PRIMITIVE_WRAPPER_MAP.get(clazz);
return (null == result) ? clazz : result;
}
@ -53,7 +53,7 @@ public enum BasicType {
if(null == clazz || clazz.isPrimitive()){
return clazz;
}
Class<?> result = wrapperPrimitiveMap.get(clazz);
Class<?> result = WRAPPER_PRIMITIVE_MAP.get(clazz);
return (null == result) ? clazz : result;
}
}

View File

@ -18,20 +18,20 @@ public class NumberChineseFormatter {
/**
* 简体中文形式
**/
private static final String[] simpleDigits = {"", "", "", "", "", "", "", "", "", ""};
private static final String[] SIMPLE_DIGITS = {"", "", "", "", "", "", "", "", "", ""};
/**
* 繁体中文形式
**/
private static final String[] traditionalDigits = {"", "", "", "", "", "", "", "", "", ""};
private static final String[] TRADITIONAL_DIGITS = {"", "", "", "", "", "", "", "", "", ""};
/**
* 简体中文单位
**/
private static final String[] simpleUnits = {"", "", "", ""};
private static final String[] SIMPLE_UNITS = {"", "", "", ""};
/**
* 繁体中文单位
**/
private static final String[] traditionalUnits = {"", "", "", ""};
private static final String[] TRADITIONAL_UNITS = {"", "", "", ""};
/**
* 阿拉伯数字转换成中文,小数点后四舍五入保留两位. 使用于整数小数的转换.
@ -53,7 +53,7 @@ public class NumberChineseFormatter {
* @return 中文
*/
public static String format(double amount, boolean isUseTraditional, boolean isMoneyMode) {
final String[] numArray = isUseTraditional ? traditionalDigits : simpleDigits;
final String[] numArray = isUseTraditional ? TRADITIONAL_DIGITS : SIMPLE_DIGITS;
if (amount > 99999999999999.99 || amount < -99999999999999.99) {
throw new IllegalArgumentException("Number support only: (-99999999999999.99 99999999999999.99)");
@ -150,7 +150,7 @@ public class NumberChineseFormatter {
* @since 5.3.9
*/
public static String numberCharToChinese(char c, boolean isUseTraditional) {
String[] numArray = isUseTraditional ? traditionalDigits : simpleDigits;
String[] numArray = isUseTraditional ? TRADITIONAL_DIGITS : SIMPLE_DIGITS;
int index = c - 48;
if (index < 0 || index >= numArray.length) {
return String.valueOf(c);
@ -170,8 +170,8 @@ public class NumberChineseFormatter {
// throw new IllegalArgumentException("Number must 0 < num < 10000");
// }
String[] numArray = isUseTraditional ? traditionalDigits : simpleDigits;
String[] units = isUseTraditional ? traditionalUnits : simpleUnits;
String[] numArray = isUseTraditional ? TRADITIONAL_DIGITS : SIMPLE_DIGITS;
String[] units = isUseTraditional ? TRADITIONAL_UNITS : SIMPLE_UNITS;
int temp = amountPart;

View File

@ -21,7 +21,7 @@ public class ChineseDate {
/**
* 1900-01-31
*/
private static final long baseDate = -2206425943000L;
private static final long BASE_DATE = -2206425943000L;
//农历年
private final int year;
//农历月
@ -46,7 +46,7 @@ public class ChineseDate {
*/
public ChineseDate(Date date) {
// 求出和1900年1月31日相差的天数
int offset = (int) ((date.getTime() - baseDate) / DateUnit.DAY.getMillis());
int offset = (int) ((date.getTime() - BASE_DATE) / DateUnit.DAY.getMillis());
// 计算农历年份
// 用offset减去每农历年的天数计算当天是农历第几天offset是当年的第几天
int daysOfYear;
@ -299,7 +299,7 @@ public class ChineseDate {
if (D >= firstNode) {
gzM = GanZhi.cyclicalm((Y - LunarInfo.BASE_YEAR) * 12 + M + 12);
}
int dayCyclical = (int) ((DateUtil.parseDate(Y + "-" + M + "-" + "1").getTime() - baseDate + 2592000000L) / DateUnit.DAY.getMillis()) + 10;
int dayCyclical = (int) ((DateUtil.parseDate(Y + "-" + M + "-" + "1").getTime() - BASE_DATE + 2592000000L) / DateUnit.DAY.getMillis()) + 10;
String gzD = GanZhi.cyclicalm(dayCyclical + D - 1);
return gzyear + "" + gzM + "" + gzD + "";
}

View File

@ -20,7 +20,7 @@ import cn.hutool.core.util.ArrayUtil;
public class DateModifier {
/** 忽略的计算的字段 */
private static final int[] ignoreFields = new int[] { //
private static final int[] IGNORE_FIELDS = new int[] { //
Calendar.HOUR_OF_DAY, // 与HOUR同名
Calendar.AM_PM, // 此字段单独处理不参与计算起始和结束
Calendar.DAY_OF_WEEK_IN_MONTH, // 不参与计算
@ -62,7 +62,7 @@ public class DateModifier {
// 循环处理各级字段精确到毫秒字段
for (int i = dateField + 1; i <= Calendar.MILLISECOND; i++) {
if (ArrayUtil.contains(ignoreFields, i)) {
if (ArrayUtil.contains(IGNORE_FIELDS, i)) {
// 忽略无关字段WEEK_OF_MONTH始终不做修改
continue;
}

View File

@ -12,7 +12,7 @@ import java.util.Date;
public class Zodiac {
/** 星座分隔时间日 */
private static final int[] dayArr = new int[] { 20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22 };
private static final int[] DAY_ARR = new int[] { 20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22 };
/** 星座 */
private static final String[] ZODIACS = new String[] { "摩羯座", "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座" };
private static final String[] CHINESE_ZODIACS = new String[] { "", "", "", "", "", "", "", "", "", "", "", "" };
@ -61,7 +61,7 @@ public class Zodiac {
*/
public static String getZodiac(int month, int day) {
// 在分隔日前为前一个星座否则为后一个星座
return day < dayArr[month] ? ZODIACS[month] : ZODIACS[month + 1];
return day < DAY_ARR[month] ? ZODIACS[month] : ZODIACS[month + 1];
}
// ----------------------------------------------------------------------------------------------------------- 生肖

View File

@ -15,71 +15,71 @@ public class LunarFestival {
//农历节日 *表示放假日
// 来自https://baike.baidu.com/item/%E4%B8%AD%E5%9B%BD%E4%BC%A0%E7%BB%9F%E8%8A%82%E6%97%A5/396100
private static final TableMap<Pair<Integer, Integer>, String> lFtv = new TableMap<>(16);
private static final TableMap<Pair<Integer, Integer>, String> L_FTV = new TableMap<>(16);
static{
lFtv.put(new Pair<>(1, 1), "春节");
lFtv.put(new Pair<>(1, 2), "犬日");
lFtv.put(new Pair<>(1, 3), "猪日");
lFtv.put(new Pair<>(1, 4), "羊日");
lFtv.put(new Pair<>(1, 5), "牛日 破五日");
lFtv.put(new Pair<>(1, 6), "马日 送穷日");
lFtv.put(new Pair<>(1, 7), "人日 人胜节");
lFtv.put(new Pair<>(1, 8), "谷日 八仙日");
lFtv.put(new Pair<>(1, 9), "天日 九皇会");
lFtv.put(new Pair<>(1, 10), "地日 石头生日");
lFtv.put(new Pair<>(1, 12), "火日 老鼠娶媳妇日");
lFtv.put(new Pair<>(1, 13), "上(试)灯日 关公升天日");
lFtv.put(new Pair<>(1, 15), "元宵节");
lFtv.put(new Pair<>(1, 18), "落灯日");
L_FTV.put(new Pair<>(1, 1), "春节");
L_FTV.put(new Pair<>(1, 2), "犬日");
L_FTV.put(new Pair<>(1, 3), "猪日");
L_FTV.put(new Pair<>(1, 4), "羊日");
L_FTV.put(new Pair<>(1, 5), "牛日 破五日");
L_FTV.put(new Pair<>(1, 6), "马日 送穷日");
L_FTV.put(new Pair<>(1, 7), "人日 人胜节");
L_FTV.put(new Pair<>(1, 8), "谷日 八仙日");
L_FTV.put(new Pair<>(1, 9), "天日 九皇会");
L_FTV.put(new Pair<>(1, 10), "地日 石头生日");
L_FTV.put(new Pair<>(1, 12), "火日 老鼠娶媳妇日");
L_FTV.put(new Pair<>(1, 13), "上(试)灯日 关公升天日");
L_FTV.put(new Pair<>(1, 15), "元宵节");
L_FTV.put(new Pair<>(1, 18), "落灯日");
// 二月
lFtv.put(new Pair<>(2, 1), "中和节 太阳生日");
lFtv.put(new Pair<>(2, 2), "龙抬头");
lFtv.put(new Pair<>(2, 12), "花朝节");
lFtv.put(new Pair<>(2, 19), "观世音圣诞");
L_FTV.put(new Pair<>(2, 1), "中和节 太阳生日");
L_FTV.put(new Pair<>(2, 2), "龙抬头");
L_FTV.put(new Pair<>(2, 12), "花朝节");
L_FTV.put(new Pair<>(2, 19), "观世音圣诞");
// 三月
lFtv.put(new Pair<>(3, 3), "上巳节");
L_FTV.put(new Pair<>(3, 3), "上巳节");
// 四月
lFtv.put(new Pair<>(4, 1), "祭雹神");
lFtv.put(new Pair<>(4, 4), "文殊菩萨诞辰");
lFtv.put(new Pair<>(4, 8), "佛诞节");
L_FTV.put(new Pair<>(4, 1), "祭雹神");
L_FTV.put(new Pair<>(4, 4), "文殊菩萨诞辰");
L_FTV.put(new Pair<>(4, 8), "佛诞节");
// 五月
lFtv.put(new Pair<>(5, 5), "端午节");
L_FTV.put(new Pair<>(5, 5), "端午节");
// 六月
lFtv.put(new Pair<>(6, 6), "晒衣节 姑姑节");
lFtv.put(new Pair<>(6, 6), "天贶节");
lFtv.put(new Pair<>(6, 24), "彝族火把节");
L_FTV.put(new Pair<>(6, 6), "晒衣节 姑姑节");
L_FTV.put(new Pair<>(6, 6), "天贶节");
L_FTV.put(new Pair<>(6, 24), "彝族火把节");
// 七月
lFtv.put(new Pair<>(7, 7), "七夕");
lFtv.put(new Pair<>(7, 14), "鬼节(南方)");
lFtv.put(new Pair<>(7, 15), "中元节");
lFtv.put(new Pair<>(7, 15), "盂兰盆节");
lFtv.put(new Pair<>(7, 30), "地藏节");
L_FTV.put(new Pair<>(7, 7), "七夕");
L_FTV.put(new Pair<>(7, 14), "鬼节(南方)");
L_FTV.put(new Pair<>(7, 15), "中元节");
L_FTV.put(new Pair<>(7, 15), "盂兰盆节");
L_FTV.put(new Pair<>(7, 30), "地藏节");
// 八月
lFtv.put(new Pair<>(8, 15), "中秋节");
L_FTV.put(new Pair<>(8, 15), "中秋节");
// 九月
lFtv.put(new Pair<>(9, 9), "重阳节");
L_FTV.put(new Pair<>(9, 9), "重阳节");
// 十月
lFtv.put(new Pair<>(10, 1), "祭祖节");
lFtv.put(new Pair<>(10, 15), "下元节");
L_FTV.put(new Pair<>(10, 1), "祭祖节");
L_FTV.put(new Pair<>(10, 15), "下元节");
// 十一月
lFtv.put(new Pair<>(11, 17), "阿弥陀佛圣诞");
L_FTV.put(new Pair<>(11, 17), "阿弥陀佛圣诞");
// 腊月
lFtv.put(new Pair<>(12, 8), "腊八节");
lFtv.put(new Pair<>(12, 16), "尾牙");
lFtv.put(new Pair<>(12, 23), "小年");
lFtv.put(new Pair<>(12, 29), "除夕");
lFtv.put(new Pair<>(12, 30), "除夕");
L_FTV.put(new Pair<>(12, 8), "腊八节");
L_FTV.put(new Pair<>(12, 16), "尾牙");
L_FTV.put(new Pair<>(12, 23), "小年");
L_FTV.put(new Pair<>(12, 29), "除夕");
L_FTV.put(new Pair<>(12, 30), "除夕");
}
/**
@ -90,6 +90,6 @@ public class LunarFestival {
* @return 获得农历节日
*/
public static List<String> getFestivals(int month, int day) {
return lFtv.getValues(new Pair<>(month, day));
return L_FTV.getValues(new Pair<>(month, day));
}
}

View File

@ -25,7 +25,7 @@ public class SolarTerms {
return -1;
}
String _table = sTermInfo[y - 1900];
String _table = S_TERM_INFO[y - 1900];
Integer[] _info = new Integer[6];
for (int i = 0; i < 6; i++) {
_info[i] = NumberUtil.parseInt("0x" + _table.substring(i * 5, 5 * (i + 1)));
@ -44,7 +44,7 @@ public class SolarTerms {
* 1900-2100各年的24节气日期速查表
* 此表来自https://github.com/jjonline/calendar.js/blob/master/calendar.js
*/
private static final String[] sTermInfo = new String[]{
private static final String[] S_TERM_INFO = new String[]{
"9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c3598082c95f8c965cc920f",
"97bd0b06bdb0722c965ce1cfcc920f", "b027097bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e",
"97bcf97c359801ec95f8c965cc920f", "97bd0b06bdb0722c965ce1cfcc920f", "b027097bd097c36b0b6fc9274c91aa",

View File

@ -38,7 +38,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
/** SHORT locale dependent date or time style. */
public static final int SHORT = DateFormat.SHORT;
private static final FormatCache<FastDateFormat> cache = new FormatCache<FastDateFormat>(){
private static final FormatCache<FastDateFormat> CACHE = new FormatCache<FastDateFormat>(){
@Override
protected FastDateFormat createInstance(final String pattern, final TimeZone timeZone, final Locale locale) {
return new FastDateFormat(pattern, timeZone, locale);
@ -55,7 +55,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return {@link FastDateFormat}
*/
public static FastDateFormat getInstance() {
return cache.getInstance();
return CACHE.getInstance();
}
/**
@ -67,7 +67,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @throws IllegalArgumentException 日期格式问题
*/
public static FastDateFormat getInstance(final String pattern) {
return cache.getInstance(pattern, null, null);
return CACHE.getInstance(pattern, null, null);
}
/**
@ -80,7 +80,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @throws IllegalArgumentException 日期格式问题
*/
public static FastDateFormat getInstance(final String pattern, final TimeZone timeZone) {
return cache.getInstance(pattern, timeZone, null);
return CACHE.getInstance(pattern, timeZone, null);
}
/**
@ -93,7 +93,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @throws IllegalArgumentException 日期格式问题
*/
public static FastDateFormat getInstance(final String pattern, final Locale locale) {
return cache.getInstance(pattern, null, locale);
return CACHE.getInstance(pattern, null, locale);
}
/**
@ -107,7 +107,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @throws IllegalArgumentException 日期格式问题
*/
public static FastDateFormat getInstance(final String pattern, final TimeZone timeZone, final Locale locale) {
return cache.getInstance(pattern, timeZone, locale);
return CACHE.getInstance(pattern, timeZone, locale);
}
// -----------------------------------------------------------------------
@ -119,7 +119,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getDateInstance(final int style) {
return cache.getDateInstance(style, null, null);
return CACHE.getDateInstance(style, null, null);
}
/**
@ -131,7 +131,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getDateInstance(final int style, final Locale locale) {
return cache.getDateInstance(style, null, locale);
return CACHE.getDateInstance(style, null, locale);
}
/**
@ -143,7 +143,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getDateInstance(final int style, final TimeZone timeZone) {
return cache.getDateInstance(style, timeZone, null);
return CACHE.getDateInstance(style, timeZone, null);
}
/**
@ -156,7 +156,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getDateInstance(final int style, final TimeZone timeZone, final Locale locale) {
return cache.getDateInstance(style, timeZone, locale);
return CACHE.getDateInstance(style, timeZone, locale);
}
// -----------------------------------------------------------------------
@ -168,7 +168,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getTimeInstance(final int style) {
return cache.getTimeInstance(style, null, null);
return CACHE.getTimeInstance(style, null, null);
}
/**
@ -180,7 +180,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getTimeInstance(final int style, final Locale locale) {
return cache.getTimeInstance(style, null, locale);
return CACHE.getTimeInstance(style, null, locale);
}
/**
@ -192,7 +192,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getTimeInstance(final int style, final TimeZone timeZone) {
return cache.getTimeInstance(style, timeZone, null);
return CACHE.getTimeInstance(style, timeZone, null);
}
/**
@ -205,7 +205,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getTimeInstance(final int style, final TimeZone timeZone, final Locale locale) {
return cache.getTimeInstance(style, timeZone, locale);
return CACHE.getTimeInstance(style, timeZone, locale);
}
// -----------------------------------------------------------------------
@ -218,7 +218,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getDateTimeInstance(final int dateStyle, final int timeStyle) {
return cache.getDateTimeInstance(dateStyle, timeStyle, null, null);
return CACHE.getDateTimeInstance(dateStyle, timeStyle, null, null);
}
/**
@ -231,7 +231,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getDateTimeInstance(final int dateStyle, final int timeStyle, final Locale locale) {
return cache.getDateTimeInstance(dateStyle, timeStyle, null, locale);
return CACHE.getDateTimeInstance(dateStyle, timeStyle, null, locale);
}
/**
@ -258,7 +258,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
* @return 本地化 {@link FastDateFormat}
*/
public static FastDateFormat getDateTimeInstance(final int dateStyle, final int timeStyle, final TimeZone timeZone, final Locale locale) {
return cache.getDateTimeInstance(dateStyle, timeStyle, timeZone, locale);
return CACHE.getDateTimeInstance(dateStyle, timeStyle, timeZone, locale);
}
// ----------------------------------------------------------------------- Constructor start

View File

@ -447,7 +447,7 @@ public class FastDateParser extends AbstractDateBasic implements DateParser {
}
@SuppressWarnings("unchecked") // OK because we are creating an array with no entries
private static final ConcurrentMap<Locale, Strategy>[] caches = new ConcurrentMap[Calendar.FIELD_COUNT];
private static final ConcurrentMap<Locale, Strategy>[] CACHES = new ConcurrentMap[Calendar.FIELD_COUNT];
/**
* Get a cache of Strategies for a particular field
@ -456,11 +456,11 @@ public class FastDateParser extends AbstractDateBasic implements DateParser {
* @return a cache of Locale to Strategy
*/
private static ConcurrentMap<Locale, Strategy> getCache(final int field) {
synchronized (caches) {
if (caches[field] == null) {
caches[field] = new ConcurrentHashMap<>(3);
synchronized (CACHES) {
if (CACHES[field] == null) {
CACHES[field] = new ConcurrentHashMap<>(3);
}
return caches[field];
return CACHES[field];
}
}

View File

@ -1052,7 +1052,7 @@ public class FastDatePrinter extends AbstractDateBasic implements DatePrinter {
// -----------------------------------------------------------------------
private static final ConcurrentMap<TimeZoneDisplayKey, String> cTimeZoneDisplayCache = new ConcurrentHashMap<>(7);
private static final ConcurrentMap<TimeZoneDisplayKey, String> C_TIME_ZONE_DISPLAY_CACHE = new ConcurrentHashMap<>(7);
/**
* <p>
@ -1067,11 +1067,11 @@ public class FastDatePrinter extends AbstractDateBasic implements DatePrinter {
*/
static String getTimeZoneDisplay(final TimeZone tz, final boolean daylight, final int style, final Locale locale) {
final TimeZoneDisplayKey key = new TimeZoneDisplayKey(tz, daylight, style, locale);
String value = cTimeZoneDisplayCache.get(key);
String value = C_TIME_ZONE_DISPLAY_CACHE.get(key);
if (value == null) {
// This is a very slow call, so cache the results.
value = tz.getDisplayName(daylight, style, locale);
final String prior = cTimeZoneDisplayCache.putIfAbsent(key, value);
final String prior = C_TIME_ZONE_DISPLAY_CACHE.putIfAbsent(key, value);
if (prior != null) {
value = prior;
}

View File

@ -26,7 +26,7 @@ abstract class FormatCache<F extends Format> {
private final ConcurrentMap<Tuple, F> cInstanceCache = new ConcurrentHashMap<>(7);
private static final ConcurrentMap<Tuple, String> cDateTimeInstanceCache = new ConcurrentHashMap<>(7);
private static final ConcurrentMap<Tuple, String> C_DATE_TIME_INSTANCE_CACHE = new ConcurrentHashMap<>(7);
/**
* 使用默认的patterntimezone和locale获得缓存中的实例
@ -163,7 +163,7 @@ abstract class FormatCache<F extends Format> {
static String getPatternForStyle(final Integer dateStyle, final Integer timeStyle, final Locale locale) {
final Tuple key = new Tuple(dateStyle, timeStyle, locale);
String pattern = cDateTimeInstanceCache.get(key);
String pattern = C_DATE_TIME_INSTANCE_CACHE.get(key);
if (pattern == null) {
try {
DateFormat formatter;
@ -175,7 +175,7 @@ abstract class FormatCache<F extends Format> {
formatter = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
}
pattern = ((SimpleDateFormat) formatter).toPattern();
final String previous = cDateTimeInstanceCache.putIfAbsent(key, pattern);
final String previous = C_DATE_TIME_INSTANCE_CACHE.putIfAbsent(key, pattern);
if (previous != null) {
// even though it doesn't matter if another thread put the pattern
// it's still good practice to return the String instance that is

View File

@ -95,7 +95,7 @@ public class GifDecoder {
protected int delay = 0; // delay in milliseconds
protected int transIndex; // transparent color index
protected static final int MaxStackSize = 4096;
protected static final int MAX_STACK_SIZE = 4096;
// max decoder pixel stack size
// LZW decoder working arrays
@ -378,9 +378,9 @@ public class GifDecoder {
if ((pixels == null) || (pixels.length < npix)) {
pixels = new byte[npix]; // allocate new pixel array
}
if (prefix == null) prefix = new short[MaxStackSize];
if (suffix == null) suffix = new byte[MaxStackSize];
if (pixelStack == null) pixelStack = new byte[MaxStackSize + 1];
if (prefix == null) prefix = new short[MAX_STACK_SIZE];
if (suffix == null) suffix = new byte[MAX_STACK_SIZE];
if (pixelStack == null) pixelStack = new byte[MAX_STACK_SIZE + 1];
// Initialize GIF data stream decoder.
@ -455,7 +455,7 @@ public class GifDecoder {
// Add a new string to the string table,
if (available >= MaxStackSize) {
if (available >= MAX_STACK_SIZE) {
pixelStack[top++] = (byte) first;
continue;
}
@ -464,7 +464,7 @@ public class GifDecoder {
suffix[available] = (byte) first;
available++;
if (((available & code_mask) == 0)
&& (available < MaxStackSize)) {
&& (available < MAX_STACK_SIZE)) {
code_size++;
code_mask += available;
}

View File

@ -29,16 +29,16 @@ package cn.hutool.core.img.gif;
*/
public class NeuQuant {
protected static final int netsize = 256; /* number of colours used */
protected static final int NETSIZE = 256; /* number of colours used */
/* four primes near 500 - assume no image has a length so large */
/* that it is divisible by all four primes */
protected static final int prime1 = 499;
protected static final int prime2 = 491;
protected static final int prime3 = 487;
protected static final int prime4 = 503;
protected static final int PRIME1 = 499;
protected static final int PRIME2 = 491;
protected static final int PRIME3 = 487;
protected static final int PRIME4 = 503;
protected static final int minpicturebytes = (3 * prime4);
protected static final int MINPICTUREBYTES = (3 * PRIME4);
/* minimum size for input image */
/* Program Skeleton
@ -56,38 +56,38 @@ public class NeuQuant {
/* Network Definitions
------------------- */
protected static final int maxnetpos = (netsize - 1);
protected static final int netbiasshift = 4; /* bias for colour values */
protected static final int ncycles = 100; /* no. of learning cycles */
protected static final int MAXNETPOS = (NETSIZE - 1);
protected static final int NETBIASSHIFT = 4; /* bias for colour values */
protected static final int NCYCLES = 100; /* no. of learning cycles */
/* defs for freq and bias */
protected static final int intbiasshift = 16; /* bias for fractions */
protected static final int intbias = (1 << intbiasshift);
protected static final int gammashift = 10; /* gamma = 1024 */
protected static final int gamma = (1 << gammashift);
protected static final int betashift = 10;
protected static final int beta = (intbias >> betashift); /* beta = 1/1024 */
protected static final int betagamma =
(intbias << (gammashift - betashift));
protected static final int INTBIASSHIFT = 16; /* bias for fractions */
protected static final int INTBIAS = (1 << INTBIASSHIFT);
protected static final int GAMMASHIFT = 10; /* gamma = 1024 */
protected static final int GAMMA = (1 << GAMMASHIFT);
protected static final int BETASHIFT = 10;
protected static final int BETA = (INTBIAS >> BETASHIFT); /* beta = 1/1024 */
protected static final int BETAGAMMA =
(INTBIAS << (GAMMASHIFT - BETASHIFT));
/* defs for decreasing radius factor */
protected static final int initrad = (netsize >> 3); /* for 256 cols, radius starts */
protected static final int radiusbiasshift = 6; /* at 32.0 biased by 6 bits */
protected static final int radiusbias = (1 << radiusbiasshift);
protected static final int initradius = (initrad * radiusbias); /* and decreases by a */
protected static final int radiusdec = 30; /* factor of 1/30 each cycle */
protected static final int INITRAD = (NETSIZE >> 3); /* for 256 cols, radius starts */
protected static final int RADIUSBIASSHIFT = 6; /* at 32.0 biased by 6 bits */
protected static final int RADIUSBIAS = (1 << RADIUSBIASSHIFT);
protected static final int INITRADIUS = (INITRAD * RADIUSBIAS); /* and decreases by a */
protected static final int RADIUSDEC = 30; /* factor of 1/30 each cycle */
/* defs for decreasing alpha factor */
protected static final int alphabiasshift = 10; /* alpha starts at 1.0 */
protected static final int initalpha = (1 << alphabiasshift);
protected static final int ALPHABIASSHIFT = 10; /* alpha starts at 1.0 */
protected static final int INITALPHA = (1 << ALPHABIASSHIFT);
protected int alphadec; /* biased by 10 bits */
/* radbias and alpharadbias used for radpower calculation */
protected static final int radbiasshift = 8;
protected static final int radbias = (1 << radbiasshift);
protected static final int alpharadbshift = (alphabiasshift + radbiasshift);
protected static final int alpharadbias = (1 << alpharadbshift);
protected static final int RADBIASSHIFT = 8;
protected static final int RADBIAS = (1 << RADBIASSHIFT);
protected static final int ALPHARADBSHIFT = (ALPHABIASSHIFT + RADBIASSHIFT);
protected static final int ALPHARADBIAS = (1 << ALPHARADBSHIFT);
/* Types and Global Variables
-------------------------- */
@ -103,10 +103,10 @@ public class NeuQuant {
protected int[] netindex = new int[256];
/* for network lookup - really 256 */
protected int[] bias = new int[netsize];
protected int[] bias = new int[NETSIZE];
/* bias and freq arrays for learning */
protected int[] freq = new int[netsize];
protected int[] radpower = new int[initrad];
protected int[] freq = new int[NETSIZE];
protected int[] radpower = new int[INITRAD];
/* radpower for precomputation */
/* Initialise network in range (0,0,0) to (255,255,255) and set parameters
@ -120,23 +120,23 @@ public class NeuQuant {
lengthcount = len;
samplefac = sample;
network = new int[netsize][];
for (i = 0; i < netsize; i++) {
network = new int[NETSIZE][];
for (i = 0; i < NETSIZE; i++) {
network[i] = new int[4];
p = network[i];
p[0] = p[1] = p[2] = (i << (netbiasshift + 8)) / netsize;
freq[i] = intbias / netsize; /* 1/netsize */
p[0] = p[1] = p[2] = (i << (NETBIASSHIFT + 8)) / NETSIZE;
freq[i] = INTBIAS / NETSIZE; /* 1/netsize */
bias[i] = 0;
}
}
public byte[] colorMap() {
byte[] map = new byte[3 * netsize];
int[] index = new int[netsize];
for (int i = 0; i < netsize; i++)
byte[] map = new byte[3 * NETSIZE];
int[] index = new int[NETSIZE];
for (int i = 0; i < NETSIZE; i++)
index[network[i][3]] = i;
int k = 0;
for (int i = 0; i < netsize; i++) {
for (int i = 0; i < NETSIZE; i++) {
int j = index[i];
map[k++] = (byte) (network[j][0]);
map[k++] = (byte) (network[j][1]);
@ -156,12 +156,12 @@ public class NeuQuant {
previouscol = 0;
startpos = 0;
for (i = 0; i < netsize; i++) {
for (i = 0; i < NETSIZE; i++) {
p = network[i];
smallpos = i;
smallval = p[1]; /* index on g */
/* find smallest in i..netsize-1 */
for (j = i + 1; j < netsize; j++) {
for (j = i + 1; j < NETSIZE; j++) {
q = network[j];
if (q[1] < smallval) { /* index on g */
smallpos = j;
@ -193,9 +193,9 @@ public class NeuQuant {
startpos = i;
}
}
netindex[previouscol] = (startpos + maxnetpos) >> 1;
netindex[previouscol] = (startpos + MAXNETPOS) >> 1;
for (j = previouscol + 1; j < 256; j++)
netindex[j] = maxnetpos; /* really 256 */
netindex[j] = MAXNETPOS; /* really 256 */
}
/* Main Learning Loop
@ -207,44 +207,44 @@ public class NeuQuant {
byte[] p;
int pix, lim;
if (lengthcount < minpicturebytes)
if (lengthcount < MINPICTUREBYTES)
samplefac = 1;
alphadec = 30 + ((samplefac - 1) / 3);
p = thepicture;
pix = 0;
lim = lengthcount;
samplepixels = lengthcount / (3 * samplefac);
delta = samplepixels / ncycles;
alpha = initalpha;
radius = initradius;
delta = samplepixels / NCYCLES;
alpha = INITALPHA;
radius = INITRADIUS;
rad = radius >> radiusbiasshift;
rad = radius >> RADIUSBIASSHIFT;
for (i = 0; i < rad; i++)
radpower[i] =
alpha * (((rad * rad - i * i) * radbias) / (rad * rad));
alpha * (((rad * rad - i * i) * RADBIAS) / (rad * rad));
//fprintf(stderr,"beginning 1D learning: initial radius=%d\n", rad);
if (lengthcount < minpicturebytes)
if (lengthcount < MINPICTUREBYTES)
step = 3;
else if ((lengthcount % prime1) != 0)
step = 3 * prime1;
else if ((lengthcount % PRIME1) != 0)
step = 3 * PRIME1;
else {
if ((lengthcount % prime2) != 0)
step = 3 * prime2;
if ((lengthcount % PRIME2) != 0)
step = 3 * PRIME2;
else {
if ((lengthcount % prime3) != 0)
step = 3 * prime3;
if ((lengthcount % PRIME3) != 0)
step = 3 * PRIME3;
else
step = 3 * prime4;
step = 3 * PRIME4;
}
}
i = 0;
while (i < samplepixels) {
b = (p[pix] & 0xff) << netbiasshift;
g = (p[pix + 1] & 0xff) << netbiasshift;
r = (p[pix + 2] & 0xff) << netbiasshift;
b = (p[pix] & 0xff) << NETBIASSHIFT;
g = (p[pix + 1] & 0xff) << NETBIASSHIFT;
r = (p[pix + 2] & 0xff) << NETBIASSHIFT;
j = contest(b, g, r);
altersingle(alpha, j, b, g, r);
@ -260,13 +260,13 @@ public class NeuQuant {
delta = 1;
if (i % delta == 0) {
alpha -= alpha / alphadec;
radius -= radius / radiusdec;
rad = radius >> radiusbiasshift;
radius -= radius / RADIUSDEC;
rad = radius >> RADIUSBIASSHIFT;
if (rad <= 1)
rad = 0;
for (j = 0; j < rad; j++)
radpower[j] =
alpha * (((rad * rad - j * j) * radbias) / (rad * rad));
alpha * (((rad * rad - j * j) * RADBIAS) / (rad * rad));
}
}
//fprintf(stderr,"finished 1D learning: final alpha=%f !\n",((float)alpha)/initalpha);
@ -285,12 +285,12 @@ public class NeuQuant {
i = netindex[g]; /* index on g */
j = i - 1; /* start at netindex[g] and work outwards */
while ((i < netsize) || (j >= 0)) {
if (i < netsize) {
while ((i < NETSIZE) || (j >= 0)) {
if (i < NETSIZE) {
p = network[i];
dist = p[1] - g; /* inx key */
if (dist >= bestd)
i = netsize; /* stop iter */
i = NETSIZE; /* stop iter */
else {
i++;
if (dist < 0)
@ -353,10 +353,10 @@ public class NeuQuant {
int i, j;
for (i = 0; i < netsize; i++) {
network[i][0] >>= netbiasshift;
network[i][1] >>= netbiasshift;
network[i][2] >>= netbiasshift;
for (i = 0; i < NETSIZE; i++) {
network[i][0] >>= NETBIASSHIFT;
network[i][1] >>= NETBIASSHIFT;
network[i][2] >>= NETBIASSHIFT;
network[i][3] = i; /* record colour no */
}
}
@ -372,8 +372,8 @@ public class NeuQuant {
if (lo < -1)
lo = -1;
hi = i + rad;
if (hi > netsize)
hi = netsize;
if (hi > NETSIZE)
hi = NETSIZE;
j = i + 1;
k = i - 1;
@ -383,18 +383,18 @@ public class NeuQuant {
if (j < hi) {
p = network[j++];
try {
p[0] -= (a * (p[0] - b)) / alpharadbias;
p[1] -= (a * (p[1] - g)) / alpharadbias;
p[2] -= (a * (p[2] - r)) / alpharadbias;
p[0] -= (a * (p[0] - b)) / ALPHARADBIAS;
p[1] -= (a * (p[1] - g)) / ALPHARADBIAS;
p[2] -= (a * (p[2] - r)) / ALPHARADBIAS;
} catch (Exception ignored) {
} // prevents 1.3 miscompilation
}
if (k > lo) {
p = network[k--];
try {
p[0] -= (a * (p[0] - b)) / alpharadbias;
p[1] -= (a * (p[1] - g)) / alpharadbias;
p[2] -= (a * (p[2] - r)) / alpharadbias;
p[0] -= (a * (p[0] - b)) / ALPHARADBIAS;
p[1] -= (a * (p[1] - g)) / ALPHARADBIAS;
p[2] -= (a * (p[2] - r)) / ALPHARADBIAS;
} catch (Exception ignored) {
}
}
@ -407,9 +407,9 @@ public class NeuQuant {
/* alter hit neuron */
int[] n = network[i];
n[0] -= (alpha * (n[0] - b)) / initalpha;
n[1] -= (alpha * (n[1] - g)) / initalpha;
n[2] -= (alpha * (n[2] - r)) / initalpha;
n[0] -= (alpha * (n[0] - b)) / INITALPHA;
n[1] -= (alpha * (n[1] - g)) / INITALPHA;
n[2] -= (alpha * (n[2] - r)) / INITALPHA;
}
/* Search for biased BGR values
@ -430,7 +430,7 @@ public class NeuQuant {
bestpos = -1;
bestbiaspos = bestpos;
for (i = 0; i < netsize; i++) {
for (i = 0; i < NETSIZE; i++) {
n = network[i];
dist = n[0] - b;
if (dist < 0)
@ -447,17 +447,17 @@ public class NeuQuant {
bestd = dist;
bestpos = i;
}
biasdist = dist - ((bias[i]) >> (intbiasshift - netbiasshift));
biasdist = dist - ((bias[i]) >> (INTBIASSHIFT - NETBIASSHIFT));
if (biasdist < bestbiasd) {
bestbiasd = biasdist;
bestbiaspos = i;
}
betafreq = (freq[i] >> betashift);
betafreq = (freq[i] >> BETASHIFT);
freq[i] -= betafreq;
bias[i] += (betafreq << gammashift);
bias[i] += (betafreq << GAMMASHIFT);
}
freq[bestpos] += beta;
bias[bestpos] -= betagamma;
freq[bestpos] += BETA;
bias[bestpos] -= BETAGAMMA;
return (bestbiaspos);
}
}

View File

@ -20,60 +20,60 @@ import cn.hutool.core.util.StrUtil;
*/
public class FileTypeUtil {
private static final Map<String, String> fileTypeMap;
private static final Map<String, String> FILE_TYPE_MAP;
static {
fileTypeMap = new ConcurrentHashMap<>();
FILE_TYPE_MAP = new ConcurrentHashMap<>();
fileTypeMap.put("ffd8ff", "jpg"); // JPEG (jpg)
fileTypeMap.put("89504e47", "png"); // PNG (png)
fileTypeMap.put("4749463837", "gif"); // GIF (gif)
fileTypeMap.put("4749463839", "gif"); // GIF (gif)
fileTypeMap.put("49492a00227105008037", "tif"); // TIFF (tif)
fileTypeMap.put("424d228c010000000000", "bmp"); // 16色位图(bmp)
fileTypeMap.put("424d8240090000000000", "bmp"); // 24位位图(bmp)
fileTypeMap.put("424d8e1b030000000000", "bmp"); // 256色位图(bmp)
fileTypeMap.put("41433130313500000000", "dwg"); // CAD (dwg)
fileTypeMap.put("7b5c727466315c616e73", "rtf"); // Rich Text Format (rtf)
fileTypeMap.put("38425053000100000000", "psd"); // Photoshop (psd)
fileTypeMap.put("46726f6d3a203d3f6762", "eml"); // Email [Outlook Express 6] (eml)
fileTypeMap.put("5374616E64617264204A", "mdb"); // MS Access (mdb)
fileTypeMap.put("252150532D41646F6265", "ps");
fileTypeMap.put("255044462d312e", "pdf"); // Adobe Acrobat (pdf)
fileTypeMap.put("2e524d46000000120001", "rmvb"); // rmvb/rm相同
fileTypeMap.put("464c5601050000000900", "flv"); // flv与f4v相同
fileTypeMap.put("00000020667479706", "mp4");
fileTypeMap.put("00000018667479706D70", "mp4");
fileTypeMap.put("49443303000000002176", "mp3");
fileTypeMap.put("000001ba210001000180", "mpg"); //
fileTypeMap.put("3026b2758e66cf11a6d9", "wmv"); // wmv与asf相同
fileTypeMap.put("52494646e27807005741", "wav"); // Wave (wav)
fileTypeMap.put("52494646d07d60074156", "avi");
fileTypeMap.put("4d546864000000060001", "mid"); // MIDI (mid)
fileTypeMap.put("526172211a0700cf9073", "rar");// WinRAR
fileTypeMap.put("235468697320636f6e66", "ini");
fileTypeMap.put("504B03040a0000000000", "jar");
fileTypeMap.put("504B0304140008000800", "jar");
FILE_TYPE_MAP.put("ffd8ff", "jpg"); // JPEG (jpg)
FILE_TYPE_MAP.put("89504e47", "png"); // PNG (png)
FILE_TYPE_MAP.put("4749463837", "gif"); // GIF (gif)
FILE_TYPE_MAP.put("4749463839", "gif"); // GIF (gif)
FILE_TYPE_MAP.put("49492a00227105008037", "tif"); // TIFF (tif)
FILE_TYPE_MAP.put("424d228c010000000000", "bmp"); // 16色位图(bmp)
FILE_TYPE_MAP.put("424d8240090000000000", "bmp"); // 24位位图(bmp)
FILE_TYPE_MAP.put("424d8e1b030000000000", "bmp"); // 256色位图(bmp)
FILE_TYPE_MAP.put("41433130313500000000", "dwg"); // CAD (dwg)
FILE_TYPE_MAP.put("7b5c727466315c616e73", "rtf"); // Rich Text Format (rtf)
FILE_TYPE_MAP.put("38425053000100000000", "psd"); // Photoshop (psd)
FILE_TYPE_MAP.put("46726f6d3a203d3f6762", "eml"); // Email [Outlook Express 6] (eml)
FILE_TYPE_MAP.put("5374616E64617264204A", "mdb"); // MS Access (mdb)
FILE_TYPE_MAP.put("252150532D41646F6265", "ps");
FILE_TYPE_MAP.put("255044462d312e", "pdf"); // Adobe Acrobat (pdf)
FILE_TYPE_MAP.put("2e524d46000000120001", "rmvb"); // rmvb/rm相同
FILE_TYPE_MAP.put("464c5601050000000900", "flv"); // flv与f4v相同
FILE_TYPE_MAP.put("00000020667479706", "mp4");
FILE_TYPE_MAP.put("00000018667479706D70", "mp4");
FILE_TYPE_MAP.put("49443303000000002176", "mp3");
FILE_TYPE_MAP.put("000001ba210001000180", "mpg"); //
FILE_TYPE_MAP.put("3026b2758e66cf11a6d9", "wmv"); // wmv与asf相同
FILE_TYPE_MAP.put("52494646e27807005741", "wav"); // Wave (wav)
FILE_TYPE_MAP.put("52494646d07d60074156", "avi");
FILE_TYPE_MAP.put("4d546864000000060001", "mid"); // MIDI (mid)
FILE_TYPE_MAP.put("526172211a0700cf9073", "rar");// WinRAR
FILE_TYPE_MAP.put("235468697320636f6e66", "ini");
FILE_TYPE_MAP.put("504B03040a0000000000", "jar");
FILE_TYPE_MAP.put("504B0304140008000800", "jar");
// MS Excel 注意wordmsi excel的文件头一样
fileTypeMap.put("d0cf11e0a1b11ae10", "xls");
fileTypeMap.put("504B0304", "zip");
fileTypeMap.put("4d5a9000030000000400", "exe");// 可执行文件
fileTypeMap.put("3c25402070616765206c", "jsp");// jsp文件
fileTypeMap.put("4d616e69666573742d56", "mf");// MF文件
fileTypeMap.put("7061636b616765207765", "java");// java文件
fileTypeMap.put("406563686f206f66660d", "bat");// bat文件
fileTypeMap.put("1f8b0800000000000000", "gz");// gz文件
fileTypeMap.put("cafebabe0000002e0041", "class");// bat文件
fileTypeMap.put("49545346030000006000", "chm");// bat文件
fileTypeMap.put("04000000010000001300", "mxp");// bat文件
fileTypeMap.put("6431303a637265617465", "torrent");
fileTypeMap.put("6D6F6F76", "mov"); // Quicktime (mov)
fileTypeMap.put("FF575043", "wpd"); // WordPerfect (wpd)
fileTypeMap.put("CFAD12FEC5FD746F", "dbx"); // Outlook Express (dbx)
fileTypeMap.put("2142444E", "pst"); // Outlook (pst)
fileTypeMap.put("AC9EBD8F", "qdf"); // Quicken (qdf)
fileTypeMap.put("E3828596", "pwl"); // Windows Password (pwl)
fileTypeMap.put("2E7261FD", "ram"); // Real Audio (ram)
FILE_TYPE_MAP.put("d0cf11e0a1b11ae10", "xls");
FILE_TYPE_MAP.put("504B0304", "zip");
FILE_TYPE_MAP.put("4d5a9000030000000400", "exe");// 可执行文件
FILE_TYPE_MAP.put("3c25402070616765206c", "jsp");// jsp文件
FILE_TYPE_MAP.put("4d616e69666573742d56", "mf");// MF文件
FILE_TYPE_MAP.put("7061636b616765207765", "java");// java文件
FILE_TYPE_MAP.put("406563686f206f66660d", "bat");// bat文件
FILE_TYPE_MAP.put("1f8b0800000000000000", "gz");// gz文件
FILE_TYPE_MAP.put("cafebabe0000002e0041", "class");// bat文件
FILE_TYPE_MAP.put("49545346030000006000", "chm");// bat文件
FILE_TYPE_MAP.put("04000000010000001300", "mxp");// bat文件
FILE_TYPE_MAP.put("6431303a637265617465", "torrent");
FILE_TYPE_MAP.put("6D6F6F76", "mov"); // Quicktime (mov)
FILE_TYPE_MAP.put("FF575043", "wpd"); // WordPerfect (wpd)
FILE_TYPE_MAP.put("CFAD12FEC5FD746F", "dbx"); // Outlook Express (dbx)
FILE_TYPE_MAP.put("2142444E", "pst"); // Outlook (pst)
FILE_TYPE_MAP.put("AC9EBD8F", "qdf"); // Quicken (qdf)
FILE_TYPE_MAP.put("E3828596", "pwl"); // Windows Password (pwl)
FILE_TYPE_MAP.put("2E7261FD", "ram"); // Real Audio (ram)
}
/**
@ -85,7 +85,7 @@ public class FileTypeUtil {
* @return 之前已经存在的文件扩展名
*/
public static String putFileType(String fileStreamHexHead, String extName) {
return fileTypeMap.put(fileStreamHexHead.toLowerCase(), extName);
return FILE_TYPE_MAP.put(fileStreamHexHead.toLowerCase(), extName);
}
/**
@ -95,7 +95,7 @@ public class FileTypeUtil {
* @return 移除的文件扩展名
*/
public static String removeFileType(String fileStreamHexHead) {
return fileTypeMap.remove(fileStreamHexHead.toLowerCase());
return FILE_TYPE_MAP.remove(fileStreamHexHead.toLowerCase());
}
/**
@ -105,7 +105,7 @@ public class FileTypeUtil {
* @return 文件类型未找到为<code>null</code>
*/
public static String getType(String fileStreamHexHead) {
for (Entry<String, String> fileTypeEntry : fileTypeMap.entrySet()) {
for (Entry<String, String> fileTypeEntry : FILE_TYPE_MAP.entrySet()) {
if (StrUtil.startWithIgnoreCase(fileStreamHexHead, fileTypeEntry.getKey())) {
return fileTypeEntry.getValue();
}

View File

@ -8,7 +8,7 @@ package cn.hutool.core.io.checksum.crc16;
*/
public class CRC16Ansi extends CRC16Checksum{
private static final int wCPoly = 0xa001;
private static final int WC_POLY = 0xa001;
@Override
public void reset() {
@ -25,7 +25,7 @@ public class CRC16Ansi extends CRC16Checksum{
int flag = wCRCin & 0x0001;
wCRCin = wCRCin >> 1;
if (flag == 1) {
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
}
}
}

View File

@ -9,7 +9,7 @@ package cn.hutool.core.io.checksum.crc16;
*/
public class CRC16CCITT extends CRC16Checksum{
private static final int wCPoly = 0x8408;
private static final int WC_POLY = 0x8408;
@Override
public void update(int b) {
@ -17,7 +17,7 @@ public class CRC16CCITT extends CRC16Checksum{
for (int j = 0; j < 8; j++) {
if ((wCRCin & 0x0001) != 0) {
wCRCin >>= 1;
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
} else {
wCRCin >>= 1;
}

View File

@ -8,7 +8,7 @@ package cn.hutool.core.io.checksum.crc16;
*/
public class CRC16CCITTFalse extends CRC16Checksum{
private static final int wCPoly = 0x1021;
private static final int WC_POLY = 0x1021;
@Override
public void reset() {
@ -28,7 +28,7 @@ public class CRC16CCITTFalse extends CRC16Checksum{
boolean c15 = ((wCRCin >> 15 & 1) == 1);
wCRCin <<= 1;
if (c15 ^ bit)
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
}
}
}

View File

@ -9,7 +9,7 @@ package cn.hutool.core.io.checksum.crc16;
*/
public class CRC16DNP extends CRC16Checksum{
private static final int wCPoly = 0xA6BC;
private static final int WC_POLY = 0xA6BC;
@Override
public void update(byte[] b, int off, int len) {
@ -23,7 +23,7 @@ public class CRC16DNP extends CRC16Checksum{
for (int j = 0; j < 8; j++) {
if ((wCRCin & 0x0001) != 0) {
wCRCin >>= 1;
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
} else {
wCRCin >>= 1;
}

View File

@ -9,7 +9,7 @@ package cn.hutool.core.io.checksum.crc16;
*/
public class CRC16IBM extends CRC16Checksum{
private static final int wCPoly = 0xa001;
private static final int WC_POLY = 0xa001;
@Override
public void update(int b) {
@ -17,7 +17,7 @@ public class CRC16IBM extends CRC16Checksum{
for (int j = 0; j < 8; j++) {
if ((wCRCin & 0x0001) != 0) {
wCRCin >>= 1;
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
} else {
wCRCin >>= 1;
}

View File

@ -9,7 +9,7 @@ package cn.hutool.core.io.checksum.crc16;
*/
public class CRC16Maxim extends CRC16Checksum{
private static final int wCPoly = 0xa001;
private static final int WC_POLY = 0xa001;
@Override
public void update(byte[] b, int off, int len) {
@ -23,7 +23,7 @@ public class CRC16Maxim extends CRC16Checksum{
for (int j = 0; j < 8; j++) {
if ((wCRCin & 0x0001) != 0) {
wCRCin >>= 1;
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
} else {
wCRCin >>= 1;
}

View File

@ -10,7 +10,7 @@ package cn.hutool.core.io.checksum.crc16;
*/
public class CRC16Modbus extends CRC16Checksum{
private static final int wCPoly = 0xa001;
private static final int WC_POLY = 0xa001;
@Override
public void reset(){
@ -23,7 +23,7 @@ public class CRC16Modbus extends CRC16Checksum{
for (int j = 0; j < 8; j++) {
if ((wCRCin & 0x0001) != 0) {
wCRCin >>= 1;
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
} else {
wCRCin >>= 1;
}

View File

@ -9,7 +9,7 @@ package cn.hutool.core.io.checksum.crc16;
*/
public class CRC16USB extends CRC16Checksum{
private static final int wCPoly = 0xa001;
private static final int WC_POLY = 0xa001;
@Override
public void reset(){
@ -28,7 +28,7 @@ public class CRC16USB extends CRC16Checksum{
for (int j = 0; j < 8; j++) {
if ((wCRCin & 0x0001) != 0) {
wCRCin >>= 1;
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
} else {
wCRCin >>= 1;
}

View File

@ -9,7 +9,7 @@ package cn.hutool.core.io.checksum.crc16;
*/
public class CRC16X25 extends CRC16Checksum{
private static final int wCPoly = 0x8408;
private static final int WC_POLY = 0x8408;
@Override
public void reset(){
@ -28,7 +28,7 @@ public class CRC16X25 extends CRC16Checksum{
for (int j = 0; j < 8; j++) {
if ((wCRCin & 0x0001) != 0) {
wCRCin >>= 1;
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
} else {
wCRCin >>= 1;
}

View File

@ -10,7 +10,7 @@ package cn.hutool.core.io.checksum.crc16;
public class CRC16XModem extends CRC16Checksum{
// 0001 0000 0010 0001 (0, 5, 12)
private static final int wCPoly = 0x1021;
private static final int WC_POLY = 0x1021;
@Override
public void update(byte[] b, int off, int len) {
@ -25,7 +25,7 @@ public class CRC16XModem extends CRC16Checksum{
boolean c15 = ((wCRCin >> 15 & 1) == 1);
wCRCin <<= 1;
if (c15 ^ bit)
wCRCin ^= wCPoly;
wCRCin ^= WC_POLY;
}
}
}

View File

@ -31,9 +31,9 @@ import cn.hutool.core.util.StrUtil;
public class ObjectId {
/** 线程安全的下一个随机数,每次生成自增+1 */
private static final AtomicInteger nextInc = new AtomicInteger(RandomUtil.randomInt());
private static final AtomicInteger NEXT_INC = new AtomicInteger(RandomUtil.randomInt());
/** 机器信息 */
private static final int machine = getMachinePiece() | getProcessPiece();
private static final int MACHINE = getMachinePiece() | getProcessPiece();
/**
* 给定的字符串是否为有效的ObjectId
@ -77,8 +77,8 @@ public class ObjectId {
public static byte[] nextBytes() {
final ByteBuffer bb = ByteBuffer.wrap(new byte[12]);
bb.putInt((int) DateUtil.currentSeconds());// 4位
bb.putInt(machine);// 4位
bb.putInt(nextInc.getAndIncrement());// 4位
bb.putInt(MACHINE);// 4位
bb.putInt(NEXT_INC.getAndIncrement());// 4位
return bb.array();
}

View File

@ -49,7 +49,7 @@ public class UUID implements java.io.Serializable, Comparable<UUID> {
* @author looly
*/
private static class Holder {
static final SecureRandom numberGenerator = RandomUtil.getSecureRandom();
static final SecureRandom NUMBER_GENERATOR = RandomUtil.getSecureRandom();
}
/**
@ -117,7 +117,7 @@ public class UUID implements java.io.Serializable, Comparable<UUID> {
* @return 随机生成的 {@code UUID}
*/
public static UUID randomUUID(boolean isSecure) {
final Random ng = isSecure ? Holder.numberGenerator : RandomUtil.getRandom();
final Random ng = isSecure ? Holder.NUMBER_GENERATOR : RandomUtil.getRandom();
final byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);

View File

@ -17,7 +17,7 @@ import java.util.Map;
*/
public class ActualTypeMapperPool {
private static final SimpleCache<Type, Map<Type, Type>> cache = new SimpleCache<>();
private static final SimpleCache<Type, Map<Type, Type>> CACHE = new SimpleCache<>();
/**
* 获取泛型变量和泛型实际类型的对应关系Map
@ -26,7 +26,7 @@ public class ActualTypeMapperPool {
* @return 泛型对应关系Map
*/
public static Map<Type, Type> get(Type type) {
return cache.get(type, () -> createTypeMap(type));
return CACHE.get(type, () -> createTypeMap(type));
}
/**

View File

@ -67,7 +67,7 @@ public class Money implements Serializable, Comparable<Money> {
* 此处是指货币的最小单位是货币的最常用单位
* 不同的币种有不同的元/分换算比例如人民币是100而日元为1
*/
private static final int[] centFactors = new int[]{1, 10, 100, 1000};
private static final int[] CENT_FACTORS = new int[]{1, 10, 100, 1000};
/**
* 金额以分为单位
@ -318,7 +318,7 @@ public class Money implements Serializable, Comparable<Money> {
* @return 本货币币种的元/分换算比率
*/
public int getCentFactor() {
return centFactors[currency.getDefaultFractionDigits()];
return CENT_FACTORS[currency.getDefaultFractionDigits()];
}
// 基本对象方法 ===================================================

View File

@ -11,41 +11,41 @@ import java.util.Map;
*/
public class MaskBit {
private static final Map<Integer, String> maskBitMap;
private static final Map<Integer, String> MASK_BIT_MAP;
static {
maskBitMap = new HashMap<>(32);
maskBitMap.put(1, "128.0.0.0");
maskBitMap.put(2, "192.0.0.0");
maskBitMap.put(3, "224.0.0.0");
maskBitMap.put(4, "240.0.0.0");
maskBitMap.put(5, "248.0.0.0");
maskBitMap.put(6, "252.0.0.0");
maskBitMap.put(7, "254.0.0.0");
maskBitMap.put(8, "255.0.0.0");
maskBitMap.put(9, "255.128.0.0");
maskBitMap.put(10, "255.192.0.0");
maskBitMap.put(11, "255.224.0.0");
maskBitMap.put(12, "255.240.0.0");
maskBitMap.put(13, "255.248.0.0");
maskBitMap.put(14, "255.252.0.0");
maskBitMap.put(15, "255.254.0.0");
maskBitMap.put(16, "255.255.0.0");
maskBitMap.put(17, "255.255.128.0");
maskBitMap.put(18, "255.255.192.0");
maskBitMap.put(19, "255.255.224.0");
maskBitMap.put(20, "255.255.240.0");
maskBitMap.put(21, "255.255.248.0");
maskBitMap.put(22, "255.255.252.0");
maskBitMap.put(23, "255.255.254.0");
maskBitMap.put(24, "255.255.255.0");
maskBitMap.put(25, "255.255.255.128");
maskBitMap.put(26, "255.255.255.192");
maskBitMap.put(27, "255.255.255.224");
maskBitMap.put(28, "255.255.255.240");
maskBitMap.put(29, "255.255.255.248");
maskBitMap.put(30, "255.255.255.252");
maskBitMap.put(31, "255.255.255.254");
maskBitMap.put(32, "255.255.255.255");
MASK_BIT_MAP = new HashMap<>(32);
MASK_BIT_MAP.put(1, "128.0.0.0");
MASK_BIT_MAP.put(2, "192.0.0.0");
MASK_BIT_MAP.put(3, "224.0.0.0");
MASK_BIT_MAP.put(4, "240.0.0.0");
MASK_BIT_MAP.put(5, "248.0.0.0");
MASK_BIT_MAP.put(6, "252.0.0.0");
MASK_BIT_MAP.put(7, "254.0.0.0");
MASK_BIT_MAP.put(8, "255.0.0.0");
MASK_BIT_MAP.put(9, "255.128.0.0");
MASK_BIT_MAP.put(10, "255.192.0.0");
MASK_BIT_MAP.put(11, "255.224.0.0");
MASK_BIT_MAP.put(12, "255.240.0.0");
MASK_BIT_MAP.put(13, "255.248.0.0");
MASK_BIT_MAP.put(14, "255.252.0.0");
MASK_BIT_MAP.put(15, "255.254.0.0");
MASK_BIT_MAP.put(16, "255.255.0.0");
MASK_BIT_MAP.put(17, "255.255.128.0");
MASK_BIT_MAP.put(18, "255.255.192.0");
MASK_BIT_MAP.put(19, "255.255.224.0");
MASK_BIT_MAP.put(20, "255.255.240.0");
MASK_BIT_MAP.put(21, "255.255.248.0");
MASK_BIT_MAP.put(22, "255.255.252.0");
MASK_BIT_MAP.put(23, "255.255.254.0");
MASK_BIT_MAP.put(24, "255.255.255.0");
MASK_BIT_MAP.put(25, "255.255.255.128");
MASK_BIT_MAP.put(26, "255.255.255.192");
MASK_BIT_MAP.put(27, "255.255.255.224");
MASK_BIT_MAP.put(28, "255.255.255.240");
MASK_BIT_MAP.put(29, "255.255.255.248");
MASK_BIT_MAP.put(30, "255.255.255.252");
MASK_BIT_MAP.put(31, "255.255.255.254");
MASK_BIT_MAP.put(32, "255.255.255.255");
}
/**
@ -55,6 +55,6 @@ public class MaskBit {
* @return 掩码
*/
public static String get(int maskBit) {
return maskBitMap.get(maskBit);
return MASK_BIT_MAP.get(maskBit);
}
}

View File

@ -20,12 +20,12 @@ import cn.hutool.core.swing.clipboard.ClipboardUtil;
*/
public class RobotUtil {
private static final Robot robot;
private static final Robot ROBOT;
private static int delay;
static {
try {
robot = new Robot();
ROBOT = new Robot();
} catch (AWTException e) {
throw new UtilException(e);
}
@ -50,7 +50,7 @@ public class RobotUtil {
* @since 4.5.7
*/
public static void mouseMove(int x, int y) {
robot.mouseMove(x, y);
ROBOT.mouseMove(x, y);
}
/**
@ -60,8 +60,8 @@ public class RobotUtil {
* @since 4.5.7
*/
public static void click() {
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
ROBOT.mousePress(InputEvent.BUTTON1_MASK);
ROBOT.mouseRelease(InputEvent.BUTTON1_MASK);
delay();
}
@ -72,8 +72,8 @@ public class RobotUtil {
* @since 4.5.7
*/
public static void rightClick() {
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
ROBOT.mousePress(InputEvent.BUTTON1_MASK);
ROBOT.mouseRelease(InputEvent.BUTTON1_MASK);
delay();
}
@ -84,7 +84,7 @@ public class RobotUtil {
* @since 4.5.7
*/
public static void mouseWheel(int wheelAmt) {
robot.mouseWheel(wheelAmt);
ROBOT.mouseWheel(wheelAmt);
delay();
}
@ -97,8 +97,8 @@ public class RobotUtil {
*/
public static void keyClick(int... keyCodes) {
for (int keyCode : keyCodes) {
robot.keyPress(keyCode);
robot.keyRelease(keyCode);
ROBOT.keyPress(keyCode);
ROBOT.keyRelease(keyCode);
}
delay();
}
@ -120,10 +120,10 @@ public class RobotUtil {
* @param key 按键
*/
public static void keyPressWithShift(int key) {
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(key);
robot.keyRelease(key);
robot.keyRelease(KeyEvent.VK_SHIFT);
ROBOT.keyPress(KeyEvent.VK_SHIFT);
ROBOT.keyPress(key);
ROBOT.keyRelease(key);
ROBOT.keyRelease(KeyEvent.VK_SHIFT);
delay();
}
@ -133,10 +133,10 @@ public class RobotUtil {
* @param key 按键
*/
public static void keyPressWithCtrl(int key) {
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(key);
robot.keyRelease(key);
robot.keyRelease(KeyEvent.VK_CONTROL);
ROBOT.keyPress(KeyEvent.VK_CONTROL);
ROBOT.keyPress(key);
ROBOT.keyRelease(key);
ROBOT.keyRelease(KeyEvent.VK_CONTROL);
delay();
}
@ -146,10 +146,10 @@ public class RobotUtil {
* @param key 按键
*/
public static void keyPressWithAlt(int key) {
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(key);
robot.keyRelease(key);
robot.keyRelease(KeyEvent.VK_ALT);
ROBOT.keyPress(KeyEvent.VK_ALT);
ROBOT.keyPress(key);
ROBOT.keyRelease(key);
ROBOT.keyRelease(KeyEvent.VK_ALT);
delay();
}
@ -180,7 +180,7 @@ public class RobotUtil {
* @return 截屏的图片
*/
public static BufferedImage captureScreen(Rectangle screenRect) {
return robot.createScreenCapture(screenRect);
return ROBOT.createScreenCapture(screenRect);
}
/**
@ -200,7 +200,7 @@ public class RobotUtil {
*/
private static void delay() {
if (delay > 0) {
robot.delay(delay);
ROBOT.delay(delay);
}
}
}

View File

@ -33,13 +33,13 @@ public class ClassLoaderUtil {
private static final char INNER_CLASS_SEPARATOR = '$';
/** 原始类型名和其class对应表例如int =》 int.class */
private static final Map<String, Class<?>> primitiveTypeNameMap = new ConcurrentHashMap<>(32);
private static final SimpleCache<String, Class<?>> classCache = new SimpleCache<>();
private static final Map<String, Class<?>> PRIMITIVE_TYPE_NAME_MAP = new ConcurrentHashMap<>(32);
private static final SimpleCache<String, Class<?>> CLASS_CACHE = new SimpleCache<>();
static {
List<Class<?>> primitiveTypes = new ArrayList<>(32);
// 加入原始类型
primitiveTypes.addAll(BasicType.primitiveWrapperMap.keySet());
primitiveTypes.addAll(BasicType.PRIMITIVE_WRAPPER_MAP.keySet());
// 加入原始类型数组类型
primitiveTypes.add(boolean[].class);
primitiveTypes.add(byte[].class);
@ -51,7 +51,7 @@ public class ClassLoaderUtil {
primitiveTypes.add(short[].class);
primitiveTypes.add(void.class);
for (Class<?> primitiveType : primitiveTypes) {
primitiveTypeNameMap.put(primitiveType.getName(), primitiveType);
PRIMITIVE_TYPE_NAME_MAP.put(primitiveType.getName(), primitiveType);
}
}
@ -150,7 +150,7 @@ public class ClassLoaderUtil {
// 加载原始类型和缓存中的类
Class<?> clazz = loadPrimitiveClass(name);
if (clazz == null) {
clazz = classCache.get(name);
clazz = CLASS_CACHE.get(name);
}
if (clazz != null) {
return clazz;
@ -188,7 +188,7 @@ public class ClassLoaderUtil {
}
// 加入缓存并返回
return classCache.put(name, clazz);
return CLASS_CACHE.put(name, clazz);
}
/**
@ -202,7 +202,7 @@ public class ClassLoaderUtil {
if (StrUtil.isNotBlank(name)) {
name = name.trim();
if (name.length() <= 8) {
result = primitiveTypeNameMap.get(name);
result = PRIMITIVE_TYPE_NAME_MAP.get(name);
}
}
return result;

View File

@ -713,7 +713,7 @@ public class ClassUtil {
if (null == clazz) {
return false;
}
return BasicType.wrapperPrimitiveMap.containsKey(clazz);
return BasicType.WRAPPER_PRIMITIVE_MAP.containsKey(clazz);
}
/**
@ -798,11 +798,11 @@ public class ClassUtil {
// 基本类型
if (targetType.isPrimitive()) {
// 原始类型
Class<?> resolvedPrimitive = BasicType.wrapperPrimitiveMap.get(sourceType);
Class<?> resolvedPrimitive = BasicType.WRAPPER_PRIMITIVE_MAP.get(sourceType);
return targetType.equals(resolvedPrimitive);
} else {
// 包装类型
Class<?> resolvedWrapper = BasicType.primitiveWrapperMap.get(sourceType);
Class<?> resolvedWrapper = BasicType.PRIMITIVE_WRAPPER_MAP.get(sourceType);
return resolvedWrapper != null && targetType.isAssignableFrom(resolvedWrapper);
}
}

View File

@ -38,7 +38,7 @@ public class IdcardUtil {
/**
* 每位加权因子
*/
private static final int[] power = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
private static final int[] POWER = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
/**
* 省市代码表
*/
@ -602,9 +602,9 @@ public class IdcardUtil {
*/
private static int getPowerSum(char[] iArr) {
int iSum = 0;
if (power.length == iArr.length) {
if (POWER.length == iArr.length) {
for (int i = 0; i < iArr.length; i++) {
iSum += Integer.parseInt(String.valueOf(iArr[i])) * power[i];
iSum += Integer.parseInt(String.valueOf(iArr[i])) * POWER[i];
}
}
return iSum;