Skip to content

Commit

Permalink
Merge pull request #217 from ozlerhakan/3.1.4
Browse files Browse the repository at this point in the history
v3.1.4
  • Loading branch information
ozlerhakan committed Dec 4, 2021
2 parents 6da674c + 4f2ae9c commit 5cbc607
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 92 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Greetings

on: [pull_request, issues]

jobs:
greeting:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: 'Thank you for contributing to Poiji! Feel free to create a PR If you want to contribute directly :)'
pr-message: 'Thank you for contributing to Poiji!. We will check your PR. Feel free to add more comments If you have'
32 changes: 32 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path

name: Maven Package

on:
release:
types: [created]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish package
run: mvn --batch-mode deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Poiji Build

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Build and Test with Maven
run: mvn clean -B package --file pom.xml -P coverage
- name: Codecov GitHub Action
uses: codecov/codecov-action@v2
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017-2020 Poiji
Copyright (c) 2017-2021 Poiji

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 6 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
:toclevels: 2

= Poiji
:version: v3.1.3
:version: v3.1.4
:branch: 3.1.4


image:https://travis-ci.org/ozlerhakan/poiji.svg?branch=master["Build Status", link="https://travis-ci.org/ozlerhakan/poiji"] image:https://app.codacy.com/project/badge/Grade/64f7e2cb9e604807b62334a4cfc3952d["Codacy code quality", link="https://www.codacy.com/gh/ozlerhakan/poiji/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ozlerhakan/poiji&utm_campaign=Badge_Grade"] image:https://coveralls.io/repos/github/ozlerhakan/poiji/badge.svg?branch=master["Coverage Status", link="https://coveralls.io/github/ozlerhakan/poiji?branch=master"] image:https://img.shields.io/badge/apache.poi-5.0.0-brightgreen.svg[] image:https://app.fossa.com/api/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji.svg?type=shield["FOSSA Status", link="https://app.fossa.com/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji?ref=badge_shield"] image:https://img.shields.io/badge/license-MIT-blue.svg[]
image:https://github.com/ozlerhakan/poiji/actions/workflows/maven.yml/badge.svg["Build Status"] image:https://app.codacy.com/project/badge/Grade/64f7e2cb9e604807b62334a4cfc3952d["Codacy code quality", link="https://www.codacy.com/gh/ozlerhakan/poiji/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ozlerhakan/poiji&utm_campaign=Badge_Grade"]
image:https://codecov.io/gh/ozlerhakan/poiji/branch/{branch}/graph/badge.svg?token=MN6V6xOWBq["Codecov", link="https://codecov.io/gh/ozlerhakan/poiji"] image:https://img.shields.io/badge/apache.poi-5.0.0-brightgreen.svg[] image:https://app.fossa.com/api/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji.svg?type=shield["FOSSA Status", link="https://app.fossa.com/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji?ref=badge_shield"]

Poiji is a tiny thread-safe Java library that provides one way mapping from Excel sheets to Java classes. In a way it lets us convert each row of the specified excel data into Java objects. Poiji uses https://poi.apache.org/[Apache Poi] (the Java API for Microsoft Documents) under the hood to fulfill the mapping process.

Expand All @@ -23,15 +24,15 @@ In your Maven/Gradle project, first add the corresponding dependency:
<dependency>
<groupId>com.github.ozlerhakan</groupId>
<artifactId>poiji</artifactId>
<version>3.1.3</version>
<version>3.1.4</version>
</dependency>
----

.gradle
[source,groovy]
----
dependencies {
compile 'com.github.ozlerhakan:poiji:3.1.3'
compile 'com.github.ozlerhakan:poiji:3.1.4'
}
----

Expand Down
76 changes: 18 additions & 58 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.ozlerhakan</groupId>
<artifactId>poiji</artifactId>
<version>3.1.3</version>
<version>3.1.4</version>
<packaging>jar</packaging>

<name>poiji</name>
Expand Down Expand Up @@ -52,8 +52,8 @@

<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<maven-enforcer-plugin.version>1.2</maven-enforcer-plugin.version>
<jdk.source>1.8</jdk.source>
<jdk.target>1.8</jdk.target>
<jdk.source>11</jdk.source>
<jdk.target>11</jdk.target>

