mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
add method
This commit is contained in:
parent
ed85f81cea
commit
75d84b4768
@ -12,6 +12,7 @@
|
||||
* 【extra 】 SenvenZExtractor改名为SevenZExtractor,增加getFirst、get方法
|
||||
* 【core 】 DateConverter修改返回java.util.Date而非DateTime(issue#I4BOAP@Gitee)
|
||||
* 【core 】 增加IterableIter、ComputeIter
|
||||
* 【core 】 CsvConfig增加disableComment方法(issue#1842@Github)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【http 】 修复HttpCookie设置cookies的方法,不符合RFC6265规范问题(pr#418@Gitee)
|
||||
|
@ -29,7 +29,7 @@ public class TreeBuilder<E> implements Builder<Tree<E>> {
|
||||
*
|
||||
* @param rootId 根节点ID
|
||||
* @param <T> ID类型
|
||||
* @return {@link TreeBuilder}
|
||||
* @return TreeBuilder
|
||||
*/
|
||||
public static <T> TreeBuilder<T> of(T rootId) {
|
||||
return of(rootId, null);
|
||||
@ -41,7 +41,7 @@ public class TreeBuilder<E> implements Builder<Tree<E>> {
|
||||
* @param rootId 根节点ID
|
||||
* @param config 配置
|
||||
* @param <T> ID类型
|
||||
* @return {@link TreeBuilder}
|
||||
* @return TreeBuilder
|
||||
*/
|
||||
public static <T> TreeBuilder<T> of(T rootId, TreeNodeConfig config) {
|
||||
return new TreeBuilder<>(rootId, config);
|
||||
|
@ -28,7 +28,7 @@ public class CsvConfig<T extends CsvConfig<T>> implements Serializable {
|
||||
/**
|
||||
* 注释符号,用于区分注释行,默认'#'
|
||||
*/
|
||||
protected char commentCharacter = '#';
|
||||
protected Character commentCharacter = '#';
|
||||
/**
|
||||
* 标题别名
|
||||
*/
|
||||
@ -57,13 +57,25 @@ public class CsvConfig<T extends CsvConfig<T>> implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 注释符号,用于区分注释行
|
||||
* 设置注释无效<br>
|
||||
* 当写出CSV时,{@link CsvWriter#writeComment(String)}将抛出异常<br>
|
||||
* 当读取CSV时,注释行按照正常行读取
|
||||
*
|
||||
* @return this
|
||||
* @since 5.7.14
|
||||
*/
|
||||
public T disableComment() {
|
||||
return setCommentCharacter(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 注释符号,用于区分注释行,{@code null}表示忽略注释
|
||||
*
|
||||
* @param commentCharacter 注释符号,用于区分注释行
|
||||
* @return this
|
||||
* @since 5.5.7
|
||||
*/
|
||||
public T setCommentCharacter(char commentCharacter) {
|
||||
public T setCommentCharacter(Character commentCharacter) {
|
||||
this.commentCharacter = commentCharacter;
|
||||
return (T) this;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ public final class CsvParser implements Closeable, Serializable {
|
||||
if(preChar < 0 || preChar == CharUtil.CR || preChar == CharUtil.LF){
|
||||
// 判断行首字符为指定注释字符的注释开始,直到遇到换行符
|
||||
// 行首分两种,1是preChar < 0表示文本开始,2是换行符后紧跟就是下一行的开始
|
||||
if(c == this.config.commentCharacter){
|
||||
if(null != this.config.commentCharacter && c == this.config.commentCharacter){
|
||||
inComment = true;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
@ -308,7 +309,8 @@ public final class CsvWriter implements Closeable, Flushable, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 写出一行注释,注释符号可自定义
|
||||
* 写出一行注释,注释符号可自定义<br>
|
||||
* 如果注释符不存在,则抛出异常
|
||||
*
|
||||
* @param comment 注释内容
|
||||
* @return this
|
||||
@ -316,6 +318,7 @@ public final class CsvWriter implements Closeable, Flushable, Serializable {
|
||||
* @since 5.5.7
|
||||
*/
|
||||
public CsvWriter writeComment(String comment) {
|
||||
Assert.notNull(this.config.commentCharacter, "Comment is disable!");
|
||||
try {
|
||||
writer.write(this.config.commentCharacter);
|
||||
writer.write(comment);
|
||||
|
Loading…
x
Reference in New Issue
Block a user