4.4 Working with FieldValues

The Document.FieldValue class in the Oracle I/PM API is used to provide document metadata when indexing a document. FieldValues are passed to createDocument as a java.util.List of Document.FieldValue instances. Each FieldValue in the list will map to a FieldDefinition in the application.

The Document.FieldValue object behaves similarly to NameId definition classes in that they can be defined to map to an application field definition by either Field ID or Field Name. If both are supplied, then the ID value supersedes the name value.

A Document.FieldValue also contains a value property. The type of the value must be be compatible with the I/PM FieldType of the field definition. The I/PM type of the value is automatically determined by the Java type used. The following table lists the I/PM field types and the corresponding compatible Java types.

I/PM Field Type Java Type
FieldType.Date java.util.Date, java.util.GregorianCalendar
FieldType.Decimal java.math.BigDecimal, float, decimal
FieldType.Number Integer, Long,
FieldType.Text String

In the table, the Java types in bold are the native types associated with the FieldType. The FieldValue will coerce other types in the table into the native type. Caution should be used when using types other than the native types since precision on the value may sometime be lost during the coercion process.

When FieldValues are use with createDocument, all field values that are defined as required must be supplied. For fields that are not required, it is also possible to deliberately set the value to null by including the FieldValue in the list but setting the FieldValue's value to null. When doing this, the FieldValue cannot determine the necessary field type based on the null Java type, so the FieldValue constructor accepting an I/PM FieldType must be used.