Skip to content

Commit

Permalink
Merge pull request #18 from biezhi/dev
Browse files Browse the repository at this point in the history
release 1.0.1
  • Loading branch information
hellokaton authored Dec 14, 2018
2 parents a55963a + 5dcc26a commit 241312f
Show file tree
Hide file tree
Showing 51 changed files with 1,203 additions and 260 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Easier to read and generate an excel file, supports `XLSX`、`XLS`、`CSV`.
<dependency>
<groupId>io.github.biezhi</groupId>
<artifactId>excel-plus</artifactId>
<version>1.0.0.Alpha</version>
<version>1.0.1</version>
</dependency>
```

Expand All @@ -44,7 +44,7 @@ snapshot version
<dependency>
<groupId>io.github.biezhi</groupId>
<artifactId>excel-plus</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>io.github.biezhi</groupId>
<artifactId>excel-plus</artifactId>
<version>1.0.0.Alpha</version>
<version>1.0.1</version>
</dependency>
```

Expand All @@ -53,7 +53,7 @@
<dependency>
<groupId>io.github.biezhi</groupId>
<artifactId>excel-plus</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
</dependency>
```

Expand Down
24 changes: 14 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.biezhi</groupId>
<artifactId>excel-plus</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1</version>
<name>excel-plus</name>
<url>https://biezhi.github.io/excel-plus</url>
<description>excel read and write framework</description>
Expand All @@ -31,7 +31,6 @@

<properties>
<poi.version>4.0.1</poi.version>
<xerces.version>2.11.0</xerces.version>
</properties>

<dependencies>
Expand All @@ -50,11 +49,6 @@
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>${xerces.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand All @@ -74,9 +68,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -100,6 +94,16 @@
<format>html</format>
<format>xml</format>
</formats>
<instrumentation>
<ignores>
<ignore>io.github.biezhi.excel.plus.annotation.*</ignore>
<ignore>io.github.biezhi.excel.plus.exception.*</ignore>
</ignores>
<excludes>
<exclude>io/github/biezhi/excel/plus/annotation/*.class</exclude>
<exclude>io/github/biezhi/excel/plus/exception/*.class</exclude>
</excludes>
</instrumentation>
<check />
</configuration>
</plugin>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/io/github/biezhi/excel/plus/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
*/
public interface Constant {

String TIP_MSG = "Please see https://biezhi.github.io/excel-plus/";

/**
* The default worksheet name.
*/
Expand Down
55 changes: 0 additions & 55 deletions src/main/java/io/github/biezhi/excel/plus/ExcelPlus.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/io/github/biezhi/excel/plus/Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public Reader<T> sheet(String sheetName) {
* @return Stream
* @throws ReaderException Thrown when an exception occurs during reading
*/
public Stream<T> asStream() throws ReaderException {
public Stream<T> asStream() {
if (modelType == null) {
throw new IllegalArgumentException("modelType can be not null");
}
Expand Down Expand Up @@ -194,7 +194,7 @@ public File fromFile() {
}

public Class<T> modelType() {
return (Class<T>) modelType;
return modelType;
}

public int sheetIndex() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/biezhi/excel/plus/Writer.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public int startRow() {
return this.startRow;
}

public String sheet() {
public String sheetName() {
return this.sheetName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package io.github.biezhi.excel.plus.conveter;

import io.github.biezhi.excel.plus.exception.ConverterException;

/**
* Boolean to string converter
*
Expand All @@ -26,12 +24,8 @@
public class BooleanConverter implements Converter<String, Boolean> {

@Override
public Boolean stringToR(String value) throws ConverterException {
try {
return Boolean.valueOf(value);
} catch (Exception e){
throw new ConverterException("convert [" + value + "] to Boolean error", e);
}
public Boolean stringToR(String value) {
return Boolean.parseBoolean(value);
}

}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
* Copyright (c) 2018, biezhi ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright (c) 2018, biezhi ([email protected])
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.biezhi.excel.plus.conveter;

Expand All @@ -20,6 +20,7 @@

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
Expand Down Expand Up @@ -49,7 +50,9 @@ public class ConverterCache {
}

public static void addConvert(Converter converter) {
CONVERTER_MAP.put(converter.getClass(), converter);
if (null != converter) {
CONVERTER_MAP.put(converter.getClass(), converter);
}
}

public static Converter getConvert(
Expand All @@ -58,8 +61,17 @@ public static Converter getConvert(
}

public static Converter computeConvert(Field field) throws Exception {
if (null == field) {
return null;
}

Class fieldType = field.getType();

ExcelColumn column = field.getAnnotation(ExcelColumn.class);
if (null != column && !NullConverter.class.equals(column.converter())) {
return column.converter().newInstance();
}

if (fieldType.equals(String.class)) {
return ConverterCache.getConvert(StringConverter.class);
} else if (fieldType.equals(int.class) || fieldType.equals(Integer.class)) {
Expand All @@ -76,6 +88,8 @@ public static Converter computeConvert(Field field) throws Exception {
return ConverterCache.getConvert(ByteConverter.class);
} else if (fieldType.equals(boolean.class) || fieldType.equals(Boolean.class)) {
return ConverterCache.getConvert(BooleanConverter.class);
} else if (fieldType.equals(BigInteger.class)) {
return ConverterCache.getConvert(BigIntConverter.class);
} else if (fieldType.equals(BigDecimal.class)) {
return ConverterCache.getConvert(DecimalConverter.class);
} else if (fieldType.equals(Date.class)) {
Expand All @@ -87,12 +101,8 @@ public static Converter computeConvert(Field field) throws Exception {
} else if (fieldType.equals(LocalDateTime.class)) {
String pattern = field.getAnnotation(ExcelColumn.class).datePattern();
return new LocalDateTimeConverter(pattern);
} else {
Class<? extends Converter> customConverter = field.getAnnotation(ExcelColumn.class).converter();
if(!NullConverter.class.equals(customConverter)){
return customConverter.newInstance();
}
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public DateConverter(String pattern) {
@Override
public Date stringToR(String value) throws ConverterException {
try {
if(null == value){
return null;
}
return df.get().parse(value);
} catch (Exception e) {
throw new ConverterException("convert [" + value + "] to Date error", e);
Expand All @@ -47,6 +50,9 @@ public Date stringToR(String value) throws ConverterException {
@Override
public String toString(Date date) throws ConverterException {
try {
if(null == date){
return null;
}
return df.get().format(date);
} catch (Exception e) {
throw new ConverterException("convert [" + date + "] to String error", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public Integer stringToR(String value) throws ConverterException {
if (StringUtil.isEmpty(value)) {
return null;
}

return Integer.parseInt(value);
} catch (Exception e) {
throw new ConverterException("convert [" + value + "] to Integer error", e);
Expand Down
Loading

0 comments on commit 241312f

Please sign in to comment.