Class PartNode


public class PartNode extends AbstractContextNode<AbstractPart>
A context tree node representing a single part of a message.
Author:
anahata
  • Constructor Details

    • PartNode

      public PartNode(AgiPanel agiPanel, AbstractPart userObject)
      Constructs a new PartNode.
      Parameters:
      agiPanel - The parent agi panel.
      userObject - The part to wrap.
  • Method Details

    • getName

      public String getName()
      Gets the human-readable display name for this node.

      Implementation details: Returns the simple class name of the part (e.g., TextPart, BlobPart) along with its sequential ID.

      Specified by:
      getName in class AbstractContextNode<AbstractPart>
      Returns:
      The name to be displayed in the tree.
    • getDescription

      public String getDescription()
      Gets a detailed description of the node's purpose or content.

      Implementation details: Returns a basic description including the concrete type of the message part.

      Specified by:
      getDescription in class AbstractContextNode<AbstractPart>
      Returns:
      The description string.
    • fetchChildObjects

      protected List<?> fetchChildObjects()
      Fetches the current list of domain objects that should be represented as children of this node.

      Implementation details: Parts are leaf nodes and do not have child objects.

      Specified by:
      fetchChildObjects in class AbstractContextNode<AbstractPart>
      Returns:
      A list of domain objects.
    • createChildNode

      protected AbstractContextNode<?> createChildNode(Object obj)
      Creates a new child node for the given domain object.
      Specified by:
      createChildNode in class AbstractContextNode<AbstractPart>
      Parameters:
      obj - The domain object to wrap.
      Returns:
      A new AbstractContextNode, or null if the object type is not supported.
    • calculateLocalTokens

      protected void calculateLocalTokens()
      Calculates the token counts for this node's own content (excluding children).

      Implementation details: Retrieves the token count directly from the underlying domain part for history metrics.

      Specified by:
      calculateLocalTokens in class AbstractContextNode<AbstractPart>
    • isActive

      public boolean isActive()
      Checks if the underlying domain object is currently active in the context.

      Subclasses override this method to define their specific active-state policy, allowing for clean, polymorphic evaluation without dirty instanceof chains.

      Specified by:
      isActive in class AbstractContextNode<AbstractPart>
      Returns:
      true if active, false otherwise.
    • updateStatus

      protected void updateStatus()
      Updates the status string for this node.

      Implementation details: Includes the remaining depth metric in the status string to visualize the Context Window Garbage Collection (CwGC) state.

      Specified by:
      updateStatus in class AbstractContextNode<AbstractPart>