|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.beanio.parser.PropertyDefinition
public abstract class PropertyDefinition
Base class for bean property settings. A property could be a simple field or a bean containing a list of its own properties.
Field Summary | |
---|---|
protected static String |
INVALID
Constant indicating the field did not pass validation. |
protected static String |
MISSING
Constant indicating the field was not present in the stream |
Constructor Summary | |
---|---|
PropertyDefinition()
Constructs a new PropertyDefinition. |
Method Summary | |
---|---|
abstract boolean |
defines(Object value)
Tests whether this definition is used to map the given bean or property value. |
Class<? extends Collection<Object>> |
getCollectionType()
Returns the collection type of this property, or null if this property is not a collection or array. |
int |
getLength()
Returns the maximum length of this property. |
int |
getMaxOccurs()
Returns the maximum occurrences of this property in a stream. |
int |
getMinOccurs()
Returns the minimum occurrences of this property in a stream. |
String |
getName()
Returns the property name. |
PropertyDefinition |
getParent()
Returns the parent property definition. |
PropertyDescriptor |
getPropertyDescriptor()
Returns the bean property descriptor for getting and setting a value for this property from its enclosing bean class. |
Class<?> |
getPropertyType()
Returns the class type of this property, or if this property is a collection, the class type of the collection value. |
boolean |
isArray()
Returns true if this property definition is for an array value. |
boolean |
isBean()
Returns whether this property describes a complex bean object that holds its own list of properties. |
boolean |
isCollection()
Returns true if this property definition is for a collection or array value. |
boolean |
isConstant()
Returns whether this property describes a constant value and does not map to field found in the stream. |
boolean |
isField()
Returns whether this property describes a field in the mapped stream. |
boolean |
isLazy()
Returns true if this property is only written to an output stream if the property value is not null. |
boolean |
isProperty()
Returns true if the value parsed by this property definition is a property of its enclosing bean. |
boolean |
isRecordIdentifier()
Returns true if the property or any descendant of this property definition is used to identify records. |
abstract boolean |
matches(Record record)
Tests if the field text in the record matches this field definition. |
protected abstract Object |
parsePropertyValue(Record record)
Parses and validates a field property value from the record. |
Object |
parseValue(Record record)
Validates and parses the value of this field from a record. |
void |
setCollectionType(Class<? extends Collection<Object>> collectionType)
Sets the collection type of this property. |
void |
setLazy(boolean lazy)
Set to true if this property is only written to an output stream if the property value is not null. |
void |
setLength(int length)
Sets the (maximum) length of this property. |
void |
setMaxOccurs(int maxOccurs)
Sets the maximum occurrences of this property in a stream. |
void |
setMinOccurs(int minOccurs)
Sets the minimum occurrences of this property in a stream. |
void |
setName(String name)
Sets the property name. |
void |
setParent(PropertyDefinition parent)
Sets the parent property definition. |
void |
setProperty(boolean property)
Set to true if the value parsed by this property definition is a property of its enclosing bean. |
void |
setPropertyDescriptor(PropertyDescriptor propertyDescriptor)
Sets the bean property descriptor for getting and setting a value for this property from its enclosing bean class. |
void |
setPropertyType(Class<?> type)
Sets the class type of this property, or if this property is a collection, the class type of the collection value. |
void |
setRecordIdentifier(boolean recordIdentifier)
Sets whether this property or any descendant of this property definition is used to identify records. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String INVALID
protected static final String MISSING
Constructor Detail |
---|
public PropertyDefinition()
Method Detail |
---|
public boolean isBean()
public boolean isField()
public boolean isConstant()
public abstract boolean matches(Record record)
record
- the record containing the field to test
public abstract boolean defines(Object value)
value
- the bean or property value to test
public Object parseValue(Record record)
record
- the record to parse and update with any field errors
MISSING
if the field was not present in the recordprotected abstract Object parsePropertyValue(Record record)
record
- the record to parse
INVALID
if the field was invalid,
or MISSING
if the field was not present in the recordpublic String getName()
public void setName(String name)
name
- the new property namepublic PropertyDescriptor getPropertyDescriptor()
public void setPropertyDescriptor(PropertyDescriptor propertyDescriptor)
propertyDescriptor
- the bean property descriptorpublic boolean isProperty()
public void setProperty(boolean property)
property
- true if the value parsed by this property definition is a property
of its enclosing beanpublic Class<?> getPropertyType()
public void setPropertyType(Class<?> type)
type
- the class type of this propertypublic int getLength()
setLength(int)
public void setLength(int length)
Delimited fields always have a length of 1, and fixed length fields have a configurable
For delimited records, the length is the number of fields. For fixed length records, the length is the number of characters. Thus a delimited field always has length of 1, while a fixed length field is configurable. For bean definitions, the length is the sum of all of its children.
Length is used to offset repeating fields that belong to a collection. All bean definitions for a collection type of with a collection type for a parent must have a fixed length. The value -1 may be returned in other cases.
length
- the length of the fields that make up this bean definitionpublic void setParent(PropertyDefinition parent)
parent
- the parent property definitionpublic PropertyDefinition getParent()
public Class<? extends Collection<Object>> getCollectionType()
TypeUtil.ARRAY_TYPE
if this property is an array,
or nullpublic void setCollectionType(Class<? extends Collection<Object>> collectionType)
TypeUtil.ARRAY_TYPE
. The collection type must be a concrete Collection
implementation, and cannot be abstract or an interface.
collectionType
- the collection type of this property, or TypeUtil.ARRAY_TYPE
for arrayspublic boolean isCollection()
public boolean isArray()
public int getMinOccurs()
public void setMinOccurs(int minOccurs)
minOccurs
- the minimum occurrences of this propertypublic int getMaxOccurs()
public void setMaxOccurs(int maxOccurs)
maxOccurs
- the maximum occurrences of this propertypublic boolean isLazy()
public void setLazy(boolean lazy)
lazy
- true to suppress writing null property values to an output streampublic boolean isRecordIdentifier()
public void setRecordIdentifier(boolean recordIdentifier)
recordIdentifier
- true if this property or any descendant of this property
definition is used to identify records
|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |