Class TextView
- All Implemented Interfaces:
ResourceView
This view integrates the V2 TextViewport for high-fidelity streaming
of large files and implements self-aware reactivity to viewport settings
changes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TextViewportThe viewport engine for processing text.Fields inherited from class AbstractResourceView
owner, tokenCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAuthoritatively retrieves the processed viewport text content for this view, ensuring the owner resource has executed reloadIfNeeded() so that content is guaranteed to be loaded.Returns a machine-readable header summarizing the interpretation state.Provides system instructions if the resource is in that position.intReturns the token count for the current processed state of this viewdoubleReturns the percentage of the underlying resource content currently visible or provided by this view to the model.booleanChecks whether this view currently has its in-memory content loaded and ready.booleanChecks whether this view's content is currently truncated or clipped (i.e. less than 100% of the underlying resource is visible).voidpopulateRag(RagMessage ragMessage) Populates the RAG message with the appropriate parts (Text or Blob).voidreload()Reloads and processes the content from the source.toString()Methods inherited from class AbstractResourceView
markDirty, resetTokenCountModifier and TypeMethodDescriptionvoidTriggers a markDirty on the owner resource to signal that the view's settings have changed and need re-interpretation, and clears the cached token count.voidResets the cached token count of this view, forcing a lazy recalculation on the next query.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceView
setOwner
-
Field Details
-
viewport
The viewport engine for processing text.
-
-
Constructor Details
-
TextView
public TextView()Constructs a default TextView and links the viewport engine. -
TextView
Constructs a TextView and links it to its parent resource.- Parameters:
owner- The owning resource.
-
TextView
Constructs a TextView with specific initial settings.- Parameters:
owner- The owning resource.settings- The initial viewport configuration.
-
-
Method Details
-
reload
-
populateRag
Populates the RAG message with the appropriate parts (Text or Blob).Adds the processed text chunk to the RAG message, wrapped in markdown.
- Parameters:
ragMessage- The target RAG message.- Throws:
Exception- if population fails.
-
getInstructions
Provides system instructions if the resource is in that position. Returns a list of processed text blocks.Returns the processed text for system instruction injection.
- Returns:
- A list of instruction strings.
- Throws:
Exception- if instruction generation fails.
-
getHeader
Description copied from interface:ResourceViewReturns a machine-readable header summarizing the interpretation state.Technical Purity: The first line always contains the implementation class FQN. The second line provides the salient interpretation details (e.g., viewport metrics).
- Returns:
- The header string.
-
toString
-
isTruncated
public boolean isTruncated()Checks whether this view's content is currently truncated or clipped (i.e. less than 100% of the underlying resource is visible).Evaluates viewport settings to determine if content is truncated, checking full-view status, character limits, offsets, grep, and tailing.
- Returns:
- true if truncated, false if 100% complete.
-
getVisiblePercentage
public double getVisiblePercentage()Returns the percentage of the underlying resource content currently visible or provided by this view to the model.For unclipped or complete views (e.g. full-view text or complete media), this returns 100.0. For paginated, clipped, or truncated views, returns a value between 0.0 and 100.0.
Calculates the exact percentage of characters currently visible in prompt memory. If even a single character is missing from EOF or pagination, ensures the value never rounds up to 100.0%.
- Returns:
- The percentage of visible content, from 0.0 to 100.0.
-
hasContent
public boolean hasContent()Checks whether this view currently has its in-memory content loaded and ready.Returns true if the viewport has processed and cached visible content.
- Returns:
- true if content is resident in memory, false if cold or uninitialized.
-
getContent
Authoritatively retrieves the processed viewport text content for this view, ensuring the owner resource has executed reloadIfNeeded() so that content is guaranteed to be loaded.- Returns:
- The visible viewport text content.
- Throws:
Exception- if reading fails.
-
getTokenCount
public int getTokenCount()Returns the token count for the current processed state of this view. * * @return The token count.Performs a lazy, model-specific token calculation of the active viewport content, caching the result to prevent redundant, CPU-intensive tokenization.
-

