diff --git a/README.md b/README.md index 10823ad..e4b3d2e 100755 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Note: This library is still under development, and some concepts or features mig ``` dependencies { ... - implementation 'com.github.CST-Group:cst:1.6.0' + implementation 'com.github.CST-Group:cst:1.6.1' } ``` @@ -53,7 +53,7 @@ Sometimes, the version number (tag) in this README gets out of date, as maintain com.github.CST-Group cst - 1.6.0 + 1.6.1 ``` diff --git a/build.gradle b/build.gradle index d44fedc..89808ce 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ java { } -version = '1.6.0' +version = '1.6.1' repositories { mavenCentral() diff --git a/src/main/java/br/unicamp/cst/representation/idea/Idea.java b/src/main/java/br/unicamp/cst/representation/idea/Idea.java index c0bc4f4..e4b34b1 100644 --- a/src/main/java/br/unicamp/cst/representation/idea/Idea.java +++ b/src/main/java/br/unicamp/cst/representation/idea/Idea.java @@ -763,7 +763,7 @@ private Float tryParseFloat(String value) { try { returnValue = Float.parseFloat(value); } catch (Exception ex) { - returnValue = null; + returnValue = 0f; } return returnValue; @@ -775,7 +775,7 @@ private Double tryParseDouble(String value) { try { returnValue = Double.parseDouble(value); } catch (Exception ex) { - returnValue = null; + returnValue = 0.0; } return returnValue; @@ -787,7 +787,7 @@ private Integer tryParseInteger(String value) { try { returnValue = Integer.parseInt(value); } catch (Exception ex) { - returnValue = null; + returnValue = 0; } return returnValue; @@ -799,7 +799,7 @@ private Long tryParseLong(String value) { try { returnValue = Long.parseLong(value); } catch (Exception ex) { - returnValue = null; + returnValue = 0L; } return returnValue; @@ -811,7 +811,7 @@ private Short tryParseShort(String value) { try { returnValue = Short.parseShort(value); } catch (Exception ex) { - returnValue = null; + returnValue = 0; } return returnValue; @@ -822,7 +822,7 @@ private Byte tryParseByte(String value) { try { returnValue = Byte.parseByte(value,16); } catch (Exception ex) { - returnValue = null; + returnValue = 0x0; } return returnValue; } diff --git a/src/test/java/br/unicamp/cst/representation/idea/TestIdea.java b/src/test/java/br/unicamp/cst/representation/idea/TestIdea.java index 1460c28..727e274 100644 --- a/src/test/java/br/unicamp/cst/representation/idea/TestIdea.java +++ b/src/test/java/br/unicamp/cst/representation/idea/TestIdea.java @@ -878,4 +878,39 @@ public List getLoggedEvents() { assertTrue(a.equals(a1)); } + static class TestIdeaClass { + public double[] mirPose; + public TestIdeaClass() { + mirPose = null; + } + } + + @Test public void testComplexConvertObject() { + + Idea i0 = new Idea("root"); + Idea i1 = new Idea("var"); + Idea i = new Idea("mirPose"); + i.add(new Idea("mirPose[0]",-5.800001621246338)); + i.add(new Idea("mirPose[1]", -8.575002670288086)); + i.add(new Idea("mirPose[2]", 0.2993086874485016)); + i.add(new Idea("mirPose[3]", -0.0)); + i.add(new Idea("mirPose[4]", 0.0)); + i.add(new Idea("mirPose[5]",-0.0)); + i0.add(i1); + i1.add(i); + System.out.println(i0.toStringFull()); + TestIdeaClass n = new TestIdeaClass(); + System.out.println(n); + Idea ii = i0.get("mirPose"); + Idea ii2 = i.get("mirPose"); + TestIdeaClass x = (TestIdeaClass) i0.getObject("var", "br.unicamp.cst.representation.idea.TestIdea$TestIdeaClass"); + for (int k=0;k<6;k++) { + double vv = (double)i.get("mirPose["+k+"]").getValue(); + System.out.println("class: "+x.mirPose[k]+" idea: "+vv); + assertEquals(x.mirPose[k],vv); + } + System.out.println(x); + + } + } \ No newline at end of file