Skip to content

Commit

Permalink
#48 The method Float.isFinite() was introduced in Java 8, but ETL wri…
Browse files Browse the repository at this point in the history
…tten for Java 6.
  • Loading branch information
stokito committed Mar 30, 2015
1 parent 6f291a4 commit 8f7f26c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<source>${maven.compile.sourceLevel}</source>
<target>${maven.compile.targetLevel}</target>
<encoding>${project.build.sourceEncoding}</encoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.serialization.serializer.OStringSerializerHelper;
import com.orientechnologies.orient.etl.OETLProcessor;
import sun.misc.FloatConsts;

import java.text.DateFormat;
import java.text.ParseException;
Expand Down Expand Up @@ -157,7 +158,7 @@ public Object executeTransform(final Object input) {
if (fieldStringValue.contains(".") || fieldStringValue.contains(",")) {
String numberAsString = fieldStringValue.replaceAll(",", ".");
fieldValue = new Float(numberAsString);
if (!Float.isFinite((Float) fieldValue)) {
if (!isFinite((Float) fieldValue)) {
fieldValue = new Double(numberAsString);
}
} else
Expand Down Expand Up @@ -191,6 +192,15 @@ public Object executeTransform(final Object input) {

return doc;
}

/**
* Backport copy of {@link Float#isFinite()} method that was introduced since Java 1.8 but we must support 1.6
* TODO replace after choosing Java 1.8 as minimal supported
**/
protected boolean isFinite(Float f) {
return Math.abs(f) <= FloatConsts.MAX_VALUE;
}

//TODO Test, and double doubleqoutes case
public String getCellContent(String iValue) {
if (iValue == null)
Expand Down

0 comments on commit 8f7f26c

Please sign in to comment.