This commit is contained in:
Looly
2023-04-12 01:22:54 +08:00
parent d2e5155ac5
commit a96a95c988
216 changed files with 480 additions and 480 deletions

View File

@@ -133,7 +133,7 @@ public class SevenZArchiver implements Archiver {
* @param filter 文件过滤器,指定哪些文件或目录可以加入,当{@link Predicate#test(Object)}为{@code true}保留null表示保留全部
*/
private void addInternal(final File file, final String path, final Predicate<File> filter) throws IOException {
if (null != filter && ! filter.test(file)) {
if (null != filter && !filter.test(file)) {
return;
}
final SevenZOutputFile out = this.sevenZOutputFile;

View File

@@ -168,7 +168,7 @@ public class StreamArchiver implements Archiver {
* @param predicate 文件过滤器,指定哪些文件或目录可以加入,当{@link Predicate#test(Object)}为{@code true}加入。
*/
private void addInternal(final File file, final String path, final Predicate<File> predicate) throws IOException {
if (null != predicate && ! predicate.test(file)) {
if (null != predicate && !predicate.test(file)) {
return;
}
final ArchiveOutputStream out = this.out;

View File

@@ -118,7 +118,7 @@ public class SevenZExtractor implements Extractor, RandomAccess {
public InputStream getFirst(final Predicate<ArchiveEntry> predicate) {
final SevenZFile sevenZFile = this.sevenZFile;
for (final SevenZArchiveEntry entry : sevenZFile.getEntries()) {
if (null != predicate && ! predicate.test(entry)) {
if (null != predicate && !predicate.test(entry)) {
continue;
}
if (entry.isDirectory()) {
@@ -144,12 +144,12 @@ public class SevenZExtractor implements Extractor, RandomAccess {
* @throws IOException IO异常
*/
private void extractInternal(final File targetDir, final Predicate<ArchiveEntry> predicate) throws IOException {
Assert.isTrue(null != targetDir && ((! targetDir.exists()) || targetDir.isDirectory()), "target must be dir.");
Assert.isTrue(null != targetDir && ((!targetDir.exists()) || targetDir.isDirectory()), "target must be dir.");
final SevenZFile sevenZFile = this.sevenZFile;
SevenZArchiveEntry entry;
File outItemFile;
while (null != (entry = sevenZFile.getNextEntry())) {
if (null != predicate && ! predicate.test(entry)) {
if (null != predicate && !predicate.test(entry)) {
continue;
}
outItemFile = FileUtil.file(targetDir, entry.getName());

View File

@@ -113,10 +113,10 @@ public class StreamExtractor implements Extractor {
ArchiveEntry entry;
try {
while (null != (entry = in.getNextEntry())) {
if (null != predicate && ! predicate.test(entry)) {
if (null != predicate && !predicate.test(entry)) {
continue;
}
if (entry.isDirectory() || ! in.canReadEntryData(entry)) {
if (entry.isDirectory() || !in.canReadEntryData(entry)) {
// 目录或无法读取的文件直接跳过
continue;
}
@@ -155,15 +155,15 @@ public class StreamExtractor implements Extractor {
* @throws IOException IO异常
*/
private void extractInternal(final File targetDir, final Predicate<ArchiveEntry> predicate) throws IOException {
Assert.isTrue(null != targetDir && ((! targetDir.exists()) || targetDir.isDirectory()), "target must be dir.");
Assert.isTrue(null != targetDir && ((!targetDir.exists()) || targetDir.isDirectory()), "target must be dir.");
final ArchiveInputStream in = this.in;
ArchiveEntry entry;
File outItemFile;
while (null != (entry = in.getNextEntry())) {
if (null != predicate && ! predicate.test(entry)) {
if (null != predicate && !predicate.test(entry)) {
continue;
}
if (! in.canReadEntryData(entry)) {
if (!in.canReadEntryData(entry)) {
// 无法读取的文件直接跳过
continue;
}

View File

@@ -61,6 +61,6 @@ public class ExpressionFactory {
return engine;
}
throw new ExpressionException("No expression jar found ! Please add one of it to your project !");
throw new ExpressionException("No expression jar found !Please add one of it to your project !");
}
}

View File

@@ -186,13 +186,13 @@ public abstract class AbstractFtp implements Closeable {
if (StrUtil.isNotEmpty(s)) {
boolean exist = true;
try {
if (! cd(s)) {
if (!cd(s)) {
exist = false;
}
} catch (final FtpException e) {
exist = false;
}
if (! exist) {
if (!exist) {
//目录不存在时创建
mkdir(s);
cd(s);

View File

@@ -232,7 +232,7 @@ public class Ftp extends AbstractFtp {
throw new IORuntimeException(e);
}
final int replyCode = client.getReplyCode(); // 是否成功登录服务器
if (! FTPReply.isPositiveCompletion(replyCode)) {
if (!FTPReply.isPositiveCompletion(replyCode)) {
try {
client.disconnect();
} catch (final IOException e) {
@@ -369,7 +369,7 @@ public class Ftp extends AbstractFtp {
String fileName;
for (final FTPFile ftpFile : ftpFiles) {
fileName = ftpFile.getName();
if (! StrUtil.equals(".", fileName) && ! StrUtil.equals("..", fileName)) {
if (!StrUtil.equals(".", fileName) && !StrUtil.equals("..", fileName)) {
if (null == predicate || predicate.test(ftpFile)) {
result.add(ftpFile);
}
@@ -390,7 +390,7 @@ public class Ftp extends AbstractFtp {
String pwd = null;
if (StrUtil.isNotBlank(path)) {
pwd = pwd();
if (! cd(path)) {
if (!cd(path)) {
throw new FtpException("Change dir to [{}] error, maybe path not exist!", path);
}
}
@@ -455,7 +455,7 @@ public class Ftp extends AbstractFtp {
final String pwd = pwd();
final String fileName = FileNameUtil.getName(path);
final String dir = StrUtil.removeSuffix(path, fileName);
if (! cd(dir)) {
if (!cd(dir)) {
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", path);
}
@@ -486,7 +486,7 @@ public class Ftp extends AbstractFtp {
childPath = StrUtil.format("{}/{}", dirPath, name);
if (ftpFile.isDirectory()) {
// 上级和本级目录除外
if (! ".".equals(name) && ! "..".equals(name)) {
if (!".".equals(name) && !"..".equals(name)) {
delDir(childPath);
}
} else {
@@ -518,7 +518,7 @@ public class Ftp extends AbstractFtp {
@Override
public boolean uploadFile(final String remotePath, final File file) {
Assert.notNull(file, "file to upload is null !");
if (! FileUtil.isFile(file)) {
if (!FileUtil.isFile(file)) {
throw new FtpException("[{}] is not a file!", file);
}
return uploadFile(remotePath, file.getName(), file);
@@ -576,7 +576,7 @@ public class Ftp extends AbstractFtp {
if (StrUtil.isNotBlank(remotePath)) {
mkDirs(remotePath);
if (! cd(remotePath)) {
if (!cd(remotePath)) {
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", remotePath);
}
}
@@ -601,7 +601,7 @@ public class Ftp extends AbstractFtp {
* @param uploadFile 上传文件或目录
*/
public void upload(final String remotePath, final File uploadFile) {
if (! FileUtil.isDirectory(uploadFile)) {
if (!FileUtil.isDirectory(uploadFile)) {
this.uploadFile(remotePath, uploadFile);
return;
}
@@ -656,9 +656,9 @@ public class Ftp extends AbstractFtp {
srcFile = StrUtil.format("{}/{}", sourcePath, fileName);
destFile = FileUtil.file(destDir, fileName);
if (! ftpFile.isDirectory()) {
if (!ftpFile.isDirectory()) {
// 本地不存在文件或者ftp上文件有修改则下载
if (! FileUtil.exists(destFile)
if (!FileUtil.exists(destFile)
|| (ftpFile.getTimestamp().getTimeInMillis() > destFile.lastModified())) {
download(srcFile, destFile);
}
@@ -682,7 +682,7 @@ public class Ftp extends AbstractFtp {
if (outFile.isDirectory()) {
outFile = new File(outFile, fileName);
}
if (! outFile.exists()) {
if (!outFile.exists()) {
FileUtil.touch(outFile);
}
try (final OutputStream out = FileUtil.getOutputStream(outFile)) {
@@ -719,7 +719,7 @@ public class Ftp extends AbstractFtp {
pwd = pwd();
}
if (! cd(path)) {
if (!cd(path)) {
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", path);
}

View File

@@ -649,7 +649,7 @@ public class MailAccount implements Serializable {
}
if (null == this.auth) {
// 如果密码非空白,则使用认证模式
this.auth = (! StrUtil.isBlank(this.pass));
this.auth = (!StrUtil.isBlank(this.pass));
}
if (null == this.port) {
// 端口在SSL状态下默认与socketFactoryPort一致非SSL状态下默认为25

View File

@@ -60,6 +60,6 @@ public class PinyinFactory {
return engine;
}
throw new PinyinException("No pinyin jar found ! Please add one of it to your project !");
throw new PinyinException("No pinyin jar found !Please add one of it to your project !");
}
}

View File

@@ -55,7 +55,7 @@ public class TinyPinyinEngine implements PinyinEngine {
@Override
public String getPinyin(final char c) {
if(! Pinyin.isChinese(c)){
if(!Pinyin.isChinese(c)){
return String.valueOf(c);
}
return Pinyin.toPinyin(c).toLowerCase();

View File

@@ -435,7 +435,7 @@ public class JschUtil {
public static Channel createChannel(final Session session, final ChannelType channelType) {
final Channel channel;
try {
if (! session.isConnected()) {
if (!session.isConnected()) {
session.connect();
}
channel = session.openChannel(channelType.getValue());

View File

@@ -307,7 +307,7 @@ public class Sftp extends AbstractFtp {
* @since 4.0.5
*/
public List<String> lsFiles(final String path) {
return ls(path, t -> ! t.getAttrs().isDir());
return ls(path, t -> !t.getAttrs().isDir());
}
/**
@@ -353,7 +353,7 @@ public class Sftp extends AbstractFtp {
try {
channel.ls(path, entry -> {
final String fileName = entry.getFilename();
if (! StrUtil.equals(".", fileName) && ! StrUtil.equals("..", fileName)) {
if (!StrUtil.equals(".", fileName) && !StrUtil.equals("..", fileName)) {
if (null == predicate || predicate.test(entry)) {
entryList.add(entry);
}
@@ -361,7 +361,7 @@ public class Sftp extends AbstractFtp {
return LsEntrySelector.CONTINUE;
});
} catch (final SftpException e) {
if (! StrUtil.startWithIgnoreCase(e.getMessage(), "No such file")) {
if (!StrUtil.startWithIgnoreCase(e.getMessage(), "No such file")) {
throw new JschRuntimeException(e);
}
// 文件不存在忽略
@@ -446,7 +446,7 @@ public class Sftp extends AbstractFtp {
@Override
@SuppressWarnings("unchecked")
public boolean delDir(final String dirPath) {
if (! cd(dirPath)) {
if (!cd(dirPath)) {
return false;
}
@@ -460,7 +460,7 @@ public class Sftp extends AbstractFtp {
String fileName;
for (final LsEntry entry : list) {
fileName = entry.getFilename();
if (! ".".equals(fileName) && ! "..".equals(fileName)) {
if (!".".equals(fileName) && !"..".equals(fileName)) {
if (entry.getAttrs().isDir()) {
delDir(fileName);
} else {
@@ -469,7 +469,7 @@ public class Sftp extends AbstractFtp {
}
}
if (! cd("..")) {
if (!cd("..")) {
return false;
}
@@ -490,7 +490,7 @@ public class Sftp extends AbstractFtp {
* @since 5.7.6
*/
public void upload(final String remotePath, final File file) {
if (! FileUtil.exists(file)) {
if (!FileUtil.exists(file)) {
return;
}
if (file.isDirectory()) {
@@ -514,7 +514,7 @@ public class Sftp extends AbstractFtp {
@SuppressWarnings("resource")
@Override
public boolean uploadFile(final String destPath, final File file) {
if(! FileUtil.isFile(file)){
if(!FileUtil.isFile(file)){
throw new FtpException("[{}] is not a file!", file);
}
this.mkDirs(destPath);
@@ -634,9 +634,9 @@ public class Sftp extends AbstractFtp {
srcFile = StrUtil.format("{}/{}", sourcePath, fileName);
destFile = FileUtil.file(destDir, fileName);
if (! item.getAttrs().isDir()) {
if (!item.getAttrs().isDir()) {
// 本地不存在文件或者ftp上文件有修改则下载
if (! FileUtil.exists(destFile)
if (!FileUtil.exists(destFile)
|| (item.getAttrs().getMTime() > (destFile.lastModified() / 1000))) {
download(srcFile, destFile);
}

View File

@@ -81,6 +81,6 @@ public class TemplateFactory {
return engine.init(config);
}
throw new TemplateException("No template found ! Please add one of template jar to your project !");
throw new TemplateException("No template found !Please add one of template jar to your project !");
}
}

View File

@@ -60,6 +60,6 @@ public class TokenizerFactory {
return engine;
}
throw new TokenizerException("No tokenizer found ! Please add some tokenizer jar to your project !");
throw new TokenizerException("No tokenizer found !Please add some tokenizer jar to your project !");
}
}