Getting an item and its values in Java classes

If you do not know the name of an item or want to traverse the items in a document, use getItems in Document; getItems returns a vector of Item objects. As you access each vector element, use the Item methods to interrogate and manipulate the object.

To access an item whose name is known, use getFirstItem in Document. Use hasItem in Document to determine if a document contains a named item.

From the Document level, getItemValueDouble, getItemValueInteger, and getItemValueString are convenient for obtaining the value of a numeric or text item that holds a single value; use getItemValueDateTimeArray to get the value or values of a date-time item. From the Item level, use getDateTimeValue, getValueDouble, getValueInteger, and getValueString to get a single date-time, numeric, or text value; use getValueDateTimeArray to get multiple date-time values. Use getItemValue in Document and getValues in Item to get the values of a single or multi-value item; getItemValue and getValues return a vector of Object objects, which must be cast to DateTime, Double, Integer, or String. In Item, containsValue determines the existence of elements in multi-value text items.

Use getText of Item to get a text rendition of an item of any type. Multi-value items are rendered with a separator, typically the semicolon, between elements. Use abstract to get a condensed text rendition of an item.

To get the text values of the items named Received in a document, use getReceivedItemText.

If multiple items in a document have the same name, programmatic access is limited to the first item. The remaining items yield invalid data. A work-around is to get the first item, process it, remove it, again get the first item (which was the second item), and so on until you process and remove all the items of a particular name. If you do not save the document, the items are not actually removed. However, the recommendation is that you avoid creating multiple items with the same name.