Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
hs_err_pid*
/build/
/classes/
/bin/
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sonatypeUsername=
sonatypePassword=
12 changes: 6 additions & 6 deletions src/org/beanio/internal/compiler/ParserFactorySupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/org/beanio/internal/util/DomUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -82,7 +82,7 @@ public static void print(String title, Node document) {
System.out.println("-------------------------------------------");
}
catch (Exception ex) {
ex.printStackTrace();
throw new BeanIOException(ex);
}
}
}
14 changes: 8 additions & 6 deletions src/org/beanio/types/xml/AbstractXmlCalendarTypeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}

Expand Down
20 changes: 20 additions & 0 deletions test/org/beanio/parser/inlinemaps/InlineMapParserTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.beanio.parser.inlinemaps;

import static org.junit.Assert.assertEquals;

import java.io.StringReader;
import java.util.Map;

Expand Down Expand Up @@ -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"));
}
}