JAVA/CORBA CLASSES
Examples: getChild, getNextSibling, and getParent methods
1. This agent gets view entries in a hierarchy down to three levels using different variables to represent the entries at different levels.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
String getEntryType(ViewEntry entry) {
String t = null;
try {
if (entry.isCategory()) t = "category";
else if (entry.isDocument()) t = "document";
else if (entry.isTotal()) t = "total"; }
catch (Exception e) {
e.printStackTrace(); }
return t; }
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext =
session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
View view = db.getView("By Category");
view.setAutoUpdate(false);
ViewNavigator nav = view.createViewNav();
int n = 0;
String tabs = null;
ViewEntry tmpentry;
ViewEntry entry = nav.getFirst();
while (entry != null) {
n++;
System.out.println
("Entry #" + n + " is a " + getEntryType(entry));
ViewEntry tmpentry2;
ViewEntry entry2 = nav.getChild(entry);
while (entry2 != null) {
n++;
System.out.println
("\tEntry #" + n + " is a " +
getEntryType(entry2));
ViewEntry tmpentry3;
ViewEntry entry3 = nav.getChild(entry2);
while (entry3 != null) {
n++;
System.out.println
("\t\tEntry #" + n + " is a " +
getEntryType(entry3));
tmpentry3 = nav.getNextSibling(entry3);
entry3.recycle();
entry3 = tmpentry3; }
tmpentry2 = nav.getNextSibling(entry2);
entry2.recycle();
entry2 = tmpentry2; }
tmpentry = nav.getNextSibling(entry);
entry.recycle();
entry = tmpentry; }
} catch(Exception e) {
e.printStackTrace();
}
}
}
2. This agent gets view entries in a hierarchy down to three levels using one variable to represent the entries at different levels.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
String getEntryType(ViewEntry entry) {
String t = null;
try {
if (entry.isCategory()) t = "category";
else if (entry.isDocument()) t = "document";
else if (entry.isTotal()) t = "total"; }
catch (Exception e) {
e.printStackTrace(); }
return t; }
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext =
session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
View view = db.getView("By Category");
view.setAutoUpdate(false);
ViewNavigator nav = view.createViewNav();
int n = 0;
ViewEntry entry = nav.getFirst();
while (entry != null) {
n++;
System.out.println
("Entry #" + n + " is a " + getEntryType(entry));
entry = nav.getChild();
if (entry != null) {
while (entry != null) {
n++;
System.out.println
("\tEntry #" + n + " is a " +
getEntryType(entry));
entry = nav.getChild();
if (entry != null) {
while (entry != null) {
n++;
System.out.println
("\t\tEntry #" + n + " is a " +
getEntryType(entry));
entry = nav.getNextSibling(); }
entry = nav.getParent(); }
entry = nav.getNextSibling(); }
entry = nav.getParent(); }
entry = nav.getNextSibling(); }
} catch(Exception e) {
e.printStackTrace();
}
}
}
See Also
getChild method
getNextSibling method
getParent method
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary