Item (Java)

Represents a discrete value or set of values in a document.

The client interface displays items in a document through fields on a form. When a field on a form and an item in a document have the same name, the field displays the item (for example, the Subject field displays the Subject item).

All items in a document are accessible programmatically, regardless of what form is used to display the document in the user interface.

Syntax

public class Item extends Base

Derived Classes

RichTextItem inherits from Item class.

Containment

Contained by: Document

Contains: DateTime, MIMEEntity

Properties

DateTimeValue through getDateTimeValue and setDateTimeValue

InputSource through getInputSource

InputSource through getInputStream

IsAuthors through isAuthors and setAuthors

IsEncrypted through isEncrypted and setEncrypted

IsNames through isNames and setNames

IsProtected through isProtected and setProtected

IsReaders through isReaders and setReaders

IsSaveToDisk through isSaveToDisk and setSaveToDisk

IsSigned through isSigned and setSigned

IsSummary through isSummary and setSummary

LastModified through getLastModified

Name through getName

Parent through getParent

Reader through getReader

Text through getText

Type through getType

ValueDouble through getValueDouble and setValueDouble

ValueInteger through getValueInteger and setValueInteger

ValueLength through getValueLength

Values through getValues and setValues

ValueString through getValueString and setValueString

Methods

abstractText

appendToTextList

containsValue

copyItemToDocument

getMIMEEntity

getValueCustomData

getValueCustomDataBytes

getValueDateTimeArray

parseXML

recycle

remove

setValueCustomData

setValueCustomDataBytes

toString

transformXML

Creation

To create a new Item object:

  • To create a new Item object from scratch, use replaceItemValue in Document. The method appendItemValue also creates an item, but creates another item of the same name if the specified item exists. Use replaceItemValue unless your intent is to create another item with the same name (not recommended).
  • To create a new Item object from one that already exists, use copyItemToDocument, copyItem, or replaceItemValue in Document.

You must call save on the document if you want the modified document to be saved to disk. The document won't display the new item in the user interface unless there is a field of the same name on the form used to display the document.

Explicitly call setSummary and specify true if you want the value to be displayed in a view or folder.

Access

To access an existing Item object:

  • To access an item when you know its name, use getFirstItem in Document.
  • To access all the items in a document, use getItems in Document.

Document has methods to access items without creating an Item object. You need to know the name of the item.

  • To get an item's value, use getItemValue.
  • To create a new item or set an item's value, use replaceItemValue.
  • To check for the existence of a particular item in a document, use hasItem.
  • To delete an item from a document, use removeItem.

Rich-text items

RichTextItem inherits the properties and methods of Item and has additional properties and methods you can use to manipulate rich text.

Saving Changes

After you create or modify an item, you must save the changes by calling the parent document's save method.

If you don't call save before the program finishes, all of your changes to an Item object are lost.

Example