Program: 69064
Project: 69064
Buggy source:
/** 
 * Validates target elements can contain transfer data. <p> If transfer data is single element, validate target's container also
 * @param targetObj target elements
 * @param transferData transfer data,single object or array are permitted
 * @param validateContainer validate target's container can contain
 * @return If target elements can't be dropped, return CONTAIN_NO.<p> If target elements can be dropped, return CONTAIN_THIS. <p> If target's container can be dropped, return CONTAIN_PARENT
 */
public static int handleValidateTargetCanContain(Object targetObj,Object transferData,boolean validateContainer){
  if (targetObj == null || transferData == null)   return CONTAIN_NO;
  if (transferData instanceof StructuredSelection) {
    return handleValidateTargetCanContain(targetObj,((StructuredSelection)transferData).toArray(),validateContainer);
  }
 else   if (transferData instanceof Object[]) {
    Object[] array=(Object[])transferData;
    if (array.length == 1) {
      return handleValidateTargetCanContain(targetObj,array[0],validateContainer);
    }
    int canContainAll=CONTAIN_NO;
    for (int i=0; i < array.length; i++) {
      int canContain=handleValidateTargetCanContain(targetObj,array[i],validateContainer);
      if (i == 0) {
        canContainAll=canContain;
      }
      if (canContain == CONTAIN_NO || canContain != canContainAll) {
        return CONTAIN_NO;
      }
    }
    return canContainAll;
  }
 else {
    if (transferData instanceof DesignElementHandle) {
      return handleValidateTargetCanContainByContainer(targetObj,(DesignElementHandle)transferData,validateContainer);
    }
 else     if (transferData instanceof ColumnBandData) {
      if (targetObj instanceof ColumnHandle) {
        return handleValidateContainColumnPaste((ColumnHandle)targetObj,(ColumnBandData)transferData,false) ? CONTAIN_PARENT : CONTAIN_NO;
      }
      return CONTAIN_NO;
    }
 else     if (transferData instanceof IDesignElement) {
      DesignElementHandle childHandle=((IDesignElement)transferData).getHandle(SessionHandleAdapter.getInstance().getReportDesignHandle().getModule());
      return handleValidateTargetCanContainByContainer(targetObj,childHandle,validateContainer);
    }
 else     if (transferData instanceof IElementCopy) {
      DesignElementHandle childHandle=((IElementCopy)transferData).getHandle(SessionHandleAdapter.getInstance().getReportDesignHandle());
      return handleValidateTargetCanContainByContainer(targetObj,childHandle,validateContainer);
    }
 else     if (transferData instanceof SlotHandle) {
      SlotHandle slot=(SlotHandle)transferData;
      Object[] childHandles=slot.getContents().toArray();
      return handleValidateTargetCanContainByContainer(targetObj,childHandles,validateContainer);
    }
 else     if (transferData instanceof IStructure) {
      return handleValidateTargetCanContainStructure(targetObj,(IStructure)transferData) ? CONTAIN_THIS : CONTAIN_NO;
    }
 else     if (transferData instanceof EmbeddedImageHandle) {
      if (targetObj instanceof ReportDesignHandle && ((EmbeddedImageHandle)transferData).getElementHandle().getRoot() instanceof LibraryHandle)       return CONTAIN_THIS;
 else       if (targetObj instanceof EmbeddedImageNode)       return CONTAIN_THIS;
 else       return CONTAIN_NO;
    }
 else {
      return CONTAIN_NO;
    }
  }
}

Fixed version (ground truth):
/** 
 * Validates target elements can contain transfer data. <p> If transfer data is single element, validate target's container also
 * @param targetObj target elements
 * @param transferData transfer data,single object or array are permitted
 * @param validateContainer validate target's container can contain
 * @return If target elements can't be dropped, return CONTAIN_NO.<p> If target elements can be dropped, return CONTAIN_THIS. <p> If target's container can be dropped, return CONTAIN_PARENT
 */
public static int handleValidateTargetCanContain(Object targetObj,Object transferData,boolean validateContainer){
  if (targetObj == null || transferData == null)   return CONTAIN_NO;
  if (transferData instanceof StructuredSelection) {
    return handleValidateTargetCanContain(targetObj,((StructuredSelection)transferData).toArray(),validateContainer);
  }
 else   if (transferData instanceof Object[]) {
    Object[] array=(Object[])transferData;
    if (array.length == 1) {
      return handleValidateTargetCanContain(targetObj,array[0],validateContainer);
    }
    int canContainAll=CONTAIN_NO;
    for (int i=0; i < array.length; i++) {
      int canContain=handleValidateTargetCanContain(targetObj,array[i],validateContainer);
      if (i == 0) {
        canContainAll=canContain;
      }
      if (canContain == CONTAIN_NO || canContain != canContainAll) {
        return CONTAIN_NO;
      }
    }
    return canContainAll;
  }
 else {
    if (transferData instanceof DesignElementHandle) {
      return handleValidateTargetCanContainByContainer(targetObj,(DesignElementHandle)transferData,validateContainer);
    }
 else     if (transferData instanceof ColumnBandData) {
      if (targetObj instanceof ColumnHandle) {
        return handleValidateContainColumnPaste((ColumnHandle)targetObj,(ColumnBandData)transferData,false) ? CONTAIN_PARENT : CONTAIN_NO;
      }
      return CONTAIN_NO;
    }
 else     if (transferData instanceof IDesignElement) {
      DesignElementHandle childHandle=((IDesignElement)transferData).getHandle(SessionHandleAdapter.getInstance().getReportDesignHandle().getModule());
      return handleValidateTargetCanContainByContainer(targetObj,childHandle,validateContainer);
    }
 else     if (transferData instanceof IElementCopy) {
      DesignElementHandle childHandle=((IElementCopy)transferData).getHandle(SessionHandleAdapter.getInstance().getReportDesignHandle());
      if (targetObj instanceof SlotHandle) {
        SlotHandle targetHandle=(SlotHandle)targetObj;
        return CopyUtil.canPaste((IElementCopy)transferData,targetHandle.getElementHandle(),targetHandle.getSlotID()) ? CONTAIN_THIS : CONTAIN_NO;
      }
      if (targetObj instanceof PropertyHandle) {
        PropertyHandle targetHandle=(PropertyHandle)targetObj;
        return CopyUtil.canPaste((IElementCopy)transferData,targetHandle.getElementHandle(),targetHandle.getPropertyDefn().getName()) ? CONTAIN_THIS : CONTAIN_NO;
      }
      return handleValidateTargetCanContainByContainer(targetObj,childHandle,validateContainer);
    }
 else     if (transferData instanceof SlotHandle) {
      SlotHandle slot=(SlotHandle)transferData;
      Object[] childHandles=slot.getContents().toArray();
      return handleValidateTargetCanContainByContainer(targetObj,childHandles,validateContainer);
    }
 else     if (transferData instanceof IStructure) {
      return handleValidateTargetCanContainStructure(targetObj,(IStructure)transferData) ? CONTAIN_THIS : CONTAIN_NO;
    }
 else     if (transferData instanceof EmbeddedImageHandle) {
      if (targetObj instanceof ReportDesignHandle && ((EmbeddedImageHandle)transferData).getElementHandle().getRoot() instanceof LibraryHandle)       return CONTAIN_THIS;
 else       if (targetObj instanceof EmbeddedImageNode)       return CONTAIN_THIS;
 else       return CONTAIN_NO;
    }
 else {
      return CONTAIN_NO;
    }
  }
}