BeanIO 1.2.3

org.beanio.config
Class StreamDefinitionFactory

java.lang.Object
  extended by org.beanio.config.StreamDefinitionFactory
Direct Known Subclasses:
FlatStreamDefinitionFactory, XmlStreamDefinitionFactory

public abstract class StreamDefinitionFactory
extends Object

A StreamDefinitionFactory is used to convert a stream configuration into a StreamDefinition for parsing an I/O stream.

Since:
1.0
Author:
Kevin Seim

Constructor Summary
StreamDefinitionFactory()
          Constructs a new StreamDefinitionFactory.
 
Method Summary
protected  void compileBeanDefinition(BeanDefinition parent, BeanConfig config, BeanDefinition definition)
          Compiles a bean definition.
protected  void compileBeanPropertyDefinition(BeanDefinition beanDefinition, BeanPropertyConfig config, BeanPropertyDefinition definition)
          Compiles a bean property definition.
protected  void compileFieldDefinition(BeanDefinition beanDefinition, FieldConfig field, FieldDefinition fieldDefinition)
          Compiles a field definition.
protected  void compileFieldDefinitions(BeanConfig beanConfig, BeanDefinition beanDefinition)
          Compiles child property definitions for a bean.
protected  void compileFieldDefinitions(RecordConfig recordConfig, RecordDefinition recordDefinition)
          Compiles child property definitions for a record.
protected  void compileGroupDefinition(StreamConfig streamConfig, GroupConfig groupConfig, GroupDefinition definition)
          Compiles a group definition from its configuration.
protected  void compileRecordDefinition(GroupDefinition group, RecordConfig config, RecordDefinition recordDefinition)
          Compiles a record definition from its configuration.
protected  void compileStreamDefinition(StreamConfig config, StreamDefinition definition)
          Compiles a stream definition from its configuration.
 StreamDefinition createStreamDefinition(StreamConfig config)
          Creates a new stream definition based on a stream configuration.
protected  Class<?> getBeanClass(BeanConfig config)
          Determines the bean class type from its configuration/
 TypeHandlerFactory getDefaultTypeHandlerFactory()
          Returns the type handler factory for this stream format, thus allowing a stream format to override default type handlers.
protected  boolean isOptionalBeanEnabled()
          Returns whether this stream format allows beans with zero minimum occurrences.
protected  boolean isOptionalFieldEnabled()
          Returns whether this stream format allows fields with zero minimum occurrences.
 boolean isReadEnabled()
          Returns whether the stream definition must support reading an input stream.
 boolean isWriteEnabled()
          Returns whether the stream definition must support writing to an output stream.
protected abstract  BeanDefinition newBeanDefinition(BeanConfig bean)
          Creates a new BeanDefinition.
protected abstract  FieldDefinition newFieldDefinition(FieldConfig field)
          Creates a new FieldDefinition.
protected  GroupDefinition newGroupDefinition(GroupConfig group)
          Creates a new GroupDefinition.
protected abstract  RecordDefinition newRecordDefinition(RecordConfig record)
          Creates a new RecordDefinition.
protected abstract  RecordReaderFactory newRecordReaderFactory()
          Creates a default record reader factory.
protected abstract  RecordWriterFactory newRecordWriterFactory()
          Creates a default record writer factory
protected abstract  StreamDefinition newStreamDefinition(StreamConfig stream)
          Creates a new StreamDefinition.
 void setTypeHandlerFactory(TypeHandlerFactory typeHandlerFactory)
          Sets the type handler factory to use to create the stream definition.
protected  void updateBeanDefinition(BeanConfig beanConfig, BeanDefinition beanDefinition)
          This method is called by compileBeanDefinition to allow the configuration of format specific bean configuration settings.
protected  void updateFieldDefinition(FieldConfig fieldConfig, FieldDefinition fieldDefinition)
          This method is called by compileFieldDefinitions to allow the configuration of format specific field configuration settings.
