Package com.pnfsoftware.jeb.util.base
Class CharSequenceList
java.lang.Object
com.pnfsoftware.jeb.util.base.CharSequenceList
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionCharSequenceList(List<CharSequence> elts) Create an object from a list of CharSequence objects. -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int index) static CharSequencegetLine(CharSequence line, int maxCharsPerLine, int charsEndLine) Shorten a line if it exceeds the provided length limit.intlength()subSequence(int start, int end) toString()toString(int maxCharsPerLine, int charsEndLine) Format this sequence as a string while optionally shortening long lines.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
CharSequenceList
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:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
toString
Format this sequence as a string while optionally shortening long lines.- Parameters:
maxCharsPerLine- maximum number of characters to keep per linecharsEndLine- number of trailing characters to preserve when a line is shortened- Returns:
- formatted string
-
getLine
Shorten a line if it exceeds the provided length limit.- Parameters:
line- input linemaxCharsPerLine- maximum number of characters to keepcharsEndLine- number of trailing characters to preserve- Returns:
- the original line, or a shortened line containing an ellipsis marker
-