public final class Segment
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Segment.FieldValue
The value of a field (scalar or composite).
|
Constructor and Description |
---|
Segment(java.lang.String id)
Construct an empty segment with the given ID.
|
Segment(java.lang.String id,
int sizeHint)
Construct an empty segment with a hint about its final size.
|
Segment(java.lang.String id,
java.util.List<java.util.List<Segment.FieldValue>> fieldValues)
Construct a segment with the given ID and list of field values.
|
Modifier and Type | Method and Description |
---|---|
void |
addFieldValue(int fieldNo,
Segment.FieldValue v)
Add a value to a given field.
|
void |
addFieldValue(int fieldNo,
java.lang.String value)
Add a scalar value to a given field.
|
void |
clearFieldValues(int fieldNo)
Clear any values from a given field
|
static Segment |
copyOf(Segment orig)
Create and return a new Segment that is a deep copy of the given segment.
|
java.lang.String |
getFieldValue(int fieldNo)
Equivalent to
getFieldValue(fieldNo, 1, 0, 0) . |
java.lang.String |
getFieldValue(int fieldNo,
int componentNo)
Equivalent to
getFieldValue(fieldNo, 1, componentNo, 0) . |
java.lang.String |
getFieldValue(int fieldNo,
int componentNo,
int subcomponentNo)
Equivalent to
getFieldValue(fieldNo, 1, componentNo, subcomponentNo) . |
java.lang.String |
getFieldValue(int fieldNo,
int repetition,
int componentNo,
int subcomponentNo)
Return the string value of a given field/component/subcomponent, or the empty string ("") if
the requested value does not exist, or is a null value.
|
java.lang.String |
getId()
Get the ID of this segment (ex.
|
void |
putFieldValues(int fieldNo,
java.util.List<Segment.FieldValue> repeatedFieldValues)
Add or replace values for a field.
|
void |
setFieldValue(int fieldNo,
int repetition,
int componentNo,
int subcomponentNo,
java.lang.String value)
Set the scalar value for a specified field/repetition/component/subcomponent.
|
void |
setFieldValue(int fieldNo,
int componentNo,
int subcomponentNo,
java.lang.String value)
|
void |
setFieldValue(int fieldNo,
int componentNo,
java.lang.String value)
Equivalent to
setFieldValue(fieldNo, 1, componentNo, 0, value) . |
void |
setFieldValue(int fieldNo,
java.lang.String value)
Equivalent to
setFieldValue(fieldNo, 1, 0, 0, value) . |
java.lang.String |
toString() |
public Segment(java.lang.String id)
public Segment(java.lang.String id, java.util.List<java.util.List<Segment.FieldValue>> fieldValues)
id
- segment IDfieldValues
- a list of list of field values. The outer list index represents the field #,
and the inner list index represents the field repetitions.public Segment(java.lang.String id, int sizeHint)
id
- segment IDsizeHint
- hint as to the total number of fields for which we should allocate our
internal data structurespublic java.lang.String getId()
public java.lang.String getFieldValue(int fieldNo, int repetition, int componentNo, int subcomponentNo)
fieldNo
- field number (>= 1)
repetition
- the repetition number, for fields that have repeated values (>= 1)
componentNo
- component number (or 0, to indicate no component)subcomponentNo
- subcomponent number (or 0, to indicate no subcomponent)public java.lang.String getFieldValue(int fieldNo)
getFieldValue(fieldNo, 1, 0, 0)
.public java.lang.String getFieldValue(int fieldNo, int componentNo)
getFieldValue(fieldNo, 1, componentNo, 0)
.public java.lang.String getFieldValue(int fieldNo, int componentNo, int subcomponentNo)
getFieldValue(fieldNo, 1, componentNo, subcomponentNo)
.public void putFieldValues(int fieldNo, java.util.List<Segment.FieldValue> repeatedFieldValues)
fieldNo
- field number (>= 1)repeatedFieldValues
- list of repetitions of field values; a null value clears
the fieldpublic void clearFieldValues(int fieldNo)
fieldNo
- field number (>= 1)public void addFieldValue(int fieldNo, Segment.FieldValue v)
fieldNo
- field number (>= 1)v
- field value to addpublic void addFieldValue(int fieldNo, java.lang.String value)
fieldNo
- field number (>= 1)value
- scalar field value to addpublic void setFieldValue(int fieldNo, int repetition, int componentNo, int subcomponentNo, java.lang.String value)
fieldNo
- field number (>= 1)
repetition
- the repetition number, for fields that have repeated values (>= 1)
componentNo
- component number (or 0, to indicate no component)subcomponentNo
- subcomponent number (or 0, to indicate no subcomponent)value
- scalar value to setpublic void setFieldValue(int fieldNo, java.lang.String value)
setFieldValue(fieldNo, 1, 0, 0, value)
.public void setFieldValue(int fieldNo, int componentNo, java.lang.String value)
setFieldValue(fieldNo, 1, componentNo, 0, value)
.public void setFieldValue(int fieldNo, int componentNo, int subcomponentNo, java.lang.String value)
public static Segment copyOf(Segment orig)
public java.lang.String toString()
toString
in class java.lang.Object