Class NarrativeFragment


  • public class NarrativeFragment
    extends java.lang.Object
    Simple POJO for a fragment in a StructuredNarrative.

    This model contains the narrative text, the line index (1 based) and the line length.

    It is used by the StructuredNarrative class to get additional information of each line in the narrative.

    Since:
    9.4.16
    • Constructor Summary

      Constructors 
      Constructor Description
      NarrativeFragment​(java.lang.String text)
      Creates a new fragment without line index or length.
      NarrativeFragment​(java.lang.String text, int lineIndex, int lineLength)
      Creates a new fragment.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLineIndex()
      This is the 1-based index of the line in the complete narrative.
      int getLineLength()
      This is the length of the complete line in the original field value before parsing.
      java.lang.String getText()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NarrativeFragment

        public NarrativeFragment​(java.lang.String text)
        Creates a new fragment without line index or length.
        Parameters:
        text - narrative line text
      • NarrativeFragment

        public NarrativeFragment​(java.lang.String text,
                                 int lineIndex,
                                 int lineLength)
        Creates a new fragment.
        Parameters:
        text - narrative line text
        lineIndex - complete narrative line index
        lineLength - complete line length
    • Method Detail

      • getText

        public java.lang.String getText()
      • getLineIndex

        public int getLineIndex()
        This is the 1-based index of the line in the complete narrative. Thus, regardless of the codeword position and on the number of line continuations, this index reflects this particular fragment position in the original field value before parsing. And it can be used for example to know if the fragment was located in the first line of the field value.
        Returns:
        1-based index of the line this fragment belongs to, in the complete field value
      • getLineLength

        public int getLineLength()
        This is the length of the complete line in the original field value before parsing. Thus, this number could contain for example the length of the codeword and slash separators before the actual narrative fragment, or when it is not the first fragment for a given codeword this could contain the length of the double slash used as continuation indicator. All in all, this value will be at least the size of the fragment, and in most cases it will be more. The purpose of this value is to provide a hint of the original line length, which could be used when reassembling the complete narrative for a codeword.
        Returns:
        the length of the complete line in the original field value before parsing
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object