JAVA/CORBA クラス
例:getDocumentByUNID メソッド
1 次のエージェントは、現在のデータベース内にあるすべての返答文書の親文書を取得します。
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();
DocumentCollection dc = db.getAllDocuments();
Document doc = dc.getFirstDocument();
while (doc != null) {
if (doc.isResponse()) {
Document pdoc =
db.getDocumentByUNID(doc.getParentDocumentUNID());
String docSubj = doc.getItemValueString("Subject");
String pdocSubj = pdoc.getItemValueString("Subject");
System.out.println("\"" + pdocSubj +
"\" has the response \"" + docSubj + "\"");
}
doc = dc.getNextDocument(doc);
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
2 次のエージェントは、NotesError.NOTES_ERR_BAD_UNID をトラップする例を示します。エラーを発生させるため、UNID は故意に変えてあります。
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();
DocumentCollection dc = db.getAllDocuments();
Document doc = dc.getFirstDocument();
while (doc != null) {
if (doc.isResponse()) {
String docSubj = "";
try {
docSubj = doc.getItemValueString("Subject");
// Deliberately munge UNID
String badUNID = "Z" +
doc.getParentDocumentUNID().substring(1);
Document pdoc = db.getDocumentByUNID(badUNID);
String pdocSubj = pdoc.getItemValueString("Subject");
System.out.println("\"" + pdocSubj +
"\" has the response \"" + docSubj + "\"");
} catch(NotesException ne) {
if (ne.id == NotesError.NOTES_ERR_BAD_UNID)
System.out.println("Bad UNID for \"" + docSubj + "\"");
else throw ne;
}
}
doc = dc.getNextDocument(doc);
}
} catch(NotesException ne) {
System.out.println(ne.id + " " + ne.text);
} catch(Exception e) {
e.printStackTrace();
}
}
}
関連項目
getDocumentByUNID メソッド
用語集
フィードバック
ヘルプ
または
プロダクトユーザビリティ
?
ヘルプの使い方
すべてのヘルプ項目
用語集