{
arrayOptions = new PropertyOptions();
}
if (!arrayOptions.isOnlyArrayOptions())
{
throw new XMPException("Only array form flags allowed for arrayOptions",
XMPError.BADOPTIONS);
}
// Check if array options are set correctly.
arrayOptions = XMPNodeUtils.verifySetOptions(arrayOptions, null);
// Locate or create the array. If it already exists, make sure the array
// form from the options
// parameter is compatible with the current state.
XMPPath arrayPath = XMPPathParser.expandXPath(schemaNS, arrayName);
// Just lookup, don't try to create.
XMPNode arrayNode = XMPNodeUtils.findNode(tree, arrayPath, false, null);
if (arrayNode != null)
{
// The array exists, make sure the form is compatible. Zero
// arrayForm means take what exists.
if (!arrayNode.getOptions().isArray())
{
throw new XMPException("The named property is not an array", XMPError.BADXPATH);
}
// if (arrayOptions != null && !arrayOptions.equalArrayTypes(arrayNode.getOptions()))
// {
// throw new XMPException("Mismatch of existing and specified array form", BADOPTIONS);
// }
}
else
{
// The array does not exist, try to create it.
if (arrayOptions.isArray())
{
arrayNode = XMPNodeUtils.findNode(tree, arrayPath, true, arrayOptions);
if (arrayNode == null)
{
throw new XMPException("Failure creating array node", XMPError.BADXPATH);
}
}
else
{
// array options missing
throw new XMPException("Explicit arrayOptions required to create new array",
XMPError.BADOPTIONS);
}
}
doSetArrayItem(arrayNode, ARRAY_LAST_ITEM, itemValue, itemOptions, true);