程序包 org.coodex.util
类 Common
java.lang.Object
org.coodex.util.Common
- 作者:
- davidoff
-
嵌套类概要
嵌套类修饰符和类型类说明static classstatic enumstatic classstatic classstatic classstatic class -
字段概要
字段 -
方法概要
修饰符和类型方法说明static <T> Set<T>arrayToSet(T[] array) static byte[]base16Decode(String hexString) static byte[]base16Decode(String hexString, String ignoreChars) static Stringbase16Encode(byte[] b) static Stringbase16Encode(byte[] b, int offset, int length) static Stringbase16Encode(byte[] b, int offset, int length, int col, String split) static Stringbase16Encode(byte[] b, int offset, int length, Function<Integer, Integer> colFunction, String split) static Stringbase16Encode(byte[] b, int col, String split) static Stringbase16Encode(byte[] b, Function<Integer, Integer> colFunction, String split) static <T extends Comparable<T>>
booleanbetween(T t, T bound1, T bound2) 已过时。static Stringbyte2hex(byte[] b) 已过时。static Stringbyte2hex(byte[] b, int offset, int length) 已过时。static String已过时。static String已过时。static Calendarcalendar(int year) static Calendarcalendar(int year, int month) static Calendarcalendar(int year, int month, int date) static Calendarcalendar(int year, int month, int date, int hour) static Calendarcalendar(int year, int month, int date, int hour, int minute) static Calendarcalendar(int year, int month, int date, int hour, int minute, int second) static Calendarcalendar(int year, int month, int date, int hour, int minute, int second, int millisecond) static StringcalendarToStr(Calendar calendar) static StringcalendarToStr(Calendar calendar, String format) static Stringstatic Stringstatic Stringstatic Stringstatic <T> Tstatic void已过时。static Stringconcat(Collection<String> list, String split) static Calendarstatic <K extends Serializable,V extends Serializable>
voidstatic voidcopyStream(InputStream is, OutputStream os) static voidcopyStream(InputStream is, OutputStream os, int blockSize, boolean flushPerBlock, int bps) static CalendardateToCalendar(Date date) static Stringstatic Stringstatic <T extends Serializable>
TdeepCopy(T object) static Objectdeserialize(byte[] buf) static <T> Set<T>difference(Set<T> org, Set<T> todiv) 差集 org - todivstatic <T> intfindInArray(T el, T[] array) static <T> TfirstValuable(T... s) static <T> voidforEachBlock(T[] all, int blockSize, boolean continuous, float redundancy, BiConsumer<Integer, Integer> consumer) 对一个大数组进行分块操作static <T> voidforEachBlock(T[] all, int blockSize, boolean continuous, float redundancy, IntFunction<T[]> arrayProvider, Consumer<T[]> consumer) 对一个大数组进行分块操作static <T> StringformatArray(T[] array, int offset, int length, Function<Integer, Integer> colFunction, String split, Function<T, String> encoder) static FilegetNewFile(String fileName) 已过时。static URLgetResource(String resource, ClassLoader... classLoaders) static DateFormatgetSafetyDateFormat(String format) static Longstatic String已过时。static byte[]已过时。static byte[]已过时。static <T> booleaninArray(T el, T[] array) static <T> intindexOf(T[] array, T t) static <T> Set<T>intersection(Set<T> set1, Set<T> set2) 交集static booleanstatic booleanisDebug()static booleanisEmpty(Collection<?> collection) static booleanstatic booleanstatic <T,C extends Collection<T>>
Cjoin(C instance, Collection<? extends T>... collections) static byte[]long2Bytes(long data) static CalendarlongToCalendar(long l) static StringlongToDateStr(long l) static StringlongToDateStr(long l, String format) static StringlowerFirstChar(String string) static <T extends Comparable<T>>
Tmax(T c1, T c2, T... others) static <T extends Comparable<T>>
Tmin(T c1, T c2, T... others) static Stringnative2AscII(String str) static Filestatic booleannotEmpty(Collection<?> collection) static Stringnow()static Stringstatic Stringstatic byterandom(byte[] range) static doublerandom(double[] range) static doublerandom(double min, double max) static floatrandom(float[] range) static intrandom(int max) static intrandom(int[] range) static intrandom(int min, int max) static longrandom(long max) static longrandom(long[] range) static longrandom(long min, long max) static shortrandom(short[] range) static <T> Trandom(T[] range) static intrandomC(int max) static intrandomC(int min, int max) static longrandomC(long max) static longrandomC(long min, long max) static charrandomChar(String s) static charstatic Stringstatic RuntimeExceptionstatic booleansameString(String str1, String str2) 已过时。static longscale(double d) static doublescale(double d, int scale) static doublescale(double d, int scale, RoundingMode roundingMode) static longscale(double d, RoundingMode roundingMode) static floatscale2F(double d, int scale) static floatscale2F(double d, int scale, RoundingMode roundingMode) static intscale2I(double d) static intscale2I(double d, RoundingMode roundingMode) static byte[]static Stringstatic Stringstatic doublesimilarity(String s1, String s2) static voidsleep(long ms) static <T> Collection<Common.ArrayBlockRef>slice(T[] all, int blockSize, boolean continuous, float redundancy) 将一个大数组分块static <T> List<T>sort(List<T> list, Comparator<T> comparator) static CalendarstrToCalendar(String str, String format) static Datestatic Datestatic <T> Tstatic StringtoAbsolutePath(String path) static String[]static String[]static booleanstatic booleanstatic byte[]toBytes(long l, int wide, Endianness endianness) static intstatic intstatic longstatic longstatic Stringstatic Stringstatic Calendarstatic StringupperFirstChar(String string)
-
字段详细资料
-
方法详细资料
-
isWindows
public static boolean isWindows() -
toAbsolutePath
-
isDebug
public static boolean isDebug() -
toBytes
-
arrayToSet
-
getUUIDStr
已过时。作为id时,使用IDGenerator.newId()替代获取uuid时,使用
UUIDHelper.getUUIDString()- 返回:
- uuid
-
sha1
-
sha1
-
inArray
public static <T> boolean inArray(T el, T[] array) -
findInArray
-
nullToStr
-
serialize
- 抛出:
IOException
-
deserialize
-
deepCopy
public static <T extends Serializable> T deepCopy(T object) throws IOException, ClassNotFoundException -
random
public static int random(int max) - 参数:
max- 正整数- 返回:
- [0, max)的随机数
-
randomC
public static int randomC(int max) - 参数:
max- 非负正数- 返回:
- [0, max]的随机数
-
random
public static int random(int min, int max) -
randomC
public static int randomC(int min, int max) -
random
public static long random(long min, long max) -
random
public static long random(long max) -
randomC
public static long randomC(long max) -
randomC
public static long randomC(long min, long max) -
random
public static double random(double min, double max) -
copyMap
public static <K extends Serializable,V extends Serializable> void copyMap(Map<K, V> org, Map<K, V> target) -
isBlank
-
firstValuable
-
isEmpty
-
notEmpty
-
copyStream
- 抛出:
IOException
-
copyStream
public static void copyStream(InputStream is, OutputStream os, int blockSize, boolean flushPerBlock, int bps) throws IOException - 抛出:
IOException
-
checkNull
已过时。 -
between
-
max
-
byte2hex
已过时。 -
byte2hex
已过时。 -
byte2hex
已过时。 -
byte2hex
已过时。 -
base16Encode
- 参数:
b- 需要编码的字节数组- 返回:
- 编码后的字符串
-
base16Encode
- 参数:
b- 需要编码的字节数组offset- 编码字节数组偏移length- 编码字节数组长度- 返回:
- 编码后的字符串
-
base16Encode
- 参数:
b- 需要编码的字节数组col- 每个字节编码后算一列,此参数用来指定编码后每行多少列,行与行之间使用系统变量line.separator来分隔split- 列于列之间的分隔字符传串,行首行尾不加- 返回:
- 编码后的字符串
-
base16Encode
- 参数:
b- 需要编码的字节数组colFunction- 每个字节编码后算一列,此参数用来指定编码后各行多少列,行与行之间使用系统变量line.separator来分隔split- 列于列之间的分隔字符传串,行首行尾不加- 返回:
- 编码后的字符串
-
base16Encode
- 参数:
b- 需要编码的字节数组offset- 编码字节数组偏移length- 编码字节数组长度col- 每个字节编码后算一列,此参数用来指定编码后每行多少列,行与行之间使用系统变量line.separator来分隔split- 列于列之间的分隔字符传串,行首行尾不加- 返回:
- 编码后的字符串
-
base16Encode
public static String base16Encode(byte[] b, int offset, int length, Function<Integer, Integer> colFunction, String split) - 参数:
b- 需要编码的字节数组offset- 编码字节数组偏移length- 编码字节数组长度colFunction- 每个字节编码后算一列,此参数用来指定编码后各行多少列,行与行之间使用系统变量line.separator来分隔split- 列于列之间的分隔字符传串,行首行尾不加- 返回:
- 编码后的字符串
-
formatArray
-
hex2byte
已过时。 -
hex2byte
已过时。 -
base16Decode
-
base16Decode
-
intersection
交集- 参数:
set1- set1set2- set2- 返回:
- 交集
-
difference
差集 org - todiv- 参数:
org- orgtodiv- todiv- 返回:
- 差集 org - todiv
-
join
@SafeVarargs public static <T,C extends Collection<T>> C join(C instance, Collection<? extends T>... collections) -
native2AscII
-
getNewFile
已过时。- 抛出:
IOException
-
newFile
- 抛出:
IOException
-
getResource
-
indexOf
public static <T> int indexOf(T[] array, T t) -
concat
-
to
-
toInt
-
toInt
-
toLong
-
toLong
-
toBool
-
toBool
-
toArray
-
toArray
-
toArray
-
trim
-
trim
-
sameString
已过时。 -
randomGB2312Char
public static char randomGB2312Char()- 返回:
- 一个随机的中文字符(GB2312的一级文字)
-
randomChar
-
random
public static <T> T random(T[] range) -
random
public static byte random(byte[] range) -
random
public static short random(short[] range) -
random
public static int random(int[] range) -
random
public static long random(long[] range) -
random
public static float random(float[] range) -
random
public static double random(double[] range) -
randomStr
-
copy
-
lowerFirstChar
-
upperFirstChar
-
camelCase
-
camelCase
-
camelCase
-
camelCase
-
similarity
- 参数:
s1- s1s2- s2- 返回:
- 两个字符串的相似度
-
subMap
-
calendarToStr
-
calendarToStr
-
dateToStr
-
dateToStr
-
getSafetyDateFormat
-
strToDate
- 抛出:
ParseException
-
strToDate
- 抛出:
ParseException
-
strToCalendar
- 抛出:
ParseException
-
long2Bytes
public static byte[] long2Bytes(long data) -
longToDateStr
-
longToDateStr
-
longToCalendar
-
dateToCalendar
-
min
-
calendar
-
calendar
-
calendar
-
calendar
-
calendar
-
calendar
-
calendar
public static Calendar calendar(int year, int month, int date, int hour, int minute, int second, int millisecond) -
truncate
-
now
-
now
-
rte
-
getSystemStart
-
cast
-
sleep
public static void sleep(long ms) -
forEachBlock
public static <T> void forEachBlock(T[] all, int blockSize, boolean continuous, float redundancy, BiConsumer<Integer, Integer> consumer) 对一个大数组进行分块操作- 类型参数:
T- 元素类型- 参数:
all- 所有的数据blockSize- 块大小continuous- 是否连续,[0,100),[100, last]为不连续,[0,100][100, last]为连续redundancy- 最后一块的冗余比例consumer- 每块数据如何处理
-
forEachBlock
public static <T> void forEachBlock(T[] all, int blockSize, boolean continuous, float redundancy, IntFunction<T[]> arrayProvider, Consumer<T[]> consumer) 对一个大数组进行分块操作- 类型参数:
T- T- 参数:
all- 所有元素blockSize- 块大小continuous- 是否连续,[0,100),[100, last]为不连续,[0,100][100, last]为连续redundancy- 最后一块的冗余比例arrayProvider- 新数组如何创建consumer- 数组处理逻辑
-
slice
public static <T> Collection<Common.ArrayBlockRef> slice(T[] all, int blockSize, boolean continuous, float redundancy) 将一个大数组分块- 类型参数:
T- T- 参数:
all- 大数组blockSize- 块大小continuous- 是否连续,[0,100),[100, last]为不连续,[0,100][100, last]为连续redundancy- 最后一块的冗余比例- 返回:
- 拆分后的数组描述(从哪个下标开始 , 长度)
-
isJava9AndLast
public static boolean isJava9AndLast() -
scale
public static long scale(double d) -
scale
-
scale2I
public static int scale2I(double d) -
scale2I
-
scale2F
public static float scale2F(double d, int scale) -
scale2F
-
scale
public static double scale(double d, int scale) -
scale
-
sort
-
Common.Edge.between(Comparable, Comparable, Comparable)替代