diff --git a/.gitignore b/.gitignore index 12746c8..89f9570 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ hs_err_pid* /build/ /classes/ +/bin/ \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..fbf0d15 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +sonatypeUsername= +sonatypePassword= \ No newline at end of file diff --git a/src/org/beanio/internal/compiler/ParserFactorySupport.java b/src/org/beanio/internal/compiler/ParserFactorySupport.java index ee62876..7b62486 100644 --- a/src/org/beanio/internal/compiler/ParserFactorySupport.java +++ b/src/org/beanio/internal/compiler/ParserFactorySupport.java @@ -389,7 +389,7 @@ protected void initializeGroup(GroupConfig config) throws BeanIOConfigurationExc protected void initializeGroupIteration(GroupConfig config, Property property) { // wrap the segment in an iteration - Component aggregation = createRecordAggregation(config, property); + Component aggregation = createRecordAggregation(config); pushParser(aggregation); if (property != null || config.getTarget() != null) { @@ -474,7 +474,7 @@ protected void initializeRecord(RecordConfig config) throws BeanIOConfigurationE protected void initializeRecordIteration(RecordConfig config, Property property) { // wrap the segment in an iteration - Component collection = createRecordAggregation(config, property); + Component collection = createRecordAggregation(config); pushParser(collection); if (property != null || config.getTarget() != null) { @@ -586,7 +586,7 @@ protected void finalizeRecord(RecordConfig config, Record record) { } - private Property findTarget(Component segment, String name) { + private static Property findTarget(Component segment, String name) { Component c = findDescendant("value", segment, name); if (c == null) { throw new BeanIOConfigurationException("Descendant value '" + name + "' not found"); @@ -602,7 +602,7 @@ private Property findTarget(Component segment, String name) { return property; } - private Component findDescendant(String type, Component c, String name) { + private static Component findDescendant(String type, Component c, String name) { if (name.equals(c.getName())) { return c; } @@ -1024,7 +1024,7 @@ else if (arrayType == null) { * @return the created {@link RecordAggregation} * @throws BeanIOConfigurationException */ - protected RecordAggregation createRecordAggregation(PropertyConfig config, Property property) + protected RecordAggregation createRecordAggregation(PropertyConfig config) throws BeanIOConfigurationException { boolean isMap = false; @@ -1049,7 +1049,7 @@ protected RecordAggregation createRecordAggregation(PropertyConfig config, Prope } // create the appropriate iteration type - RecordAggregation aggregation;; + RecordAggregation aggregation; if (collectionType == TypeUtil.ARRAY_TYPE) { aggregation = new RecordArray(); } diff --git a/src/org/beanio/internal/util/DomUtil.java b/src/org/beanio/internal/util/DomUtil.java index 930a21a..9a5c1b5 100644 --- a/src/org/beanio/internal/util/DomUtil.java +++ b/src/org/beanio/internal/util/DomUtil.java @@ -65,7 +65,7 @@ public static Document newDocument() { * @param title the name of the DOM * @param document the DOM to print */ - public static void print(String title, Node document) { + public static void print(String title, Node document) throws BeanIOException{ try { TransformerFactory factory = TransformerFactory.newInstance(); Transformer trans = factory.newTransformer(); @@ -82,7 +82,7 @@ public static void print(String title, Node document) { System.out.println("-------------------------------------------"); } catch (Exception ex) { - ex.printStackTrace(); + throw new BeanIOException(ex); } } } diff --git a/src/org/beanio/types/xml/AbstractXmlCalendarTypeHandler.java b/src/org/beanio/types/xml/AbstractXmlCalendarTypeHandler.java index 808b575..627b52f 100644 --- a/src/org/beanio/types/xml/AbstractXmlCalendarTypeHandler.java +++ b/src/org/beanio/types/xml/AbstractXmlCalendarTypeHandler.java @@ -31,7 +31,9 @@ */ public abstract class AbstractXmlCalendarTypeHandler extends CalendarTypeHandler { - protected static final DatatypeFactory dataTypeFactory; + private static final String DATE_TIME = "dateTime"; + private static final String INVALID_XML = "Invalid XML "; + protected static final DatatypeFactory dataTypeFactory; static { try { dataTypeFactory = DatatypeFactory.newInstance(); @@ -67,20 +69,20 @@ public Calendar parse(String text) throws TypeConversionException { try { XMLGregorianCalendar xcal = dataTypeFactory.newXMLGregorianCalendar(text); if (!lenientDatatype && type != null && !xcal.getXMLSchemaType().equals(type)) { - throw new TypeConversionException("Invalid XML " + type.getLocalPart()); + throw new TypeConversionException(INVALID_XML + type.getLocalPart()); } if (!isTimeZoneAllowed() && xcal.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { - String typeName = type == null ? "dateTime" : type.getLocalPart(); - throw new TypeConversionException("Invalid XML " + typeName + + String typeName = type == null ? DATE_TIME : type.getLocalPart(); + throw new TypeConversionException(INVALID_XML + typeName + ", time zone not allowed"); } return xcal.toGregorianCalendar(); } catch (IllegalArgumentException ex) { - String typeName = type == null ? "dateTime" : type.getLocalPart(); - throw new TypeConversionException("Invalid XML " + typeName); + String typeName = type == null ? DATE_TIME : type.getLocalPart(); + throw new TypeConversionException(INVALID_XML + typeName); } } diff --git a/test/org/beanio/parser/inlinemaps/InlineMapParserTest.java b/test/org/beanio/parser/inlinemaps/InlineMapParserTest.java index 521d5c7..bfb9141 100644 --- a/test/org/beanio/parser/inlinemaps/InlineMapParserTest.java +++ b/test/org/beanio/parser/inlinemaps/InlineMapParserTest.java @@ -1,5 +1,7 @@ package org.beanio.parser.inlinemaps; +import static org.junit.Assert.assertEquals; + import java.io.StringReader; import java.util.Map; @@ -104,5 +106,23 @@ public void testMapRecordGroup() { "entity,PERSON,-22.282174,166.441458,TEST_ENTITY_3\n"; BeanReader in = factory.createReader("stream5", new StringReader(text)); + + Map map = (Map) in.read(); + assertEquals("ACTIVE", map.get("status")); + assertEquals("PERSON", map.get("subtype")); + assertEquals (Double.valueOf(8.4), map.get("lat")); + assertEquals(Double.valueOf(-77.2), map.get("lon")); + + map = (Map) in.read(); + assertEquals ("ACTIVE", map.get("status")); + assertEquals("PERSON", map.get("subtype")); + assertEquals (Double.valueOf(-33.99367), map.get("lat")); + assertEquals(Double.valueOf(25.67632), map.get("lon")); + + map = (Map) in.read(); + assertEquals ("ACTIVE", map.get("status")); + assertEquals("PERSON", map.get("subtype")); + assertEquals (Double.valueOf(-22.282174), map.get("lat")); + assertEquals(Double.valueOf(166.441458), map.get("lon")); } }