<maven.version>3.0.4</maven.version>
</properties>
Expand Down Expand Up @@ -87,16 +87,6 @@
<finalName>${project.artifactId}</finalName>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<!-- <argLine>${add.opens}</argLine>-->
<argLine>-Djava.awt.headless=true</argLine>
<argLine>-Duser.language=en -Duser.region=US</argLine>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -151,33 +141,14 @@
<goal>jar</goal>
</goals>
<configuration>
<source>11</source>
<detectJavaApiLink>false</detectJavaApiLink>
<additionalparam>${javadoc.none}</additionalparam>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<repoToken>${env.COVERALLS_TOKEN}</repoToken>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<format>xml</format>
<maxmem>256m</maxmem>
<aggregate>true</aggregate>
<check/>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand Down Expand Up @@ -206,17 +177,6 @@
</build>

<profiles>
<profile>
<id>java9</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<!-- we need to open a specific package of a platform module to the unnamed module that uses deep reflection at runtime,
currently this is allowed but deep reflection in the unnamed module will not be validated in a future release of JDK at runtime -->
<add.opens>--add-opens java.base/java.io=ALL-UNNAMED --add-opens java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED</add.opens>
</properties>
</profile>
<profile>
<id>javadoclint</id>
<activation>
Expand All @@ -227,25 +187,25 @@
</properties>
</profile>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>doRelease</name>
<value>true</value>
</property>
</activation>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>sign</goal>
<goal>report</goal>
</goals>
</execution>
</executions>
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/com/poiji/config/DefaultCasting.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -132,7 +127,7 @@ private Float floatValue(String value, String sheetName, int row, int col, Poiji

private BigDecimal bigDecimalValue(String value, String sheetName, int row, int col, PoijiOptions options) {
try {
return Parsers.bigDecimals().parse(value);
return Parsers.bigDecimals(options.getLocale()).parse(value);
} catch (NumberFormatException | IllegalStateException e) {
return onError(value, sheetName, row, col, e, options.preferNullOverDefault() ? null : BigDecimal.ZERO);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/poiji/option/PoijiOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public PoijiOptionsBuilder skip(int skip) {
}

/**
* limit a number of rows after the header & skipped rows row. The header & skipped rows are not counted.
* limit a number of rows after the header &amp; skipped rows row. The header &amp; skipped rows are not counted.
*
* @param limit number
* @return this
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/poiji/parser/BigDecimalParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ public class BigDecimalParser implements Parser<BigDecimal> {

private final NumberParser delegate;

BigDecimalParser() {
this.delegate = new NumberParser(getDecimalFormatInstance());
BigDecimalParser(NumberFormat numberFormat) {
this.delegate = new NumberParser(getDecimalFormatInstance(numberFormat));
}

private DecimalFormat getDecimalFormatInstance() {
NumberFormat numberFormat = NumberFormat.getInstance();
private DecimalFormat getDecimalFormatInstance(NumberFormat numberFormat) {
DecimalFormat decimalFormat = (DecimalFormat) numberFormat;
decimalFormat.setParseBigDecimal(true);
return decimalFormat;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/poiji/parser/Parsers.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static NumberParser integers() {
return new NumberParser(format);
}

public static BigDecimalParser bigDecimals() {
return new BigDecimalParser();
public static BigDecimalParser bigDecimals(Locale locale) {
return new BigDecimalParser(NumberFormat.getInstance(locale));
}

public static NumberParser numbers(Locale locale) {
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/com/poiji/util/DefaultCastingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ public void castLocalDateTime() {

@Test
public void castBigDecimalDE() {

Locale.setDefault(Locale.GERMANY);
PoijiOptions options = PoijiOptionsBuilder.settings().setLocale(Locale.GERMANY).build();
BigDecimal testVal = (BigDecimal) casting.castValue(BigDecimal.class, "81,56", options);

assertEquals(BigDecimal.valueOf(81.56), testVal);
Expand Down

0 comments on commit 5cbc607

Please sign in to comment.