Examples: Categories property (Database - Java)

  1. This agent prints the categories of the current database.
    import lotus.domino.*;
    public class JavaAgent extends AgentBase {
      public void NotesMain() {
        try {
          Session session = getSession();
          AgentContext agentContext = 
              session.getAgentContext();
          // (Your code goes here) 
          Database db = agentContext.getCurrentDatabase();
          String title = db.getTitle();
          String cat = db.getCategories();
          if (cat != "")
            System.out.println("Database \"" +
            title + "\" has the categories: " + cat);
          else
            System.out.println("Database \"" +
            title + "\" has no categories");
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This agent sets the Categories property of the current database to "Examples database."
    import lotus.domino.*;
    public class JavaAgent extends AgentBase {
      public void NotesMain() {
        try {
          Session session = getSession();
          AgentContext agentContext = 
              session.getAgentContext();
          // (Your code goes here) 
          Database db = agentContext.getCurrentDatabase();
          db.setCategories("Examples database");
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }