BeanIO 2.0.4

org.beanio.internal.parser.format.xml
Class XmlElementField

java.lang.Object
  extended by org.beanio.internal.parser.format.xml.XmlFieldFormat
      extended by org.beanio.internal.parser.format.xml.XmlElementField
All Implemented Interfaces:
FieldFormat, XmlNode

public class XmlElementField
extends XmlFieldFormat

A FieldFormat for a field in an XML formatted stream parsed as an element of its parent.

Since:
2.0
Author:
Kevin Seim

Field Summary
 
Fields inherited from interface org.beanio.internal.parser.format.xml.XmlNode
XML_TYPE_ATTRIBUTE, XML_TYPE_ELEMENT, XML_TYPE_NONE, XML_TYPE_TEXT
 
Constructor Summary
XmlElementField()
          Constructs a new XmlElementField.
 
Method Summary
 String extractText(XmlUnmarshallingContext context)
          Extracts a field from a record during unmarshalling.
 String getLocalName()
          Returns the XML local name for this node.
 String getNamespace()
          Returns the namespace of this node.
 String getPrefix()
          Returns the namespace prefix for marshaling this node, or null if the namespace should override the default namespace.
 int getType()
          Returns the XML node type.
 void insertText(XmlMarshallingContext ctx, String fieldText)
          Inserts a field into the record during marshalling.
 boolean isNamespaceAware()
          Returns true if a namespace was configured for this node, and is therefore used to unmarshal and marshal the node.
 boolean isNillable()
          Returns whether this field is nillable.
 boolean isRepeating()
          Returns whether this node may repeat in the context of its immediate parent.
 void setLocalName(String localName)
          Sets the element name.
 void setNamespace(String namespace)
          Sets the namespace of this element.
 void setNamespaceAware(boolean namespaceAware)
          Sets whether this element is namespace aware.
 void setNillable(boolean nillable)
          Sets whether this element is nillable.
 void setPrefix(String prefix)
          Sets a prefix to use for the namespace during marshalling.
 void setRepeating(boolean repeating)
          Sets whether this element repeats within the context of its parent.
 void toParamString(StringBuilder s)
          Called by XmlFieldFormat.toString() to append attributes of this field.
 
Methods inherited from class org.beanio.internal.parser.format.xml.XmlFieldFormat
extract, getName, getPadding, getSize, insertField, insertValue, isLazy, setLazy, setName, setPadding, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlElementField

public XmlElementField()
Constructs a new XmlElementField.

Method Detail

extractText

public String extractText(XmlUnmarshallingContext context)
Description copied from class: XmlFieldFormat
Extracts a field from a record during unmarshalling.

Specified by:
extractText in class XmlFieldFormat
Parameters:
context - the XmlUnmarshallingContext holding the record
Returns:
the extracted field text

insertText

public void insertText(XmlMarshallingContext ctx,
                       String fieldText)
Description copied from class: XmlFieldFormat
Inserts a field into the record during marshalling.

Specified by:
insertText in class XmlFieldFormat
Parameters:
ctx - the XmlMarshallingContext holding the record
fieldText - the field text to insert

isRepeating

public boolean isRepeating()
Description copied from interface: XmlNode
Returns whether this node may repeat in the context of its immediate parent.

Returns:
true if this node repeats, false otherwise

setRepeating

public void setRepeating(boolean repeating)
Sets whether this element repeats within the context of its parent.

Parameters:
repeating - true if repeating, false otherwise

getType

public int getType()
Description copied from interface: XmlNode
Returns the XML node type.

Returns:
one of XmlNode.XML_TYPE_NONE, XmlNode.XML_TYPE_ELEMENT, XmlNode.XML_TYPE_ATTRIBUTE, or XmlNode.XML_TYPE_TEXT

getLocalName

public String getLocalName()
Description copied from interface: XmlNode
Returns the XML local name for this node.

Returns:
the XML local name

setLocalName

public void setLocalName(String localName)
Sets the element name.

Parameters:
localName - the element name

getNamespace

public String getNamespace()
Description copied from interface: XmlNode
Returns the namespace of this node. If there is no namespace for this node, or this node is not namespace aware, null is returned.

Returns:
the XML namespace of this node

setNamespace

public void setNamespace(String namespace)
Sets the namespace of this element.

Parameters:
namespace - the namespace

getPrefix

public String getPrefix()
Description copied from interface: XmlNode
Returns the namespace prefix for marshaling this node, or null if the namespace should override the default namespace.

Returns:
the namespace prefix

setPrefix

public void setPrefix(String prefix)
Sets a prefix to use for the namespace during marshalling.

Parameters:
prefix - the namespace prefix

isNillable

public boolean isNillable()
Description copied from interface: FieldFormat
Returns whether this field is nillable.

Returns:
true if nillable, false otherwise

setNillable

public void setNillable(boolean nillable)
Sets whether this element is nillable.

Parameters:
nillable - true if nillable, false otherwise

isNamespaceAware

public boolean isNamespaceAware()
Description copied from interface: XmlNode
Returns true if a namespace was configured for this node, and is therefore used to unmarshal and marshal the node.

Returns:
true if this node uses a namespace for matching and formatting this node

setNamespaceAware

public void setNamespaceAware(boolean namespaceAware)
Sets whether this element is namespace aware.

Parameters:
namespaceAware - true if namespace aware, false otherwise

toParamString

public void toParamString(StringBuilder s)
Description copied from class: XmlFieldFormat
Called by XmlFieldFormat.toString() to append attributes of this field.

Overrides:
toParamString in class XmlFieldFormat
Parameters:
s - the text to append

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim