hcl-bot
September 10, 2003, 2:03am
1
Hi I tried to convertsome of my scribt to java, but it seems not to work.
In my code I try to get all designelement in a Database by the method GetdocumentbyId.
It works well in scribt but does not in Java
Scribtcode that works:
Dim Doc As NotesDocument
Dim i As Long
For i=1 To 65535
Set Doc=Db.GetDocumentByID(Hex$(i))
Forall x In Doc.Items
Print x
End Forall
Next
When I activate my Java-code I get following message.
java.lang.NullPointerException
at JavaAgent.NotesMain(JavaAgent.java:16)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(NotesThread.java:208)
Javacode:
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
long i;
for (i=1; i<=65535; i=i+1) {
String Hexstringvalue =Long.toHexString(i);
Document doc = db.getDocumentByID(Hexstringvalue);
Vector items = doc.getItems();
System.out.println(Hexstringvalue);
for (int j=0; j<items.size(); j++) {
Item item = (Item)items.elementAt(j);
System.out.println(“\t” + item.getName());
}
}
hcl-bot
September 10, 2003, 4:06am
2
Subject: ScribtCode createt in Java
I think you can not guarantee that every ID is in your database. So when you make a getDocumentbyid with an id which is not there you get “null” back. So you must check in your code for null values.
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
long i;
for (i=1; i<=65535; i=i+1) {
String Hexstringvalue =Long.toHexString(i);
Document doc = db.getDocumentByID(Hexstringvalue);
if (doc!=null){
Vector items = doc.getItems();
System.out.println(Hexstringvalue);
for (int j=0; j<items.size(); j++) {
Item item = (Item)items.elementAt(j);
System.out.println(“\t” + item.getName());
}
}
}
Greetings from Austria
Ralf M Petter
hcl-bot
September 10, 2003, 5:32am
3
Subject: RE: ScribtCode createt in Java
I think I already check that the Doc not is Null.Other suggestions.
hcl-bot
September 10, 2003, 6:05am
4
Subject: RE: ScribtCode createt in Java
In the code you have posted you do not check for null values!!! please post your actual code or i can not help you!
hcl-bot
September 10, 2003, 9:11am
5
Subject: RE: ScribtCode createt in Java
Correct I did not test if the Doc was null.Thanks it works now.