Class StructuredNarrativeField
- java.lang.Object
-
- com.prowidesoftware.swift.model.field.Field
-
- com.prowidesoftware.swift.model.field.StructuredNarrativeField
-
- All Implemented Interfaces:
JsonSerializable
,NarrativeContainer
,PatternContainer
- Direct Known Subclasses:
Field29A
,Field37N
,Field45B
,Field46B
,Field47B
,Field49M
,Field49N
,Field70
,Field71B
,Field71D
,Field71E
,Field72
,Field72Z
,Field73
,Field73A
,Field74
,Field75
,Field76
,Field77
,Field77A
,Field77B
,Field77D
,Field77J
public abstract class StructuredNarrativeField extends Field implements NarrativeContainer
Common API for fields supporting a structured narrative option.These fields support having a simple unstructured content splitted in lines and also a structured version with codewords. The codewords are separated with slashes and can be use to categorize part of the narrative content.
Different structured line formats are defined depending on the field number and letter option. This API provides a simple way to get portions of the structured narrative using the code words, regardless of the specific line format the field supports.
- Since:
- 9.0.1
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COMPONENTS_PATTERN
Deprecated.UsetypesPattern()
insteadstatic java.lang.String
PARSER_PATTERN
static java.lang.String
TYPES_PATTERN
Types pattern Contains a description of the type of each component-
Fields inherited from class com.prowidesoftware.swift.model.field.Field
components, labelMap
-
-
Constructor Summary
Constructors Constructor Description StructuredNarrativeField()
Default constructor.StructuredNarrativeField(java.lang.String value)
Creates a new field and initializes its components with content from the parameter value.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description NarrativeContainer
appendLine(java.lang.String line)
Appends a line of content to this field.java.lang.String
componentsPattern()
Deprecated.UsetypesPattern()
insteadint
componentsSize()
Returns the defined amount of components.
This is not the amount of components present in the field instance, but the total amount of components that this field accepts as defined.java.lang.String
getComponent1()
Gets the single field component with the complete consolidated narrative content.java.util.List<java.lang.String>
getComponentLabels()
Returns english label for components.protected java.util.Map<java.lang.Integer,java.lang.String>
getComponentMap()
Returns a mapping between component numbers and their label in camel case format.protected java.util.Map<java.lang.String,java.lang.Integer>
getLabelMap()
Returns a mapping between component labels and the internal component number.abstract java.lang.String
getName()
Returns the field's name composed by the field number and the letter option (if any)java.lang.String
getValue()
Serializes the fields' components into the single string value (SWIFT format)java.lang.String
getValueDisplay(int component, java.util.Locale locale)
Returns a localized suitable for showing to humans string of a field component.boolean
isGeneric()
Returns true if the field is a GENERIC FIELD as specified by the standard.boolean
isOptional(int component)
Given a component number it returns true if the component is optional, regardless of the field being mandatory in a particular message.Narrative
narrative()
Parses the field content into a narrative model.void
parse(java.lang.String value)
Parses the parameter value into the internal components structure.java.lang.String
parserPattern()
Returns the field parser patternNarrativeContainer
setNarrative(Narrative narrative)
Sets or overrides this field value serializing the content of the structured narrative provided by parameter.java.lang.String
typesPattern()
Returns the field component types pattern This method returns a letter representing the type for each component in the Field.abstract java.lang.String
validatorPattern()
Returns the field validator pattern, that could vary er specific field-
Methods inherited from class com.prowidesoftware.swift.model.field.Field
append, appendInLines, appendInLines, asTag, componentNameToNumber, equals, findComponentStartingWith, format, formatAccount, formatNumber, fromJson, getAsBigDecimal, getComponent, getComponent, getComponentAs, getComponentAs, getComponentAsNumber, getComponentAsNumber, getComponentLabel, getComponentLabel, getComponents, getField, getField, getLabel, getLabel, getLabelComponents, getLine, getValueByCodeword, getValueDisplay, getValueDisplay, getValueDisplay, hashCode, init, is, is, is, is, isEmpty, isLetterOption, isNameAnyOf, joinComponents, joinComponents, joinComponents, joinComponents, letterOption, notNull, setComponent, setComponent, setComponents, toJson, toString, validName
-
-
-
-
Field Detail
-
PARSER_PATTERN
public static final java.lang.String PARSER_PATTERN
- See Also:
- Constant Field Values
-
COMPONENTS_PATTERN
@Deprecated @ProwideDeprecated(phase4=SRU2024) public static final java.lang.String COMPONENTS_PATTERN
Deprecated.UsetypesPattern()
instead- See Also:
- Constant Field Values
-
TYPES_PATTERN
public static final java.lang.String TYPES_PATTERN
Types pattern Contains a description of the type of each component- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StructuredNarrativeField
public StructuredNarrativeField()
Default constructor. Creates a new field setting all components to null.
-
StructuredNarrativeField
public StructuredNarrativeField(java.lang.String value)
Creates a new field and initializes its components with content from the parameter value.- Parameters:
value
- complete field value including separators and CRLF
-
-
Method Detail
-
parse
public void parse(java.lang.String value)
Parses the parameter value into the internal components structure.The narrative fields are modelled as a single String component containing the complete field value, with all its lines and structured content if any. The API provided for this class allows getting specific lines or specific portions of the structured narrative content with ease.
-
getValueDisplay
public java.lang.String getValueDisplay(int component, java.util.Locale locale)
Description copied from class:Field
Returns a localized suitable for showing to humans string of a field component.- Specified by:
getValueDisplay
in classField
- Parameters:
component
- number of the component to displaylocale
- optional locale to format date and amounts, if null, the default locale is used- Returns:
- formatted component value or null if component number is invalid or not present
-
getValue
public java.lang.String getValue()
Serializes the fields' components into the single string value (SWIFT format)
-
getName
public abstract java.lang.String getName()
Description copied from class:Field
Returns the field's name composed by the field number and the letter option (if any)
-
componentsPattern
@Deprecated @ProwideDeprecated(phase4=SRU2024) public final java.lang.String componentsPattern()
Deprecated.UsetypesPattern()
instead- Specified by:
componentsPattern
in classField
-
typesPattern
public final java.lang.String typesPattern()
Returns the field component types pattern This method returns a letter representing the type for each component in the Field. It supersedes the Components Pattern because it distinguishes between N (Number) and I (BigDecimal).- Specified by:
typesPattern
in interfacePatternContainer
- Specified by:
typesPattern
in classField
- Returns:
- the static value of TYPES_PATTERN
- See Also:
TYPES_PATTERN
-
parserPattern
public final java.lang.String parserPattern()
Returns the field parser pattern- Specified by:
parserPattern
in interfacePatternContainer
- Returns:
- the static value of PARSER_PATTERN
-
validatorPattern
public abstract java.lang.String validatorPattern()
Returns the field validator pattern, that could vary er specific field- Specified by:
validatorPattern
in classField
-
isOptional
public boolean isOptional(int component)
Given a component number it returns true if the component is optional, regardless of the field being mandatory in a particular message.- Specified by:
isOptional
in classField
- Parameters:
component
- component number, first component of a field is referenced as 1- Returns:
- always returns false since Narrative fields are modelled as a single mandatory component
-
isGeneric
public boolean isGeneric()
Returns true if the field is a GENERIC FIELD as specified by the standard.
-
componentsSize
public int componentsSize()
Returns the defined amount of components.
This is not the amount of components present in the field instance, but the total amount of components that this field accepts as defined.- Specified by:
componentsSize
in classField
- Returns:
- for narrative fields this method always returns 1
- Since:
- 7.7
-
getComponentLabels
public java.util.List<java.lang.String> getComponentLabels()
Returns english label for components.
The index in the list is in sync with specific field component structure.- Specified by:
getComponentLabels
in classField
- Returns:
- for Narrative fields returns a single element for the "Narrative" as a single component
- Since:
- 7.8.4
- See Also:
Field.getComponentLabel(int)
-
getComponentMap
protected java.util.Map<java.lang.Integer,java.lang.String> getComponentMap()
Returns a mapping between component numbers and their label in camel case format.- Specified by:
getComponentMap
in classField
- Returns:
- for Narrative fields returns a single entry for the "Narrative" as a single component
- Since:
- 7.10.3
-
getLabelMap
protected java.util.Map<java.lang.String,java.lang.Integer> getLabelMap()
Description copied from class:Field
Returns a mapping between component labels and the internal component number. Component labels are in lowercase and without spaces and separators. If a for a given component there is more than one label option, both are mapped to the same component number.- Specified by:
getLabelMap
in classField
- Since:
- 9.3.12
- See Also:
Field.getLabelMap()
-
getComponent1
public java.lang.String getComponent1()
Gets the single field component with the complete consolidated narrative content.- Returns:
- the narrative content
-
narrative
public Narrative narrative()
Description copied from interface:NarrativeContainer
Parses the field content into a narrative model.- Specified by:
narrative
in interfaceNarrativeContainer
- Returns:
- the content parsed into a Narrative or an empty Narrative it the field is not well-formed
- See Also:
NarrativeContainer.narrative()
-
appendLine
public NarrativeContainer appendLine(java.lang.String line)
Description copied from interface:NarrativeContainer
Appends a line of content to this field.The parameter line is added to the current value without restrictions or validation. This method is intended for use cases when the internal structure of the field is well-known and you are confident of the content that is added has valid line formats for the specific field.
- Specified by:
appendLine
in interfaceNarrativeContainer
- Parameters:
line
- a properly formatted line of content such as "/NAME/Joe Doe"- Returns:
- this field
- See Also:
NarrativeContainer.appendLine(String)
-
setNarrative
public NarrativeContainer setNarrative(Narrative narrative)
Description copied from interface:NarrativeContainer
Sets or overrides this field value serializing the content of the structured narrative provided by parameter.- Specified by:
setNarrative
in interfaceNarrativeContainer
- Parameters:
narrative
- a narrative instance- Returns:
- this field
- See Also:
NarrativeContainer.setNarrative(Narrative)
-
-