BeanIO 1.2.3

org.beanio.parser
Class RecordDefinition

java.lang.Object
  extended by org.beanio.parser.NodeDefinition
      extended by org.beanio.parser.RecordDefinition
Direct Known Subclasses:
FlatRecordDefinition, XmlRecordDefinition

public abstract class RecordDefinition
extends NodeDefinition

A RecordDefinition is used to parse and format a record. Exception for record level validation, most of the work is delegated to a bean definition.

Since:
1.0
Author:
Kevin Seim
See Also:
BeanDefinition

Constructor Summary
RecordDefinition()
          Creates a new RecordDefinition.
 
Method Summary
 NodeDefinition findDefinitionFor(Object bean)
          Returns a record definition (i.e.
 Object formatBean(Object bean)
          Formats a Java bean into a record (whose class type will depend on the type of stream and record writer being used).
 BeanDefinition getBeanDefinition()
          Returns the bean definition used to parse and format this record.
 List<NodeDefinition> getChildren()
          Returns a list of this node's children.
 boolean isRecordDefinition()
          Returns true if this node is a leaf node, or in this case a record definition.
 boolean matches(Record record)
          Test if a record matches this record definition.
 Object parseBean(Record record)
          Validates and parses a record into a Java bean.
 void setBeanDefinition(BeanDefinition beanDefinition)
          Sets the bean definition used to parse and format this record.
 String toString()
           
protected  void validateRecord(Record record)
          Performs record level validations.
 
Methods inherited from class org.beanio.parser.NodeDefinition
getMaxOccurs, getMinOccurs, getName, getOrder, setMaxOccurs, setMinOccurs, setName, setOrder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RecordDefinition

public RecordDefinition()
Creates a new RecordDefinition.

Method Detail

getChildren

public final List<NodeDefinition> getChildren()
Description copied from class: NodeDefinition
Returns a list of this node's children.

Specified by:
getChildren in class NodeDefinition
Returns:
the list list of the node's children

isRecordDefinition

public final boolean isRecordDefinition()
Description copied from class: NodeDefinition
Returns true if this node is a leaf node, or in this case a record definition.

Specified by:
isRecordDefinition in class NodeDefinition
Returns:
true if this node is a leaf node / record definition

findDefinitionFor

public NodeDefinition findDefinitionFor(Object bean)
Description copied from class: NodeDefinition
Returns a record definition (i.e. leaf node) capable of formatting the given bean.

Specified by:
findDefinitionFor in class NodeDefinition
Parameters:
bean - the bean to format
Returns:
the node context capable of formatting the bean, or null if one could not be found

matches

public boolean matches(Record record)
Test if a record matches this record definition.

Parameters:
record - the record to test
Returns:
true if all key fields are matched by this record

parseBean

public Object parseBean(Record record)
                 throws InvalidRecordException
Validates and parses a record into a Java bean.

Parameters:
record - the record to parse
Returns:
the parsed Java bean
Throws:
InvalidRecordException

validateRecord

protected void validateRecord(Record record)
Performs record level validations. If a validation error occurs, a record error should be added to the record.

Parameters:
record - the record to validate

formatBean

public Object formatBean(Object bean)
Formats a Java bean into a record (whose class type will depend on the type of stream and record writer being used).

Parameters:
bean - the bean to format
Returns:
the formatted record

getBeanDefinition

public BeanDefinition getBeanDefinition()
Returns the bean definition used to parse and format this record.

Returns:
the bean definition

setBeanDefinition

public void setBeanDefinition(BeanDefinition beanDefinition)
Sets the bean definition used to parse and format this record.

Parameters:
beanDefinition - the bean definition

toString

public String toString()
Overrides:
toString in class Object

BeanIO 1.2.3

Copyright © 2010-2012 Kevin Seim