public class Segment extends ParserComponent
Parser components, such as fields
and other segments.
A segment may be bound to a Property by calling
setProperty(Property).
Repeating segments will always marshal a value when marshal(MarshallingContext)
is called. If not repeating, lazy segments are only marshalled if hasContent(ParsingContext)
returns true.
| Constructor and Description |
|---|
Segment()
Constructs a new Segment.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearValue(ParsingContext context)
Clears the current property value.
|
Property |
getProperty() |
int |
getSize()
Returns the size of a single occurrence of this element, which is used to offset
field positions for repeating segments and fields.
|
Object |
getValue(ParsingContext context)
Returns the unmarshalled property value.
|
boolean |
hasContent(ParsingContext context)
Returns whether this parser or any of its descendant have content for marshalling.
|
boolean |
isExistencePredetermined() |
boolean |
isIdentifier()
Returns whether this parser or any descendant of this parser is used to identify
a record during unmarshalling.
|
boolean |
isOptional()
Returns whether this node must exist during unmarshalling.
|
boolean |
isRepeating() |
boolean |
marshal(MarshallingContext context)
Marshals a record.
|
boolean |
matches(UnmarshallingContext context)
Returns whether this parser and its children match a record
being unmarshalled.
|
void |
registerLocals(Set<ParserLocal<?>> locals)
Called by a stream to register variables stored in the parsing context.
|
void |
setExistencePredetermined(boolean existencePredetermined) |
void |
setIdentifier(boolean identifier) |
void |
setOptional(boolean optional) |
void |
setProperty(Property property) |
void |
setRepeating(boolean repeating) |
void |
setSize(int size) |
void |
setValue(ParsingContext context,
Object value)
Sets the property value for marshaling.
|
protected void |
toParamString(StringBuilder s)
Called by
TreeNode.toString() to append node parameters to the output. |
boolean |
unmarshal(UnmarshallingContext context)
Unmarshals a record.
|
isSupportedChildadd, clone, find, getChildren, getFirst, getName, isDescendant, iterator, print, print, setName, size, sort, toString, updateReferencesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic void clearValue(ParsingContext context)
Parsercontext - the ParsingContextpublic boolean matches(UnmarshallingContext context)
Parsercontext - the UnmarshallingContextpublic boolean unmarshal(UnmarshallingContext context)
Parsercontext - the UnmarshallingContextpublic boolean marshal(MarshallingContext context) throws IOException
Parsercontext - the MarshallingContextIOException - if an I/O error occurspublic boolean hasContent(ParsingContext context)
Parsercontext - the ParsingContextpublic Object getValue(ParsingContext context)
Parsercontext - the ParsingContextpublic void setValue(ParsingContext context, Object value)
Parsercontext - the ParsingContextvalue - the property valuepublic Property getProperty()
public void setProperty(Property property)
public boolean isOptional()
Parserpublic void setOptional(boolean optional)
public void setSize(int size)
public int getSize()
ParserThe concept of size is dependent on the stream format. The size of an element in a fixed length stream format is determined by the length of the element in characters, while other stream formats calculate size based on the number of fields. Some stream formats, such as XML, may ignore size settings.
public boolean isIdentifier()
Parserpublic void setIdentifier(boolean identifier)
public void registerLocals(Set<ParserLocal<?>> locals)
ComponentregisterLocals in class Componentlocals - set of local variablespublic boolean isExistencePredetermined()
public void setExistencePredetermined(boolean existencePredetermined)
public boolean isRepeating()
public void setRepeating(boolean repeating)
protected void toParamString(StringBuilder s)
TreeNodeTreeNode.toString() to append node parameters to the output.toParamString in class TreeNode<Component>s - the output to append