BeanIO 2.0.4

org.beanio.internal.config
Class SegmentConfig

java.lang.Object
  extended by org.beanio.internal.util.TreeNode<ComponentConfig>
      extended by org.beanio.internal.config.ComponentConfig
          extended by org.beanio.internal.config.PropertyConfig
              extended by org.beanio.internal.config.SegmentConfig
All Implemented Interfaces:
Cloneable, Iterable<ComponentConfig>, Replicateable
Direct Known Subclasses:
RecordConfig

public class SegmentConfig
extends PropertyConfig

A segment is used to combine fields, constants and other segments. Wrapper component may also be added to segment.

A segment can be bound to a bean object by calling PropertyConfig.setType(String). (The bound attribute is ignored for segments- setting type to null has the same effect as setting bound to false.)

A segment may repeat if its maximum occurrences is greater than one, and be bound to a collection or array by calling PropertyConfig.setCollection(String).

Segments will have their position calculated automatically during compilation.

The constant attribute is set during compilation, and is meant for internal use only.

Since:
2.0
Author:
Kevin Seim

Field Summary
 
Fields inherited from class org.beanio.internal.config.PropertyConfig
JSON_TYPE_ARRAY, JSON_TYPE_BOOLEAN, JSON_TYPE_NONE, JSON_TYPE_NUMBER, JSON_TYPE_OBJECT, JSON_TYPE_STRING
 
Fields inherited from class org.beanio.internal.config.ComponentConfig
CONSTANT, FIELD, GROUP, RECORD, SEGMENT, STREAM, WRAPPER
 
Constructor Summary
SegmentConfig()
          Constructs a new SegmentConfig.
 
Method Summary
 char getComponentType()
          Returns the component type.
 boolean getDefaultExistence()
          Returns the default existence setting for this segment as calculated during pre-processing.
 String getKey()
          Returns the name of the property descendant to use for the Map key when collection is set to map.
 List<PropertyConfig> getPropertyList()
          Returns a list of all immediate children including segments, fields and constants and the immediate children of any wrapper child.
 String getTarget()
          Returns the name of the target property for this segment.
 boolean isConstant()
          Returns whether this segment is used to define a bean constant.
 boolean isLazy()
          Returns whether the property assigned to this segment should only be instantiated if at least one child element is not null or the empty string.
protected  boolean isSupportedChild(ComponentConfig child)
          Returns whether a node is a supported child of this node.
 void setConstant(boolean constant)
          Sets whether this segment is used to define a bean constant.
 void setDefaultExistence(boolean defaultExistence)
          Sets the default existence for this segment, which is calculated during pre-processing.
 void setKey(String key)
          Sets the name of the property descendant to use for the Map key when collection is set to map.
 void setLazy(boolean lazy)
          Sets whether the property assigned to this segment should only be instantiated if at least one child element is not null or the empty string.
 void setTarget(String target)
          Sets the name of the target property for this segment, which can be used in lieu of class to return simple field types contained within the segment.
 
Methods inherited from class org.beanio.internal.config.PropertyConfig
getCollection, getGetter, getJsonArrayIndex, getJsonName, getJsonType, getMaxOccurs, getMaxSize, getMinOccurs, getMinSize, getPosition, getSetter, getType, getUntil, getXmlType, isBound, isCollection, isIdentifier, isJsonArray, isNillable, isRepeating, setBound, setCollection, setGetter, setIdentifier, setJsonArray, setJsonArrayIndex, setJsonName, setJsonType, setMaxOccurs, setMaxSize, setMinOccurs, setMinSize, setNillable, setPosition, setSetter, setType, setUntil, setXmlType
 
Methods inherited from class org.beanio.internal.config.ComponentConfig
getXmlName, getXmlNamespace, getXmlPrefix, isXmlNamespaceAware, setXmlName, setXmlNamespace, setXmlNamespaceAware, setXmlPrefix
 
Methods inherited from class org.beanio.internal.util.TreeNode
add, clone, find, getChildren, getFirst, getName, iterator, print, setName, size, sort, toParamString, toString, updateReferences
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SegmentConfig

public SegmentConfig()
Constructs a new SegmentConfig.

Method Detail

getComponentType

public char getComponentType()
Description copied from class: ComponentConfig
Returns the component type.

Specified by:
getComponentType in class ComponentConfig
Returns:
one of ComponentConfig.GROUP, ComponentConfig.RECORD, ComponentConfig.SEGMENT, ComponentConfig.FIELD, ComponentConfig.CONSTANT or ComponentConfig.WRAPPER

getPropertyList

public List<PropertyConfig> getPropertyList()
Returns a list of all immediate children including segments, fields and constants and the immediate children of any wrapper child.

Returns:
list of children

isConstant

public boolean isConstant()
Returns whether this segment is used to define a bean constant.

Returns:
true if there is no field descendant of this segment

setConstant

public void setConstant(boolean constant)
Sets whether this segment is used to define a bean constant.

Parameters:
constant - true if there is no field descendant of this segment

isSupportedChild

protected boolean isSupportedChild(ComponentConfig child)
Description copied from class: TreeNode
Returns whether a node is a supported child of this node. Called by TreeNode.add(TreeNode).

Overrides:
isSupportedChild in class PropertyConfig
Parameters:
child - the node to test
Returns:
true if the child is allowed

getDefaultExistence

public boolean getDefaultExistence()
Returns the default existence setting for this segment as calculated during pre-processing.

Returns:
the default existence

setDefaultExistence

public void setDefaultExistence(boolean defaultExistence)
Sets the default existence for this segment, which is calculated during pre-processing.

Parameters:
defaultExistence - the default existence

getKey

public String getKey()
Returns the name of the property descendant to use for the Map key when collection is set to map.

Overrides:
getKey in class PropertyConfig
Returns:
the key property name

setKey

public void setKey(String key)
Sets the name of the property descendant to use for the Map key when collection is set to map.

Parameters:
key - the key property name

getTarget

public String getTarget()
Returns the name of the target property for this segment.

Returns:
the target property name

setTarget

public void setTarget(String target)
Sets the name of the target property for this segment, which can be used in lieu of class to return simple field types contained within the segment.

Parameters:
target - the target property name

isLazy

public boolean isLazy()
Returns whether the property assigned to this segment should only be instantiated if at least one child element is not null or the empty string.

Overrides:
isLazy in class PropertyConfig

setLazy

public void setLazy(boolean lazy)
Sets whether the property assigned to this segment should only be instantiated if at least one child element is not null or the empty string.

Parameters:
lazy - the new lazy value

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim