Examples: Getting text renditions of rich text items in Java classes

  1. This agent uses Document.getItemValueString to get a text rendition of the Body item in the first (or only) selected document.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          DocumentCollection dc = agentContext.getUnprocessedDocuments();
          Document doc = dc.getFirstDocument();
          String body = doc.getItemValueString("Body");
          System.out.println(body);
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This agent uses Item.getText to get a text rendition of the Body item in the first (or only) selected document.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          DocumentCollection dc = agentContext.getUnprocessedDocuments();
          Document doc = dc.getFirstDocument();
          Item item = doc.getFirstItem("Body");
          String body = item.getText();
          System.out.println(body);
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  3. This agent uses Item.getValueString to get a text rendition of the Body item in the first (or only) selected document.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          DocumentCollection dc = agentContext.getUnprocessedDocuments();
          Document doc = dc.getFirstDocument();
          Item item = doc.getFirstItem("Body");
          String body = item.getValueString();
          System.out.println(body);
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  4. This agent uses Item.abstractText to get an abbreviated text rendition of the Body item in the first (or only) selected document.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          DocumentCollection dc = agentContext.getUnprocessedDocuments();
          Document doc = dc.getFirstDocument();
          Item item = doc.getFirstItem("Body");
          String body = item.abstractText(32, true, false);
          System.out.println(body);
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  5. This agent uses RichTextItem.getFormattedText to get a modified text rendition of the Body item in the first (or only) selected document.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          DocumentCollection dc = agentContext.getUnprocessedDocuments();
          Document doc = dc.getFirstDocument();
          RichTextItem item = (RichTextItem)doc.getFirstItem("Body");
          String body = item.getFormattedText(true, 20, 0);
          System.out.println(body);
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  6. This agent uses RichTextItem.getUnformattedText to get a text rendition of the Body item in the first (or only) selected document.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          DocumentCollection dc = agentContext.getUnprocessedDocuments();
          Document doc = dc.getFirstDocument();
          RichTextItem item = (RichTextItem)doc.getFirstItem("Body");
          String body = item.getUnformattedText();
          System.out.println(body);
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }