├── .gitignore ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── build.gradle ├── changelog.txt ├── docs └── reference │ ├── index.html │ └── style.css ├── site ├── 2011 │ └── 01 │ │ └── .htaccess ├── favicon.ico ├── images │ └── logo.png ├── index.html └── style.css ├── src └── org │ └── beanio │ ├── BeanIOConfigurationException.java │ ├── BeanIOException.java │ ├── BeanReader.java │ ├── BeanReaderErrorHandler.java │ ├── BeanReaderErrorHandlerSupport.java │ ├── BeanReaderException.java │ ├── BeanReaderIOException.java │ ├── BeanWriter.java │ ├── BeanWriterException.java │ ├── BeanWriterIOException.java │ ├── InvalidBeanException.java │ ├── InvalidRecordException.java │ ├── InvalidRecordGroupException.java │ ├── MalformedRecordException.java │ ├── Marshaller.java │ ├── RecordContext.java │ ├── StreamFactory.java │ ├── UnexpectedRecordException.java │ ├── UnidentifiedRecordException.java │ ├── Unmarshaller.java │ ├── annotation │ ├── AnnotationConstants.java │ ├── Field.java │ ├── Fields.java │ ├── Group.java │ ├── Record.java │ ├── Segment.java │ └── package.html │ ├── builder │ ├── Align.java │ ├── CsvParserBuilder.java │ ├── DelimitedParserBuilder.java │ ├── FieldBuilder.java │ ├── FixedLengthParserBuilder.java │ ├── GroupBuilder.java │ ├── GroupBuilderSupport.java │ ├── ParserBuilder.java │ ├── PropertyBuilderSupport.java │ ├── RecordBuilder.java │ ├── SegmentBuilder.java │ ├── SegmentBuilderSupport.java │ ├── StreamBuilder.java │ ├── XmlParserBuilder.java │ ├── XmlType.java │ └── package.html │ ├── internal │ ├── DefaultStreamFactory.java │ ├── compiler │ │ ├── ParserFactory.java │ │ ├── ParserFactorySupport.java │ │ ├── Preprocessor.java │ │ ├── ProcessorSupport.java │ │ ├── PropertyAccessorFactory.java │ │ ├── StreamCompiler.java │ │ ├── accessor │ │ │ └── ReflectionAccessorFactory.java │ │ ├── csv │ │ │ ├── CsvParserFactory.java │ │ │ └── package.html │ │ ├── delimited │ │ │ ├── DelimitedParserFactory.java │ │ │ └── package.html │ │ ├── fixedlength │ │ │ ├── FixedLengthParserFactory.java │ │ │ ├── FixedLengthPreprocessor.java │ │ │ └── package.html │ │ ├── flat │ │ │ ├── FlatParserFactory.java │ │ │ ├── FlatPreprocessor.java │ │ │ └── package.html │ │ ├── json │ │ │ ├── JsonParserFactory.java │ │ │ ├── JsonPreprocessor.java │ │ │ └── package.html │ │ ├── package.html │ │ └── xml │ │ │ ├── XmlParserFactory.java │ │ │ ├── XmlPreprocessor.java │ │ │ └── package.html │ ├── config │ │ ├── BeanConfig.java │ │ ├── BeanIOConfig.java │ │ ├── ComponentConfig.java │ │ ├── ConfigurationLoader.java │ │ ├── ConstantConfig.java │ │ ├── FieldConfig.java │ │ ├── GroupConfig.java │ │ ├── PropertyConfig.java │ │ ├── RecordConfig.java │ │ ├── SegmentConfig.java │ │ ├── SelectorConfig.java │ │ ├── SimplePropertyConfig.java │ │ ├── StreamConfig.java │ │ ├── TypeHandlerConfig.java │ │ ├── XmlTypeConstants.java │ │ ├── annotation │ │ │ ├── AnnotationParser.java │ │ │ └── package.html │ │ ├── beanio.properties │ │ ├── package.html │ │ └── xml │ │ │ ├── XmlConfigurationLoader.java │ │ │ ├── XmlMapping.java │ │ │ ├── XmlMappingParser.java │ │ │ ├── XmlMappingReader.java │ │ │ └── package.html │ ├── package.html │ ├── parser │ │ ├── AbortRecordUnmarshalligException.java │ │ ├── Aggregation.java │ │ ├── ArrayParser.java │ │ ├── Bean.java │ │ ├── BeanReaderImpl.java │ │ ├── BeanWriterImpl.java │ │ ├── CollectionBean.java │ │ ├── CollectionParser.java │ │ ├── Component.java │ │ ├── Constant.java │ │ ├── DelegatingParser.java │ │ ├── ErrorContext.java │ │ ├── Field.java │ │ ├── FieldFormat.java │ │ ├── Group.java │ │ ├── Iteration.java │ │ ├── MapParser.java │ │ ├── MarshallerImpl.java │ │ ├── MarshallingContext.java │ │ ├── MessageFactory.java │ │ ├── ObjectUtils.java │ │ ├── Parser.java │ │ ├── ParserComponent.java │ │ ├── ParserLocal.java │ │ ├── ParsingContext.java │ │ ├── Property.java │ │ ├── PropertyAccessor.java │ │ ├── PropertyComponent.java │ │ ├── Record.java │ │ ├── RecordAggregation.java │ │ ├── RecordArray.java │ │ ├── RecordCollection.java │ │ ├── RecordFormat.java │ │ ├── RecordMap.java │ │ ├── Segment.java │ │ ├── Selector.java │ │ ├── Stream.java │ │ ├── StreamFormat.java │ │ ├── StreamFormatSupport.java │ │ ├── UnmarshallerImpl.java │ │ ├── UnmarshallingContext.java │ │ ├── Value.java │ │ ├── accessor │ │ │ ├── FieldReflectionAccessor.java │ │ │ ├── MapAccessor.java │ │ │ ├── MethodReflectionAccessor.java │ │ │ ├── PropertyAccessorSupport.java │ │ │ └── package.html │ │ ├── format │ │ │ ├── FieldPadding.java │ │ │ ├── csv │ │ │ │ ├── CsvStreamFormat.java │ │ │ │ └── package.html │ │ │ ├── delimited │ │ │ │ ├── DelimitedFieldFormat.java │ │ │ │ ├── DelimitedMarshallingContext.java │ │ │ │ ├── DelimitedRecordFormat.java │ │ │ │ ├── DelimitedStreamFormat.java │ │ │ │ ├── DelimitedUnmarshallingContext.java │ │ │ │ ├── defaultMessages.properties │ │ │ │ └── package.html │ │ │ ├── fixedlength │ │ │ │ ├── FixedLengthFieldFormat.java │ │ │ │ ├── FixedLengthFieldPadding.java │ │ │ │ ├── FixedLengthMarshallingContext.java │ │ │ │ ├── FixedLengthRecordFormat.java │ │ │ │ ├── FixedLengthStreamFormat.java │ │ │ │ ├── FixedLengthUnmarshallingContext.java │ │ │ │ ├── defaultMessages.properties │ │ │ │ └── package.html │ │ │ ├── flat │ │ │ │ ├── FlatFieldFormat.java │ │ │ │ ├── FlatFieldFormatSupport.java │ │ │ │ └── package.html │ │ │ ├── json │ │ │ │ ├── JsonFieldFormat.java │ │ │ │ ├── JsonMarshallingContext.java │ │ │ │ ├── JsonNode.java │ │ │ │ ├── JsonNodeUtil.java │ │ │ │ ├── JsonStreamFormat.java │ │ │ │ ├── JsonUnmarshallingContext.java │ │ │ │ ├── JsonWrapper.java │ │ │ │ ├── defaultMessages.properties │ │ │ │ └── package.html │ │ │ ├── package.html │ │ │ └── xml │ │ │ │ ├── XmlAttributeField.java │ │ │ │ ├── XmlElementField.java │ │ │ │ ├── XmlFieldFormat.java │ │ │ │ ├── XmlMarshallingContext.java │ │ │ │ ├── XmlNode.java │ │ │ │ ├── XmlNodeUtil.java │ │ │ │ ├── XmlSelectorWrapper.java │ │ │ │ ├── XmlStreamFormat.java │ │ │ │ ├── XmlTextField.java │ │ │ │ ├── XmlUnmarshallingContext.java │ │ │ │ ├── XmlWrapper.java │ │ │ │ ├── defaultMessages.properties │ │ │ │ └── package.html │ │ ├── message │ │ │ ├── ResourceBundleMessageFactory.java │ │ │ └── package.html │ │ └── package.html │ └── util │ │ ├── BeanUtil.java │ │ ├── DebugUtil.java │ │ ├── Debuggable.java │ │ ├── DomUtil.java │ │ ├── EnumTypeHandler.java │ │ ├── IOUtil.java │ │ ├── JsonUtil.java │ │ ├── LocaleUtil.java │ │ ├── RecordFilterReader.java │ │ ├── Replicateable.java │ │ ├── Replicator.java │ │ ├── ReplicatorTest.java │ │ ├── Settings.java │ │ ├── StatefulWriter.java │ │ ├── StringUtil.java │ │ ├── ToStringEnumTypeHandler.java │ │ ├── TreeNode.java │ │ ├── TypeHandlerFactory.java │ │ ├── TypeUtil.java │ │ └── package.html │ ├── package.html │ ├── stream │ ├── RecordIOException.java │ ├── RecordMarshaller.java │ ├── RecordParserFactory.java │ ├── RecordParserFactorySupport.java │ ├── RecordReader.java │ ├── RecordUnmarshaller.java │ ├── RecordWriter.java │ ├── csv │ │ ├── CsvParserConfiguration.java │ │ ├── CsvReader.java │ │ ├── CsvRecordParser.java │ │ ├── CsvRecordParserFactory.java │ │ ├── CsvWriter.java │ │ └── package.html │ ├── delimited │ │ ├── DelimitedParserConfiguration.java │ │ ├── DelimitedReader.java │ │ ├── DelimitedRecordParser.java │ │ ├── DelimitedRecordParserFactory.java │ │ ├── DelimitedWriter.java │ │ └── package.html │ ├── fixedlength │ │ ├── FixedLengthParserConfiguration.java │ │ ├── FixedLengthReader.java │ │ ├── FixedLengthRecordParser.java │ │ ├── FixedLengthRecordParserFactory.java │ │ ├── FixedLengthWriter.java │ │ └── package.html │ ├── json │ │ ├── JsonParserConfiguration.java │ │ ├── JsonReader.java │ │ ├── JsonReaderSupport.java │ │ ├── JsonRecordMarshaller.java │ │ ├── JsonRecordParserFactory.java │ │ ├── JsonRecordUnmarshaller.java │ │ ├── JsonWriter.java │ │ ├── JsonWriterSupport.java │ │ └── package.html │ ├── package.html │ ├── util │ │ ├── CommentReader.java │ │ └── package.html │ └── xml │ │ ├── ElementStack.java │ │ ├── XmlParserConfiguration.java │ │ ├── XmlReader.java │ │ ├── XmlRecordMarshaller.java │ │ ├── XmlRecordParserFactory.java │ │ ├── XmlRecordUnmarshaller.java │ │ ├── XmlStreamConfiguration.java │ │ ├── XmlStreamConfigurationAware.java │ │ ├── XmlWriter.java │ │ └── package.html │ ├── types │ ├── BigDecimalTypeHandler.java │ ├── BigIntegerTypeHandler.java │ ├── BooleanTypeHandler.java │ ├── ByteTypeHandler.java │ ├── CalendarTypeHandler.java │ ├── CharacterTypeHandler.java │ ├── ConfigurableTypeHandler.java │ ├── DateTypeHandler.java │ ├── DateTypeHandlerSupport.java │ ├── DoubleTypeHandler.java │ ├── FloatTypeHandler.java │ ├── IntegerTypeHandler.java │ ├── LocaleSupport.java │ ├── LongTypeHandler.java │ ├── NumberTypeHandler.java │ ├── ShortTypeHandler.java │ ├── StringTypeHandler.java │ ├── TypeConversionException.java │ ├── TypeHandler.java │ ├── URLTypeHandler.java │ ├── UUIDTypeHandler.java │ ├── package.html │ └── xml │ │ ├── AbstractXmlCalendarTypeHandler.java │ │ ├── AbstractXmlDateTypeHandler.java │ │ ├── XmlBooleanTypeHandler.java │ │ ├── XmlCalendarDateTimeTypeHandler.java │ │ ├── XmlCalendarDateTypeHandler.java │ │ ├── XmlCalendarTimeTypeHandler.java │ │ ├── XmlDateTimeTypeHandler.java │ │ ├── XmlDateTypeHandler.java │ │ ├── XmlTimeTypeHandler.java │ │ └── package.html │ └── xsd │ ├── 2011 │ └── 01 │ │ └── mapping.xsd │ └── 2012 │ └── 03 │ └── mapping.xsd └── test └── org └── beanio ├── StreamFactoryTest.java ├── beans ├── Bean.groovy ├── Order.java ├── OrderBatch.java ├── OrderItem.java └── Person.java ├── builder └── BuilderTest.groovy ├── config ├── ConcreteBean.java ├── InterfaceBean.java ├── XmlMappingConfigurationTest.java ├── a.xml ├── ab.xml ├── ab_template.xml ├── b.xml ├── collectionAttributeField.xml ├── fieldNamespaceForText.xml ├── import.xml ├── imported.xml ├── invalidBeanClass.xml ├── invalidBeanXmlType.xml ├── invalidFieldXmlType.xml ├── invalidImport_InvalidResource.xml ├── invalidImport_ResourceNotFound.xml ├── invalidSetter.xml ├── invalidStreamMode.xml ├── invalidStreamXmlType.xml ├── nillableAttributeField.xml ├── noBeanProperty.xml ├── noReadableMethod.xml ├── noWriteableMethod.xml └── prefixWithNoNamespace.xml ├── file.txt ├── mapping.xml ├── parser ├── AbstractParserTest.groovy ├── ParserTest.java ├── annotation │ ├── AnnotatedBulb.java │ ├── AnnotatedFloor.java │ ├── AnnotatedGroupTest.groovy │ ├── AnnotatedLight.java │ ├── AnnotatedRoom.java │ ├── AnnotatedUser.java │ ├── AnnotatedUserInterface.java │ ├── AnnotatedUserSupport.java │ └── AnnotationTest.java ├── bean │ ├── BeanParserTest.java │ ├── Widget.java │ ├── w10_nestedBeans.txt │ ├── w1_position.txt │ ├── w2_collections.txt │ ├── w3_fixedLength.txt │ ├── w4_map.txt │ ├── w5_outOfOrder.txt │ ├── w6_fieldError.txt │ ├── w9_flcollections.txt │ └── widget.xml ├── collection │ ├── CollectionBean.java │ ├── CollectionFieldParserTest.java │ ├── collection.xml │ ├── dc1_valid.txt │ ├── dc2_nullPrimitive.txt │ └── fc1_valid.txt ├── comments │ ├── CommentsParserTest.java │ ├── c1.txt │ └── comments_mapping.xml ├── constructor ├── defaultValue │ └── DefaultValueTest.groovy ├── delimited │ ├── DelimitedParserTest.java │ ├── d1_messages.properties │ ├── d1_recordErrors.txt │ ├── d2_optionalField.txt │ ├── d3_padding.txt │ └── delimited.xml ├── direct │ ├── DirectParserTest.java │ ├── DirectUser.java │ ├── d1.txt │ └── direct_mapping.xml ├── dynamicOccurs │ ├── DynamicOccursParserTest.java │ └── dynamicOccurs_mapping.xml ├── fixedlength │ ├── FixedLengthParserTest.java │ ├── f1_maxLength.txt │ ├── f1_minLength.txt │ ├── f1_valid.txt │ ├── f2_invalid.txt │ ├── f2_messages.properties │ ├── f2_valid.txt │ ├── f3_valid.txt │ ├── f4_padding.txt │ ├── f5_valid.txt │ ├── f7.txt │ └── fixedlength.xml ├── groups │ ├── GroupParserTest.java │ ├── g1_empty.txt │ ├── g1_missingBatchTrailer.txt │ ├── g1_noHeader.txt │ ├── g1_noTrailer.txt │ ├── g1_nobatch.txt │ ├── g1_oneBatch.txt │ ├── g1_threeBatch.txt │ ├── g1_tooManyHeaders.txt │ ├── g1_unidentifiedRecord.txt │ ├── g2_empty.txt │ ├── g2_missingGroup.txt │ ├── g2_tooManyGroups.txt │ ├── g2_twoLayout.txt │ ├── g2_valid1.txt │ ├── g3_valid.txt │ ├── g4_endOfGroup.txt │ ├── g4_repeatingGroup.txt │ ├── g4_tooManyGroups.txt │ ├── g5_subgroups.txt │ ├── g6_missingRecordEOF.txt │ ├── g7_missingGroupEOF.txt │ ├── g8_repeatingStream.txt │ └── group.xml ├── ignoreUnidentifiedRecords │ ├── IgnoreUnidentifiedRecordsParserTest.java │ ├── ignoreUnidentifiedRecords1.txt │ └── ignore_mapping.xml ├── imports │ ├── ImportParserTest.java │ ├── circular_mapping1.xml │ ├── circular_mapping2.xml │ ├── circular_mapping3.xml │ ├── import_mapping1.xml │ ├── import_mapping2.xml │ └── import_mapping3.xml ├── indeterminates │ ├── IndeterminateSegmentsTest.java │ └── indeterminates_mapping.xml ├── inlinemaps │ ├── InlineMapParserTest.java │ ├── InlineMapsTest.groovy │ ├── Job.java │ └── map_mapping.xml ├── json │ ├── JsonTestRecordParserFactory.java │ ├── field │ │ ├── JsonFieldParserTest.java │ │ ├── jf1.txt │ │ └── jsonField_mapping.xml │ └── segment │ │ ├── JsonSegmentParserTest.java │ │ ├── js1.txt │ │ ├── js2.txt │ │ ├── js3.txt │ │ ├── js4.txt │ │ ├── jsonSegment_mapping.xml │ │ └── notes.txt ├── lazy │ ├── Account.java │ ├── LazyMapTest.groovy │ ├── LazyTest.java │ ├── LazyUser.java │ ├── Transaction.java │ └── lazy_mapping.xml ├── lenientPadding │ └── LenientPaddingTest.groovy ├── misc │ ├── MiscParserTest.java │ ├── m1.txt │ └── misc_mapping.xml ├── multiline │ ├── MultilineRecordTest.java │ ├── ml1.txt │ ├── ml2.txt │ ├── ml3.txt │ ├── ml4.txt │ ├── ml5.txt │ ├── ml6.txt │ ├── ml7.txt │ └── multiline_mapping.xml ├── ordinal │ └── OrdinalTest.groovy ├── property │ ├── PropertyParserTest.java │ ├── User.java │ ├── p1.txt │ └── property_mapping.xml ├── ridlength │ ├── RidLengthTest.java │ ├── r1.txt │ └── ridlength_mapping.xml ├── skip │ ├── SkippingParserTest.java │ ├── s1.txt │ └── skip_mapping.xml ├── strict │ ├── StrictTest.java │ ├── s1_invalidRecordLength.txt │ ├── s1_invalidSequence.txt │ └── strict_mapping.xml ├── substitution │ ├── PropertySubstitutionParserTest.java │ └── substitution_mapping.xml ├── target │ ├── TargetTest.java │ ├── targetAndClass.xml │ ├── targetIsNotProperty.xml │ ├── targetNotFound.xml │ ├── targetRepeating.xml │ └── target_mapping.xml ├── template │ ├── TemplateParserTest.java │ ├── t1.txt │ ├── t3.txt │ └── template_mapping.xml ├── trim │ ├── TrimTest.java │ └── trim_mapping.xml ├── types │ ├── ObjectRecord.java │ ├── PrimitiveRecord.java │ ├── TypeEnum.java │ ├── TypeHandlerLocaleTest.groovy │ ├── TypesParserTest.java │ ├── t1_valid.txt │ ├── t2_valid.txt │ ├── t3_valid.txt │ ├── t4_valid.txt │ ├── t5_valid.txt │ ├── t7_valid.txt │ ├── t8_valid.txt │ └── types.xml ├── validation │ ├── FieldValidationTest.java │ ├── MarshalledFieldValidationTest.groovy │ ├── v1.txt │ ├── v1_messages.properties │ └── validation.xml ├── writemode │ ├── PersonInterface.java │ ├── WriteModeParserTest.java │ └── writemode_mapping.xml └── xml │ ├── Address.java │ ├── Male.java │ ├── Person.java │ ├── TestXmlWriterFactory.java │ ├── XmlParserTest.java │ ├── bean │ ├── XmlBeansTest.java │ ├── b1_in.xml │ ├── b1_out.xml │ ├── b2_in.xml │ ├── b2_out.xml │ ├── b3_in.xml │ ├── b4_in.xml │ ├── b5_in.xml │ ├── b5_out.xml │ └── beans_mapping.xml │ ├── collection │ ├── XmlCollectionTest.java │ ├── c1_in.xml │ └── collection_mapping.xml │ ├── field │ ├── XmlFieldTest.java │ ├── f1_in.xml │ ├── f2_in.xml │ ├── f2_out.xml │ ├── f3_in.xml │ └── field_mapping.xml │ ├── groups │ ├── XmlGroupsTest.java │ ├── g1_in.xml │ ├── g2_in.xml │ ├── g3_in.xml │ └── groups_mapping.xml │ ├── marshaller │ ├── XmlMarshallerTest.java │ └── marshaller_mapping.xml │ ├── multiline │ ├── XmlMultilineRecordTest.java │ ├── ml1_in.xml │ ├── ml1_out.xml │ └── xml_multiline_mapping.xml │ ├── namespace │ ├── XmlNamespaceTest.java │ ├── namespace_mapping.xml │ ├── ns10_out.xml │ ├── ns11_out.xml │ ├── ns12_out.xml │ ├── ns13_out.xml │ ├── ns1_in.xml │ ├── ns1_out.xml │ ├── ns2_out.xml │ ├── ns3_out.xml │ ├── ns4_out.xml │ ├── ns5_out.xml │ ├── ns6_out.xml │ ├── ns7_out.xml │ ├── ns8_out.xml │ ├── ns9_out.xml │ ├── ns_noMatchingField.xml │ ├── ns_noMatchingGroup.xml │ ├── ns_noMatchingRecord.xml │ └── ns_noMatchingStream.xml │ ├── record │ ├── XmlRecordTest.java │ ├── r1_in.xml │ └── record_mapping.xml │ ├── typehandler │ ├── XmlTypeHandlerTest.java │ ├── th1_in.xml │ └── typehandler_mapping.xml │ ├── types │ ├── NillableStringTypeHandler.java │ ├── XmlTypesTest.java │ ├── t1_in.xml │ ├── t1_out.xml │ ├── t2_in.xml │ ├── t2_out.xml │ ├── t3_in.xml │ ├── t3_out.xml │ ├── t5_in.xml │ ├── t6_in.xml │ ├── t7_out.xml │ └── types_mapping.xml │ ├── validation │ ├── XmlValidationTest.java │ ├── v1_in.xml │ ├── v2_in.xml │ └── validation_mapping.xml │ └── wrapper │ ├── XmlWrapperTest.java │ ├── w1_in.xml │ ├── w2_in.xml │ ├── w3_in.xml │ └── wrapper_mapping.xml ├── stream ├── CsvReaderTest.java ├── CsvRecordParserTest.java ├── CsvWriterTest.java ├── DelimitedReaderTest.java ├── DelimitedRecordParserTest.java ├── DelimitedWriterTest.java ├── FixedLengthReaderTest.java ├── FixedLengthWriterTest.java ├── JsonReaderTest.java ├── JsonWriterTest.java └── StrictStringReader.java ├── types ├── CalendarTypeHandlerTest.groovy ├── CharacterTypeHandlerTest.java ├── DateTypeHandlerTest.java ├── NumberTypeHandlerTest.java ├── StringTypeHandlerTest.java ├── TypeHandlerFactoryTest.java ├── XmlBooleanTypeHandlerTest.java ├── XmlCalendarDateTimeTypeHandlerTest.java ├── XmlCalendarDateTypeHandlerTest.java ├── XmlCalendarTimeTypeHandlerTest.java ├── XmlDateTimeTypeHandlerTest.java ├── XmlDateTypeHandlerTest.java └── XmlTimeTypeHandlerTest.java └── util ├── IOUtilTest.java ├── StringUtilTest.java └── TypeUtilTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .classpath 3 | .settings 4 | .project 5 | .gradle 6 | 7 | # Mobile Tools for Java (J2ME) 8 | .mtj.tmp/ 9 | 10 | # Package Files # 11 | *.jar 12 | *.war 13 | *.ear 14 | 15 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 16 | hs_err_pid* 17 | /build/ 18 | /classes/ 19 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2010-2014 Kevin Seim 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | BeanIO 2 | ====== 3 | 4 | A Java library for marshalling and unmarshalling bean objects from XML, CSV, delimited and fixed length stream formats. 5 | 6 | For more information, including an online reference guide, please visit http://www.beanio.org. 7 | 8 | #### Note 9 | This repository houses the source code for the future BeanIO 3.x. For older versions, please see https://code.google.com/p/beanio/. 10 | 11 | -------------------------------------------------------------------------------- /docs/reference/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | width: 900px; 3 | margin: 0 auto 0 auto; 4 | font-family: verdana, arial, sans-serif; 5 | font-size: 85%; 6 | } 7 | 8 | .wrapping li { margin-top: 6px } 9 | tt { font-size: 10pt; } 10 | pre { font-size: 9pt; } 11 | .toc { margin-left: 3%; } 12 | .indent { margin-left: 5%;} 13 | .red { color: red; } 14 | 15 | .title { 16 | font-size: 180%; 17 | font-weight: bold; 18 | margin-top: 20px; 19 | } 20 | 21 | h1 { 22 | font-size: 155%; 23 | margin-top: 1em; 24 | } 25 | h2 { 26 | font-size: 130%; 27 | font-weight: bold; 28 | } 29 | h3 { 30 | font-size: 115%; 31 | font-style: italic; 32 | } 33 | h4 { 34 | margin-bottom: 0; 35 | } 36 | 37 | .file { 38 | background: #F5F5F5; 39 | border: 1px solid black; 40 | margin-left: 5%; 41 | margin-right: 5%; 42 | padding: 3px 8px 3px 8px; 43 | } 44 | 45 | .java { 46 | background: #F5F5F5; 47 | border: 1px solid black; 48 | margin-left: 5%; 49 | margin-right: 5%; 50 | padding: 3px 8px 3px 8px; 51 | } 52 | .comment { 53 | color: green; 54 | } 55 | 56 | pre b, .highlight { 57 | color: #000088; 58 | font-weight: bold; 59 | } 60 | 61 | .typeTable { 62 | margin-left: 5%; 63 | } 64 | 65 | table { border-collapse: collapse; } 66 | 67 | td, th { 68 | vertical-align: top; 69 | padding-right: 20px; 70 | padding-left: 5px; 71 | border: 1px solid gray; 72 | } 73 | -------------------------------------------------------------------------------- /site/2011/01/.htaccess: -------------------------------------------------------------------------------- 1 | DirectoryIndex mapping.xsd -------------------------------------------------------------------------------- /site/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinseim/beanio/c31768943b963a8c48ed13f66498e331fdb0f2bc/site/favicon.ico -------------------------------------------------------------------------------- /site/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinseim/beanio/c31768943b963a8c48ed13f66498e331fdb0f2bc/site/images/logo.png -------------------------------------------------------------------------------- /src/org/beanio/BeanIOException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio; 17 | 18 | /** 19 | * Base class for all exceptions thrown by the BeanIO framework. 20 | * 21 | * @author Kevin Seim 22 | * @since 1.0 23 | */ 24 | public class BeanIOException extends RuntimeException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructs a new BeanIOException. 30 | * @param message the error message 31 | * @param cause the root cause 32 | */ 33 | public BeanIOException(String message, Throwable cause) { 34 | super(message, cause); 35 | } 36 | 37 | /** 38 | * Constructs a new BeanIOException. 39 | * @param message the error message 40 | */ 41 | public BeanIOException(String message) { 42 | super(message); 43 | } 44 | 45 | /** 46 | * Constructs a new BeanIOException. 47 | * @param cause the root cause 48 | */ 49 | public BeanIOException(Throwable cause) { 50 | super(cause); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/org/beanio/BeanReaderErrorHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio; 17 | 18 | /** 19 | * A callback interface for handling exceptions thrown by a {@link BeanReader}. When set on a BeanReader, 20 | * the BeanReader will delegate all exception handling to this class. When an error handler 21 | * is not set on a reader, the BeanReader's read() will simply throw the exception. 22 | * 23 | * @author Kevin Seim 24 | * @since 1.0 25 | * @see BeanReader 26 | */ 27 | public interface BeanReaderErrorHandler { 28 | 29 | /** 30 | * Callback method for handling a {@link BeanReaderException} when using 31 | * a {@link BeanReader}. 32 | * @param ex the {@link BeanReaderException} to handle 33 | * @throws Exception if the BeanReaderException is rethrown or the error 34 | * handler throws a new Exception 35 | */ 36 | public void handleError(BeanReaderException ex) throws Exception; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/org/beanio/BeanReaderIOException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * Exception thrown when a {@link BeanReader}'s underlying 22 | * input stream throws an {@link IOException}. 23 | * 24 | * @author Kevin Seim 25 | * @since 1.0 26 | */ 27 | public class BeanReaderIOException extends BeanReaderException { 28 | 29 | private static final long serialVersionUID = 2L; 30 | 31 | /** 32 | * Constructs a new BeanReaderIOException. 33 | * @param message the error message 34 | */ 35 | public BeanReaderIOException(String message) { 36 | this(message, null); 37 | } 38 | 39 | /** 40 | * Constructs a new BeanReaderIOException. 41 | * @param message the error message 42 | * @param cause the root cause 43 | */ 44 | public BeanReaderIOException(String message, IOException cause) { 45 | super(message, cause); 46 | } 47 | 48 | @Override 49 | public IOException getCause() { 50 | return (IOException) super.getCause(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/org/beanio/InvalidBeanException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio; 17 | 18 | /** 19 | * Exception thrown by a {@link BeanWriter} or {@link Marshaller}, when a bean 20 | * cannot be marshalled to meet the configured field validation rules. 21 | * @author Kevin Seim 22 | */ 23 | public class InvalidBeanException extends BeanWriterException { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | /** 28 | * Constructs a new InvalidBeanException. 29 | * @param message the error message 30 | */ 31 | public InvalidBeanException(String message) { 32 | super(message); 33 | } 34 | 35 | /** 36 | * Constructs a new InvalidBeanException. 37 | * @param message the error message 38 | * @param cause the root cause 39 | */ 40 | public InvalidBeanException(String message, Throwable cause) { 41 | super(message, cause); 42 | } 43 | 44 | /** 45 | * Constructs a new InvalidBeanException. 46 | * @param cause the root cause 47 | */ 48 | public InvalidBeanException(Throwable cause) { 49 | super(cause); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/org/beanio/UnexpectedRecordException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio; 17 | 18 | /** 19 | * Exception thrown when the record type of last record read by a {@link BeanReader} 20 | * is out of order based on the expected order defined by the stream's mapping file. 21 | * After this exception is thrown, further reads from the stream will likely result in 22 | * further exceptions. 23 | * 24 | * @author Kevin Seim 25 | * @since 1.0 26 | */ 27 | public class UnexpectedRecordException extends BeanReaderException { 28 | 29 | private static final long serialVersionUID = 2L; 30 | 31 | /** 32 | * Constructs a new UnexpectedRecordException. 33 | * @param context the current context of the bean reader 34 | * @param message the error message 35 | */ 36 | public UnexpectedRecordException(RecordContext context, String message) { 37 | super(message); 38 | setRecordContext(context); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/org/beanio/UnidentifiedRecordException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio; 17 | 18 | /** 19 | * Exception thrown when the record type of the last record read from a {@link BeanReader} 20 | * could not be determined. If the mapping file is used to enforce strict record ordering, 21 | * further reads from the stream will likely cause further exceptions. 22 | * 23 | * @author Kevin Seim 24 | * @since 1.0 25 | */ 26 | public class UnidentifiedRecordException extends BeanReaderException { 27 | 28 | private static final long serialVersionUID = 2L; 29 | 30 | /** 31 | * Constructs a new UnidentifiedRecordException. 32 | * @param context the current context of the bean reader 33 | * @param message the error message 34 | */ 35 | public UnidentifiedRecordException(RecordContext context, String message) { 36 | super(message); 37 | setRecordContext(context); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/org/beanio/annotation/AnnotationConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.annotation; 17 | 18 | /** 19 | * Constant annotation values. 20 | * 21 | * @author Kevin Seim 22 | * @since 2.1.0 23 | */ 24 | public interface AnnotationConstants { 25 | 26 | /** The default value for undefined XML related annotation properties */ 27 | public static final String UNDEFINED = "{undefined}"; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/beanio/annotation/Fields.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.annotation; 17 | 18 | import java.lang.annotation.*; 19 | 20 | /** 21 | * Annotation used to add fields to a record or segment that are not bound 22 | * to a class property. 23 | * 24 | * @author Kevin Seim 25 | * @since 2.1.0 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) 29 | public @interface Fields { 30 | 31 | /** 32 | * The list of fields. 33 | * @return the list of fields 34 | */ 35 | Field[] value(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/org/beanio/annotation/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Stream builder annotations. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/builder/Align.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.builder; 17 | 18 | /** 19 | * Enumeration of text alignments in a padded field. 20 | * @author Kevin Seim 21 | * @since 2.1.0 22 | */ 23 | public enum Align { 24 | 25 | /** Text is aligned to the left */ 26 | LEFT, 27 | 28 | /** Text is aligned to the right */ 29 | RIGHT; 30 | 31 | @Override 32 | public String toString() { 33 | return name().toLowerCase(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/org/beanio/builder/ParserBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.builder; 17 | 18 | import org.beanio.internal.config.BeanConfig; 19 | import org.beanio.stream.RecordParserFactory; 20 | 21 | /** 22 | * @author Kevin Seim 23 | * @since 2.1.0 24 | */ 25 | public abstract class ParserBuilder { 26 | 27 | ParserBuilder() { } 28 | 29 | public abstract BeanConfig build(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/org/beanio/builder/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Stream builder API. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/PropertyAccessorFactory.java: -------------------------------------------------------------------------------- 1 | package org.beanio.internal.compiler; 2 | 3 | import java.beans.PropertyDescriptor; 4 | import java.lang.reflect.Field; 5 | 6 | import org.beanio.internal.parser.PropertyAccessor; 7 | 8 | /** 9 | * Factory interface for creating {@link PropertyAccessor} 10 | * implementations. 11 | * 12 | * @author Kevin Seim 13 | * @since 2.0.1 14 | */ 15 | public interface PropertyAccessorFactory { 16 | 17 | /** 18 | * Creates a new {@link PropertyAccessor}. 19 | * @param parent the parent bean object type 20 | * @param descriptor the {@link PropertyDescriptor} to access 21 | * @param carg the constructor argument index 22 | * @return the new {@link PropertyAccessor} 23 | */ 24 | public PropertyAccessor getPropertyAccessor( 25 | Class parent, PropertyDescriptor descriptor, int carg); 26 | 27 | /** 28 | * Creates a new {@link PropertyAccessor}. 29 | * @param parent the parent bean object type 30 | * @param field the {@link Field} to access 31 | * @param carg the constructor argument index 32 | * @return the new {@link PropertyAccessor} 33 | */ 34 | public PropertyAccessor getPropertyAccessor( 35 | Class parent, Field field, int carg); 36 | } 37 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/accessor/ReflectionAccessorFactory.java: -------------------------------------------------------------------------------- 1 | package org.beanio.internal.compiler.accessor; 2 | 3 | import java.beans.PropertyDescriptor; 4 | import java.lang.reflect.Field; 5 | 6 | import org.beanio.internal.compiler.PropertyAccessorFactory; 7 | import org.beanio.internal.parser.PropertyAccessor; 8 | import org.beanio.internal.parser.accessor.*; 9 | 10 | /** 11 | * {@link PropertyAccessorFactory} implementations based on Java reflection. 12 | * 13 | * @author Kevin Seim 14 | * @since 2.0.1 15 | */ 16 | public class ReflectionAccessorFactory implements PropertyAccessorFactory { 17 | 18 | /* 19 | * (non-Javadoc) 20 | * @see org.beanio.internal.compiler.PropertyAccessorFactory#getPropertyAccessor(java.lang.Class, java.beans.PropertyDescriptor, int) 21 | */ 22 | public PropertyAccessor getPropertyAccessor( 23 | Class parent, PropertyDescriptor descriptor, int carg) { 24 | 25 | MethodReflectionAccessor a = new MethodReflectionAccessor(descriptor, carg); 26 | a.setConstructorArgumentIndex(carg); 27 | return a; 28 | } 29 | 30 | /* 31 | * (non-Javadoc) 32 | * @see org.beanio.internal.compiler.PropertyAccessorFactory#getPropertyAccessor(java.lang.Class, java.lang.reflect.Field, int) 33 | */ 34 | public PropertyAccessor getPropertyAccessor( 35 | Class parent, Field field, int carg) { 36 | 37 | FieldReflectionAccessor a = new FieldReflectionAccessor(field, carg); 38 | a.setConstructorArgumentIndex(carg); 39 | return a; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/csv/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | ParserFactory implementation for the CSV stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/delimited/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | ParserFactory implementation for the delimited stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/fixedlength/FixedLengthPreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.compiler.fixedlength; 17 | 18 | import org.beanio.internal.compiler.Preprocessor; 19 | import org.beanio.internal.compiler.flat.FlatPreprocessor; 20 | import org.beanio.internal.config.*; 21 | 22 | /** 23 | * Configuration {@link Preprocessor} for a fixed length stream format. 24 | * 25 | * @author Kevin Seim 26 | * @since 2.0 27 | */ 28 | public class FixedLengthPreprocessor extends FlatPreprocessor { 29 | 30 | /** 31 | * Constructs a new FixedLengthPreprocessor. 32 | * @param stream the stream configuration to pre-process 33 | */ 34 | public FixedLengthPreprocessor(StreamConfig stream) { 35 | super(stream); 36 | } 37 | 38 | @Override 39 | protected int getSize(FieldConfig field) { 40 | return field.getLength(); 41 | } 42 | 43 | @Override 44 | protected boolean isFixedLength() { 45 | return true; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/fixedlength/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | ParserFactory implementation for the fixed length stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/flat/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Base ParserFactory implementation for flat stream formats (CSV, delimited and fixed length). 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/json/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | ParserFactory implementation for the JSON stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Classes to "compile" a stream configuration into a Stream parser. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/compiler/xml/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | ParserFactory implementation for the XML stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/config/ConfigurationLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.config; 17 | 18 | import java.io.*; 19 | import java.util.*; 20 | 21 | import org.beanio.BeanIOConfigurationException; 22 | 23 | /** 24 | * A ConfigurationLoader is used to load BeanIO mapping configurations from 25 | * an input stream. 26 | * 27 | *

