Class TextUtils
java.lang.Object
uno.anahata.ai.internal.TextUtils
Utility methods for processing and formatting text content.
This class includes logic for paginating large text blocks, filtering lines with regex, and truncating long lines for efficient context management.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatValue(Object value) Formats a value for display in a summary, escaping newlines and truncating in the middle if necessary.static booleanisNullOrEmpty(Object value) Checks if an object is null, a blank string, or an empty collection/map.static TextChunkprocessText(String text, Integer startIndex, Integer pageSize, String grepPattern, Integer maxLineLength) Processes a block of text with pagination, filtering, and line truncation.
-
Constructor Details
-
TextUtils
public TextUtils()
-
-
Method Details
-
processText
public static TextChunk processText(String text, Integer startIndex, Integer pageSize, String grepPattern, Integer maxLineLength) Processes a block of text with pagination, filtering, and line truncation.- Parameters:
text- The full text content to process.startIndex- The starting line number (0-based) for pagination. Can be null.pageSize- The number of lines to return. Can be null for no limit.grepPattern- A regex pattern to filter lines. Can be null or empty.maxLineLength- The maximum length of each line. Lines longer than this will be truncated. Can be null or 0 for no limit.- Returns:
- A
TextChunkobject containing metadata and the processed text.
-
isNullOrEmpty
Checks if an object is null, a blank string, or an empty collection/map.- Parameters:
value- The object to check.- Returns:
trueif the object is considered null or empty.
-
formatValue
-
