This commit is contained in:
Looly 2023-03-13 01:11:43 +08:00
parent f05e084a3b
commit 5b559d19bd
94 changed files with 320 additions and 309 deletions

View File

@ -17,69 +17,6 @@
<description>Hutool是一个优雅而小巧的Java工具类库</description>
<url>https://github.com/looly/hutool</url>
<dependencies>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-db</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-extra</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-http</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-log</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-setting</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-cron</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-json</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-poi</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-socket</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-swing</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

View File

@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base16Codec;
import cn.hutool.core.codec.binary.Base16Codec;
import cn.hutool.core.exceptions.UtilException;
import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.CharsetUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base16Codec;
import cn.hutool.core.codec.binary.Base16Codec;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.text.CharPool;
import cn.hutool.core.text.StrUtil;

View File

@ -1,4 +1,4 @@
package cn.hutool.core.codec.BaseN;
package cn.hutool.core.codec.binary;
import cn.hutool.core.codec.Decoder;
import cn.hutool.core.codec.Encoder;
@ -81,7 +81,7 @@ public class Base16Codec implements Encoder<byte[], char[]>, Decoder<CharSequenc
* 转换的字符串如果u后不足4位则前面用0填充例如
*
* <pre>
* '你' ='\u4f60'
* '你' ='&#92;u4f60'
* </pre>
*
* @param ch char值

View File

@ -1,4 +1,4 @@
package cn.hutool.core.codec.BaseN;
package cn.hutool.core.codec.binary;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.text.StrUtil;

View File