protected  void updateGroupDefinition(GroupDefinition parent, GroupConfig config, GroupDefinition definition)
          This method is called by compileGroupDefinition to allow the configuration of stream specific group configuration settings.
protected  void updateStreamDefinition(StreamConfig config, StreamDefinition definition)
          This method is called by compileStreamDefinition to allow the configuration of stream specific stream configuration settings.
protected  void validateRecordIdentifyingCriteria(FieldDefinition fieldDefinition)
          This method validates a record identifying field has a literal or regular expression configured for identifying a record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamDefinitionFactory

public StreamDefinitionFactory()
Constructs a new StreamDefinitionFactory.

Method Detail

createStreamDefinition

public StreamDefinition createStreamDefinition(StreamConfig config)
                                        throws BeanIOConfigurationException
Creates a new stream definition based on a stream configuration.

Parameters:
config - the stream configuration
Returns:
the new StreamDefinition
Throws:
BeanIOConfigurationException - if the configuration is invalid

compileStreamDefinition

protected void compileStreamDefinition(StreamConfig config,
                                       StreamDefinition definition)
                                throws BeanIOConfigurationException
Compiles a stream definition from its configuration.

Parameters:
config - the stream configuration
definition - the stream definition to compile
Throws:
BeanIOConfigurationException - if the configuration is invalid

updateStreamDefinition

protected void updateStreamDefinition(StreamConfig config,
                                      StreamDefinition definition)
This method is called by compileStreamDefinition to allow the configuration of stream specific stream configuration settings.

Parameters:
config - the stream configuration
definition - the stream definition
Since:
1.1

compileGroupDefinition

protected final void compileGroupDefinition(StreamConfig streamConfig,
                                            GroupConfig groupConfig,
                                            GroupDefinition definition)
Compiles a group definition from its configuration.

Parameters:
streamConfig - the parent stream configuration
groupConfig - the group configuration
definition - the group definition to compile

updateGroupDefinition

protected void updateGroupDefinition(GroupDefinition parent,
                                     GroupConfig config,
                                     GroupDefinition definition)
This method is called by compileGroupDefinition to allow the configuration of stream specific group configuration settings.

Parameters:
parent - the parent group definition
config - the group configuration
definition - the group definition
Since:
1.1

compileRecordDefinition

protected void compileRecordDefinition(GroupDefinition group,
                                       RecordConfig config,
                                       RecordDefinition recordDefinition)
Compiles a record definition from its configuration.

Parameters:
config - the record configuration
recordDefinition - the record definition

compileBeanDefinition

protected void compileBeanDefinition(BeanDefinition parent,
                                     BeanConfig config,
                                     BeanDefinition definition)
Compiles a bean definition.

Parameters:
config - the bean configuration
definition - the bean definition to update

isOptionalBeanEnabled

protected boolean isOptionalBeanEnabled()
Returns whether this stream format allows beans with zero minimum occurrences. Returns false by default.

Returns:
true if the stream format allows optional beans
Since:
1.1

updateBeanDefinition

protected void updateBeanDefinition(BeanConfig beanConfig,
                                    BeanDefinition beanDefinition)
This method is called by compileBeanDefinition to allow the configuration of format specific bean configuration settings.

Parameters:
beanConfig - the bean configuration
beanDefinition - the bean definition
Since:
1.1

compileFieldDefinitions

protected void compileFieldDefinitions(RecordConfig recordConfig,
                                       RecordDefinition recordDefinition)
Compiles child property definitions for a record. The compiled property definitions are added to the record definition.

Parameters:
recordConfig - the record configuration
recordDefinition - the record definition to update

compileFieldDefinitions

protected void compileFieldDefinitions(BeanConfig beanConfig,
                                       BeanDefinition beanDefinition)
Compiles child property definitions for a bean. The compiled property definitions are added to the bean definition.

Parameters:
beanConfig - the bean configuration
beanDefinition - the bean definition to update

compileBeanPropertyDefinition

