* @param objectType the object type
* @return a new resource object wrapper
*/
public ResourceObject createResource(AbstractNamedAFPObject namedObj,
AFPResourceInfo resourceInfo, Registry.ObjectType objectType) {
ResourceObject resourceObj = null;
String resourceName = resourceInfo.getName();
if (resourceName != null) {
resourceObj = factory.createResource(resourceName);
} else {
resourceObj = factory.createResource();
}
if (namedObj instanceof Document) {
resourceObj.setType(ResourceObject.TYPE_DOCUMENT);
} else if (namedObj instanceof PageSegment) {
resourceObj.setType(ResourceObject.TYPE_PAGE_SEGMENT);
} else if (namedObj instanceof Overlay) {
resourceObj.setType(ResourceObject.TYPE_OVERLAY_OBJECT);
} else if (namedObj instanceof AbstractDataObject) {
AbstractDataObject dataObj = (AbstractDataObject)namedObj;
if (namedObj instanceof ObjectContainer) {
resourceObj.setType(ResourceObject.TYPE_OBJECT_CONTAINER);
// set object classification
final boolean dataInContainer = true;
final boolean containerHasOEG = false; // must be included
final boolean dataInOCD = true;
// mandatory triplet for object container
resourceObj.setObjectClassification(
ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
objectType, dataInContainer, containerHasOEG, dataInOCD);
} else if (namedObj instanceof ImageObject) {
// ioca image type
resourceObj.setType(ResourceObject.TYPE_IMAGE);
} else if (namedObj instanceof GraphicsObject) {
resourceObj.setType(ResourceObject.TYPE_GRAPHIC);
} else {
throw new UnsupportedOperationException(
"Unsupported resource object for data object type " + dataObj);
}
} else {
throw new UnsupportedOperationException(
"Unsupported resource object type " + namedObj);
}
// set the resource information/classification on the data object
resourceObj.setDataObject(namedObj);
return resourceObj;
}