Class TextUtils

java.lang.Object
uno.anahata.ai.internal.TextUtils

public class TextUtils extends Object
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 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 TextChunk object containing metadata and the processed text.
    • isNullOrEmpty

      public static boolean isNullOrEmpty(Object value)
      Checks if an object is null, a blank string, or an empty collection/map.
      Parameters:
      value - The object to check.
      Returns:
      true if the object is considered null or empty.
    • formatValue

      public static String formatValue(Object value)
      Formats a value for display in a summary, escaping newlines and truncating in the middle if necessary.
      Parameters:
      value - The object to format.
      Returns:
      A formatted, truncated string.