protected void compileBeanPropertyDefinition(BeanDefinition beanDefinition,
                                             BeanPropertyConfig config,
                                             BeanPropertyDefinition definition)
Compiles a bean property definition.

Parameters:
beanDefinition - the parent bean definition
config - the property configuration
definition - the property definition

compileFieldDefinition

protected void compileFieldDefinition(BeanDefinition beanDefinition,
                                      FieldConfig field,
                                      FieldDefinition fieldDefinition)
Compiles a field definition.

Parameters:
beanDefinition - the parent bean definition
field - the field configuration
fieldDefinition - the field definition
Since:
1.2

updateFieldDefinition

protected void updateFieldDefinition(FieldConfig fieldConfig,
                                     FieldDefinition fieldDefinition)
This method is called by compileFieldDefinitions to allow the configuration of format specific field configuration settings.

Parameters:
fieldConfig - the field configuration
fieldDefinition - the field definition
Since:
1.1

validateRecordIdentifyingCriteria

protected void validateRecordIdentifyingCriteria(FieldDefinition fieldDefinition)
This method validates a record identifying field has a literal or regular expression configured for identifying a record.

Parameters:
fieldDefinition - the record identifying field definition to validate
Since:
1.1

isOptionalFieldEnabled

protected boolean isOptionalFieldEnabled()
Returns whether this stream format allows fields with zero minimum occurrences. Returns false by default.

Returns:
true if the stream format allows optional fields
Since:
1.1

getBeanClass

protected Class<?> getBeanClass(BeanConfig config)
Determines the bean class type from its configuration/

Parameters:
config - the bean configuration
Returns:
the bean class

newFieldDefinition

protected abstract FieldDefinition newFieldDefinition(FieldConfig field)
Creates a new FieldDefinition.

Parameters:
field - the field configuration
Returns:
the new FieldDefinition

newBeanDefinition

protected abstract BeanDefinition newBeanDefinition(BeanConfig bean)
Creates a new BeanDefinition.

Parameters:
bean - the bean configuration
Returns:
the new BeanDefinition

newRecordDefinition

protected abstract RecordDefinition newRecordDefinition(RecordConfig record)
Creates a new RecordDefinition.

Parameters:
record - the record configuration
Returns:
the new RecordDefinition

newGroupDefinition

protected GroupDefinition newGroupDefinition(GroupConfig group)
Creates a new GroupDefinition.

Parameters:
group - the group configuration
Returns:
the new GroupDefinition

newStreamDefinition

protected abstract StreamDefinition newStreamDefinition(StreamConfig stream)
Creates a new StreamDefinition.

Parameters:
stream - the stream configuration
Returns:
the new StreamDefinition

newRecordReaderFactory

protected abstract RecordReaderFactory newRecordReaderFactory()
Creates a default record reader factory.

Returns:
the new RecordReaderFactory

newRecordWriterFactory

protected abstract RecordWriterFactory newRecordWriterFactory()
Creates a default record writer factory

Returns:
the new RecordWriterFactory

setTypeHandlerFactory

public void setTypeHandlerFactory(TypeHandlerFactory typeHandlerFactory)
Sets the type handler factory to use to create the stream definition.

Parameters:
typeHandlerFactory - the TypeHandlerFactory to use to create the stream definition

getDefaultTypeHandlerFactory

public TypeHandlerFactory getDefaultTypeHandlerFactory()
Returns the type handler factory for this stream format, thus allowing a stream format to override default type handlers.

Returns:
the type handler factory
Since:
1.1

isReadEnabled

public boolean isReadEnabled()
Returns whether the stream definition must support reading an input stream.

Returns:
true if the stream definition must support reading an input stream
Since:
1.2

isWriteEnabled

public boolean isWriteEnabled()
Returns whether the stream definition must support writing to an output stream.

Returns:
true if the stream definition must support writing to an output stream
Since:
1.2

BeanIO 1.2.3

Copyright © 2010-2012 Kevin Seim