@ -1,4 +1,4 @@
package cn.hutool.core.codec.BaseN;
package cn.hutool.core.codec.binary;
import cn.hutool.core.codec.Decoder;
import cn.hutool.core.codec.Encoder;
@ -21,6 +21,9 @@ import java.util.Arrays;
*/
public class Base32Codec implements Encoder<byte[], String>, Decoder<CharSequence, byte[]> {
/**
* 单例对象
*/
public static Base32Codec INSTANCE = new Base32Codec();
@Override

View File

@ -1,4 +1,4 @@
package cn.hutool.core.codec.BaseN;
package cn.hutool.core.codec.binary;
import cn.hutool.core.exceptions.UtilException;
import cn.hutool.core.exceptions.ValidateException;

View File

@ -1,4 +1,4 @@
package cn.hutool.core.codec.BaseN;
package cn.hutool.core.codec.binary;
import cn.hutool.core.codec.Decoder;
import cn.hutool.core.codec.Encoder;

View File

@ -1,4 +1,4 @@
package cn.hutool.core.codec.BaseN;
package cn.hutool.core.codec.binary;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IoUtil;

View File

@ -1,4 +1,4 @@
package cn.hutool.core.codec.BaseN;
package cn.hutool.core.codec.binary;
import cn.hutool.core.codec.Decoder;
import cn.hutool.core.codec.Encoder;

View File

@ -1,4 +1,4 @@
package cn.hutool.core.codec.BaseN;
package cn.hutool.core.codec.binary;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IoUtil;

View File

@ -1,4 +1,4 @@
package cn.hutool.core.codec.BaseN;
package cn.hutool.core.codec.binary;
import cn.hutool.core.codec.Decoder;
import cn.hutool.core.lang.mutable.MutableInt;
@ -13,6 +13,9 @@ import cn.hutool.core.util.ArrayUtil;
*/
public class Base64Decoder implements Decoder<byte[], byte[]> {
/**
* 单例对象
*/
public static Base64Decoder INSTANCE = new Base64Decoder();
private static final byte PADDING = -2;

View File

@ -0,0 +1,11 @@
/**
* BaseN编码解码提供将bytes和baseN的编码转换功能
* <ul>
* <li>Base16</li>
* <li>Base32</li>
* <li>Base58</li>
* <li>Base62</li>
* <li>Base64</li>
* </ul>
*/
package cn.hutool.core.codec.binary;

View File

@ -1,6 +1,6 @@
package cn.hutool.core.convert.impl;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.convert.AbstractConverter;
import cn.hutool.core.convert.Convert;

View File

@ -164,8 +164,6 @@ public class TemporalAccessorUtil extends TemporalUtil{
result = ((OffsetTime) temporalAccessor).atDate(LocalDate.now()).toInstant();
} else {
// issue#1891@Github
// Instant.from不能完成日期转换
//result = Instant.from(temporalAccessor);
result = toInstant(TimeUtil.of(temporalAccessor));
}

View File

@ -16,7 +16,10 @@ import cn.hutool.core.date.format.DefaultDateBasic;
* @since 6.0.0
*/
public class CSTDateParser extends DefaultDateBasic implements DateParser {
private static final long serialVersionUID = 1L;
/**
* 单例对象
*/
public static CSTDateParser INSTANCE = new CSTDateParser();
@Override

View File

@ -21,7 +21,11 @@ import cn.hutool.core.util.CharUtil;
* @since 6.0.0
*/
public class NormalDateParser extends DefaultDateBasic implements DateParser {
private static final long serialVersionUID = 1L;
/**
* 单例
*/
public static NormalDateParser INSTANCE = new NormalDateParser();
@Override

View File

@ -16,6 +16,7 @@ import java.util.Locale;
* @since 6.0.0
*/
public class PatternsDateParser extends DefaultDateBasic implements DateParser {
private static final long serialVersionUID = 1L;
/**
* 创建 PatternsDateParser

View File

@ -18,7 +18,11 @@ import cn.hutool.core.date.format.DefaultDateBasic;
* @since 6.0.0
*/
public class PureDateParser extends DefaultDateBasic implements DateParser {
private static final long serialVersionUID = 1L;
/**
* 单例
*/
public static PureDateParser INSTANCE = new PureDateParser();
@Override

View File

@ -17,7 +17,11 @@ import cn.hutool.core.text.StrUtil;
* @since 6.0.0
*/
public class TimeParser extends DefaultDateBasic implements DateParser {
private static final long serialVersionUID = 1L;
/**
* 单例
*/
public static TimeParser INSTANCE = new TimeParser();
@Override

View File

@ -109,6 +109,7 @@ public class UTCDateParser extends DefaultDateBasic implements DateParser {
* @param after 毫秒部分的后一个字符
* @return 规范之后的毫秒部分
*/
@SuppressWarnings("SameParameterValue")
private static String normalizeMillSeconds(final String dateStr, final CharSequence before, final CharSequence after) {
if (StrUtil.isBlank(after)) {
final String millOrNaco = StrUtil.subPre(StrUtil.subAfter(dateStr, before, true), 3);

View File

@ -6,28 +6,66 @@ package cn.hutool.core.exceptions;
* @author looly
*/
public class InvocationTargetRuntimeException extends UtilException {
private static final long serialVersionUID = 1L;
/**
* 构造
*
* @param e 异常
*/
public InvocationTargetRuntimeException(final Throwable e) {
super(e);
}
/**
* 构造
*
* @param message 消息
*/
public InvocationTargetRuntimeException(final String message) {
super(message);
}
/**
* 构造
*
* @param messageTemplate 消息模板
* @param params 参数
*/
public InvocationTargetRuntimeException(final String messageTemplate, final Object... params) {
super(messageTemplate, params);
}
public InvocationTargetRuntimeException(final String message, final Throwable throwable) {
super(message, throwable);
/**
* 构造
*
* @param message 消息
* @param cause 被包装的子异常
*/
public InvocationTargetRuntimeException(final String message, final Throwable cause) {
super(message, cause);
}
public InvocationTargetRuntimeException(final String message, final Throwable throwable, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, throwable, enableSuppression, writableStackTrace);
/**
* 构造
*
* @param message 消息
* @param cause 被包装的子异常
* @param enableSuppression 是否启用抑制
* @param writableStackTrace 堆栈跟踪是否应该是可写的
*/
public InvocationTargetRuntimeException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public InvocationTargetRuntimeException(final Throwable throwable, final String messageTemplate, final Object... params) {
super(throwable, messageTemplate, params);
/**
* 构造
*
* @param cause 被包装的子异常
* @param messageTemplate 消息模板
* @param params 参数
*/
public InvocationTargetRuntimeException(final Throwable cause, final String messageTemplate, final Object... params) {
super(cause, messageTemplate, params);
}
}

View File

@ -10,8 +10,8 @@ import cn.hutool.core.text.StrUtil;
public class UtilException extends RuntimeException {
private static final long serialVersionUID = 8247610319171014183L;
public UtilException(final Throwable e) {
super(ExceptionUtil.getMessage(e), e);
public UtilException(final Throwable cause) {
super(ExceptionUtil.getMessage(cause), cause);
}
public UtilException(final String message) {
@ -22,15 +22,15 @@ public class UtilException extends RuntimeException {
super(StrUtil.format(messageTemplate, params));
}
public UtilException(final String message, final Throwable throwable) {
super(message, throwable);
public UtilException(final String message, final Throwable cause) {
super(message, cause);
}
public UtilException(final String message, final Throwable throwable, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, throwable, enableSuppression, writableStackTrace);
public UtilException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public UtilException(final Throwable throwable, final String messageTemplate, final Object... params) {
super(StrUtil.format(messageTemplate, params), throwable);
public UtilException(final Throwable cause, final String messageTemplate, final Object... params) {
super(StrUtil.format(messageTemplate, params), cause);
}
}

View File

@ -882,6 +882,19 @@ public class IoUtil extends NioUtil {
}
}
/**
* 关闭<br>
* 关闭失败不会抛出异常
*
* @param closeable 被关闭的对象
* @throws IOException IO异常
*/
public static void nullSafeClose(final Closeable closeable) throws IOException {
if (null != closeable) {
closeable.close();
}
}
/**
* 尝试关闭指定对象<br>
* 判断对象如果实现了{@link AutoCloseable}则调用之

View File

@ -59,7 +59,6 @@ public class PathCopier extends SrcToDestCopier<Path, PathCopier> {
this.src = src;
this.target = Assert.notNull(target, "Target path must be not null !");
this.options = ObjUtil.defaultIfNull(options, new CopyOption[]{});
;
}
/**

View File

@ -58,7 +58,7 @@ public class PathMover {
}
this.src = src;
this.target = Assert.notNull(target, "Target path must be not null !");
this.options = ObjUtil.defaultIfNull(options, new CopyOption[]{});;
this.options = ObjUtil.defaultIfNull(options, new CopyOption[]{});
}
/**

View File

@ -1,6 +1,5 @@
package cn.hutool.core.io.stream;
import java.io.IOException;
import java.io.OutputStream;
/**
@ -47,11 +46,10 @@ public class EmptyOutputStream extends OutputStream {
* 什么也不做写出到 {@code /dev/null}.
*
* @param b 写出的数据
* @throws IOException 不抛出
*/
@SuppressWarnings("NullableProblems")
@Override
public void write(final byte[] b) throws IOException {
public void write(final byte[] b) {
// to /dev/null
}

View File

@ -31,6 +31,7 @@ import java.util.stream.Collectors;
* @since 5.8.0
*/
public class ReferenceConcurrentMap<K, V> implements ConcurrentMap<K, V>, Iterable<Map.Entry<K, V>>, Serializable {
private static final long serialVersionUID = 1L;
final ConcurrentMap<Reference<K>, V> raw;
private final ReferenceQueue<K> lastQueue;

View File

@ -39,7 +39,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
*
* @param mapFactory 生成集合的工厂方法
*/
protected AbsCollValueMap(Supplier<Map<K, Collection<V>>> mapFactory) {
protected AbsCollValueMap(final Supplier<Map<K, Collection<V>>> mapFactory) {
super(mapFactory);
}
@ -48,7 +48,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
*
* @param map 提供初始数据的集合
*/
protected AbsCollValueMap(Map<K, Collection<V>> map) {
protected AbsCollValueMap(final Map<K, Collection<V>> map) {
super(new HashMap<>(map));
}
@ -72,7 +72,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
* @return 是否成功添加
*/
@Override
public boolean putAllValues(K key, Collection<V> coll) {
public boolean putAllValues(final K key, final Collection<V> coll) {
if (ObjUtil.isNull(coll)) {
return false;
}
@ -91,7 +91,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
* @return 是否成功添加
*/
@Override
public boolean putValue(K key, V value) {
public boolean putValue(final K key, final V value) {
return super.computeIfAbsent(key, k -> createCollection())
.add(value);
}
@ -104,7 +104,7 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
* @return 是否成功删除
*/
@Override
public boolean removeValue(K key, V value) {
public boolean removeValue(final K key, final V value) {
return Opt.ofNullable(super.get(key))
.map(t -> t.remove(value))
.orElse(false);
@ -118,11 +118,11 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
* @return 是否成功删除
*/
@Override
public boolean removeAllValues(K key, Collection<V> values) {
public boolean removeAllValues(final K key, final Collection<V> values) {
if (CollUtil.isEmpty(values)) {
return false;
}
Collection<V> coll = get(key);
final Collection<V> coll = get(key);
return ObjUtil.isNotNull(coll) && coll.removeAll(values);
}
@ -133,10 +133,10 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
* @return 当前实例
*/
@Override
public MultiValueMap<K, V> filterAllValues(BiPredicate<K, V> filter) {
public MultiValueMap<K, V> filterAllValues(final BiPredicate<K, V> filter) {
entrySet().forEach(e -> {
K k = e.getKey();
Collection<V> coll = e.getValue().stream()
final K k = e.getKey();
final Collection<V> coll = e.getValue().stream()
.filter(v -> filter.test(k, v))
.collect(Collectors.toCollection(this::createCollection));
e.setValue(coll);
@ -151,10 +151,10 @@ public abstract class AbsCollValueMap<K, V> extends MapWrapper<K, Collection<V>>
* @return 当前实例
*/
@Override
public MultiValueMap<K, V> replaceAllValues(BiFunction<K, V, V> operate) {
public MultiValueMap<K, V> replaceAllValues(final BiFunction<K, V, V> operate) {
entrySet().forEach(e -> {
K k = e.getKey();
Collection<V> coll = e.getValue().stream()
final K k = e.getKey();
final Collection<V> coll = e.getValue().stream()
.map(v -> operate.apply(k, v))
.collect(Collectors.toCollection(this::createCollection));
e.setValue(coll);

View File

@ -14,6 +14,7 @@ import java.util.function.Predicate;
* @since 6.0.0
*/
public class Graph<T> extends SetValueMap<T, T> {
private static final long serialVersionUID = 1L;
/**
* 添加边

View File

@ -3,7 +3,6 @@ package cn.hutool.core.thread;
import cn.hutool.core.exceptions.UtilException;
import java.io.Closeable;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
@ -70,6 +69,7 @@ public class SyncFinisher implements Closeable {
* @param runnable 工作线程
* @return this
*/
@SuppressWarnings("resource")
public SyncFinisher addRepeatWorker(final Runnable runnable) {
for (int i = 0; i < this.threadSize; i++) {
addWorker(new Worker() {
@ -197,7 +197,7 @@ public class SyncFinisher implements Closeable {
}
@Override
public void close() throws IOException {
public void close() {
stop();
}

View File

@ -593,7 +593,7 @@ public class AnnotatedElementUtilTest {
private @interface Annotation4 {}
@Annotation4
private static class Super {};
private static class Super {}
// ================= interface =================
@ -608,7 +608,7 @@ public class AnnotatedElementUtilTest {
private @interface Annotation6 {}
@Annotation6
private interface Interface {};
private interface Interface {}
// ================= foo =================

View File

@ -115,6 +115,6 @@ public class GenericAnnotationMappingTest {
}
@Annotation1("foo")
private static class Foo {};
private static class Foo {}
}

View File

@ -203,6 +203,6 @@ public class HierarchicalAnnotatedElementTest {
public String method() { return null; }
@Annotation1
public static String method2() { return null; }
};
}
}

View File

@ -211,6 +211,6 @@ public class MetaAnnotatedElementTest {
@Annotation3(name = "foo")
@Annotation4("foo")
private static class Foo {};
private static class Foo {}
}

View File

@ -296,6 +296,6 @@ public class ResolvedAnnotationMappingTest {
@Annotation3(value = "Annotation3", alias = 312)
@Annotation2(value = "Annotation2")
@Annotation1(value = "Annotation1", alias = "goo", unDefVal = "foo", unDefVal2 = "foo")
private static class Foo {};
private static class Foo {}
}

View File

@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base32;
import cn.hutool.core.codec.binary.Base32;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.text.StrUtil;
import org.junit.Assert;

View File

@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base58;
import cn.hutool.core.codec.binary.Base58;
import org.junit.Assert;
import org.junit.Test;

View File

@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base62;
import cn.hutool.core.codec.binary.Base62;
import cn.hutool.core.util.RandomUtil;
import org.junit.Assert;
import org.junit.Test;

View File

@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.text.StrUtil;

View File

@ -152,7 +152,9 @@ public class CollStreamUtilTest {
// 对null友好
final Map<Long, Map<Long, Student>> termIdClassIdStudentMap = CollStreamUtil.group2Map(Arrays.asList(null, new Student(2, 2, 1, "王五")), Student::getTermId, Student::getClassId);
final Map<Long, Map<Long, Student>> termIdClassIdStudentCompareMap = new HashMap<Long, Map<Long, Student>>() {{
final Map<Long, Map<Long, Student>> termIdClassIdStudentCompareMap = new HashMap<Long, Map<Long, Student>>() {
private static final long serialVersionUID = 1L;
{
put(null, MapUtil.empty());
put(2L, MapUtil.of(2L, new Student(2, 2, 1, "王五")));
}};
@ -269,6 +271,7 @@ public class CollStreamUtilTest {
Assert.assertEquals(set, compare);
}
@SuppressWarnings("ConstantValue")
@Test
public void testMerge() {
Map<Long, Student> map1 = null;

View File

@ -152,8 +152,8 @@ public class NumberChineseFormatterTest {
@Test
public void formatTest3() {
// String f1 = NumberChineseFormatter.format(5000_8000, false, false);
// Assert.assertEquals("五千万零八千", f1);
final String f1 = NumberChineseFormatter.format(5000_8000, false, false);
Assert.assertEquals("五千万零八千", f1);
final String f2 = NumberChineseFormatter.format(1_0035_0089, false, false);
Assert.assertEquals("一亿零三十五万零八十九", f2);

View File

@ -28,7 +28,7 @@ public class NioUtilTest {
@Test
@Ignore
public void copyByNIOTest2() throws IOException {
public void copyByNIOTest2() {
final File file = FileUtil.file("d:/test/logo.jpg");
final BufferedInputStream in = FileUtil.getInputStream(file);
final BufferedOutputStream out = FileUtil.getOutputStream("d:/test/2logo.jpg");

View File

@ -11,12 +11,14 @@ import java.util.Map;
public class AssertTest {
@SuppressWarnings("ConstantValue")
@Test
public void isNullTest() {
final String a = null;
Assert.isNull(a);
}
@SuppressWarnings("ConstantValue")
@Test
public void notNullTest() {
final String a = null;
@ -113,10 +115,9 @@ public class AssertTest {
Assert.isTrue(i > 0, () -> new IndexOutOfBoundsException("relation message to return"));
}
@SuppressWarnings("ConstantValue")
@Test
public void equalsTest() {
//String a="ab";
//final String b = new String("abc");
final String a = null;
final String b = null;
Assert.equals(a, b);
@ -124,18 +125,16 @@ public class AssertTest {
Assert.equals(a, b, () -> new RuntimeException(StrUtil.format("{}和{}不相等", a, b)));
}
@SuppressWarnings("ConstantValue")
@Test
public void notEqualsTest() {
//String c="19";
//final String d = new String("19");
final String c = null;
final String d = "null";
//Assert.notEquals(c,d);
//Assert.notEquals(c,d,"{}等于{}",c,d);
Assert.notEquals(c, d, () -> new RuntimeException(StrUtil.format("{}和{}相等", c, d)));
}
@SuppressWarnings("ConstantValue")
@Test
public void notEqualsTest2() {
final Object c = null;

View File

@ -162,16 +162,25 @@ public class EntryStreamTest {
@Test
public void testAppend() {
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){{
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){
private static final long serialVersionUID = 2091911960221937275L;
{
put(1, 1);
put(2, 2);
}};
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){{
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){
private static final long serialVersionUID = 4802315578432177802L;
{
put(3, 3);
put(4, 4);
}};
Assert.assertEquals(
new ArrayList<Map.Entry<Integer, Integer>>(){{
new ArrayList<Map.Entry<Integer, Integer>>(){
private static final long serialVersionUID = -4045530648496761947L;
{
addAll(map1.entrySet());
addAll(map2.entrySet());
}},
@ -184,16 +193,25 @@ public class EntryStreamTest {
@Test
public void testPrepend() {
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){{
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){
private static final long serialVersionUID = -8772310525807986780L;
{
put(1, 1);
put(2, 2);
}};
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){{
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){
private static final long serialVersionUID = -8453400649627773936L;
{
put(3, 3);
put(4, 4);
}};
Assert.assertEquals(
new ArrayList<Map.Entry<Integer, Integer>>(){{
new ArrayList<Map.Entry<Integer, Integer>>(){
private static final long serialVersionUID = 7564826138581563332L;
{
addAll(map2.entrySet());
addAll(map1.entrySet());
}},
@ -254,7 +272,7 @@ public class EntryStreamTest {
map.put(1, 1);
map.put(2, 2);
map.put(3, 3);
List<Integer> keys = EntryStream.of(map).collectKeys(Collectors.toList());
final List<Integer> keys = EntryStream.of(map).collectKeys(Collectors.toList());
Assert.assertEquals(new ArrayList<>(map.keySet()), keys);
}
@ -264,7 +282,7 @@ public class EntryStreamTest {
map.put(1, 1);
map.put(2, 2);
map.put(3, 3);
List<Integer> keys = EntryStream.of(map).collectValues(Collectors.toList());
final List<Integer> keys = EntryStream.of(map).collectValues(Collectors.toList());
Assert.assertEquals(new ArrayList<>(map.keySet()), keys);
}
@ -324,7 +342,7 @@ public class EntryStreamTest {
map.put(1, 1);
map.put(2, 2);
map.put(3, 3);
List<Integer> list = EntryStream.of(map)
final List<Integer> list = EntryStream.of(map)
.flatMap(e -> Stream.of(e.getKey(), e.getKey() + 1))
.collect(Collectors.toList());
Assert.assertEquals(Arrays.asList(1, 2, 2, 3, 3, 4), list);
@ -567,7 +585,7 @@ public class EntryStreamTest {
private final K key;
private final V value;
public Entry(K key, V value) {
public Entry(final K key, final V value) {
this.key = key;
this.value = value;
}
@ -583,7 +601,7 @@ public class EntryStreamTest {
}
@Override
public V setValue(V value) {
public V setValue(final V value) {
return null;
}
}

View File

@ -20,6 +20,7 @@ import java.util.function.Function;
*/
public class ObjUtilTest {
@SuppressWarnings("ConstantValue")
@Test
public void equalsTest() {
Object a = null;
@ -109,6 +110,7 @@ public class ObjUtilTest {
Assert.assertFalse(ObjUtil.isNotEmpty(Collections.emptyIterator()));
}
@SuppressWarnings("ConstantValue")
@Test
public void defaultIfNullTest() {
final Object val1 = new Object();
@ -227,7 +229,7 @@ public class ObjUtilTest {
private final Integer id;
@Override
protected Object clone() throws CloneNotSupportedException {
throw new RuntimeException("can not clone this object");
throw new CloneNotSupportedException("can not clone this object");
}
}
@ -255,6 +257,6 @@ public class ObjUtilTest {
}
@SuppressWarnings("unused")
private interface TypeArgument<A, B> {};
private interface TypeArgument<A, B> {}
}

View File

@ -53,9 +53,6 @@ public class TaskExecutorManager implements Serializable {
synchronized (this.executors) {
this.executors.add(executor);
}
// 子线程是否为deamon线程取决于父线程因此此处无需显示调用
// executor.setDaemon(this.scheduler.daemon);
// executor.start();
this.scheduler.threadExecutor.execute(executor);
return executor;
}

View File

@ -17,6 +17,10 @@ public class TaskLauncherManager implements Serializable {
/** 启动器列表 */
protected final List<TaskLauncher> launchers = new ArrayList<>();
/**
* 构造
* @param scheduler {@link Scheduler}
*/
public TaskLauncherManager(final Scheduler scheduler) {
this.scheduler = scheduler;
}
@ -31,9 +35,6 @@ public class TaskLauncherManager implements Serializable {
synchronized (this.launchers) {
this.launchers.add(launcher);
}
//子线程是否为deamon线程取决于父线程因此此处无需显示调用
//launcher.setDaemon(this.scheduler.daemon);
// launcher.start();
this.scheduler.threadExecutor.execute(launcher);
return launcher;
}

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.Assert;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.codec.HexUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.text.StrUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.asymmetric;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.io.stream.FastByteArrayOutputStream;
import cn.hutool.crypto.CipherWrapper;
import cn.hutool.crypto.CryptoException;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.asymmetric;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.codec.HexUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.IoUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.asymmetric;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.lang.Assert;
import cn.hutool.crypto.CryptoException;
import cn.hutool.crypto.KeyUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.asymmetric;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.CharsetUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.digest.mac;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.CharsetUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.digest.otp;
import cn.hutool.core.codec.BaseN.Base32;
import cn.hutool.core.codec.binary.Base32;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.crypto.digest.HMac;
import cn.hutool.crypto.digest.HmacAlgorithm;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.symmetric;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.codec.HexUtil;
import cn.hutool.core.text.StrUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.symmetric;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.CharsetUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.asymmetric;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.codec.HexUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.asymmetric;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.codec.HexUtil;
import cn.hutool.core.text.StrUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.digest;
import cn.hutool.core.codec.BaseN.Base32;
import cn.hutool.core.codec.binary.Base32;
import cn.hutool.crypto.digest.otp.HOTP;
import cn.hutool.crypto.digest.otp.TOTP;
import org.junit.Assert;

View File

@ -1,6 +1,6 @@
package cn.hutool.crypto.symmetric;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.codec.HexUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.crypto.KeyUtil;

View File

@ -151,17 +151,16 @@ public class ResultColumn {
return className;
}
public static enum ColumnNullable {
public enum ColumnNullable {
NO_NULLS(ResultSetMetaData.columnNoNulls),
NULLABLE(ResultSetMetaData.columnNullable),
UNKNOWN(ResultSetMetaData.columnNullableUnknown);
final int value;
private ColumnNullable(final int value) {
this.value = value;
}
/**
* ResultSetMetaData中的int值转枚举
* @param nullable nullable值
* @return ColumnNullable
*/
public static ColumnNullable of(final int nullable) {
switch (nullable) {
case ResultSetMetaData.columnNoNulls:
@ -172,5 +171,10 @@ public class ResultColumn {
return UNKNOWN;
}
}
final int value;
ColumnNullable(final int value) {
this.value = value;
}
}
}

View File

@ -13,6 +13,7 @@ import java.util.List;
* @since 5.7.21
*/
public class ConditionGroup extends Condition {
private static final long serialVersionUID = 1L;
/**
* 条件列表
*/

View File

@ -5,7 +5,6 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import java.sql.SQLException;
import java.util.List;
/**
@ -19,7 +18,7 @@ public class DerbyTest {
private static final String DS_GROUP_NAME = "derby";
@BeforeClass
public static void init() throws SQLException {
public static void init() {
final Db db = Db.of(DS_GROUP_NAME);
db.execute("CREATE TABLE test(a INTEGER, b BIGINT)");
@ -31,14 +30,14 @@ public class DerbyTest {
@Test
@Ignore
public void queryTest() throws SQLException {
public void queryTest() {
final List<Entity> query = Db.of(DS_GROUP_NAME).query("select * from test");
Assert.assertEquals(4, query.size());
}
@Test
@Ignore
public void findTest() throws SQLException {
public void findTest() {
final List<Entity> query = Db.of(DS_GROUP_NAME).find(Entity.of("test"));
Assert.assertEquals(4, query.size());
}

View File

@ -37,12 +37,13 @@ public class MailAccount implements Serializable {
// System Properties
private static final String SPLIT_LONG_PARAMS = "mail.mime.splitlongparameters";
//private static final String ENCODE_FILE_NAME = "mail.mime.encodefilename";
//private static final String CHARSET = "mail.mime.charset";
// 其他
private static final String MAIL_DEBUG = "mail.debug";
/**
* 默认mail配置查询路径
*/
public static final String[] MAIL_SETTING_PATHS = new String[]{"config/mail.setting", "config/mailAccount.setting", "mail.setting"};
/**

View File

@ -1,6 +1,6 @@
package cn.hutool.extra.qrcode;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.swing.img.ImgUtil;
import com.google.zxing.BarcodeFormat;

View File

@ -499,6 +499,7 @@ public class Sftp extends AbstractFtp {
}
}
@SuppressWarnings("resource")
@Override
public boolean uploadFile(final String destPath, final File file) {
if(false == FileUtil.isFile(file)){
@ -521,13 +522,11 @@ public class Sftp extends AbstractFtp {
* @param destPath 服务端路径可以为{@code null} 或者相对路径或绝对路径
* @param fileName 文件名
* @param fileStream 文件流
* @return 是否上传成功
* @since 5.7.16
*/
public boolean uploadFile(String destPath, final String fileName, final InputStream fileStream) {
public void uploadFile(String destPath, final String fileName, final InputStream fileStream) {
destPath = StrUtil.addSuffixIfNot(destPath, StrUtil.SLASH) + StrUtil.removePrefix(fileName, StrUtil.SLASH);
put(fileStream, destPath, null, Mode.OVERWRITE);
return true;
}
/**

View File

@ -105,7 +105,7 @@ public class FtpTest {
@Test
@Ignore
public void existSftpTest() throws Exception {
public void existSftpTest() {
try (final Sftp ftp = new Sftp("127.0.0.1", 22, "test", "test")) {
Console.log(ftp.pwd());
Console.log(ftp.exist(null));

View File

@ -1,6 +1,6 @@
package cn.hutool.extra.qrcode;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.Console;

View File

@ -27,18 +27,16 @@ public class JschUtilTest {
@Test
@Ignore
public void bindRemotePort() throws InterruptedException {
public void bindRemotePort() {
// 建立会话
final Session session = JschUtil.getSession("looly.centos", 22, "test", "123456");
// 绑定ssh服务端8089端口到本机的8000端口上
final boolean b = JschUtil.bindRemotePort(session, 8089, "localhost", 8000);
Assert.assertTrue(b);
// 保证一直运行
// while (true){
// Thread.sleep(3000);
// }
}
@SuppressWarnings("resource")
@Test
@Ignore
public void sftpTest() {

View File

@ -1,6 +1,6 @@
package cn.hutool.http;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.net.url.UrlQueryUtil;
import cn.hutool.core.text.StrUtil;
import cn.hutool.http.client.ClientConfig;

View File

@ -4,7 +4,6 @@ import cn.hutool.http.client.body.BytesBody;
import cn.hutool.http.client.body.HttpBody;
import org.apache.hc.core5.http.io.entity.AbstractHttpEntity;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
@ -50,8 +49,8 @@ public class HttpClient5BodyEntity extends AbstractHttpEntity {
}
@Override
public void close() throws IOException {
public void close() {
// do nothing
}
@Override

View File

@ -403,10 +403,6 @@ public class HttpConnection implements HeaderOperation<HttpConnection> {
final StringBuilder sb = StrUtil.builder();
sb.append("Request URL: ").append(this.url).append(StrUtil.CRLF);
sb.append("Request Method: ").append(this.getMethod()).append(StrUtil.CRLF);
// sb.append("Request Headers: ").append(StrUtil.CRLF);
// for (Entry<String, List<String>> entry : this.conn.getHeaderFields().entrySet()) {
// sb.append(" ").append(entry).append(StrUtil.CRLF);
// }
return sb.toString();
}

View File

@ -79,7 +79,7 @@ public class JdkClientEngine implements ClientEngine {
}
@Override
public void close() throws IOException {
public void close() {
if (null != conn) {
conn.disconnectQuietly();
}

View File

@ -1,7 +1,6 @@
package cn.hutool.http.client.engine.okhttp;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.http.client.ClientConfig;
import cn.hutool.http.client.ClientEngine;
import cn.hutool.http.client.Request;
@ -60,8 +59,8 @@ public class OkHttpEngine implements ClientEngine {
}
@Override
public void close() throws IOException {
// ignore
public void close() {
// do nothing
}
/**

View File

@ -7,14 +7,9 @@ import kotlin.Pair;
import okhttp3.Headers;
import okhttp3.ResponseBody;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* OkHttp3的{@link okhttp3.Response} 响应包装
@ -74,7 +69,9 @@ public class OkHttpResponse implements Response {
}
@Override
public void close() throws IOException {
rawRes.close();
public void close() {
if(null != this.rawRes){
rawRes.close();
}
}
}

View File

@ -201,12 +201,16 @@ public final class HTMLFilter {
}
}
// ---------------------------------------------------------------
// my versions of some PHP library functions
public static String chr(final int decimal) {
return String.valueOf((char) decimal);
}
/**
* HTML特殊字符替换
*
* @param s HTML
* @return 替换后的HTML
*/
public static String htmlSpecialChars(final String s) {
String result = s;
result = regexReplace(P_AMP, "&amp;", result);
@ -250,10 +254,22 @@ public final class HTMLFilter {
return s;
}
/**
* flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "&lt;b text &lt;/b&gt;" becomes "&lt;b&gt; text &lt;/g&gt;").
* If set to false, unbalanced angle brackets will be
* html escaped.
*
* @return alwaysMakeTags
*/
public boolean isAlwaysMakeTags() {
return alwaysMakeTags;
}
/**
* flag determining whether comments are allowed in input String.
*
* @return stripComment
*/
public boolean isStripComments() {
return stripComment;
}
@ -364,7 +380,6 @@ public final class HTMLFilter {
final String body = m.group(2);
String ending = m.group(3);
// debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
if (allowed(name)) {
final StringBuilder params = new StringBuilder();
@ -386,10 +401,6 @@ public final class HTMLFilter {
paramName = paramNames.get(ii).toLowerCase();
paramValue = paramValues.get(ii);
// debug( "paramName='" + paramName + "'" );
// debug( "paramValue='" + paramValue + "'" );
// debug( "allowed? " + vAllowed.get( name ).contains( paramName ) );
if (allowedAttribute(name, paramName)) {
if (inArray(paramName, vProtocolAtts)) {
paramValue = processParamProtocol(paramValue);
@ -454,7 +465,7 @@ public final class HTMLFilter {
while (m.find()) {
final String match = m.group(1);
final int decimal = Integer.decode(match);
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
m.appendReplacement(buf, Matcher.quoteReplacement(CharUtil.toString((char) decimal)));
}
m.appendTail(buf);
s = buf.toString();
@ -464,7 +475,7 @@ public final class HTMLFilter {
while (m.find()) {
final String match = m.group(1);
final int decimal = Integer.parseInt(match, 16);
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
m.appendReplacement(buf, Matcher.quoteReplacement(CharUtil.toString((char) decimal)));
}
m.appendTail(buf);
s = buf.toString();
@ -474,7 +485,7 @@ public final class HTMLFilter {
while (m.find()) {
final String match = m.group(1);
final int decimal = Integer.parseInt(match, 16);
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
m.appendReplacement(buf, Matcher.quoteReplacement(CharUtil.toString((char) decimal)));
}
m.appendTail(buf);
s = buf.toString();

View File

@ -1,6 +1,6 @@
package cn.hutool.http;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.StreamProgress;

View File

@ -1,6 +1,6 @@
package cn.hutool.json.jwt;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.date.format.GlobalCustomFormat;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.map.MapUtil;

View File

@ -1,6 +1,6 @@
package cn.hutool.json.jwt;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.exceptions.ValidateException;

View File

@ -1,6 +1,6 @@
package cn.hutool.json.jwt.signers;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.text.StrUtil;
import cn.hutool.crypto.asymmetric.Sign;

View File

@ -14,6 +14,7 @@ import io.github.logtube.core.IEventLogger;
* @since 5.6.6
*/
public class LogTubeLog extends AbstractLog {
private static final long serialVersionUID = 1L;
private final IEventLogger logger;

View File

@ -19,9 +19,6 @@ public class LogTest {
log.debug("This is {} log", Level.DEBUG);
log.info("This is {} log", Level.INFO);
log.warn("This is {} log", Level.WARN);
// Exception e = new Exception("test Exception");
// log.error(e, "This is {} log", Level.ERROR);
}
/**

View File

@ -12,12 +12,7 @@ import java.io.Closeable;
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
/**
* CSV行解析器参考FastCSV
@ -32,7 +27,7 @@ public final class CsvParser extends ComputeIter<CsvRow> implements Closeable, S
private final Reader reader;
private final CsvReadConfig config;
private final Buffer buf = new Buffer(IoUtil.DEFAULT_LARGE_BUFFER_SIZE);
private final Buffer buf;
/**
* 前一个特殊分界字符
*/
@ -78,8 +73,20 @@ public final class CsvParser extends ComputeIter<CsvRow> implements Closeable, S
* @param config 配置null则为默认配置
*/
public CsvParser(final Reader reader, final CsvReadConfig config) {
this(reader, config, IoUtil.DEFAULT_LARGE_BUFFER_SIZE);
}
/**
* CSV解析器
*
* @param reader Reader
* @param config 配置null则为默认配置
* @param bufferSize 默认缓存大小
*/
public CsvParser(final Reader reader, final CsvReadConfig config, final int bufferSize) {
this.reader = Objects.requireNonNull(reader, "reader must not be null");
this.config = ObjUtil.defaultIfNull(config, CsvReadConfig::defaultConfig);
this.buf = new Buffer(bufferSize);
}
/**

View File

@ -1,13 +1,12 @@
package cn.hutool.poi.csv;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.lang.func.SerConsumer;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.file.Path;
@ -132,14 +131,9 @@ public class CsvReader extends CsvBaseReader implements Iterable<CsvRow>, Closea
* @since 5.7.14
*/
public Stream<CsvRow> stream() {
return StreamSupport.stream(spliterator(), false)
.onClose(() -> {
try {
close();
} catch (final IOException e) {
throw new IORuntimeException(e);
}
});
return StreamSupport
.stream(spliterator(), false)
.onClose(this::close);
}
@Override
@ -148,7 +142,7 @@ public class CsvReader extends CsvBaseReader implements Iterable<CsvRow>, Closea
}
@Override
public void close() throws IOException {
public void close() {
IoUtil.close(this.reader);
}
}

View File

@ -73,21 +73,11 @@ public class NullCell implements Cell {
return null;
}
@Deprecated
public CellType getCellTypeEnum() {
return null;
}
@Override
public CellType getCachedFormulaResultType() {
return null;
}
@Deprecated
public CellType getCachedFormulaResultTypeEnum() {
return null;
}
@Override
public void setCellValue(final double value) {
throw new UnsupportedOperationException("Can not set any thing to null cell!");

View File

@ -11,12 +11,14 @@ public class Issue2783Test {
@Test
@Ignore
public void readTest() {
// final CsvWriter writer = CsvUtil.getWriter("d:/test/big.csv", CharsetUtil.UTF_8);
// for (int i = 0; i < Integer.MAX_VALUE; i++) {
// writer.writeLine("aaaa", "bbbb", "ccccc", "dddd");
// }
// writer.close();
// 测试数据
final CsvWriter writer = CsvUtil.getWriter("d:/test/big.csv", CharsetUtil.UTF_8);
for (int i = 0; i < Integer.MAX_VALUE; i++) {
writer.writeLine("aaaa", "bbbb", "ccccc", "dddd");
}
writer.close();
// 读取
final CsvReader reader = CsvUtil.getReader(FileUtil.getReader("d:/test/big.csv", CharsetUtil.UTF_8));
reader.read((SerConsumer<CsvRow>) strings -> {

View File

@ -1,7 +1,6 @@
package cn.hutool.setting;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.net.url.URLUtil;
import cn.hutool.core.text.StrUtil;
@ -183,10 +182,9 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
* 加载设置文件 此方法不会关闭流对象
*
* @param settingStream 文件流
* @return 加载成功与否
* @throws IOException IO异常
*/
public boolean load(final InputStream settingStream) throws IOException {
public void load(final InputStream settingStream) throws IOException {
super.clear();
BufferedReader reader = null;
try {
@ -233,7 +231,6 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
} finally {
IoUtil.close(reader);
}
return true;
}
/**

View File

@ -96,10 +96,9 @@ public class SettingLoader {
* 加载设置文件 此方法不会关闭流对象
*
* @param settingStream 文件流
* @return 加载成功与否
* @throws IOException IO异常
*/
synchronized public boolean load(final InputStream settingStream) throws IOException {
synchronized public void load(final InputStream settingStream) throws IOException {
this.groupedMap.clear();
LineReader reader = null;
try {
@ -141,7 +140,6 @@ public class SettingLoader {
} finally {
IoUtil.close(reader);
}
return true;
}
/**

View File

@ -1,6 +1,6 @@
package cn.hutool.swing.captcha;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.IoUtil;

View File

@ -16,21 +16,16 @@ import java.util.Set;
* @author looly
* @since 4.5.6
*/
public enum ClipboardMonitor implements ClipboardOwner, Runnable, Closeable {
/**
* 监听器单例
*/
INSTANCE;
public class ClipboardMonitor implements ClipboardOwner, Runnable, Closeable {
/** 默认重试此时10 */
public static final int DEFAULT_TRY_COUNT = 10;
/** 默认重试等待100 */
public static final long DEFAULT_DELAY = 100;
/** 重试次数 */
private int tryCount;
private final int tryCount;
/** 重试等待 */
private long delay;
private final long delay;
/** 系统剪贴板对象 */
private final Clipboard clipboard;
/** 监听事件处理 */
@ -42,7 +37,7 @@ public enum ClipboardMonitor implements ClipboardOwner, Runnable, Closeable {
/**
* 构造尝试获取剪贴板内容的次数为10第二次之后延迟100毫秒
*/
ClipboardMonitor() {
public ClipboardMonitor() {
this(DEFAULT_TRY_COUNT, DEFAULT_DELAY);
}
@ -52,7 +47,7 @@ public enum ClipboardMonitor implements ClipboardOwner, Runnable, Closeable {
* @param tryCount 尝试获取剪贴板内容的次数
* @param delay 响应延迟当从第二次开始延迟一定毫秒数等待剪贴板可以获取当tryCount小于2时无效
*/
ClipboardMonitor(final int tryCount, final long delay) {
public ClipboardMonitor(final int tryCount, final long delay) {
this(tryCount, delay, ClipboardUtil.getClipboard());
}
@ -69,29 +64,6 @@ public enum ClipboardMonitor implements ClipboardOwner, Runnable, Closeable {
this.clipboard = clipboard;
}
// ---------------------------------------------------------------------------------------------------------- Constructor end
/**
* 设置重试次数
*
* @param tryCount 重试次数
* @return this
*/
public ClipboardMonitor setTryCount(final int tryCount) {
this.tryCount = tryCount;
return this;
}
/**
* 设置重试等待
*
* @param delay 重试等待
* @return this
*/
public ClipboardMonitor setDelay(final long delay) {
this.delay = delay;
return this;
}
/**
* 设置 监听事件处理
*
@ -192,7 +164,6 @@ public enum ClipboardMonitor implements ClipboardOwner, Runnable, Closeable {
for (int i = 0; i < this.tryCount; i++) {
if (this.delay > 0 && i > 0) {
// 第一次获取不等待只有从第二次获取时才开始等待
//noinspection BusyWait
Thread.sleep(this.delay);
}

View File

@ -134,6 +134,7 @@ public class ClipboardUtil {
return (Image) get(content, DataFlavor.imageFlavor);
}
// region ----- listen
/**
* 监听剪贴板修改事件
*
@ -161,17 +162,27 @@ public class ClipboardUtil {
* 监听剪贴板修改事件
*
* @param tryCount 尝试获取剪贴板内容的次数
* @param delay 响应延迟当从第二次开始延迟一定毫秒数等待剪贴板可以获取
* @param delay 响应延迟当从第二次开始延迟一定毫秒数等待剪贴板可以获取当tryCount小于2时无效
* @param listener 监听处理接口
* @param sync 是否同步阻塞
* @since 4.5.6
* @see ClipboardMonitor#listen(boolean)
*/
public static void listen(final int tryCount, final long delay, final ClipboardListener listener, final boolean sync) {
ClipboardMonitor.INSTANCE//
.setTryCount(tryCount)//
.setDelay(delay)//
.addListener(listener)//
.listen(sync);
getMonitor(tryCount, delay, listener).listen(sync);
}
/**
* 获取一个{@link ClipboardMonitor}
* @param tryCount 尝试获取剪贴板内容的次数
* @param delay 响应延迟当从第二次开始延迟一定毫秒数等待剪贴板可以获取当tryCount小于2时无效
* @param listener 监听处理接口
* @return {@link ClipboardMonitor}
*/
@SuppressWarnings("resource")
public static ClipboardMonitor getMonitor(final int tryCount, final long delay, final ClipboardListener listener){
return new ClipboardMonitor(tryCount, delay, null)
.addListener(listener);
}
// endregion
}

View File

@ -1,6 +1,6 @@
package cn.hutool.swing.img;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.io.file.FileUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.IoUtil;