BeanIO 1.2.3

org.beanio.parser
Class BeanDefinition

java.lang.Object
  extended by org.beanio.parser.PropertyDefinition
      extended by org.beanio.parser.BeanDefinition
Direct Known Subclasses:
FlatBeanDefinition, XmlBeanDefinition

public abstract class BeanDefinition
extends PropertyDefinition

Property definition that defines a bean class and holds its own list of properties for setting on the bean class.

Since:
1.0
Author:
Kevin Seim

Field Summary
 
Fields inherited from class org.beanio.parser.PropertyDefinition
INVALID, MISSING
 
Constructor Summary
BeanDefinition()
          Creates a new BeanDefinition.
 
Method Summary
 void addProperty(PropertyDefinition f)
          Adds a property definition to this bean definition.
 boolean defines(Object bean)
          Tests whether this definition is used to map the given bean or property value.
abstract  Object formatRecord(Object bean)
          Formats a Java bean into a record (whose class type will depend on the type of stream and record writer being used).
 List<FieldDefinition> getAllFields()
          Returns a list of all field definition descendants of this bean.
 Object getBeanProperty(PropertyDefinition definition, Object bean)
          Retrieves a property from a bean object created by this definition.
 PropertyDefinition getProperty(int index)
          Returns the property definition.
 int getPropertyCount()
          Returns the number of properties that make up this bean.
 List<PropertyDefinition> getPropertyList()
          Returns the list of properties that make up this bean.
 boolean isBean()
          Returns true indicating this property definition defines a bean object.
 boolean isBeanExistenceKnown()
          Returns true if a bean is known to exist before parsing its child fields.
 boolean isDefinitionFor(Object bean)
          Deprecated. use defines(Object)
 boolean isPropertyTypeMap()
          Returns true if the property type of this bean object is assignable to java.util.Map.
 boolean isRecordIdentifer()
          Deprecated. use PropertyDefinition.isRecordIdentifier()
 boolean matches(Record record)
          Test if a record matches this record definition.
protected  Object parsePropertyValue(Record record)
          Validates and parses a record into a Java bean.
 void setBeanProperty(PropertyDefinition property, Object bean, Object value)
          Sets a property on a bean object created by this definition.
 void setPropertyList(List<PropertyDefinition> list)
          Sets the list of properties that make up this bean.
 void setPropertyType(Class<?> type)
          Sets the property type of this bean, or if this bean is a collection, the property type of the collection value.
 void setRecordIdentifer(boolean recordIdentifer)
          Deprecated. use PropertyDefinition.setRecordIdentifier(boolean)
 
Methods inherited from class org.beanio.parser.PropertyDefinition
getCollectionType, getLength, getMaxOccurs, getMinOccurs, getName, getParent, getPropertyDescriptor, getPropertyType, isArray, isCollection, isConstant, isField, isLazy, isProperty, isRecordIdentifier, parseValue, setCollectionType, setLazy, setLength, setMaxOccurs, setMinOccurs, setName, setParent, setProperty, setPropertyDescriptor, setRecordIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanDefinition

public BeanDefinition()
Creates a new BeanDefinition.

Method Detail

isBean

public final boolean isBean()
Returns true indicating this property definition defines a bean object.

Overrides:
isBean in class PropertyDefinition
Returns:
true

matches

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

Specified by:
matches in class PropertyDefinition
Parameters:
record - the record to test
Returns:
true if all key fields are matched by this record

parsePropertyValue

protected Object parsePropertyValue(Record record)
                             throws InvalidRecordException
Validates and parses a record into a Java bean.

Specified by:
parsePropertyValue in class PropertyDefinition
Parameters:
record - the record to parse
Returns:
the parsed Java bean
Throws:
InvalidRecordException

isBeanExistenceKnown

public boolean isBeanExistenceKnown()
Returns true if a bean is known to exist before parsing its child fields. If false is returned, at least one bean field must exist in the stream before the bean is created.

Returns:
true if a bean is known to exist before parsing its fields

setBeanProperty

public void setBeanProperty(PropertyDefinition property,
                            Object bean,
                            Object value)
Sets a property on a bean object created by this definition.

Parameters:
property - the property definition
bean - the bean to set the property on
value - the property value to set

getBeanProperty

public Object getBeanProperty(PropertyDefinition definition,
                              Object bean)
Retrieves a property from a bean object created by this definition.

Parameters:
definition - the property definition
bean - the bean to get the property from
Returns:
the property value

defines

public boolean defines(Object bean)
Description copied from class: PropertyDefinition
Tests whether this definition is used to map the given bean or property value. If this property is not used to identify records, the return value of this method is undefined.

Specified by:
defines in class PropertyDefinition
Parameters:
bean - the bean or property value to test
Returns:
true if this definition is used to map the given value

isDefinitionFor

public boolean isDefinitionFor(Object bean)
Deprecated. use defines(Object)

Tests if this bean definition describes a given bean object.

Parameters:
bean - the bean object to test
Returns:
true if the bean definition describes the bean object

getAllFields

public List<FieldDefinition> getAllFields()
Returns a list of all field definition descendants of this bean.

Returns:
the list of field definitions

formatRecord

public abstract Object formatRecord(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

addProperty

public void addProperty(PropertyDefinition f)
Adds a property definition to this bean definition.

Parameters:
f - the property definition to add

getProperty

public PropertyDefinition getProperty(int index)
Returns the property definition.

Parameters:
index - the index of the property definition
Returns:
the property definition
Throws:
IndexOutOfBoundsException - if there is no property definition for the given index

getPropertyList

public List<PropertyDefinition> getPropertyList()
Returns the list of properties that make up this bean.

Returns:
the list of properties that make up this bean

getPropertyCount

public int getPropertyCount()
Returns the number of properties that make up this bean.

Returns:
the number of properties

setPropertyList

public void setPropertyList(List<PropertyDefinition> list)
Sets the list of properties that make up this bean.

Parameters:
list - the list of properties that make up this bean

setPropertyType

public void setPropertyType(Class<?> type)
Sets the property type of this bean, or if this bean is a collection, the property type of the collection value.

Overrides:
setPropertyType in class PropertyDefinition
Parameters:
type - the property type of this bean

isPropertyTypeMap

public boolean isPropertyTypeMap()
Returns true if the property type of this bean object is assignable to java.util.Map.

Returns:
true if the property type of this bean is a Map

isRecordIdentifer

public boolean isRecordIdentifer()
Deprecated. use PropertyDefinition.isRecordIdentifier()

Returns true if any field descendant of this bean definition is used to identify the record.

Returns:
true if any field descendant of this bean definition is used to identify the record

setRecordIdentifer

public void setRecordIdentifer(boolean recordIdentifer)
Deprecated. use PropertyDefinition.setRecordIdentifier(boolean)

Sets whether any field descendant of this bean definition is used to identify the reccord.

Parameters:
recordIdentifer - true if any field descendant of this bean definition is used to identify the record

BeanIO 1.2.3

Copyright © 2010-2012 Kevin Seim