This commit is contained in:
Looly 2020-08-29 11:57:31 +08:00
parent 68ad664fec
commit dd1f89b555
3 changed files with 12 additions and 7 deletions

View File

@ -107,7 +107,7 @@ public final class CsvRow implements List<String> {
* @since 5.3.6 * @since 5.3.6
*/ */
public <T> T toBean(Class<T> clazz){ public <T> T toBean(Class<T> clazz){
return BeanUtil.mapToBean(getFieldMap(), clazz, true); return BeanUtil.toBeanIgnoreError(getFieldMap(), clazz);
} }
/** /**

View File

@ -5,10 +5,11 @@ import org.junit.Test;
public class XMLTest { public class XMLTest {
@SuppressWarnings("ConstantConditions")
@Test @Test
public void toXmlTest(){ public void toXmlTest(){
final JSONObject put = JSONUtil.createObj().put("aaa", "你好").put("键2", "test"); final JSONObject put = JSONUtil.createObj()
.set("aaa", "你好")
.set("键2", "test");
final String s = JSONUtil.toXmlStr(put); final String s = JSONUtil.toXmlStr(put);
Assert.assertEquals("<aaa>你好</aaa><键2>test</键2>", s); Assert.assertEquals("<aaa>你好</aaa><键2>test</键2>", s);
} }

View File

@ -289,7 +289,7 @@ public class ExcelUtil {
*/ */
public static ExcelReader getReader(InputStream bookStream, int sheetIndex) { public static ExcelReader getReader(InputStream bookStream, int sheetIndex) {
try { try {
return new ExcelReader(bookStream, sheetIndex, true); return new ExcelReader(bookStream, sheetIndex);
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG); throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
} }
@ -303,10 +303,12 @@ public class ExcelUtil {
* @param closeAfterRead 读取结束是否关闭流 * @param closeAfterRead 读取结束是否关闭流
* @return {@link ExcelReader} * @return {@link ExcelReader}
* @since 4.0.3 * @since 4.0.3
* @deprecated 使用完毕无论是否closeAfterReadpoi会关闭流此参数无意义
*/ */
@Deprecated
public static ExcelReader getReader(InputStream bookStream, int sheetIndex, boolean closeAfterRead) { public static ExcelReader getReader(InputStream bookStream, int sheetIndex, boolean closeAfterRead) {
try { try {
return new ExcelReader(bookStream, sheetIndex, closeAfterRead); return new ExcelReader(bookStream, sheetIndex);
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG); throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
} }
@ -322,7 +324,7 @@ public class ExcelUtil {
*/ */
public static ExcelReader getReader(InputStream bookStream, String sheetName) { public static ExcelReader getReader(InputStream bookStream, String sheetName) {
try { try {
return new ExcelReader(bookStream, sheetName, true); return new ExcelReader(bookStream, sheetName);
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG); throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
} }
@ -335,10 +337,12 @@ public class ExcelUtil {
* @param sheetName sheet名第一个默认是sheet1 * @param sheetName sheet名第一个默认是sheet1
* @param closeAfterRead 读取结束是否关闭流 * @param closeAfterRead 读取结束是否关闭流
* @return {@link ExcelReader} * @return {@link ExcelReader}
* @deprecated 使用完毕无论是否closeAfterReadpoi会关闭流此参数无意义
*/ */
@Deprecated
public static ExcelReader getReader(InputStream bookStream, String sheetName, boolean closeAfterRead) { public static ExcelReader getReader(InputStream bookStream, String sheetName, boolean closeAfterRead) {
try { try {
return new ExcelReader(bookStream, sheetName, closeAfterRead); return new ExcelReader(bookStream, sheetName);
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG); throw new DependencyException(ObjectUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG);
} }