Class CharSequenceList

java.lang.Object
com.pnfsoftware.jeb.util.base.CharSequenceList
All Implemented Interfaces:
CharSequence

public class CharSequenceList extends Object implements CharSequence
Manager for a list of CharSequence, itself a CharSequence.

Sequences in the list are joined with a new-line character. Example in pseudo-code:
CharSequence("abc", "def") => "abc\ndef\n"

  • Constructor Details

    • CharSequenceList

      public CharSequenceList(List<CharSequence> elts)
      Create an object from a list of CharSequence objects. The list is not deeply copied. The caller must ensure its contents is not modified after construction.
      Parameters:
      elts - list of strings
  • Method Details

    • length

      public int length()
      Specified by:
      length in interface CharSequence
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • toString

      public String toString()
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object
    • toString

      public String toString(int maxCharsPerLine, int charsEndLine)
      Format this sequence as a string while optionally shortening long lines.
      Parameters:
      maxCharsPerLine - maximum number of characters to keep per line
      charsEndLine - number of trailing characters to preserve when a line is shortened
      Returns:
      formatted string
    • getLine

      public static CharSequence getLine(CharSequence line, int maxCharsPerLine, int charsEndLine)
      Shorten a line if it exceeds the provided length limit.
      Parameters:
      line - input line
      maxCharsPerLine - maximum number of characters to keep
      charsEndLine - number of trailing characters to preserve
      Returns:
      the original line, or a shortened line containing an ellipsis marker