Implementations must be thread safe.

28 | * 29 | * @author Kevin Seim 30 | * @since 1.0 31 | */ 32 | public interface ConfigurationLoader { 33 | 34 | /** 35 | * Loads a BeanIO configuration from an input stream. 36 | * @param in the input stream to read the configuration from 37 | * @param properties the {@link Properties} for expansion in the mapping file 38 | * @return a collection of loaded BeanIO configurations 39 | * @throws IOException if an I/O error occurs 40 | * @throws BeanIOConfigurationException if the configuration is invalid or malformed 41 | * @since 1.2.1 42 | */ 43 | public Collection loadConfiguration(InputStream in, Properties properties) 44 | throws IOException, BeanIOConfigurationException; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/org/beanio/internal/config/XmlTypeConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.config; 17 | 18 | /** 19 | * XML node type constants. 20 | * 21 | * @author Kevin Seim 22 | * @since 1.1 23 | */ 24 | public interface XmlTypeConstants { 25 | 26 | /** The XML node type to indicate the node is not a structural part of the document */ 27 | public static final String XML_TYPE_NONE = "none"; 28 | /** The XML node type for an element */ 29 | public static final String XML_TYPE_ELEMENT = "element"; 30 | /** The XML node type for an attribute */ 31 | public static final String XML_TYPE_ATTRIBUTE = "attribute"; 32 | /** The XML node type for elemental text */ 33 | public static final String XML_TYPE_TEXT = "text"; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/org/beanio/internal/config/annotation/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Annotation based mapping loader. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/config/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mapping file configuration counterparts. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/config/xml/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | XML based mapping loader. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Internal BeanIO implementation classes. Class level API's are subject to change in any release 4 | without support for backwards compatibility. 5 | 6 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/AbortRecordUnmarshalligException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.parser; 17 | 18 | /** 19 | * This exception may be thrown by {@link Parser#unmarshal(UnmarshallingContext)} to 20 | * abort record unmarshalling after a critical validation error has occurred. 21 | * @author Kevin Seim 22 | * @since 2.1.0 23 | */ 24 | @SuppressWarnings("serial") 25 | public class AbortRecordUnmarshalligException extends RuntimeException { 26 | 27 | /** 28 | * Constructs a new AbortRecordUnmarshalligException. 29 | */ 30 | public AbortRecordUnmarshalligException() { } 31 | 32 | /** 33 | * Constructs a new AbortRecordUnmarshalligException. 34 | * @param message the error message (for debugging purposes only) 35 | */ 36 | public AbortRecordUnmarshalligException(String message) { 37 | super(message); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/Iteration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2013 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.parser; 17 | 18 | /** 19 | * Repeating components must implement Iteration to offset record positions 20 | * during marshalling and unmarshalling. 21 | * 22 | * @author Kevin Seim 23 | * @since 2.0 24 | */ 25 | public interface Iteration { 26 | 27 | /** 28 | * Returns the index of the current iteration relative to its parent. 29 | * @return the index of the current iteration 30 | */ 31 | public int getIterationIndex(ParsingContext context); 32 | 33 | /** 34 | * Returns the size of the components that make up a single iteration. 35 | * @return the iteration size 36 | */ 37 | public int getIterationSize(); 38 | 39 | /** 40 | * Returns whether the iteration size is variable based on another field 41 | * in the record. 42 | * @return true if variable, false otherwise 43 | */ 44 | public boolean isDynamicIteration(); 45 | } 46 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/ObjectUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.parser; 17 | 18 | import org.beanio.BeanIOException; 19 | 20 | /** 21 | * Utility class for instantiating objects. 22 | * @author Kevin 23 | * @since 2.0.3 24 | */ 25 | class ObjectUtils { 26 | 27 | public static T newInstance(Class type) { 28 | if (type == null) { 29 | return null; 30 | } 31 | 32 | try { 33 | return type.newInstance(); 34 | } 35 | catch (Exception ex) { 36 | throw new BeanIOException("Failed to instantiate class '" + type.getName() + "'"); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/ParserComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.parser; 17 | 18 | /** 19 | * Base class for all parser components in that implement {@link Parser}. 20 | * 21 | *

The method {@link #isSupportedChild(Component)} is overridden to restrict 22 | * children to components that also implement {@link Parser}. 23 | * 24 | * @author Kevin Seim 25 | * @since 2.0 26 | * @see Parser 27 | */ 28 | public abstract class ParserComponent extends Component implements Parser { 29 | 30 | /** 31 | * Constructs a new ParserComponent. 32 | */ 33 | public ParserComponent() { 34 | super(); 35 | } 36 | 37 | /** 38 | * Constructs a new ParserComponent. 39 | * @param size the initial child capacity 40 | */ 41 | public ParserComponent(int size) { 42 | super(size); 43 | } 44 | 45 | @Override 46 | protected boolean isSupportedChild(Component child) { 47 | return child instanceof Parser; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/RecordFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.parser; 17 | 18 | /** 19 | * A RecordFormat provides format specific processing for a {@link Record} parser. 20 | * 21 | *

Implementations of this interface must be thread-safe. 22 | * 23 | * @author Kevin Seim 24 | * @since 2.0 25 | */ 26 | public interface RecordFormat { 27 | 28 | /** 29 | * Returns whether the record meets configured matching criteria 30 | * during unmarshalling. 31 | * @param context the {@link UnmarshallingContext} 32 | * @return true if the record meets all matching criteria, false otherwise 33 | * @since 2.0.3 34 | */ 35 | public boolean matches(UnmarshallingContext context); 36 | 37 | /** 38 | * Validates a record during unmarshalling. 39 | * @param context the {@link UnmarshallingContext} to validate 40 | */ 41 | public void validate(UnmarshallingContext context); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/Value.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.parser; 17 | 18 | /** 19 | * Stores special property values. 20 | * @author Kevin Seim 21 | * @since 2.0 22 | */ 23 | public interface Value { 24 | 25 | /** Constant indicating the field did not pass validation. */ 26 | public static final String INVALID = new String("-invalid-"); 27 | 28 | /** Constant indicating the field was not present in the stream */ 29 | public static final String MISSING = new String("-missing-"); 30 | 31 | /** Constant indicating the field was nil (XML only) */ 32 | public static final String NIL = new String("-nil-"); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/accessor/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PropertyAccessor implementation classes. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/csv/CsvStreamFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.parser.format.csv; 17 | 18 | import org.beanio.internal.parser.StreamFormatSupport; 19 | import org.beanio.internal.parser.format.delimited.DelimitedStreamFormat; 20 | 21 | /** 22 | * A {@link StreamFormatSupport} implementation for the CSV format. 23 | * 24 | * @author Kevin Seim 25 | * @since 2.0 26 | */ 27 | public class CsvStreamFormat extends DelimitedStreamFormat { 28 | 29 | /** 30 | * Constructs a new CsvStreamFormat. 31 | */ 32 | public CsvStreamFormat() { } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/csv/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Parser implementation for the CSV stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/delimited/DelimitedFieldFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2013 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.parser.format.delimited; 17 | 18 | import org.beanio.internal.parser.*; 19 | import org.beanio.internal.parser.format.flat.FlatFieldFormatSupport; 20 | 21 | /** 22 | * A {@link FieldFormat} implementation for a field in a delimited stream. 23 | * 24 | * @author Kevin Seim 25 | * @since 2.0 26 | */ 27 | public class DelimitedFieldFormat extends FlatFieldFormatSupport implements FieldFormat { 28 | 29 | /** 30 | * Constructs a new DelimitedFieldFormat. 31 | */ 32 | public DelimitedFieldFormat() { } 33 | 34 | @Override 35 | public void insertFieldText(MarshallingContext context, String fieldText, boolean commit) { 36 | ((DelimitedMarshallingContext)context).setField(getPosition(), fieldText, commit); 37 | } 38 | 39 | @Override 40 | public String extractFieldText(UnmarshallingContext context, boolean reporting) { 41 | return ((DelimitedUnmarshallingContext)context).getFieldText(getName(), getPosition(), getUntil()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/delimited/DelimitedStreamFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.parser.format.delimited; 17 | 18 | import org.beanio.internal.parser.*; 19 | 20 | /** 21 | * A {@link StreamFormatSupport} implementation for the delimited stream format. 22 | * 23 | * @author Kevin Seim 24 | * @since 2.0 25 | */ 26 | public class DelimitedStreamFormat extends StreamFormatSupport { 27 | 28 | /* 29 | * (non-Javadoc) 30 | * @see org.beanio.internal.parser.StreamFormat#createUnmarshallingContext() 31 | */ 32 | public UnmarshallingContext createUnmarshallingContext() { 33 | return new DelimitedUnmarshallingContext(); 34 | } 35 | 36 | /* 37 | * (non-Javadoc) 38 | * @see org.beanio.internal.parser.StreamFormat#createMarshallingContext() 39 | */ 40 | public MarshallingContext createMarshallingContext(boolean streaming) { 41 | return new DelimitedMarshallingContext(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/delimited/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Parser implementation for the delimited stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/fixedlength/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Parser implementation for the fixed length stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/flat/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Base parser implementation for flat stream formats (CSV, delimited and fixed length). 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/json/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Parser implementation for the JSON stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Format specific parser implementation classes. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/format/xml/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Parser implementation for the XML stream format. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/message/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MessageFactory implementation classes. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/parser/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BeanReader and BeanWriter implementation classes. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/internal/util/DebugUtil.java: -------------------------------------------------------------------------------- 1 | package org.beanio.internal.util; 2 | 3 | import java.io.*; 4 | 5 | import org.beanio.internal.parser.format.FieldPadding; 6 | 7 | /** 8 | * Utility methods for formatting debug output. 9 | * @author Kevin Seim 10 | * @since 2.1.0 11 | */ 12 | public class DebugUtil { 13 | 14 | private DebugUtil() { } 15 | 16 | public static String formatRange(int min, int max) { 17 | if (max == Integer.MAX_VALUE) { 18 | return min + "+"; 19 | } 20 | else { 21 | return min + "-" + max; 22 | } 23 | } 24 | 25 | public static String formatOption(String option, boolean value) { 26 | if (value) { 27 | return option; 28 | } 29 | else { 30 | return "!" + option; 31 | } 32 | } 33 | 34 | public static String formatPadding(FieldPadding padding) { 35 | if (padding == null) { 36 | return ""; 37 | } 38 | else { 39 | return ", padded[" + 40 | "length=" + padding.getLength() + 41 | ", filler=" + padding.getFiller() + 42 | ", align=" + padding.getJustify() + 43 | "]"; 44 | } 45 | } 46 | 47 | public static String toString(Debuggable c) { 48 | try { 49 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 50 | c.debug(new PrintStream(out)); 51 | return new String(out.toByteArray(), "ASCII"); 52 | } 53 | catch (UnsupportedEncodingException e) { 54 | throw new IllegalStateException(e); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/org/beanio/internal/util/Debuggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.util; 17 | 18 | import java.io.PrintStream; 19 | 20 | /** 21 | * Interface implemented by marshallers and unmarshallers for debugging 22 | * BeanIO's compiled configuration. The information displayed by these 23 | * methods may be changed without notice. 24 | * @author Kevin Seim 25 | * @since 2.1.0 26 | */ 27 | public interface Debuggable { 28 | 29 | /** 30 | * Prints the internal view of the stream configuration 31 | * to {@link System#out} 32 | */ 33 | public void debug(); 34 | 35 | /** 36 | * Prints the internal view of the stream configuration. 37 | * @param out the {@link PrintStream} to write to 38 | */ 39 | public void debug(PrintStream out); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/org/beanio/internal/util/EnumTypeHandler.java: -------------------------------------------------------------------------------- 1 | package org.beanio.internal.util; 2 | 3 | import org.beanio.types.*; 4 | 5 | /** 6 | * Default {@link Enum} type handler that uses {@link Enum#valueOf(Class, String)} 7 | * to parse a value and {@link Enum#name()} to format a value. 8 | * 9 | * @author Kevin Seim 10 | * @since 2.0.1 11 | */ 12 | @SuppressWarnings({"unchecked", "rawtypes"}) 13 | public class EnumTypeHandler implements TypeHandler { 14 | 15 | private Class type; 16 | 17 | /** 18 | * Constructs a new EnumTypeHandler. 19 | * @param type the Enum class 20 | */ 21 | public EnumTypeHandler(Class type) { 22 | this.type = type; 23 | } 24 | 25 | /* 26 | * (non-Javadoc) 27 | * @see org.beanio.types.TypeHandler#parse(java.lang.String) 28 | */ 29 | public Object parse(String text) throws TypeConversionException { 30 | if (text == null || "".equals(text)) { 31 | return null; 32 | } 33 | try { 34 | return Enum.valueOf(type, text); 35 | } 36 | catch (IllegalArgumentException ex) { 37 | throw new TypeConversionException("Invalid " + getType().getSimpleName() + 38 | " enum value '" + text + "'", ex); 39 | } 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * @see org.beanio.types.TypeHandler#format(java.lang.Object) 45 | */ 46 | public String format(Object value) { 47 | if (value == null) { 48 | return null; 49 | } 50 | return ((Enum)value).name(); 51 | } 52 | 53 | /* 54 | * (non-Javadoc) 55 | * @see org.beanio.types.TypeHandler#getType() 56 | */ 57 | public Class getType() { 58 | return type; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/org/beanio/internal/util/Replicateable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.internal.util; 17 | 18 | import java.util.Map; 19 | 20 | /** 21 | * Graph nodes that use a {@link Replicator} for cloning itself must implement 22 | * this interface. 23 | * 24 | * @author Kevin Seim 25 | * @since 2.0 26 | * @see Replicator 27 | */ 28 | public interface Replicateable extends Cloneable { 29 | 30 | /** 31 | * Updates a node's references to other nodes. 32 | * @param map the (identity) map of clones by prior object reference 33 | */ 34 | public void updateReferences(Map map); 35 | 36 | /** 37 | * Clones this node. 38 | * @return the clone 39 | */ 40 | public Object clone(); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/org/beanio/internal/util/StatefulWriter.java: -------------------------------------------------------------------------------- 1 | package org.beanio.internal.util; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * StatefulWriter can be implemented by writers that maintain state, so 7 | * that in case of an error, the last updated state of the writer can be restored and 8 | * writing can resume. 9 | * 10 | *

This interface is used to implement a restartable flat file item writer for 11 | * Spring Batch.

12 | * 13 | * @author Kevin Seim 14 | * @since 1.2 15 | */ 16 | public interface StatefulWriter { 17 | 18 | /** 19 | * Updates a Map with the current state of the Writer to allow for 20 | * restoration at a later time. 21 | * @param namespace a String to prefix all state keys with 22 | * @param state the Map to update with the latest state 23 | */ 24 | public void updateState(String namespace, Map state); 25 | 26 | /** 27 | * Restores a Map of previously stored state information. 28 | * @param namespace a String to prefix all state keys with 29 | * @param state the Map containing the state to restore 30 | * @throws IllegalStateException if the Map is missing any state information 31 | */ 32 | public void restoreState(String namespace, Map state) throws IllegalStateException; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/beanio/internal/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Internal utility classes. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Core BeanIO API. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/stream/RecordMarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.stream; 17 | 18 | /** 19 | * Interface for marshalling a single record object. 20 | * 21 | *

The class used to represent a record is specific to the 22 | * format of a record. For example, a delimited record marshaller may use 23 | * Stringp[].

24 | * 25 | * @author Kevin Seim 26 | * @since 2.0 27 | */ 28 | public interface RecordMarshaller { 29 | 30 | /** 31 | * Marshals a single record object to a String. 32 | * @param record the record object to marshal 33 | * @return the marshalled record text 34 | */ 35 | public String marshal(Object record); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/org/beanio/stream/RecordUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.stream; 17 | 18 | /** 19 | * Interface for unmarshalling a single record. 20 | * 21 | *

The class used to represent a record is specific to the 22 | * format of a record. For example, a delimited record marshaller may use 23 | * Stringp[]. 24 | * 25 | * @author Kevin Seim 26 | * @since 2.0 27 | */ 28 | public interface RecordUnmarshaller { 29 | 30 | /** 31 | * Unmarshals a single record. 32 | * @param text the record text to unmarshal 33 | * @return the unmarshalled record object 34 | * @throws RecordIOException if the record is malformed and cannot be parsed 35 | */ 36 | public Object unmarshal(String text) throws RecordIOException; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/org/beanio/stream/csv/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CSV record parser implementation. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/stream/delimited/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Delimited record parser implementation. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/stream/fixedlength/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Fixed length record parser implementation. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/stream/json/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | JSON record parser implementation. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/stream/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Record parsing API. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/stream/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Utility classes for record reader and writer implementations. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/stream/xml/XmlStreamConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.stream.xml; 17 | 18 | import org.w3c.dom.Document; 19 | 20 | /** 21 | * This interface provides access to the XMl stream definition for XML 22 | * RecordReaderFactory classes that implement XmlStreamConfigurationAware. 23 | * 24 | * @author Kevin Seim 25 | * @since 1.1 26 | * @see XmlStreamConfigurationAware 27 | */ 28 | public interface XmlStreamConfiguration { 29 | 30 | /** 31 | * Returns the base document object model that defines the group structure 32 | * of the XML read from an input stream. The returned DOM object 33 | * should only be used to parse a single stream. 34 | * @return the base document object model 35 | */ 36 | public Document getDocument(); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/org/beanio/stream/xml/XmlStreamConfigurationAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.stream.xml; 17 | 18 | /** 19 | * This callback interface can be implemented by RecordReader implementations 20 | * for XML formatted streams that wish to obtain configuration information from the 21 | * XML stream definition. 22 | * 23 | * @author Kevin Seim 24 | * @since 1.1 25 | */ 26 | public interface XmlStreamConfigurationAware { 27 | 28 | /** 29 | * This method is invoked by a XML stream definition when a RecordReader 30 | * implementation is registered. 31 | * @param configuration the XML stream configuration 32 | */ 33 | public void setConfiguration(XmlStreamConfiguration configuration); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/org/beanio/stream/xml/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | XML record parser implementation. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/types/BigDecimalTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.math.*; 19 | import java.text.DecimalFormat; 20 | 21 | /** 22 | * A type handler implementation for the BigDecimal class. If pattern 23 | * is set, a DecimalFormat is used to parse and format the value. Otherwise, 24 | * the value is parsed and formatted using the BigDecimal class. 25 | * 26 | * @author Kevin Seim 27 | * @since 1.0 28 | * @see DecimalFormat 29 | */ 30 | public class BigDecimalTypeHandler extends NumberTypeHandler { 31 | 32 | @Override 33 | protected BigDecimal createNumber(String text) throws NumberFormatException { 34 | return new BigDecimal(text); 35 | } 36 | 37 | @Override 38 | protected BigDecimal createNumber(BigDecimal bg) throws ArithmeticException { 39 | return bg; 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * @see org.beanio.types.TypeHandler#getType() 45 | */ 46 | public Class getType() { 47 | return BigDecimal.class; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/org/beanio/types/BigIntegerTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.math.*; 19 | import java.text.DecimalFormat; 20 | 21 | /** 22 | * A type handler implementation for the BigInteger class. If pattern 23 | * is set, a DecimalFormat is used to parse and format the value. Otherwise, 24 | * the value is parsed and formatted using the BigInteger class. 25 | * 26 | * @author Kevin Seim 27 | * @since 1.0 28 | * @see DecimalFormat 29 | */ 30 | public class BigIntegerTypeHandler extends NumberTypeHandler { 31 | 32 | @Override 33 | protected BigInteger createNumber(String text) throws NumberFormatException { 34 | return new BigInteger(text); 35 | } 36 | 37 | @Override 38 | protected BigInteger createNumber(BigDecimal bg) throws ArithmeticException { 39 | return bg.toBigIntegerExact(); 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * @see org.beanio.types.TypeHandler#getType() 45 | */ 46 | public Class getType() { 47 | return BigInteger.class; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/org/beanio/types/ByteTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.math.*; 19 | import java.text.DecimalFormat; 20 | 21 | /** 22 | * A type handler implementation for the Byte class. If pattern 23 | * is set, a DecimalFormat is used to parse and format the value. Otherwise, 24 | * the value is parsed and formatted using the Byte class. 25 | * 26 | * @author Kevin Seim 27 | * @since 1.0 28 | * @see DecimalFormat 29 | */ 30 | public class ByteTypeHandler extends NumberTypeHandler { 31 | 32 | @Override 33 | protected Byte createNumber(String text) throws NumberFormatException { 34 | return new Byte(text); 35 | } 36 | 37 | @Override 38 | protected Byte createNumber(BigDecimal bg) throws ArithmeticException { 39 | return bg.byteValueExact(); 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * @see org.beanio.types.TypeHandler#getType() 45 | */ 46 | public Class getType() { 47 | return Byte.class; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/org/beanio/types/ConfigurableTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.util.Properties; 19 | 20 | /** 21 | * Interface for type handlers that support field specific customization. When a type 22 | * handler is registered that implements this interface, the TypeHandlerFactory 23 | * invokes newInstance(Properties) if any type handler field properties were 24 | * set. 25 | * 26 | * @author Kevin Seim 27 | * @since 1.0 28 | */ 29 | public interface ConfigurableTypeHandler extends TypeHandler { 30 | 31 | /** The field format pattern */ 32 | public static final String FORMAT_SETTING = "format"; 33 | 34 | /** 35 | * Creates a customized instance of this type handler. 36 | * @param properties the properties for customizing the instance 37 | * @return the new TypeHandler 38 | * @throws IllegalArgumentException if a property value is invalid 39 | */ 40 | public TypeHandler newInstance(Properties properties) throws IllegalArgumentException; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/org/beanio/types/DoubleTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.math.BigDecimal; 19 | import java.text.DecimalFormat; 20 | 21 | /** 22 | * A type handler implementation for the Double class. If pattern 23 | * is set, a DecimalFormat is used to parse and format the value. Otherwise, 24 | * the value is parsed and formatted using the Double class. 25 | * 26 | * @author Kevin Seim 27 | * @since 1.0 28 | * @see DecimalFormat 29 | */ 30 | public class DoubleTypeHandler extends NumberTypeHandler { 31 | 32 | @Override 33 | protected Double createNumber(String text) throws NumberFormatException { 34 | return new Double(text); 35 | } 36 | 37 | @Override 38 | protected Double createNumber(BigDecimal bg) throws ArithmeticException { 39 | return bg.doubleValue(); 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * @see org.beanio.types.TypeHandler#getType() 45 | */ 46 | public Class getType() { 47 | return Double.class; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/org/beanio/types/FloatTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.math.BigDecimal; 19 | 20 | /** 21 | * A type handler implementation for the Float class. If pattern 22 | * is set, a DecimalFormat is used to parse and format the value. Otherwise, 23 | * the value is parsed and formatted using the Float class. 24 | * 25 | * @author Kevin Seim 26 | * @since 1.0 27 | */ 28 | public class FloatTypeHandler extends NumberTypeHandler { 29 | 30 | @Override 31 | protected Float createNumber(String text) throws NumberFormatException { 32 | return new Float(text); 33 | } 34 | 35 | @Override 36 | protected Float createNumber(BigDecimal bg) throws ArithmeticException { 37 | return bg.floatValue(); 38 | } 39 | 40 | /* 41 | * (non-Javadoc) 42 | * @see org.beanio.types.TypeHandler#getType() 43 | */ 44 | public Class getType() { 45 | return Float.class; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/beanio/types/IntegerTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.math.BigDecimal; 19 | import java.text.DecimalFormat; 20 | 21 | /** 22 | * A type handler implementation for the Integer class. If pattern 23 | * is set, a DecimalFormat is used to parse and format the value. Otherwise, 24 | * the value is parsed and formatted using the Integer class. 25 | * 26 | * @author Kevin Seim 27 | * @since 1.0 28 | * @see DecimalFormat 29 | */ 30 | public class IntegerTypeHandler extends NumberTypeHandler { 31 | 32 | @Override 33 | protected Integer createNumber(String text) throws NumberFormatException { 34 | return new Integer(text); 35 | } 36 | 37 | @Override 38 | protected Integer createNumber(BigDecimal bg) throws ArithmeticException { 39 | return bg.intValueExact(); 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * @see org.beanio.types.TypeHandler#getType() 45 | */ 46 | public Class getType() { 47 | return Integer.class; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/org/beanio/types/LocaleSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.util.Locale; 19 | 20 | import org.beanio.internal.util.LocaleUtil; 21 | 22 | /** 23 | * Base class for {@link Locale} aware type handlers. 24 | * @author Kevin Seim 25 | * @since 2.1.0 26 | */ 27 | public abstract class LocaleSupport { 28 | 29 | protected Locale locale; 30 | 31 | /** 32 | * Constructs a new LocaleSupport. 33 | */ 34 | public LocaleSupport() { 35 | locale = LocaleUtil.getDefaultLocale(); 36 | } 37 | 38 | /** 39 | * Returns the configured locale, or the default if not 40 | * explicitly configured. 41 | * @return the configured locale 42 | */ 43 | public String getLocale() { 44 | return locale.toString(); 45 | } 46 | 47 | /** 48 | * Sets the locale. 49 | * @param localeString the locale (e.g. en_US) 50 | */ 51 | public void setLocale(String localeString) { 52 | locale = LocaleUtil.parseLocale(localeString); 53 | if (locale == null) { 54 | locale = LocaleUtil.getDefaultLocale(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/org/beanio/types/LongTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.math.BigDecimal; 19 | import java.text.DecimalFormat; 20 | 21 | /** 22 | * A type handler implementation for the Long class. If pattern 23 | * is set, a DecimalFormat is used to parse and format the value. Otherwise, 24 | * the value is parsed and formatted using the Long class. 25 | * 26 | * @author Kevin Seim 27 | * @since 1.0 28 | * @see DecimalFormat 29 | */ 30 | public class LongTypeHandler extends NumberTypeHandler { 31 | 32 | @Override 33 | protected Long createNumber(String text) throws NumberFormatException { 34 | return new Long(text); 35 | } 36 | 37 | @Override 38 | protected Long createNumber(BigDecimal bg) throws ArithmeticException { 39 | return bg.longValueExact(); 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * @see org.beanio.types.TypeHandler#getType() 45 | */ 46 | public Class getType() { 47 | return Long.class; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/org/beanio/types/ShortTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import java.math.BigDecimal; 19 | import java.text.DecimalFormat; 20 | 21 | /** 22 | * A type handler implementation for the Short class. If pattern 23 | * is set, a DecimalFormat is used to parse and format the value. Otherwise, 24 | * the value is parsed and formatted using the Short class. 25 | * 26 | * @author Kevin Seim 27 | * @since 1.0 28 | * @see DecimalFormat 29 | */ 30 | public class ShortTypeHandler extends NumberTypeHandler { 31 | 32 | @Override 33 | protected Short createNumber(String text) throws NumberFormatException { 34 | return new Short(text); 35 | } 36 | 37 | @Override 38 | protected Short createNumber(BigDecimal bg) throws ArithmeticException { 39 | return bg.shortValueExact(); 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * @see org.beanio.types.TypeHandler#getType() 45 | */ 46 | public Class getType() { 47 | return Short.class; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/org/beanio/types/TypeConversionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | /** 19 | * Thrown when field text cannot be parsed into a value object. 20 | * 21 | * @author Kevin Seim 22 | * @since 1.0 23 | */ 24 | public class TypeConversionException extends Exception { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructs a new TypeConversionException. 30 | * @param message the error message 31 | * @param cause the root cause 32 | */ 33 | public TypeConversionException(String message, Throwable cause) { 34 | super(message, cause); 35 | } 36 | 37 | /** 38 | * Constructs a new TypeConversionException. 39 | * @param message the error message 40 | */ 41 | public TypeConversionException(String message) { 42 | super(message); 43 | } 44 | 45 | /** 46 | * Constructs a new TypeConversionException. 47 | * @param cause the root cause 48 | */ 49 | public TypeConversionException(Throwable cause) { 50 | super(cause); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/org/beanio/types/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Type handler API and default implementations for BeanIO supported types. 4 | 5 | -------------------------------------------------------------------------------- /src/org/beanio/types/xml/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Default type handler implementations specific to XML formatted streams. 4 | 5 | -------------------------------------------------------------------------------- /test/org/beanio/beans/Bean.groovy: -------------------------------------------------------------------------------- 1 | package org.beanio.beans 2 | 3 | /** 4 | * A common bean object used by Groovy test cases. 5 | * @author Kevin Seim 6 | */ 7 | class Bean { 8 | 9 | // simple properties 10 | String type; 11 | String text; 12 | String field1; 13 | private String field2; 14 | String field3; 15 | 16 | // collection properties 17 | Map map; 18 | List list; 19 | 20 | // bean properties 21 | Bean group; 22 | Bean record; 23 | Bean segment; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /test/org/beanio/beans/OrderBatch.java: -------------------------------------------------------------------------------- 1 | package org.beanio.beans; 2 | 3 | import java.util.*; 4 | 5 | public class OrderBatch { 6 | 7 | private int batchCount; 8 | private Order order; 9 | private List orders; 10 | 11 | public int getBatchCount() { 12 | return batchCount; 13 | } 14 | public void setBatchCount(int batchCount) { 15 | this.batchCount = batchCount; 16 | } 17 | public Order getOrder() { 18 | return order; 19 | } 20 | public void setOrder(Order order) { 21 | this.order = order; 22 | } 23 | public List getOrders() { 24 | return orders; 25 | } 26 | public void setOrders(List orders) { 27 | this.orders = orders; 28 | } 29 | public Order[] getOrderArray() { 30 | if (orders != null) { 31 | Order[] array = new Order[orders.size()]; 32 | orders.toArray(array); 33 | return array; 34 | } 35 | return null; 36 | } 37 | public void setOrderArray(Order[] orderArray) { 38 | orders = Arrays.asList(orderArray); 39 | } 40 | 41 | public String toString() { 42 | return "OrderBatch" + 43 | "[count=" + batchCount + 44 | ", orders=" + orders + 45 | "]"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test/org/beanio/beans/OrderItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.beans; 17 | 18 | public class OrderItem { 19 | 20 | private String name; 21 | private int quantity; 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | public int getQuantity() { 30 | return quantity; 31 | } 32 | public void setQuantity(int quantity) { 33 | this.quantity = quantity; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/org/beanio/beans/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.beans; 17 | 18 | import java.util.List; 19 | 20 | public class Person { 21 | 22 | private String id; 23 | private String firstName; 24 | private String lastName; 25 | private List numbers; 26 | 27 | public String getId() { 28 | return id; 29 | } 30 | public void setId(String id) { 31 | this.id = id; 32 | } 33 | public String getFirstName() { 34 | return firstName; 35 | } 36 | public void setFirstName(String firstName) { 37 | this.firstName = firstName; 38 | } 39 | public String getLastName() { 40 | return lastName; 41 | } 42 | public void setLastName(String lastName) { 43 | this.lastName = lastName; 44 | } 45 | public String toString() { 46 | return firstName + " " + lastName; 47 | } 48 | public List getNumbers() { 49 | return numbers; 50 | } 51 | public void setNumbers(List numbers) { 52 | this.numbers = numbers; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /test/org/beanio/config/ConcreteBean.java: -------------------------------------------------------------------------------- 1 | package org.beanio.config; 2 | 3 | public class ConcreteBean { 4 | 5 | private String name; 6 | private int age; 7 | 8 | public String getName() { 9 | return name; 10 | } 11 | 12 | public int getAge() { 13 | return age; 14 | } 15 | 16 | public void setAge(int age) { 17 | this.age = age; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/org/beanio/config/InterfaceBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.config; 17 | 18 | /** 19 | * Interface bean class for testing stream mode validation. 20 | * @author Kevin Seim 21 | * @since 1.2 22 | */ 23 | public interface InterfaceBean { 24 | 25 | public void setValue(String value); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test/org/beanio/config/a.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/ab.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/org/beanio/config/ab_template.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /test/org/beanio/config/b.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/collectionAttributeField.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/fieldNamespaceForText.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/import.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/org/beanio/config/imported.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/org/beanio/config/invalidBeanClass.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/invalidBeanXmlType.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/org/beanio/config/invalidFieldXmlType.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/invalidImport_InvalidResource.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/org/beanio/config/invalidImport_ResourceNotFound.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/org/beanio/config/invalidSetter.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/invalidStreamMode.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/invalidStreamXmlType.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/nillableAttributeField.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/noBeanProperty.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/noReadableMethod.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/noWriteableMethod.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/config/prefixWithNoNamespace.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/file.txt: -------------------------------------------------------------------------------- 1 | H 2 | T -------------------------------------------------------------------------------- /test/org/beanio/mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/org/beanio/parser/AbstractParserTest.groovy: -------------------------------------------------------------------------------- 1 | package org.beanio.parser 2 | 3 | import org.beanio.BeanReader 4 | import org.beanio.StreamFactory 5 | import org.beanio.builder.StreamBuilder 6 | 7 | abstract class AbstractParserTest { 8 | 9 | protected BeanReader createReader(StreamFactory factory, String input, String name="s") { 10 | return factory.createReader(name, new StringReader(input)) 11 | } 12 | 13 | protected StreamFactory createFactory(String xml=null) { 14 | StreamFactory factory = StreamFactory.newInstance() 15 | if (xml) { 16 | xml = "\n" + xml + "\n" 17 | factory.load(new ByteArrayInputStream(xml.getBytes("UTF-8"))) 18 | } 19 | return factory 20 | } 21 | 22 | protected StreamFactory createFactory(StreamBuilder builder) { 23 | StreamFactory factory = StreamFactory.newInstance(); 24 | if (builder != null) { 25 | factory.define(builder) 26 | } 27 | return factory; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /test/org/beanio/parser/annotation/AnnotatedBulb.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.annotation; 2 | 3 | import org.beanio.annotation.Field; 4 | 5 | public class AnnotatedBulb { 6 | 7 | @Field(at=0) 8 | public int watts; 9 | 10 | @Field(at=1) 11 | public String style; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /test/org/beanio/parser/annotation/AnnotatedFloor.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.annotation; 2 | 3 | import org.beanio.annotation.Field; 4 | import org.beanio.annotation.Fields; 5 | 6 | @Fields({ 7 | @Field(at=0, name="floor", literal="hardwood") 8 | }) 9 | public class AnnotatedFloor { 10 | 11 | @Field(at=1) 12 | public int width; 13 | 14 | @Field(at=2) 15 | public int height; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /test/org/beanio/parser/annotation/AnnotatedLight.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.annotation; 2 | 3 | import java.util.*; 4 | 5 | import org.beanio.annotation.*; 6 | import org.beanio.builder.XmlType; 7 | 8 | public class AnnotatedLight { 9 | 10 | @Field(at=0, xmlType=XmlType.ATTRIBUTE) 11 | public int quantity; 12 | 13 | @Segment(at=1, collection=LinkedList.class, minOccurs=2, maxOccurs=2) 14 | public List bulbs; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/org/beanio/parser/annotation/AnnotatedRoom.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.annotation; 2 | 3 | import org.beanio.annotation.*; 4 | 5 | @Record 6 | public class AnnotatedRoom { 7 | 8 | @Segment(at=0, type=AnnotatedLight.class, getter="getLightFixture", setter="setLightFixture") 9 | private Object light; 10 | 11 | @Field(at=5) 12 | public String name; 13 | 14 | private AnnotatedFloor floor; 15 | 16 | public AnnotatedLight getLightFixture() { 17 | return (AnnotatedLight) light; 18 | } 19 | 20 | public void setLightFixture(AnnotatedLight light) { 21 | this.light = light; 22 | } 23 | 24 | @Segment(at=6) 25 | public AnnotatedFloor getFlooring() { 26 | return floor; 27 | } 28 | 29 | public void setFlooring(AnnotatedFloor floor) { 30 | this.floor = floor; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/org/beanio/parser/annotation/AnnotatedUser.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.annotation; 2 | 3 | import java.util.*; 4 | 5 | import org.beanio.annotation.*; 6 | import org.beanio.builder.*; 7 | 8 | /** 9 | * Sample annotated object. 10 | */ 11 | @Record(xmlName="user", xmlNamespace="http://org.beanio.test") 12 | @Fields({ 13 | @Field(name="type", at=0, rid=true, literal="USER", xmlType=XmlType.ATTRIBUTE) 14 | }) 15 | public class AnnotatedUser extends AnnotatedUserSupport implements AnnotatedUserInterface { 16 | 17 | private String[] hands; 18 | 19 | @Field(at=6, type=Integer.class, padding='0', align=Align.RIGHT, length=4) 20 | private Object age; 21 | 22 | @Field(at=5, format="yyyy-MM-dd") 23 | public Date birthDate; 24 | 25 | @Field(at=7, minOccurs=2) 26 | public List letters; 27 | 28 | @SuppressWarnings("rawtypes") 29 | @Field(at=9, until=-1, type=Integer.class, collection=LinkedList.class, minOccurs=1, maxOccurs=-1) 30 | public List numbers; 31 | 32 | @Field(at=-1) 33 | public String end; 34 | 35 | public String[] getHands() { 36 | return hands; 37 | } 38 | public void setHands(String[] hands) { 39 | this.hands = hands; 40 | } 41 | 42 | public Object getAge() { 43 | return age; 44 | } 45 | public void setAge(Object age) { 46 | this.age = age; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test/org/beanio/parser/annotation/AnnotatedUserInterface.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.annotation; 2 | 3 | import org.beanio.annotation.Field; 4 | 5 | public interface AnnotatedUserInterface { 6 | 7 | @Field(at=3, minOccurs=2, regex="(left|right)") 8 | public String[] getHands(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test/org/beanio/parser/annotation/AnnotatedUserSupport.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.annotation; 2 | 3 | import org.beanio.annotation.Field; 4 | 5 | public abstract class AnnotatedUserSupport { 6 | 7 | @Field(at=1, required=true) 8 | private String firstName; 9 | 10 | @Field(at=2, getter="getSurname", setter="setSurname") 11 | private String lastName; 12 | 13 | public String getFirstName() { 14 | return firstName; 15 | } 16 | public void setFirstName(String firstName) { 17 | this.firstName = firstName; 18 | } 19 | public String getSurname() { 20 | return lastName; 21 | } 22 | public void setSurname(String lastName) { 23 | this.lastName = lastName; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /test/org/beanio/parser/bean/w10_nestedBeans.txt: -------------------------------------------------------------------------------- 1 | 0 1 1 2 0 1 1 2 eof 2 | a b c d e f g h eof -------------------------------------------------------------------------------- /test/org/beanio/parser/bean/w1_position.txt: -------------------------------------------------------------------------------- 1 | TEST,Widget1,1,2,Widget2,Widget3,3 2 | -------------------------------------------------------------------------------- /test/org/beanio/parser/bean/w2_collections.txt: -------------------------------------------------------------------------------- 1 | 1,1M,1A,1AM,1B,1BM,2,2M,2A,2AM,2B,2BM,3 -------------------------------------------------------------------------------- /test/org/beanio/parser/bean/w3_fixedLength.txt: -------------------------------------------------------------------------------- 1 | 1name1mode1 2 | 1name1mode1 2name2mode2 3 4name4 3 | 1name1mode1 2name2mode2 4name4mode4 -------------------------------------------------------------------------------- /test/org/beanio/parser/bean/w4_map.txt: -------------------------------------------------------------------------------- 1 | 1name12name2 2 | 1name12name23name3 -------------------------------------------------------------------------------- /test/org/beanio/parser/bean/w5_outOfOrder.txt: -------------------------------------------------------------------------------- 1 | 123name1name2name3 -------------------------------------------------------------------------------- /test/org/beanio/parser/bean/w6_fieldError.txt: -------------------------------------------------------------------------------- 1 | 1,name1,2,name2,A,name3 -------------------------------------------------------------------------------- /test/org/beanio/parser/bean/w9_flcollections.txt: -------------------------------------------------------------------------------- 1 | 1 1part1 2part2name -------------------------------------------------------------------------------- /test/org/beanio/parser/collection/CollectionBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.parser.collection; 17 | 18 | import java.util.*; 19 | 20 | /** 21 | * Test bean used by CollectionFieldParserTest. 22 | * 23 | * @author Kevin Seim 24 | * @since 1.0 25 | */ 26 | public class CollectionBean { 27 | 28 | private List list; 29 | private Set set; 30 | private int[] array; 31 | 32 | public List getList() { 33 | return list; 34 | } 35 | public void setList(List list) { 36 | this.list = list; 37 | } 38 | public Set getSet() { 39 | return set; 40 | } 41 | public void setSet(Set set) { 42 | this.set = set; 43 | } 44 | public int[] getArray() { 45 | return array; 46 | } 47 | public void setArray(int[] array) { 48 | this.array = array; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/org/beanio/parser/collection/collection.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /test/org/beanio/parser/collection/dc1_valid.txt: -------------------------------------------------------------------------------- 1 | George,Gary,Jon,1,2,3,4 2 | George,Gary,Jon 3 | George,Gary 4 | -------------------------------------------------------------------------------- /test/org/beanio/parser/collection/dc2_nullPrimitive.txt: -------------------------------------------------------------------------------- 1 | 1,,3 -------------------------------------------------------------------------------- /test/org/beanio/parser/collection/fc1_valid.txt: -------------------------------------------------------------------------------- 1 | 001100024ABBC 2 | 000400500 3 | -------------------------------------------------------------------------------- /test/org/beanio/parser/comments/c1.txt: -------------------------------------------------------------------------------- 1 | $ comment 2 | joe,25 3 | # comment 4 | john,42 5 | \, comment 6 | mary,33 -------------------------------------------------------------------------------- /test/org/beanio/parser/comments/comments_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/org/beanio/parser/constructor/AnnotatedColor.groovy: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.constructor 2 | 3 | import org.beanio.annotation.Field 4 | import org.beanio.annotation.Record; 5 | 6 | @Record 7 | class AnnotatedColor { 8 | 9 | String name 10 | int r 11 | int g 12 | int b 13 | 14 | AnnotatedColor() { 15 | this("black", 0, 0, 0) 16 | } 17 | 18 | AnnotatedColor(String name, 19 | @Field(at=1, name="r") int r, 20 | @Field(at=2, name="g") int g, 21 | @Field(at=3, name="b") int b) 22 | { 23 | this.name = name; 24 | this.r = r; 25 | this.g = g; 26 | this.b = b; 27 | } 28 | 29 | @Field(at=0, setter="#1") 30 | String getName() { 31 | return this.name; 32 | } 33 | 34 | int getR() { 35 | return r; 36 | } 37 | 38 | int getG() { 39 | return g; 40 | } 41 | 42 | int getB() { 43 | return b; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/org/beanio/parser/constructor/Color.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.constructor; 2 | 3 | public class Color { 4 | 5 | private String name; 6 | private int r; 7 | private int g; 8 | private int b; 9 | 10 | public Color() { 11 | this("black", 0, 0, 0); 12 | } 13 | 14 | public Color(String name, int r, int g, int b) { 15 | this.name = name; 16 | this.r = r; 17 | this.g = g; 18 | this.b = b; 19 | } 20 | 21 | public String getName() { 22 | return this.name; 23 | } 24 | 25 | public int getR() { 26 | return r; 27 | } 28 | 29 | public int getG() { 30 | return g; 31 | } 32 | 33 | public int getB() { 34 | return b; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/org/beanio/parser/constructor/ConstructorParserTest.groovy: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.constructor; 2 | 3 | import org.beanio.*; 4 | import org.beanio.builder.StreamBuilder; 5 | import org.beanio.parser.AbstractParserTest; 6 | import org.beanio.parser.ParserTest; 7 | import org.junit.*; 8 | 9 | /** 10 | * JUnit test cases for fields and segments that use dynamic occurrences. 11 | * @author Kevin Seim 12 | */ 13 | class ConstructorParserTest extends AbstractParserTest { 14 | 15 | private StreamFactory factory; 16 | 17 | @Test 18 | void testConstructor() { 19 | StreamFactory factory = createFactory(""" 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | """); 28 | 29 | Unmarshaller u = factory.createUnmarshaller("c1"); 30 | def color = u.unmarshal("red,255,0,0"); 31 | assert color.name == "red" 32 | assert color.r == 255 33 | assert color.g == 0 34 | assert color.b == 0 35 | } 36 | 37 | @Test 38 | void testAnnotatedConstructor() { 39 | StreamFactory factory = createFactory(new StreamBuilder("c1") 40 | .format("csv") 41 | .addRecord(AnnotatedColor.class)); 42 | 43 | Unmarshaller u = factory.createUnmarshaller("c1"); 44 | def color = u.unmarshal("red,255,0,0"); 45 | assert color.name == "red" 46 | assert color.r == 255 47 | assert color.g == 0 48 | assert color.b == 0 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /test/org/beanio/parser/constructor/constructor_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/org/beanio/parser/delimited/d1_messages.properties: -------------------------------------------------------------------------------- 1 | recorderror.record1.minLength = Too few fields {3} 2 | recorderror.record1.maxLength = Too many fields {4} -------------------------------------------------------------------------------- /test/org/beanio/parser/delimited/d1_recordErrors.txt: -------------------------------------------------------------------------------- 1 | 2 | ,,,, 3 | value1,value2,value3 4 | value1,value2,value3, -------------------------------------------------------------------------------- /test/org/beanio/parser/delimited/d2_optionalField.txt: -------------------------------------------------------------------------------- 1 | value1,value2 -------------------------------------------------------------------------------- /test/org/beanio/parser/delimited/d3_padding.txt: -------------------------------------------------------------------------------- 1 | xx1 xx2 xx3 xxx -------------------------------------------------------------------------------- /test/org/beanio/parser/delimited/delimited.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/org/beanio/parser/direct/DirectParserTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.parser.direct; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | import org.beanio.*; 21 | import org.beanio.parser.ParserTest; 22 | import org.junit.*; 23 | 24 | /** 25 | * JUnit test cases for direct access to public class attributes. 26 | * 27 | * @author Kevin Seim 28 | * @since 2.0.2 29 | */ 30 | public class DirectParserTest extends ParserTest { 31 | 32 | private StreamFactory factory; 33 | 34 | @Before 35 | public void setup() throws Exception { 36 | factory = newStreamFactory("direct_mapping.xml"); 37 | } 38 | 39 | @Test 40 | public void testDirectAccess() { 41 | Unmarshaller u = factory.createUnmarshaller("d1"); 42 | DirectUser p = (DirectUser) u.unmarshal("george,true"); 43 | 44 | assertEquals("george", p.firstName); 45 | assertTrue(p.enabled); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /test/org/beanio/parser/direct/DirectUser.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.direct; 2 | 3 | public class DirectUser { 4 | public String firstName; 5 | public boolean enabled; 6 | } 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/direct/d1.txt: -------------------------------------------------------------------------------- 1 | george,true -------------------------------------------------------------------------------- /test/org/beanio/parser/direct/direct_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f1_maxLength.txt: -------------------------------------------------------------------------------- 1 | value 0000012345valuexxxxx----------values -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f1_minLength.txt: -------------------------------------------------------------------------------- 1 | value 0000012345valuexxxxx----------valu -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f1_valid.txt: -------------------------------------------------------------------------------- 1 | value 0000012345valuexxxxx----------value -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f2_invalid.txt: -------------------------------------------------------------------------------- 1 | 12345 2 | 123456789012345678901 3 | 1234512345val -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f2_messages.properties: -------------------------------------------------------------------------------- 1 | label.record=Record Label 2 | recorderror.record.minLength=minLength, {0}, {1}, {2}, {3}, {4} 3 | recorderror.maxLength=maxLength, {0}, {1}, {2}, {3}, {4} -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f2_valid.txt: -------------------------------------------------------------------------------- 1 | 1234512345value12345 2 | 1234512345value 3 | 1234512345 -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f3_valid.txt: -------------------------------------------------------------------------------- 1 | 00001 XXXXX 2 | 00002Val2 3 | 1000 4 | -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f4_padding.txt: -------------------------------------------------------------------------------- 1 | INT000000000100010001000100010000 2 | CHAAB D 3 | STLTXTTX T 4 | STRTXT TX T -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f5_valid.txt: -------------------------------------------------------------------------------- 1 | Smith -------------------------------------------------------------------------------- /test/org/beanio/parser/fixedlength/f7.txt: -------------------------------------------------------------------------------- 1 | kevin 2 | smith -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g1_empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinseim/beanio/c31768943b963a8c48ed13f66498e331fdb0f2bc/test/org/beanio/parser/groups/g1_empty.txt -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g1_missingBatchTrailer.txt: -------------------------------------------------------------------------------- 1 | H 2 | H1 3 | D1 4 | D1 5 | D1 6 | D1 7 | D1 8 | D1 9 | D1 10 | D1 11 | D1 12 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g1_noHeader.txt: -------------------------------------------------------------------------------- 1 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g1_noTrailer.txt: -------------------------------------------------------------------------------- 1 | H 2 | -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g1_nobatch.txt: -------------------------------------------------------------------------------- 1 | H 2 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g1_oneBatch.txt: -------------------------------------------------------------------------------- 1 | H 2 | H1 3 | D1 4 | T1 5 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g1_threeBatch.txt: -------------------------------------------------------------------------------- 1 | H 2 | H1 3 | D1 4 | T1 5 | H1 6 | T1 7 | H1 8 | T1 9 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g1_tooManyHeaders.txt: -------------------------------------------------------------------------------- 1 | H 2 | H 3 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g1_unidentifiedRecord.txt: -------------------------------------------------------------------------------- 1 | H 2 | H1 3 | D1 4 | D1 5 | D1 6 | D1 7 | D1 8 | D2 9 | D1 10 | D1 11 | D1 12 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g2_empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinseim/beanio/c31768943b963a8c48ed13f66498e331fdb0f2bc/test/org/beanio/parser/groups/g2_empty.txt -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g2_missingGroup.txt: -------------------------------------------------------------------------------- 1 | H 2 | H2 3 | T2 4 | D 5 | D 6 | H2 7 | T2 8 | D 9 | D 10 | D 11 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g2_tooManyGroups.txt: -------------------------------------------------------------------------------- 1 | H 2 | H2 3 | T2 4 | H2 5 | T2 6 | H1 7 | T1 8 | D 9 | D 10 | D 11 | H1 12 | T1 13 | D 14 | D 15 | H1 16 | T1 17 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g2_twoLayout.txt: -------------------------------------------------------------------------------- 1 | H 2 | H1 3 | T1 4 | D 5 | T 6 | H 7 | H1 8 | T1 9 | D 10 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g2_valid1.txt: -------------------------------------------------------------------------------- 1 | H 2 | H2 3 | T2 4 | D 5 | D 6 | D 7 | D 8 | D 9 | H2 10 | T2 11 | H1 12 | D 13 | D 14 | D 15 | H1 16 | T1 17 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g3_valid.txt: -------------------------------------------------------------------------------- 1 | H 2 | 3 3 | 1 4 | 2 5 | 1 6 | 2 7 | 2 8 | 2 9 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g4_endOfGroup.txt: -------------------------------------------------------------------------------- 1 | H 2 | BD 3 | BT 4 | BD 5 | O 6 | BD 7 | O 8 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g4_repeatingGroup.txt: -------------------------------------------------------------------------------- 1 | H 2 | BD 3 | BT 4 | BD 5 | BT 6 | BH 7 | BD 8 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g4_tooManyGroups.txt: -------------------------------------------------------------------------------- 1 | H 2 | BD 3 | BT 4 | BD 5 | O 6 | BD 7 | O 8 | BD 9 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g5_subgroups.txt: -------------------------------------------------------------------------------- 1 | CH 2 | FH 3 | TH 4 | T 5 | T 6 | T 7 | TT 8 | TH 9 | T 10 | TT 11 | FT 12 | FH 13 | TH 14 | TT 15 | TH 16 | T 17 | TT 18 | TH 19 | TT 20 | FT 21 | FH 22 | FT 23 | CT -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g6_missingRecordEOF.txt: -------------------------------------------------------------------------------- 1 | H 2 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g7_missingGroupEOF.txt: -------------------------------------------------------------------------------- 1 | H 2 | T -------------------------------------------------------------------------------- /test/org/beanio/parser/groups/g8_repeatingStream.txt: -------------------------------------------------------------------------------- 1 | GH 2 | GT 3 | T 4 | GH 5 | GT 6 | T 7 | GH 8 | T 9 | GH -------------------------------------------------------------------------------- /test/org/beanio/parser/ignoreUnidentifiedRecords/IgnoreUnidentifiedRecordsParserTest.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.ignoreUnidentifiedRecords; 2 | 3 | import java.io.InputStreamReader; 4 | 5 | import org.beanio.*; 6 | import org.beanio.parser.ParserTest; 7 | import org.junit.*; 8 | 9 | /** 10 | * Unit test cases for ignoring unidentified records. 11 | * 12 | * @author Kevin Seim 13 | */ 14 | public class IgnoreUnidentifiedRecordsParserTest extends ParserTest { 15 | 16 | private StreamFactory factory; 17 | 18 | @Before 19 | public void setup() throws Exception { 20 | factory = newStreamFactory("ignore_mapping.xml"); 21 | } 22 | 23 | @Test 24 | public void testIgnoreUnidentfiedRecords() { 25 | BeanReader in = factory.createReader("stream1", new InputStreamReader( 26 | getClass().getResourceAsStream("ignoreUnidentifiedRecords1.txt"))); 27 | 28 | try { 29 | 30 | in.read(); 31 | Assert.assertEquals("header", in.getRecordName()); 32 | in.read(); 33 | Assert.assertEquals("group_header", in.getRecordName()); 34 | in.read(); 35 | Assert.assertEquals("group_trailer", in.getRecordName()); 36 | 37 | in.read(); 38 | Assert.assertEquals("header", in.getRecordName()); 39 | in.read(); 40 | Assert.assertEquals("group_header", in.getRecordName()); 41 | in.read(); 42 | Assert.assertEquals("group_trailer", in.getRecordName()); 43 | 44 | Assert.assertNull(in.read()); 45 | } 46 | finally { 47 | in.close(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/org/beanio/parser/ignoreUnidentifiedRecords/ignoreUnidentifiedRecords1.txt: -------------------------------------------------------------------------------- 1 | X 2 | H 3 | X 4 | GH 5 | X 6 | X 7 | GT 8 | X 9 | X 10 | H 11 | X 12 | GH 13 | GT -------------------------------------------------------------------------------- /test/org/beanio/parser/ignoreUnidentifiedRecords/ignore_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/org/beanio/parser/imports/circular_mapping1.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/org/beanio/parser/imports/circular_mapping2.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/imports/circular_mapping3.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/imports/import_mapping1.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/org/beanio/parser/imports/import_mapping2.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/org/beanio/parser/imports/import_mapping3.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/org/beanio/parser/inlinemaps/Job.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.inlinemaps; 2 | 3 | import java.util.Map; 4 | 5 | @SuppressWarnings("rawtypes") 6 | public class Job { 7 | 8 | private String id; 9 | private Map codes; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | public void setId(String id) { 15 | this.id = id; 16 | } 17 | public Map getCodes() { 18 | return codes; 19 | } 20 | public void setCodes(Map codes) { 21 | this.codes = codes; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/org/beanio/parser/json/JsonTestRecordParserFactory.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.json; 2 | 3 | import org.beanio.stream.json.JsonRecordParserFactory; 4 | 5 | public class JsonTestRecordParserFactory extends JsonRecordParserFactory { 6 | public JsonTestRecordParserFactory() { 7 | setPretty(true); 8 | setIndentation(2); 9 | setLineSeparator("\r\n"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/org/beanio/parser/json/field/JsonFieldParserTest.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.json.field; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.*; 6 | import java.util.*; 7 | 8 | import org.beanio.*; 9 | import org.beanio.parser.ParserTest; 10 | import org.junit.*; 11 | 12 | /** 13 | * JUnit test cases for JSON fields. 14 | * 15 | * @author Kevin Seim 16 | * @since 2.0 17 | */ 18 | public class JsonFieldParserTest extends ParserTest { 19 | 20 | private StreamFactory factory; 21 | 22 | @Before 23 | public void setup() throws Exception { 24 | factory = newStreamFactory("jsonField_mapping.xml"); 25 | } 26 | 27 | @Test 28 | @SuppressWarnings("rawtypes") 29 | public void testField_Simple() { 30 | BeanReader in = factory.createReader("stream", new InputStreamReader( 31 | getClass().getResourceAsStream("jf1.txt"))); 32 | 33 | try { 34 | Map map = (Map) in.read(); 35 | assertEquals("Joe", map.get("firstName")); 36 | assertEquals("Johnson", map.get("lastName")); 37 | assertEquals("20", map.get("age")); 38 | assertEquals(1, map.get("number")); 39 | assertEquals(Boolean.TRUE, map.get("healthy")); 40 | assertArrayEquals(new Integer[] { 10, 20 }, ((List)map.get("array")).toArray()); 41 | 42 | StringWriter text = new StringWriter(); 43 | factory.createWriter("stream", text).write(map); 44 | assertEquals(load("jf1.txt"), text.toString()); 45 | } 46 | finally { 47 | in.close(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/org/beanio/parser/json/field/jf1.txt: -------------------------------------------------------------------------------- 1 | { 2 | "first": "Joe", 3 | "last": "Johnson", 4 | "age": 20, 5 | "number": [1], 6 | "healthy": true, 7 | "array": [10, 20] 8 | } 9 | -------------------------------------------------------------------------------- /test/org/beanio/parser/json/field/jsonField_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /test/org/beanio/parser/json/segment/js1.txt: -------------------------------------------------------------------------------- 1 | { 2 | "customer": { 3 | "firstName": "Jen", 4 | "lastName": "Jones" 5 | }, 6 | "account": "1234" 7 | } 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/json/segment/js2.txt: -------------------------------------------------------------------------------- 1 | { 2 | "friends": [ 3 | {"firstName": "Jen", "lastName": "Jones"}, 4 | {"firstName": "Mary", "lastName": "Smith"} 5 | ], 6 | "count": 2 7 | } 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/json/segment/js3.txt: -------------------------------------------------------------------------------- 1 | { 2 | "array": [[1, 2, 3], {"firstName": "Jen", "lastName": "Jones"}] 3 | } 4 | -------------------------------------------------------------------------------- /test/org/beanio/parser/json/segment/js4.txt: -------------------------------------------------------------------------------- 1 | { 2 | "firstName": "Jen", 3 | "lastName": "Jones", 4 | "account": "1234" 5 | } 6 | { 7 | "firstName": "Jason", 8 | "lastName": "Jones", 9 | "account": "5678" 10 | } 11 | -------------------------------------------------------------------------------- /test/org/beanio/parser/lazy/Account.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.lazy; 2 | 3 | import java.util.List; 4 | 5 | public class Account { 6 | private Integer number; 7 | private String text; 8 | private List transactions; 9 | 10 | public Integer getNumber() { 11 | return number; 12 | } 13 | public void setNumber(Integer number) { 14 | this.number = number; 15 | } 16 | public String getText() { 17 | return text; 18 | } 19 | public void setText(String text) { 20 | this.text = text; 21 | } 22 | public List getTransactions() { 23 | return transactions; 24 | } 25 | public void setTransactions(List transactions) { 26 | this.transactions = transactions; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/org/beanio/parser/lazy/LazyUser.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.lazy; 2 | 3 | import java.util.List; 4 | 5 | public class LazyUser { 6 | 7 | public String name; 8 | public Account account; 9 | public List accounts; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/org/beanio/parser/lazy/Transaction.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.lazy; 2 | 3 | public class Transaction { 4 | 5 | private String type; 6 | 7 | public String getType() { 8 | return type; 9 | } 10 | 11 | public void setType(String type) { 12 | this.type = type; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/org/beanio/parser/lazy/lazy_mapping.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /test/org/beanio/parser/lenientPadding/LenientPaddingTest.groovy: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.lenientPadding 2 | 3 | import org.beanio.* 4 | import org.beanio.parser.AbstractParserTest 5 | import org.junit.Test 6 | 7 | 8 | /** 9 | * Test cases for the 'lenientPadding' field attribute. 10 | * @author Kevin Seim 11 | */ 12 | class LenientPaddingTest extends AbstractParserTest { 13 | 14 | @Test 15 | void testLazySegmentMap() { 16 | StreamFactory factory = createFactory(""" 17 | 18 | 19 | 20 | 21 | 22 | 23 | """); 24 | 25 | Unmarshaller u = factory.createUnmarshaller("s") 26 | def obj = u.unmarshal("aaabb") 27 | assert obj?.field1 == "aaa" 28 | assert obj?.field2 == "bb" 29 | 30 | obj = u.unmarshal("aaabb c") 31 | assert obj?.field1 == "aaa" 32 | assert obj?.field2 == "bb" 33 | assert obj?.field3 == "c" 34 | 35 | obj = u.unmarshal("aaa") 36 | assert obj?.field1 == "aaa" 37 | assert obj.field2 == null 38 | assert obj.field3 == null 39 | 40 | try { 41 | u.unmarshal("aa") 42 | assert false, "InvalidRecordException expected" 43 | } 44 | catch (InvalidRecordException ex) { } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /test/org/beanio/parser/misc/m1.txt: -------------------------------------------------------------------------------- 1 | FirstName,LastName 2 | Joe,Smith 3 | John,Doe -------------------------------------------------------------------------------- /test/org/beanio/parser/multiline/ml1.txt: -------------------------------------------------------------------------------- 1 | order,100,2012-01-01 2 | customer,George,Smith 3 | item,soda,2 4 | item,carrots,5 5 | order,101,2012-01-01 6 | item,banana,a 7 | order,102,2012-02-100 8 | item,apple,a 9 | order,102,2012-02-100 10 | customer,John,Smith 11 | item,apple,a 12 | item,orange,5 13 | order,103,2012-01-01 14 | item,bread,1 15 | item,cereal,2 16 | -------------------------------------------------------------------------------- /test/org/beanio/parser/multiline/ml2.txt: -------------------------------------------------------------------------------- 1 | header,2 2 | order,100,2012-01-01 3 | customer,George,Smith 4 | item,orange,1 5 | item,apple,2 6 | order,101,2012-01-01 7 | customer,Joe,Johnson 8 | item,banana,1 9 | header,1 10 | order,103,2012-01-02 11 | customer,George,Smith 12 | item,carrot,1 13 | -------------------------------------------------------------------------------- /test/org/beanio/parser/multiline/ml3.txt: -------------------------------------------------------------------------------- 1 | header,2 2 | order,100,2012-01-01 3 | customer,George,Smith 4 | order,101,2012-01-01 5 | customer,John,Smith 6 | header,1 7 | order,103,2012-01-01 8 | customer,Jen,Smith 9 | -------------------------------------------------------------------------------- /test/org/beanio/parser/multiline/ml4.txt: -------------------------------------------------------------------------------- 1 | order,100,2012-01-01 2 | item,soda,2 3 | item,carrots,5 4 | order,101,2012-01-01 5 | item,banana,1 6 | item,apple,2 7 | item,cereal,3 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/multiline/ml5.txt: -------------------------------------------------------------------------------- 1 | header,2 2 | order,100,2012-01-01 3 | customer,George,Smith 4 | -------------------------------------------------------------------------------- /test/org/beanio/parser/multiline/ml6.txt: -------------------------------------------------------------------------------- 1 | order,100,2012-01-01 2 | -------------------------------------------------------------------------------- /test/org/beanio/parser/multiline/ml7.txt: -------------------------------------------------------------------------------- 1 | key1,value1 2 | key2,value2 3 | key3,value3 -------------------------------------------------------------------------------- /test/org/beanio/parser/ordinal/OrdinalTest.groovy: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.ordinal 2 | 3 | import org.beanio.* 4 | 5 | import org.beanio.annotation.* 6 | import org.beanio.builder.StreamBuilder 7 | import org.beanio.parser.AbstractParserTest 8 | import org.junit.Test 9 | 10 | /** 11 | * Test cases for the 'ordinal' annotation setting. 12 | * @author Kevin Seim 13 | */ 14 | class OrdinalTest extends AbstractParserTest { 15 | 16 | @Test 17 | void testOrdinal() { 18 | 19 | StreamFactory factory = StreamFactory.newInstance() 20 | factory.define(new StreamBuilder("c1") 21 | .format("csv") 22 | .addRecord(Man.class)) 23 | 24 | Marshaller m = factory.createMarshaller("c1"); 25 | 26 | Man man = new Man() 27 | man.with{ 28 | age = 15 29 | lastName = "jones" 30 | firstName = "jason" 31 | company = "apple" 32 | ext = "1234" 33 | } 34 | 35 | assert m.marshal(man).toString() == "jason,jones,15,apple,1234" 36 | } 37 | 38 | @Record 39 | public static class Man { 40 | @Field 41 | String company; 42 | @Field(ordinal=3) 43 | int age; 44 | @Field 45 | String ext; 46 | @Field(ordinal=2) 47 | String lastName; 48 | @Field(ordinal=1) 49 | String firstName; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /test/org/beanio/parser/property/User.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.property; 2 | 3 | public class User { 4 | 5 | private int type; 6 | private String name; 7 | 8 | public int getType() { 9 | return type; 10 | } 11 | public void setType(int type) { 12 | this.type = type; 13 | } 14 | public String getName() { 15 | return name; 16 | } 17 | public void setName(String name) { 18 | this.name = name; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /test/org/beanio/parser/property/p1.txt: -------------------------------------------------------------------------------- 1 | Header,2011-07-04 2 | Detail,John 3 | Trailer,1 -------------------------------------------------------------------------------- /test/org/beanio/parser/property/property_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/org/beanio/parser/ridlength/r1.txt: -------------------------------------------------------------------------------- 1 | 1,2 2 | 1,2,3 3 | 1 4 | 1,2,3,4 -------------------------------------------------------------------------------- /test/org/beanio/parser/ridlength/ridlength_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/org/beanio/parser/skip/s1.txt: -------------------------------------------------------------------------------- 1 | Header 2 | Ignore,Invalid 3 | Detail 4 | Ignore 5 | Detail 6 | Detail 7 | Detail 8 | Trailer -------------------------------------------------------------------------------- /test/org/beanio/parser/skip/skip_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /test/org/beanio/parser/strict/s1_invalidRecordLength.txt: -------------------------------------------------------------------------------- 1 | header,2012-01-01 2 | detail,Joe,Smith 3 | detail,John,Smith,extra 4 | trailer,1 -------------------------------------------------------------------------------- /test/org/beanio/parser/strict/s1_invalidSequence.txt: -------------------------------------------------------------------------------- 1 | detail,Joe,Smith 2 | header,2012-01-01 3 | trailer,1 -------------------------------------------------------------------------------- /test/org/beanio/parser/strict/strict_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/org/beanio/parser/substitution/substitution_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/org/beanio/parser/target/targetAndClass.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/parser/target/targetIsNotProperty.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/org/beanio/parser/target/targetNotFound.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/org/beanio/parser/target/targetRepeating.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/org/beanio/parser/target/target_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/org/beanio/parser/template/t1.txt: -------------------------------------------------------------------------------- 1 | 1,joe,M 2 | 2,john,M -------------------------------------------------------------------------------- /test/org/beanio/parser/template/t3.txt: -------------------------------------------------------------------------------- 1 | 1,joe,smith,M 2 | 2,john,doe,M -------------------------------------------------------------------------------- /test/org/beanio/parser/template/template_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 13 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/org/beanio/parser/trim/TrimTest.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.trim; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.Map; 6 | 7 | import org.beanio.*; 8 | import org.beanio.parser.ParserTest; 9 | import org.junit.*; 10 | 11 | /** 12 | * JUnit test cases for testing the trim attribute of a field element. 13 | * 14 | * @author Kevin Seim 15 | * @since 2.0.2 16 | */ 17 | public class TrimTest extends ParserTest { 18 | 19 | private StreamFactory factory; 20 | 21 | @Before 22 | public void setup() throws Exception { 23 | factory = newStreamFactory("trim_mapping.xml"); 24 | } 25 | 26 | @Test 27 | public void testLazySegment() { 28 | Unmarshaller u = factory.createUnmarshaller("s1"); 29 | 30 | @SuppressWarnings("rawtypes") 31 | Map map = (Map) u.unmarshal("\"jen \",jen ,1 "); 32 | assertEquals("jen ", map.get("text")); 33 | assertEquals("jen", map.get("text_trim")); 34 | assertEquals(new Integer(1), map.get("number")); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/org/beanio/parser/trim/trim_mapping.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/org/beanio/parser/types/TypeEnum.java: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.types; 2 | 3 | public enum TypeEnum { 4 | ONE, 5 | TWO; 6 | 7 | public String toString() { 8 | return super.toString().toLowerCase(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/org/beanio/parser/types/TypeHandlerLocaleTest.groovy: -------------------------------------------------------------------------------- 1 | package org.beanio.parser.types 2 | 3 | import org.beanio.* 4 | import org.beanio.beans.Bean 5 | import org.beanio.parser.AbstractParserTest 6 | import org.junit.Test 7 | 8 | /** 9 | * Unit test cases for type handling locale support 10 | * @author Kevin Seim 11 | */ 12 | class TypeHandlerLocaleTest extends AbstractParserTest { 13 | 14 | @Test 15 | void testFieldWithDefault() { 16 | Date date = new GregorianCalendar(2013, 1, 1).getTime(); 17 | 18 | StreamFactory factory = createFactory(""" 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | """); 32 | 33 | String text = '10.000,"10,000",01.02.2013 00:00:00' 34 | Map map = ['int1':10000, 'int2':10000, 'date':date] 35 | 36 | Marshaller m = factory.createMarshaller("s") 37 | assert m.marshal(map).toString() == text 38 | 39 | Unmarshaller u = factory.createUnmarshaller("s") 40 | assert u.unmarshal(text) == map 41 | } 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /test/org/beanio/parser/types/t1_valid.txt: -------------------------------------------------------------------------------- 1 | 10,10,-10,10,10.1,-10.1,A,ABC,010170,true,10,10,04-5-2013,fbd9d2be-35dc-41fb-abc9-f4b4c8757eb5,http://www.google.com,ONE,two 2 | ,,,,,,,,,,,,,,,, 3 | -------------------------------------------------------------------------------- /test/org/beanio/parser/types/t2_valid.txt: -------------------------------------------------------------------------------- 1 | 10,10,-10,10,10.1,-10.1,A,true 2 | ,,,,,,, -------------------------------------------------------------------------------- /test/org/beanio/parser/types/t3_valid.txt: -------------------------------------------------------------------------------- 1 | 01-01-1970 2 | 02-01-1970 -------------------------------------------------------------------------------- /test/org/beanio/parser/types/t4_valid.txt: -------------------------------------------------------------------------------- 1 | 12:00:00 2 | 01:00:00 -------------------------------------------------------------------------------- /test/org/beanio/parser/types/t5_valid.txt: -------------------------------------------------------------------------------- 1 | 2 | Text 3 | -------------------------------------------------------------------------------- /test/org/beanio/parser/types/t7_valid.txt: -------------------------------------------------------------------------------- 1 | 1x,2x,-3x,4x,5.1x,-6.1x,2011-01-01,10x,10.5x -------------------------------------------------------------------------------- /test/org/beanio/parser/types/t8_valid.txt: -------------------------------------------------------------------------------- 1 | 2000-01-01 -------------------------------------------------------------------------------- /test/org/beanio/parser/validation/v1.txt: -------------------------------------------------------------------------------- 1 | regex,12345 2 | regex,abc 3 | minLength,ab 4 | minLength,a 5 | maxLength,abcde 6 | maxLength,abcdef 7 | rwt,"value" 8 | rwt," " 9 | typeHandler,010170 10 | typeHandler,010170a 11 | rwot," " 12 | rwot, 13 | literal,value 14 | literal,other -------------------------------------------------------------------------------- /test/org/beanio/parser/validation/v1_messages.properties: -------------------------------------------------------------------------------- 1 | ## Copyright 2010 Kevin Seim 2 | ## 3 | ## Licensed under the Apache License, Version 2.0 (the "License"); 4 | ## you may not use this file except in compliance with the License. 5 | ## You may obtain a copy of the License at 6 | ## 7 | ## http://www.apache.org/licenses/LICENSE-2.0 8 | ## 9 | ## Unless required by applicable law or agreed to in writing, software 10 | ## distributed under the License is distributed on an "AS IS" BASIS, 11 | ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ## See the License for the specific language governing permissions and 13 | ## limitations under the License. 14 | 15 | ## test error messages by error 16 | fielderror.regex=regex(''{4}'') at line {0} 17 | fielderror.minLength=minLength({4}) at line {0} 18 | fielderror.maxLength=maxLength({5}) at line {0} 19 | fielderror.required=required at line {0} 20 | 21 | ## test error messages by record 22 | fielderror.typeHandler.type=type at line {0} 23 | 24 | ## test error messages by record and field 25 | fielderror.literal.field.literal=Invalid {2} at line {0} on {1}, expected ''{4}'' 26 | 27 | ## test record label 28 | label.literal=Literal Record 29 | 30 | ## test field label 31 | label.literal.field=Literal Field -------------------------------------------------------------------------------- /test/org/beanio/parser/writemode/PersonInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.parser.writemode; 17 | 18 | import java.util.Date; 19 | 20 | /** 21 | * Person bean object interface for testing write only mode which should allow 22 | * writing to non-concrete classes. 23 | * @author Kevin Seim 24 | * @since 1.2 25 | */ 26 | public interface PersonInterface { 27 | 28 | public String getFirstName(); 29 | public String getLastName(); 30 | public int getAge(); 31 | public Date getBirthDate(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /test/org/beanio/parser/writemode/writemode_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/Address.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.parser.xml; 17 | 18 | /** 19 | * Test bean object for XML parser related test cases. 20 | * @author Kevin Seim 21 | * @since 1.1 22 | */ 23 | public class Address { 24 | 25 | private String city; 26 | private String state; 27 | private String zip; 28 | 29 | public String getCity() { 30 | return city; 31 | } 32 | public void setCity(String city) { 33 | this.city = city; 34 | } 35 | public String getState() { 36 | return state; 37 | } 38 | public void setState(String state) { 39 | this.state = state; 40 | } 41 | public String getZip() { 42 | return zip; 43 | } 44 | public void setZip(String zip) { 45 | this.zip = zip; 46 | } 47 | 48 | public String toString() { 49 | return "[" + city + ", " + state + " " + zip + "]"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/Male.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.parser.xml; 17 | 18 | /** 19 | * Test bean object for XML parser related test cases. 20 | * @author Kevin Seim 21 | * @since 1.1 22 | */ 23 | public class Male extends Person { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/TestXmlWriterFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.parser.xml; 17 | 18 | import org.beanio.stream.xml.*; 19 | 20 | /** 21 | * Default writer factory for XML related test cases. 22 | *

23 | * To simplify comparison of generated XML output, the line separator and 24 | * indentation are explicitly set. 25 | * 26 | * @author Kevin Seim 27 | * @since 1.1 28 | */ 29 | public class TestXmlWriterFactory extends XmlRecordParserFactory { 30 | 31 | /** 32 | * Constructs a new TestXmlWriterFactory. 33 | */ 34 | public TestXmlWriterFactory() { 35 | super(); 36 | setSuppressHeader(true); 37 | setLineSeparator("\r\n"); 38 | setIndentation(2); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/bean/b1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | 5 | IL 6 | 60610 7 | 8 | 9 | 10 | Mary 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/bean/b1_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | 5 | IL 6 | 60610 7 | 8 | 9 | 10 | Mary 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/bean/b2_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | 5 | IL 6 | 60610 7 | 8 | 9 | 10 | Mary 11 | 12 | 13 | George 14 | 15 | IL 16 | 60610 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/bean/b2_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | 5 | IL 6 | 60610 7 | 8 | 9 | 10 | Mary 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/bean/b3_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |

IL
4 |
CO
5 |
MN
6 | John 7 | 8 | 9 | Mary 10 | 11 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/bean/b4_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | IL 5 | 60610 6 | 7 | 8 | Mary 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/bean/b5_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 |
5 | IL 6 | 60610 7 |
8 |
9 | 10 | Mary 11 |
12 | 13 | 14 | Mary 15 |
16 | IL 17 |
18 |
19 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/bean/b5_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 |
5 | IL 6 | 60610 7 |
8 |
9 | 10 | Mary 11 |
12 | 13 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/collection/c1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | Red 5 | Blue 6 | Green 7 | 8 | 9 | George 10 | 11 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/collection/collection_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/field/f1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 00025 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/field/f2_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 00025 4 | 5 | 6 | 7 | 8 | 9 | 025 10 | 11 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/field/f2_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 00025 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/field/f3_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Joe 4 | 5 | 6 | 7 | J 8 | 9 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/field/field_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/groups/g1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 |
IL
5 | 6 | David 7 | Mary 8 | 9 |
10 | 11 | George1 12 | 13 | 14 | George2 15 |
IL
16 |
17 | 18 | Kevin 19 | Jen 20 | 21 |
-------------------------------------------------------------------------------- /test/org/beanio/parser/xml/groups/g2_in.xml: -------------------------------------------------------------------------------- 1 | 2 | John 3 |
IL
4 | George 5 | Jane 6 |
-------------------------------------------------------------------------------- /test/org/beanio/parser/xml/groups/g3_in.xml: -------------------------------------------------------------------------------- 1 | 2 | John
IL
3 |
-------------------------------------------------------------------------------- /test/org/beanio/parser/xml/marshaller/marshaller_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/multiline/ml1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 100 5 | 2012-01-01 6 | 7 | 8 | George 9 | Smith 10 | 11 | 12 | soda 13 | 2 14 | 15 | 16 | carrots 17 | 5 18 | 19 | 20 | 21 | 101 22 | 2012-01-01 23 | 24 | 25 | banana 26 | a 27 | 28 | 29 | 30 | 102 31 | 2012-01-01 32 | 33 | 34 | apple 35 | a 36 | 37 | 38 | 39 | 103 40 | 2012-01-01 41 | 42 | 43 | John 44 | Smith 45 | 46 | 47 | apple 48 | a 49 | 50 | 51 | orange 52 | 5 53 | 54 | 55 | 56 | 104 57 | 2012-01-01 58 | 59 | 60 | bread 61 | 1 62 | 63 | 64 | cereal 65 | 2 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/multiline/ml1_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 100 4 | 2012-01-01 5 | 6 | 7 | George 8 | Smith 9 | 10 | 11 | soda 12 | 2 13 | 14 | 15 | carrots 16 | 5 17 | 18 | 19 | 100 20 | 2012-01-01 21 | 22 | 23 | 24 | 25 | 26 | 27 | 104 28 | 2012-01-01 29 | 30 | 31 | bread 32 | 1 33 | 34 | 35 | cereal 36 | 2 37 | 38 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/multiline/xml_multiline_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns10_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Smith 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns11_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Joe 6 | Smith 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns12_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns13_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns1_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns2_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns3_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns4_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns5_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns6_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | David 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns7_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns8_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | John 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns9_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | John 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns_noMatchingField.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns_noMatchingGroup.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns_noMatchingRecord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/namespace/ns_noMatchingStream.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | John 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/record/r1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | 22 5 | 6 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/record/record_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/typehandler/th1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2011-01-01 4 | 2011-01-01T13:45:00 5 | 6 | 01/01/2011 7 | true 8 | 9 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/typehandler/typehandler_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/NillableStringTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.parser.xml.types; 17 | 18 | import org.beanio.types.*; 19 | 20 | /** 21 | * Custom String type handler for testing NIL's. 22 | * @author Kevin Seim 23 | * @since 1.2 24 | */ 25 | public class NillableStringTypeHandler extends StringTypeHandler implements TypeHandler { 26 | 27 | @Override 28 | public String format(Object value) { 29 | if ("nil".equals(value)) { 30 | return TypeHandler.NIL; 31 | } 32 | return super.format(value); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/t1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | Smith 5 | 6 | 7 | 8 | Smith 9 | 10 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/t1_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | Smith 5 | 6 | 7 | 8 | Smith 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/t2_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/t2_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/t3_in.xml: -------------------------------------------------------------------------------- 1 | 2 | John 3 | Mary 4 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/t3_out.xml: -------------------------------------------------------------------------------- 1 | 2 | John 3 | Mary 4 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/t5_in.xml: -------------------------------------------------------------------------------- 1 | 2 | M 3 | F 4 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/t6_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | M 4 | John 5 | 6 | 7 | F 8 | Mary 9 | 10 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/types/t7_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/validation/v1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/validation/v2_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | IL 5 |
6 |
7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/validation/validation_mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/wrapper/w1_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John 4 | 5 | 6 | Red 7 | Blue 8 | Green 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
CO
17 |
IL
18 |
19 |
20 |
-------------------------------------------------------------------------------- /test/org/beanio/parser/xml/wrapper/w2_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Red 5 | Blue 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/org/beanio/parser/xml/wrapper/w3_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/org/beanio/stream/StrictStringReader.java: -------------------------------------------------------------------------------- 1 | package org.beanio.stream; 2 | 3 | import java.io.*; 4 | 5 | /** 6 | * A StringReader that throw an IOException if another read is made 7 | * after the EOF is reported once. 8 | * @author Kevin Seim 9 | */ 10 | public class StrictStringReader extends Reader { 11 | private int pos = 0; 12 | private char[] c; 13 | 14 | /** 15 | * Constructs a new StrictStringReader. 16 | * @param input 17 | */ 18 | public StrictStringReader(String input) { 19 | c = input.toCharArray(); 20 | } 21 | 22 | @Override 23 | public int read() throws IOException { 24 | return internalRead(); 25 | } 26 | 27 | private int internalRead() throws IOException { 28 | if (pos == -1) { 29 | throw new IOException("Stream is closed"); 30 | } 31 | if (pos < c.length) { 32 | return c[pos++]; 33 | } 34 | pos = -1; 35 | return pos; 36 | } 37 | 38 | @Override 39 | public void close() throws IOException { 40 | 41 | } 42 | 43 | @Override 44 | public int read(char[] cbuf, int off, int len) throws IOException { 45 | throw new UnsupportedOperationException(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test/org/beanio/types/StringTypeHandlerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2011 Kevin Seim 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.beanio.types; 17 | 18 | import org.junit.Test; 19 | 20 | import static org.junit.Assert.*; 21 | 22 | /** 23 | * JUnit test cases for the StringTypeHandler class. 24 | * 25 | * @author Kevin Seim 26 | * @since 1.0 27 | */ 28 | public class StringTypeHandlerTest { 29 | 30 | @Test 31 | public void testTrim() { 32 | StringTypeHandler handler = new StringTypeHandler(); 33 | handler.setTrim(true); 34 | assertTrue(handler.isTrim()); 35 | assertEquals("value", handler.parse(" value ")); 36 | } 37 | 38 | @Test 39 | public void testNullIfEmpty() { 40 | StringTypeHandler handler = new StringTypeHandler(); 41 | handler.setNullIfEmpty(true); 42 | assertTrue(handler.isNullIfEmpty()); 43 | assertNull(handler.parse("")); 44 | } 45 | 46 | @Test 47 | public void testFormatNull() { 48 | StringTypeHandler handler = new StringTypeHandler(); 49 | assertNull(handler.format(null)); 50 | } 51 | } 52 | --------------------------------------------------------------------------------