Is it possible to get the index of a set of values in a document using Java just as you can do with indexOf()
in array? I have tried to look it up in the Notes help but could not find and helpful tip.

- 12,285
- 11
- 58
- 45

- 403
- 8
- 19
3 Answers
First you have to create a Vector of your item's values with getValues()
and then you can use indexOf()
:
Item item = doc.getFirstItem(itemName);
int index = item.getValues().indexOf("yourValue")
As an alternative, you can use Document's getItemValue()
to get the Vector of your item's values:
int index = doc.getItemValue(itemName).indexOf("yourValue")

- 30,880
- 4
- 31
- 67
No, you have to take the text from the document and to parse it. Take a look here.
-
indexOf() did not work with NotesItem i have tried that – simon peter Apr 19 '15 at 16:59
-
A solution is to put the document text into a data structure (like String), and after that you can parse easily. – florinm Apr 19 '15 at 17:26
After this line of code...
Vector v = session.evaluate("@Member(\"value\";\"itemName\")");
v.firstElement()
will contain the index of the value you are searching for, but it is one-based instead of zero-based. I.e., if the first value in the item matches the value you are looking for, the return is 1, not the 0 that would expect for indexOf() with a Java ArrayList.
Note: the fact that evaluate() returns a Vector seems odd in this context, but most Notes formula language constructs can return either a single value or a list, depending on values in the document, so it always returns a vector even when the formula really only returns one value.

- 14,463
- 2
- 23
- 41