Examples: Name class

  1. This agent creates a hierarchical name and displays its Common, Abbreviated, and Canonical properties.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
    
          // Create a hierarchical name
          Name nam = session.createName(
            "CN=John B Goode/OU=Sales/OU=East/O=Acme/C=US");
    
          // Returns:
          // John B Goode
          // John B Goode/Sales/East/Acme/US
          // CN=John B Goode/OU=Sales/OU=East/O=Acme/C=US
          System.out.println(nam.getCommon());
          System.out.println(nam.getAbbreviated());
          System.out.println(nam.getCanonical());
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This agent creates an Internet address and displays its Addr822Phrase, Addr821, Addr822Comment1, Addr822Comment2, and Addr822Comment3 properties.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
    
          // Create a hierarchical name
          Name nam = session.createName(
            "\"John B Goode\" <jbg@us.acme.com> (Guitars) (Music) (East)");
            
          // Returns:
          // "John B Goode"
          // jbg@us.acme.com
          // Guitars
          // Music
          // East
          System.out.println(nam.getAddr822Phrase());
          System.out.println(nam.getAddr821());
          System.out.println(nam.getAddr822Comment1());
          System.out.println(nam.getAddr822Comment2());
          System.out.println(nam.getAddr822Comment3());
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  3. This agent displays the Common, Abbreviated, and Canonical properties of the user name.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
    
          // Get user name
          Name nam = session.createName(session.getUserName());
      
          // Display common, abbreviated, and canonical formats
          System.out.println(nam.getCommon());
          System.out.println(nam.getAbbreviated());
          System.out.println(nam.getCanonical());
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  4. This agent gets the SendTo item of the current document, a mail message, and displays its Addr821 property.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          Document doc = agentContext.getDocumentContext();
    
          // Create NotesName from SendTo item
          // We expect an Internet name
          Name nam = session.createName(doc.getItemValueString("SendTo"));
      
          // Display Addr821 name
          System.out.println(nam.getAddr821());
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }