mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
package cn.hutool.extra.mail;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeUtility;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 邮件内部工具类
|
||||
@@ -30,15 +30,13 @@ public class InternalMailUtil {
|
||||
public static InternetAddress[] parseAddressFromStrs(String[] addrStrs, Charset charset) {
|
||||
final List<InternetAddress> resultList = new ArrayList<>(addrStrs.length);
|
||||
InternetAddress[] addrs;
|
||||
for (int i = 0; i < addrStrs.length; i++) {
|
||||
addrs = parseAddress(addrStrs[i], charset);
|
||||
if(ArrayUtil.isNotEmpty(addrs)) {
|
||||
for(int j = 0 ; j < addrs.length; j++) {
|
||||
resultList.add(addrs[j]);
|
||||
}
|
||||
for (String addrStr : addrStrs) {
|
||||
addrs = parseAddress(addrStr, charset);
|
||||
if (ArrayUtil.isNotEmpty(addrs)) {
|
||||
Collections.addAll(resultList, addrs);
|
||||
}
|
||||
}
|
||||
return resultList.toArray(new InternetAddress[resultList.size()]);
|
||||
return resultList.toArray(new InternetAddress[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,10 +1,11 @@
|
||||
package cn.hutool.extra.mail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.DataSource;
|
||||
@@ -19,13 +20,11 @@ import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import javax.mail.util.ByteArrayDataSource;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 邮件发送客户端
|
||||
@@ -38,7 +37,7 @@ public class Mail {
|
||||
/**
|
||||
* 邮箱帐户信息以及一些客户端配置信息
|
||||
*/
|
||||
private MailAccount mailAccount;
|
||||
private final MailAccount mailAccount;
|
||||
/**
|
||||
* 收件人列表
|
||||
*/
|
||||
@@ -70,7 +69,7 @@ public class Mail {
|
||||
/**
|
||||
* 正文、附件和图片的混合部分
|
||||
*/
|
||||
private Multipart multipart = new MimeMultipart();
|
||||
private final Multipart multipart = new MimeMultipart();
|
||||
/**
|
||||
* 是否使用全局会话,默认为false
|
||||
*/
|
||||
|
@@ -467,7 +467,7 @@ public class MailAccount implements Serializable {
|
||||
|
||||
if (this.starttlsEnable) {
|
||||
//STARTTLS是对纯文本通信协议的扩展。它将纯文本连接升级为加密连接(TLS或SSL), 而不是使用一个单独的加密通信端口。
|
||||
p.put(STARTTLS_ENABLE, String.valueOf(this.starttlsEnable));
|
||||
p.put(STARTTLS_ENABLE, "true");
|
||||
|
||||
if (null == this.sslEnable) {
|
||||
//为了兼容旧版本,当用户没有此项配置时,按照starttlsEnable开启状态时对待
|
||||
|
@@ -1,5 +1,10 @@
|
||||
package cn.hutool.extra.mail;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
@@ -7,11 +12,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 邮件工具类,基于javax.mail封装
|
||||
*
|
||||
@@ -370,14 +370,14 @@ public class MailUtil {
|
||||
|
||||
// 可选抄送人
|
||||
if (CollUtil.isNotEmpty(ccs)) {
|
||||
mail.setCcs(ccs.toArray(new String[ccs.size()]));
|
||||
mail.setCcs(ccs.toArray(new String[0]));
|
||||
}
|
||||
// 可选密送人
|
||||
if (CollUtil.isNotEmpty(bccs)) {
|
||||
mail.setBccs(bccs.toArray(new String[bccs.size()]));
|
||||
mail.setBccs(bccs.toArray(new String[0]));
|
||||
}
|
||||
|
||||
mail.setTos(tos.toArray(new String[tos.size()]));
|
||||
mail.setTos(tos.toArray(new String[0]));
|
||||
mail.setTitle(subject);
|
||||
mail.setContent(content);
|
||||
mail.setHtml(isHtml);
|
||||
|
@@ -11,8 +11,8 @@ import javax.mail.PasswordAuthentication;
|
||||
*/
|
||||
public class UserPassAuthenticator extends Authenticator {
|
||||
|
||||
private String user;
|
||||
private String pass;
|
||||
private final String user;
|
||||
private final String pass;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -99,6 +99,7 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
@Override
|
||||
public LuminanceSource rotateCounterClockwise() {
|
||||
|
||||
|
@@ -20,7 +20,7 @@ public enum JschSessionPool {
|
||||
/**
|
||||
* SSH会话池,key:host,value:Session对象
|
||||
*/
|
||||
private Map<String, Session> sessionPool = new ConcurrentHashMap<>();
|
||||
private final Map<String, Session> sessionPool = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* 锁
|
||||
*/
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package cn.hutool.extra.template.engine.enjoy;
|
||||
|
||||
import cn.hutool.extra.template.AbstractTemplate;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.extra.template.AbstractTemplate;
|
||||
|
||||
/**
|
||||
* Engoy模板实现
|
||||
*
|
||||
@@ -16,7 +16,7 @@ import cn.hutool.extra.template.AbstractTemplate;
|
||||
public class EnjoyTemplate extends AbstractTemplate implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private com.jfinal.template.Template rawTemplate;
|
||||
private final com.jfinal.template.Template rawTemplate;
|
||||
|
||||
/**
|
||||
* 包装Enjoy模板
|
||||
|
@@ -18,7 +18,7 @@ import java.util.Map;
|
||||
public class RythmTemplate extends AbstractTemplate implements Serializable {
|
||||
private static final long serialVersionUID = -132774960373894911L;
|
||||
|
||||
private org.rythmengine.template.ITemplate rawTemplate;
|
||||
private final org.rythmengine.template.ITemplate rawTemplate;
|
||||
|
||||
/**
|
||||
* 包装Rythm模板
|
||||
|
@@ -1,21 +1,20 @@
|
||||
package cn.hutool.extra.template.engine.thymeleaf;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.thymeleaf.TemplateEngine;
|
||||
import org.thymeleaf.context.Context;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.template.AbstractTemplate;
|
||||
import org.thymeleaf.TemplateEngine;
|
||||
import org.thymeleaf.context.Context;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Thymeleaf模板实现
|
||||
@@ -26,9 +25,9 @@ import cn.hutool.extra.template.AbstractTemplate;
|
||||
public class ThymeleafTemplate extends AbstractTemplate implements Serializable {
|
||||
private static final long serialVersionUID = 781284916568562509L;
|
||||
|
||||
private TemplateEngine engine;
|
||||
private String template;
|
||||
private Charset charset;
|
||||
private final TemplateEngine engine;
|
||||
private final String template;
|
||||
private final Charset charset;
|
||||
|
||||
/**
|
||||
* 包装Thymeleaf模板
|
||||
|
@@ -1,19 +1,18 @@
|
||||
package cn.hutool.extra.template.engine.velocity;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.template.AbstractTemplate;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Velocity模板包装
|
||||
@@ -24,7 +23,7 @@ import cn.hutool.extra.template.AbstractTemplate;
|
||||
public class VelocityTemplate extends AbstractTemplate implements Serializable {
|
||||
private static final long serialVersionUID = -132774960373894911L;
|
||||
|
||||
private org.apache.velocity.Template rawTemplate;
|
||||
private final org.apache.velocity.Template rawTemplate;
|
||||
private String charset;
|
||||
|
||||
/**
|
||||
|
@@ -37,7 +37,7 @@ public class VelocityUtil {
|
||||
/**
|
||||
* 全局上下文,当设定值时,对于每个模板都有效
|
||||
*/
|
||||
private static Map<String, Object> globalContext = new HashMap<>();
|
||||
private static final Map<String, Object> globalContext = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 设置Velocity全局上下文<br>
|
||||
|
@@ -16,7 +16,7 @@ import cn.hutool.extra.tokenizer.Result;
|
||||
*/
|
||||
public class HanLPEngine implements TokenizerEngine {
|
||||
|
||||
private Segment seg;
|
||||
private final Segment seg;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -13,7 +13,7 @@ import cn.hutool.extra.tokenizer.Word;
|
||||
public class HanLPWord implements Word {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Term term;
|
||||
private final Term term;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -15,7 +15,7 @@ import cn.hutool.extra.tokenizer.Result;
|
||||
*/
|
||||
public class IKAnalyzerEngine implements TokenizerEngine {
|
||||
|
||||
private IKSegmenter seg;
|
||||
private final IKSegmenter seg;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -1,13 +1,12 @@
|
||||
package cn.hutool.extra.tokenizer.engine.ikanalyzer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.wltea.analyzer.core.IKSegmenter;
|
||||
import org.wltea.analyzer.core.Lexeme;
|
||||
|
||||
import cn.hutool.extra.tokenizer.AbstractResult;
|
||||
import cn.hutool.extra.tokenizer.TokenizerException;
|
||||
import cn.hutool.extra.tokenizer.Word;
|
||||
import org.wltea.analyzer.core.IKSegmenter;
|
||||
import org.wltea.analyzer.core.Lexeme;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* IKAnalyzer分词结果实现<br>
|
||||
@@ -18,7 +17,7 @@ import cn.hutool.extra.tokenizer.Word;
|
||||
*/
|
||||
public class IKAnalyzerResult extends AbstractResult {
|
||||
|
||||
private IKSegmenter seg;
|
||||
private final IKSegmenter seg;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -13,7 +13,7 @@ import cn.hutool.extra.tokenizer.Word;
|
||||
public class IKAnalyzerWord implements Word {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Lexeme word;
|
||||
private final Lexeme word;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -1,17 +1,16 @@
|
||||
package cn.hutool.extra.tokenizer.engine.jcseg;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.tokenizer.Result;
|
||||
import cn.hutool.extra.tokenizer.TokenizerEngine;
|
||||
import cn.hutool.extra.tokenizer.TokenizerException;
|
||||
import org.lionsoul.jcseg.ISegment;
|
||||
import org.lionsoul.jcseg.dic.ADictionary;
|
||||
import org.lionsoul.jcseg.dic.DictionaryFactory;
|
||||
import org.lionsoul.jcseg.segmenter.SegmenterConfig;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.tokenizer.TokenizerEngine;
|
||||
import cn.hutool.extra.tokenizer.Result;
|
||||
import cn.hutool.extra.tokenizer.TokenizerException;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
||||
/**
|
||||
* Jcseg分词引擎实现<br>
|
||||
@@ -22,7 +21,7 @@ import cn.hutool.extra.tokenizer.TokenizerException;
|
||||
*/
|
||||
public class JcsegEngine implements TokenizerEngine {
|
||||
|
||||
private ISegment segment;
|
||||
private final ISegment segment;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -19,7 +19,7 @@ import java.util.NoSuchElementException;
|
||||
*/
|
||||
public class JcsegResult implements Result{
|
||||
|
||||
private ISegment result;
|
||||
private final ISegment result;
|
||||
private Word cachedWord;
|
||||
|
||||
/**
|
||||
|
@@ -16,8 +16,8 @@ import cn.hutool.extra.tokenizer.Result;
|
||||
*/
|
||||
public class JiebaEngine implements TokenizerEngine {
|
||||
|
||||
private JiebaSegmenter jiebaSegmenter;
|
||||
private SegMode mode;
|
||||
private final JiebaSegmenter jiebaSegmenter;
|
||||
private final SegMode mode;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -1,14 +1,13 @@
|
||||
package cn.hutool.extra.tokenizer.engine.mmseg;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.tokenizer.Result;
|
||||
import cn.hutool.extra.tokenizer.TokenizerEngine;
|
||||
import com.chenlb.mmseg4j.ComplexSeg;
|
||||
import com.chenlb.mmseg4j.Dictionary;
|
||||
import com.chenlb.mmseg4j.MMSeg;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.tokenizer.TokenizerEngine;
|
||||
import cn.hutool.extra.tokenizer.Result;
|
||||
import java.io.StringReader;
|
||||
|
||||
/**
|
||||
* mmseg4j分词引擎实现<br>
|
||||
@@ -19,7 +18,7 @@ import cn.hutool.extra.tokenizer.Result;
|
||||
*/
|
||||
public class MmsegEngine implements TokenizerEngine {
|
||||
|
||||
private MMSeg mmSeg;
|
||||
private final MMSeg mmSeg;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -1,12 +1,11 @@
|
||||
package cn.hutool.extra.tokenizer.engine.mmseg;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.chenlb.mmseg4j.MMSeg;
|
||||
|
||||
import cn.hutool.extra.tokenizer.AbstractResult;
|
||||
import cn.hutool.extra.tokenizer.TokenizerException;
|
||||
import cn.hutool.extra.tokenizer.Word;
|
||||
import com.chenlb.mmseg4j.MMSeg;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* mmseg4j分词结果实现<br>
|
||||
@@ -17,7 +16,7 @@ import cn.hutool.extra.tokenizer.Word;
|
||||
*/
|
||||
public class MmsegResult extends AbstractResult {
|
||||
|
||||
private MMSeg mmSeg;
|
||||
private final MMSeg mmSeg;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -17,7 +17,7 @@ import cn.hutool.extra.tokenizer.TokenizerEngine;
|
||||
*/
|
||||
public class MynlpEngine implements TokenizerEngine {
|
||||
|
||||
private Lexer lexer;
|
||||
private final Lexer lexer;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -1,12 +1,11 @@
|
||||
package cn.hutool.extra.tokenizer.engine.mynlp;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.mayabot.nlp.segment.Sentence;
|
||||
import com.mayabot.nlp.segment.WordTerm;
|
||||
|
||||
import cn.hutool.extra.tokenizer.Result;
|
||||
import cn.hutool.extra.tokenizer.Word;
|
||||
import com.mayabot.nlp.segment.Sentence;
|
||||
import com.mayabot.nlp.segment.WordTerm;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* MYNLP 中文NLP工具包分词结果实现<br>
|
||||
@@ -17,7 +16,7 @@ import cn.hutool.extra.tokenizer.Word;
|
||||
*/
|
||||
public class MynlpResult implements Result {
|
||||
|
||||
private Iterator<WordTerm> result;
|
||||
private final Iterator<WordTerm> result;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -17,7 +17,7 @@ import cn.hutool.extra.tokenizer.TokenizerEngine;
|
||||
*/
|
||||
public class WordEngine implements TokenizerEngine {
|
||||
|
||||
private Segmentation segmentation;
|
||||
private final Segmentation segmentation;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package cn.hutool.extra.tokenizer.engine.word;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.extra.tokenizer.Result;
|
||||
import cn.hutool.extra.tokenizer.Word;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Word分词结果实现<br>
|
||||
* 项目地址:https://github.com/ysc/word
|
||||
@@ -15,7 +15,7 @@ import cn.hutool.extra.tokenizer.Word;
|
||||
*/
|
||||
public class WordResult implements Result{
|
||||
|
||||
private Iterator<org.apdplat.word.segmentation.Word> wordIter;
|
||||
private final Iterator<org.apdplat.word.segmentation.Word> wordIter;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
Reference in New Issue
Block a user