|
BeanIO 2.0.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.beanio.internal.compiler.ProcessorSupport org.beanio.internal.compiler.ParserFactorySupport
public abstract class ParserFactorySupport
Base ParserFactory
implementation.
A StreamConfig
is "compiled" into a Stream
in two passes. First, a
Preprocessor
is used to validate and set default configuration settings. And
secondly, the finalized configuration is walked again (using a ProcessorSupport
,
to create the parser and property tree structure. As components are initialized they can
be added to the tree structure using stacks with the pushParser(Component)
and
pushProperty(Component)
methods. After a component is finalized, it should be
removed from the stack using the popParser()
or popProperty()
method.
Constructor Summary | |
---|---|
ParserFactorySupport()
Constructs a new ParserFactory. |
Method Summary | |
---|---|
protected Aggregation |
createAggregation(PropertyConfig config,
Property property)
Creates an iteration for a repeating segment or field. |
protected abstract FieldFormat |
createFieldFormat(FieldConfig config,
Class<?> type)
Creates a format specific FieldFormat . |
protected Preprocessor |
createPreprocessor(StreamConfig config)
Creates a stream configuration pre-processor. |
protected Property |
createProperty(PropertyConfig config,
boolean required)
Creates a property for holding other properties. |
protected RecordAggregation |
createRecordAggregation(PropertyConfig config,
Property property)
Creates an aggregation for a repeating record or group. |
protected abstract RecordFormat |
createRecordFormat(RecordConfig config)
Creates a format specific RecordFormat . |
protected RecordParserFactory |
createRecordParserFactory(StreamConfig config)
Creates the RecordParserFactory for a stream configuration. |
Stream |
createStream(StreamConfig config)
Creates a new stream definition based on a stream configuration. |
protected abstract StreamFormat |
createStreamFormat(StreamConfig config)
Creates a format specific StreamFormat . |
protected void |
finalizeGroup(GroupConfig config)
Finalizes a group configuration after its children have been processed. |
protected void |
finalizeGroup(GroupConfig config,
Group group)
Invoked by finalizeGroupMain(GroupConfig) to allow subclasses to perform
further finalization of the created Group . |
protected void |
finalizeGroupIteration(GroupConfig config)
|
protected void |
finalizeGroupMain(GroupConfig config)
|
protected void |
finalizeRecord(RecordConfig config)
Finalizes a record configuration after its children have been processed. |
protected void |
finalizeRecord(RecordConfig config,
Record record)
Invoked by finalizeRecord(RecordConfig) to allow subclasses to perform
further finalization of the created Record . |
protected void |
finalizeRecordIteration(RecordConfig config)
|
protected void |
finalizeRecordMain(RecordConfig config)
|
protected void |
finalizeSegment(SegmentConfig config)
Finalizes a segment configuration after its children have been processed. |
protected void |
finalizeSegment(SegmentConfig config,
Segment segment)
Invoked by finalizeSegmentMain(SegmentConfig) to allow subclasses to perform
further finalization of the created Segment . |
protected void |
finalizeSegmentIteration(SegmentConfig config)
Called by finalizeSegment(SegmentConfig) to finalize segment iteration. |
protected void |
finalizeSegmentMain(SegmentConfig config)
Called by finalizeSegment(SegmentConfig) to finalize the segment component. |
protected void |
finalizeStream(StreamConfig config)
Finalizes a stream configuration after its children have been processed. |
protected Class<?> |
getBeanClass(PropertyConfig config)
Returns the bean class for a segment configuration. |
protected abstract RecordParserFactory |
getDefaultRecordParserFactory()
Returns the default RecordParserFactory . |
protected Field |
getField(String property)
Returns the public non-final Field for a given property
name from the current bean class on the property stack. |
protected void |
handleConstant(ConstantConfig config)
Processes a constant configuration. |
protected void |
handleField(FieldConfig config)
Processes a field configuration. |
protected void |
initializeGroup(GroupConfig config)
Initializes a group configuration before its children have been processed. |
protected void |
initializeGroupIteration(GroupConfig config,
Property property)
|
protected void |
initializeGroupMain(GroupConfig config,
Property property)
|
protected void |
initializeRecord(RecordConfig config)
Initializes a record configuration before its children have been processed. |
protected void |
initializeRecordIteration(RecordConfig config,
Property property)
|
protected void |
initializeRecordMain(RecordConfig config,
Property property)
|
protected void |
initializeSegment(SegmentConfig config)
Initializes a segment configuration before its children have been processed. |
protected void |
initializeSegmentIteration(SegmentConfig config,
Property property)
Called by initializeSegment(SegmentConfig) to initialize segment iteration. |
protected void |
initializeSegmentMain(SegmentConfig config,
Property property)
Called by initializeSegment(SegmentConfig) to initialize the segment. |
protected void |
initializeStream(StreamConfig config)
Initializes a stream configuration before its children have been processed. |
protected boolean |
isBound()
Returns true if a property has been pushed onto the property stack, indicating that further properties will be bound to a parent property. |
boolean |
isReadEnabled()
Returns whether the stream definition must support reading an input stream. |
protected boolean |
isSegmentRequired(SegmentConfig config)
|
boolean |
isWriteEnabled()
Returns whether the stream definition must support writing to an output stream. |
protected Object |
parseDefaultValue(Field field,
String text)
Parses a default field value. |
protected Component |
popParser()
Removes the last component added to the parser stack. |
protected Property |
popProperty()
Removes the last component added to the property stack. |
protected void |
pushParser(Component component)
Adds a component to the parser stack. |
protected void |
pushProperty(Component component)
Adds a component to the property stack. |
protected Class<?> |
reflectCollectionType(Property iteration,
Property property,
String getter,
String setter)
|
protected void |
reflectPropertyType(PropertyConfig config,
Property property)
Sets the property type and accessor using bean introspection. |
void |
setClassLoader(ClassLoader classLoader)
Sets the ClassLoader to use for resolving configured class names. |
void |
setTypeHandlerFactory(TypeHandlerFactory typeHandlerFactory)
Sets the type handler factory to use to create the stream definition. |
protected void |
updateConstructor(Bean bean)
Updates a Bean 's constructor if one or more of its properties are
constructor arguments. |
Methods inherited from class org.beanio.internal.compiler.ProcessorSupport |
---|
getParent, handleComponent, process |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ParserFactorySupport()
Method Detail |
---|
public Stream createStream(StreamConfig config) throws BeanIOConfigurationException
createStream
in interface ParserFactory
config
- the stream configuration
Stream
BeanIOConfigurationException
- if the configuration is invalidprotected Preprocessor createPreprocessor(StreamConfig config)
config
- the stream configuration to pre-process
Preprocessor
protected abstract StreamFormat createStreamFormat(StreamConfig config)
StreamFormat
.
config
- the stream configuration
StreamFormat
protected abstract RecordFormat createRecordFormat(RecordConfig config)
RecordFormat
.
config
- the record configuration
RecordFormat
protected abstract FieldFormat createFieldFormat(FieldConfig config, Class<?> type)
FieldFormat
.
config
- the field configurationtype
- the property type, or null if not bound to a property
FieldFormat
protected void pushParser(Component component)
component
- the component to addprotected Component popParser()
protected void pushProperty(Component component)
component
- the component to addprotected Property popProperty()
protected void updateConstructor(Bean bean)
Bean
's constructor if one or more of its properties are
constructor arguments.
bean
- the Bean
to checkprotected boolean isBound()
protected void initializeStream(StreamConfig config) throws BeanIOConfigurationException
ProcessorSupport
initializeStream
in class ProcessorSupport
config
- the stream configuration to process
BeanIOConfigurationException
protected void finalizeStream(StreamConfig config) throws BeanIOConfigurationException
ProcessorSupport
finalizeStream
in class ProcessorSupport
config
- the stream configuration to finalize
BeanIOConfigurationException
protected void initializeGroup(GroupConfig config) throws BeanIOConfigurationException
ProcessorSupport
initializeGroup
in class ProcessorSupport
config
- the group configuration to process
BeanIOConfigurationException
protected void initializeGroupIteration(GroupConfig config, Property property)
protected void initializeGroupMain(GroupConfig config, Property property)
protected void finalizeGroup(GroupConfig config) throws BeanIOConfigurationException
ProcessorSupport
finalizeGroup
in class ProcessorSupport
config
- the group configuration to finalize
BeanIOConfigurationException
protected void finalizeGroupMain(GroupConfig config)
protected void finalizeGroupIteration(GroupConfig config)
protected void finalizeGroup(GroupConfig config, Group group)
finalizeGroupMain(GroupConfig)
to allow subclasses to perform
further finalization of the created Group
.
config
- the group configurationgroup
- the Group
being finalizedprotected void initializeRecord(RecordConfig config) throws BeanIOConfigurationException
ProcessorSupport
initializeRecord
in class ProcessorSupport
config
- the record configuration to process
BeanIOConfigurationException
protected void initializeRecordIteration(RecordConfig config, Property property)
protected void initializeRecordMain(RecordConfig config, Property property)
protected void finalizeRecord(RecordConfig config) throws BeanIOConfigurationException
ProcessorSupport
finalizeRecord
in class ProcessorSupport
config
- the record configuration to process
BeanIOConfigurationException
protected void finalizeRecordMain(RecordConfig config)
protected void finalizeRecordIteration(RecordConfig config)
protected void finalizeRecord(RecordConfig config, Record record)
finalizeRecord(RecordConfig)
to allow subclasses to perform
further finalization of the created Record
.
config
- the record configurationrecord
- the Record
being finalizedprotected final void initializeSegment(SegmentConfig config) throws BeanIOConfigurationException
ProcessorSupport
initializeSegment
in class ProcessorSupport
config
- the segment configuration to process
BeanIOConfigurationException
protected void initializeSegmentIteration(SegmentConfig config, Property property)
initializeSegment(SegmentConfig)
to initialize segment iteration.
config
- the segment configurationproperty
- the Property
bound to the segment, or null if no bean was boundprotected void initializeSegmentMain(SegmentConfig config, Property property)
initializeSegment(SegmentConfig)
to initialize the segment.
config
- the segment configurationproperty
- the property bound to the segment, or null if no property was boundprotected boolean isSegmentRequired(SegmentConfig config)
protected final void finalizeSegment(SegmentConfig config) throws BeanIOConfigurationException
ProcessorSupport
finalizeSegment
in class ProcessorSupport
config
- the segment configuration to process
BeanIOConfigurationException
protected void finalizeSegmentIteration(SegmentConfig config)
finalizeSegment(SegmentConfig)
to finalize segment iteration.
config
- the segment configurationprotected void finalizeSegmentMain(SegmentConfig config)
finalizeSegment(SegmentConfig)
to finalize the segment component.
config
- the segment configurationprotected void finalizeSegment(SegmentConfig config, Segment segment)
finalizeSegmentMain(SegmentConfig)
to allow subclasses to perform
further finalization of the created Segment
.
config
- the segment configurationsegment
- the new Segment
protected void handleField(FieldConfig config) throws BeanIOConfigurationException
ProcessorSupport
handleField
in class ProcessorSupport
config
- the field configuration to process
BeanIOConfigurationException
protected void handleConstant(ConstantConfig config) throws BeanIOConfigurationException
ProcessorSupport
handleConstant
in class ProcessorSupport
config
- the constant configuration to process
BeanIOConfigurationException
protected Aggregation createAggregation(PropertyConfig config, Property property) throws BeanIOConfigurationException
config
- the property configurationproperty
- the property component, may be null if the iteration is not
a property of its parent bean
BeanIOConfigurationException
- if the collection type is invalidprotected RecordAggregation createRecordAggregation(PropertyConfig config, Property property) throws BeanIOConfigurationException
config
- the record or group configurationproperty
- the property component
RecordAggregation
BeanIOConfigurationException
protected Class<?> reflectCollectionType(Property iteration, Property property, String getter, String setter) throws BeanIOConfigurationException
iteration
- property
- getter
- setter
-
BeanIOConfigurationException
protected void reflectPropertyType(PropertyConfig config, Property property) throws BeanIOConfigurationException
config
- the property configurationproperty
- the property
BeanIOConfigurationException
- if the configured type is not assignable
to the type determined through introspectionprotected Field getField(String property)
Field
for a given property
name from the current bean class on the property stack.
property
- the propety name
Field
or null if not foundprotected Property createProperty(PropertyConfig config, boolean required)
config
- the PropertyConfig
required
- whether the property is required and should always be instantiated
Property
or null if the PropertyConfig
was not
bound to a bean classprotected Class<?> getBeanClass(PropertyConfig config)
config
- the property configuration
BeanIOConfigurationException
- if the segment configuration is invalidprotected Object parseDefaultValue(Field field, String text)
field
- the fieldtext
- the text to parse
protected abstract RecordParserFactory getDefaultRecordParserFactory()
RecordParserFactory
.
RecordParserFactory
public void setTypeHandlerFactory(TypeHandlerFactory typeHandlerFactory)
setTypeHandlerFactory
in interface ParserFactory
typeHandlerFactory
- the TypeHandlerFactory to use to
create the stream definitionpublic boolean isReadEnabled()
public boolean isWriteEnabled()
protected RecordParserFactory createRecordParserFactory(StreamConfig config)
RecordParserFactory
for a stream configuration.
config
- the stream configuration
RecordParserFactory
public void setClassLoader(ClassLoader classLoader)
ParserFactory
ClassLoader
to use for resolving configured class names.
setClassLoader
in interface ParserFactory
classLoader
- the ClassLoader
|
BeanIO 2.0.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |