Example usage for java.util Vector toArray

List of usage examples for java.util Vector toArray

Introduction

In this page you can find the example usage for java.util Vector toArray.

Prototype

@SuppressWarnings("unchecked")
public synchronized <T> T[] toArray(T[] a) 

Source Link

Document

Returns an array containing all of the elements in this Vector in the correct order; the runtime type of the returned array is that of the specified array.

Usage

From source file:com.windroilla.invoker.gcm.MyGcmListenerService.java

/**
 * Called when message is received.//w w  w  .ja v a  2s.  c  o m
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
    String message = data.getString("message");
    Log.d(TAG, "From: " + from);
    Log.d(TAG, "Message: " + message);

    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        Log.i("Device ID ", deviceID);
        // normal downstream message.
        apiService.getBlockTimes(new RequestBlockTimes(deviceID)).subscribeOn(Schedulers.newThread())
                .observeOn(Schedulers.newThread()).subscribe(new Action1<BlockTimeList>() {
                    @Override
                    public void call(BlockTimeList blockTimeList) {
                        Log.d(TAG, blockTimeList.access_time);
                        Vector<ContentValues> cVVector = new Vector<ContentValues>(
                                blockTimeList.getBlockTimes().size());
                        AlarmManager mgrAlarm = (AlarmManager) getApplicationContext()
                                .getSystemService(ALARM_SERVICE);
                        ArrayList<PendingIntent> intentArray = new ArrayList<PendingIntent>();
                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        formatter.setLenient(false);

                        for (int i = 0; i < blockTimeList.getBlockTimes().size(); i++) {
                            BlockTime blockTime = blockTimeList.getBlockTimes().get(i);
                            Log.d(TAG,
                                    blockTime.getCourse_id() + " " + blockTime.getId() + " "
                                            + blockTime.getStarttime() + " " + blockTime.getEndtime() + " "
                                            + blockTime.getCreated_time());
                            ContentValues blockTimeValues = new ContentValues();
                            blockTimeValues.put(BlocktimeContract.BlocktimeEntry.COLUMN_START_TIME,
                                    blockTime.getStarttime());
                            blockTimeValues.put(BlocktimeContract.BlocktimeEntry.COLUMN_END_TIME,
                                    blockTime.getEndtime());
                            blockTimeValues.put(BlocktimeContract.BlocktimeEntry.COLUMN_CREATED_TIME,
                                    blockTime.getCreated_time());
                            Intent startIntent = new Intent(getBaseContext(), AlarmReceiver.class);
                            startIntent.setAction("com.windroilla.invoker.blockservice.start");
                            Intent endIntent = new Intent(getBaseContext(), AlarmReceiver.class);
                            endIntent.setAction("com.windroilla.invoker.blockservice.stop");
                            PendingIntent pendingStartIntent = PendingIntent.getBroadcast(
                                    getApplicationContext(), blockTime.getId(), startIntent,
                                    PendingIntent.FLAG_UPDATE_CURRENT);
                            PendingIntent pendingEndIntent = PendingIntent.getBroadcast(getApplicationContext(),
                                    -blockTime.getId(), endIntent, PendingIntent.FLAG_UPDATE_CURRENT);
                            try {
                                mgrAlarm.set(AlarmManager.RTC_WAKEUP,
                                        formatter.parse(blockTime.getStarttime()).getTime(),
                                        pendingStartIntent);
                                Log.d(TAG,
                                        formatter.parse(blockTime.getStarttime()).getTime() + " "
                                                + System.currentTimeMillis() + " "
                                                + (formatter.parse(blockTime.getStarttime()).getTime()
                                                        - System.currentTimeMillis()));
                                Log.d(TAG,
                                        formatter.parse(blockTime.getEndtime()).getTime() + " "
                                                + System.currentTimeMillis() + " "
                                                + (formatter.parse(blockTime.getEndtime()).getTime()
                                                        - System.currentTimeMillis()));
                                mgrAlarm.set(AlarmManager.RTC_WAKEUP,
                                        formatter.parse(blockTime.getEndtime()).getTime(), pendingEndIntent);
                            } catch (ParseException e) {
                                Log.e(TAG, e.toString());
                            }
                            intentArray.add(pendingStartIntent);
                            intentArray.add(pendingEndIntent);
                            cVVector.add(blockTimeValues);
                        }
                        Log.d(TAG, intentArray.size() + " PendingIntents have been progressed");
                        int inserted = 0;
                        // add to database
                        if (cVVector.size() > 0) {
                            ContentValues[] cvArray = new ContentValues[cVVector.size()];
                            cVVector.toArray(cvArray);
                            getBaseContext().getContentResolver()
                                    .bulkInsert(BlocktimeContract.BlocktimeEntry.CONTENT_URI, cvArray);
                        }

                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        Log.e(TAG, "BlockTimes Sync failed! " + throwable);
                    }
                });

    }

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */
    sendNotification(message);
    // [END_EXCLUDE]
}

From source file:SWTFileViewerDemo.java

/**
 * Handles a drop on a dropTarget.//  ww  w .  j a v a  2  s  .  c o m
 * <p>
 * Used in drop().<br>
 * Note event.detail is modified by this method.
 * </p>
 * 
 * @param event
 *            the DropTargetEvent passed as parameter to the drop() method
 * @param targetFile
 *            the File representing the drop target location under
 *            inspection, or null if none
 */
private void dropTargetHandleDrop(DropTargetEvent event, File targetFile) {
    // Get dropped data (an array of filenames)
    if (!dropTargetValidate(event, targetFile))
        return;
    final String[] sourceNames = (String[]) event.data;
    if (sourceNames == null)
        event.detail = DND.DROP_NONE;
    if (event.detail == DND.DROP_NONE)
        return;

    // Open progress dialog
    progressDialog = new ProgressDialog(shell,
            (event.detail == DND.DROP_MOVE) ? ProgressDialog.MOVE : ProgressDialog.COPY);
    progressDialog.setTotalWorkUnits(sourceNames.length);
    progressDialog.open();

    // Copy each file
    Vector /* of File */ processedFiles = new Vector();
    for (int i = 0; (i < sourceNames.length) && (!progressDialog.isCancelled()); i++) {
        final File source = new File(sourceNames[i]);
        final File dest = new File(targetFile, source.getName());
        if (source.equals(dest))
            continue; // ignore if in same location

        progressDialog.setDetailFile(source, ProgressDialog.COPY);
        while (!progressDialog.isCancelled()) {
            if (copyFileStructure(source, dest)) {
                processedFiles.add(source);
                break;
            } else if (!progressDialog.isCancelled()) {
                if (event.detail == DND.DROP_MOVE && (!isDragging)) {
                    // It is not possible to notify an external drag source
                    // that a drop
                    // operation was only partially successful. This is
                    // particularly a
                    // problem for DROP_MOVE operations since unless the
                    // source gets
                    // DROP_NONE, it will delete the original data including
                    // bits that
                    // may not have been transferred successfully.
                    MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.RETRY | SWT.CANCEL);
                    box.setText(getResourceString("dialog.FailedCopy.title"));
                    box.setMessage(
                            getResourceString("dialog.FailedCopy.description", new Object[] { source, dest }));
                    int button = box.open();
                    if (button == SWT.CANCEL) {
                        i = sourceNames.length;
                        event.detail = DND.DROP_NONE;
                        break;
                    }
                } else {
                    // We can recover gracefully from errors if the drag
                    // source belongs
                    // to this application since it will look at
                    // processedDropFiles.
                    MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.ABORT | SWT.RETRY | SWT.IGNORE);
                    box.setText(getResourceString("dialog.FailedCopy.title"));
                    box.setMessage(
                            getResourceString("dialog.FailedCopy.description", new Object[] { source, dest }));
                    int button = box.open();
                    if (button == SWT.ABORT)
                        i = sourceNames.length;
                    if (button != SWT.RETRY)
                        break;
                }
            }
            progressDialog.addProgress(1);
        }
    }
    if (isDragging) {
        // Remember exactly which files we processed
        processedDropFiles = ((File[]) processedFiles.toArray(new File[processedFiles.size()]));
    } else {
        progressDialog.close();
        progressDialog = null;
    }
    notifyRefreshFiles(new File[] { targetFile });
}

From source file:org.kchine.r.server.DirectJNI.java

public static String[] getROptions() {
    String[] roptions = new String[] { "--no-save" };

    if (System.getProperty("proxy_host") != null && !System.getProperty("proxy_host").equals("")) {
        roptions = new String[] { "--no-save", "--internet2" };
    }//from w w w  .  j a  v a2s.  c  o m

    if (System.getProperty("r.options") != null && !System.getProperty("r.options").equals("")) {
        Vector<String> roptionsVector = new Vector<String>();
        StringTokenizer st = new StringTokenizer(System.getProperty("r.options"), " ");
        while (st.hasMoreElements())
            roptionsVector.add((String) st.nextElement());
        roptions = roptionsVector.toArray(new String[0]);
    }
    System.out.println("r options:" + Arrays.toString(roptions));
    return roptions;
}

From source file:org.knime.knip.io.nodes.imgreader.ReadFileImgTable.java

/**
 * {@inheritDoc}//from w  w  w. java  2 s.co  m
 */
@Override
public RowIterator iterator() {

    if (m_fileList == null) {
        return new RowIterator() {
            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public DataRow next() {
                return null;
            }

        };
    }

    /* Cellfactory to create image cells */
    final ImgPlusCellFactory cellFactory = new ImgPlusCellFactory(m_exec);

    /*
     * Iterate over the row
     */
    return new RowIterator() {

        /* id of the current file */
        private String currentFile;

        /*
         * base row key for the currently read file (possibly with the
         * series id appended to it later on)
         */
        private String rowKey;

        /* current image of the series contained in one file */
        private int currentSeries = m_selectedSeries == -1 ? 0 : m_selectedSeries;

        /* iterator over filelist */
        private final Iterator<String> fileIterator = m_fileList.iterator();

        /* the current iterator position */
        private int idx = 0;

        private int progressCount = 0;

        /* number of series */
        private int seriesCount = 0;

        {
            m_error = false;
        }

        @Override
        public boolean hasNext() {
            if (m_selectedSeries == -1 && (currentSeries + 1) < seriesCount) {
                return true;
            }
            return fileIterator.hasNext();
        }

        @SuppressWarnings("unchecked")
        @Override
        public DataRow next() {
            final Vector<DataCell> row = new Vector<DataCell>();

            final DataCell[] result = new DataCell[m_omexml ? 2 : 1];
            try {
                if ((currentSeries + 1) < seriesCount && m_selectedSeries == -1) {
                    // if there still is a series left and ALL series are
                    // selected to be read (m_selectedSeries!=-1)
                    currentSeries++;
                } else {
                    /* prepare next file name and the according row key */
                    progressCount++;
                    currentFile = fileIterator.next().trim();
                    rowKey = currentFile;

                    // replace relative file pathes knime://knime.workflow
                    currentFile = DialogComponentMultiFileChooser.convertToFilePath(currentFile,
                            m_workflowCanonicalPath);

                    // download file and return new file path, if
                    // 'currentFile' is an url
                    String newLoc;
                    if ((newLoc = downloadFileFromURL(currentFile)) != null) {
                        rowKey = currentFile;
                        currentFile = newLoc;
                    } else {
                        // if file wasn't downloaded from a url, re-set
                        // row-key
                        // check whether file exists
                        File f = new File(currentFile);
                        if (!f.exists()) {
                            throw new KNIPException("Image " + rowKey + " doesn't exist!");
                        }
                        if (!m_completePathRowKey) {
                            rowKey = f.getName();
                        }

                    }

                    seriesCount = m_imgSource.getSeriesCount(currentFile);
                    currentSeries = m_selectedSeries == -1 ? 0 : m_selectedSeries;

                    idx++;
                }
                if (currentSeries >= seriesCount) {
                    LOGGER.warn("Image file only contains " + seriesCount + " series, but series number "
                            + currentSeries + " selected. File skipped!");
                }

                List<CalibratedAxis> calibAxes = m_imgSource.getAxes(currentFile, currentSeries);

                final Pair<TypedAxis, long[]>[] axisSelectionConstraints = m_sel.createSelectionConstraints(
                        m_imgSource.getDimensions(currentFile, currentSeries),
                        calibAxes.toArray(new CalibratedAxis[calibAxes.size()]));

                // reads the ome xml metadata
                if (m_omexml) {
                    result[result.length - 1] = XMLCellFactory
                            .create(m_imgSource.getOMEXMLMetadata(currentFile));
                }

                // One _can_ be sure that if and only if
                // some dims are removed (as they are of
                // size 1) an optimized iterable interval
                // is created
                final ImgPlus<T> resImgPlus = (ImgPlus<T>) m_imgSource.getImg(currentFile, currentSeries,
                        axisSelectionConstraints);

                result[0] = cellFactory.createCell(resImgPlus);

            } catch (final FormatException e) {
                LOGGER.warn("Format not supported for image " + rowKey + " (" + e.getMessage() + ")");
                m_error = true;

            } catch (final IOException e) {
                LOGGER.error("An IO problem occured while opening the image " + rowKey + " (" + e.getMessage()
                        + ")");
                m_error = true;
            } catch (final KNIPException e) {
                LOGGER.warn(e.getLocalizedMessage());
                m_error = true;
            } catch (final Exception e) {
                LOGGER.error(e);
                e.printStackTrace();
                m_error = true;
            }

            for (final DataCell cell : result) {
                if (cell == null) {
                    row.add(DataType.getMissingCell());
                } else {
                    row.add(cell);
                }
            }

            DataCell[] rowvalues = new DataCell[row.size()];
            rowvalues = row.toArray(rowvalues);
            m_exec.setProgress((double) progressCount / m_numberOfFiles);

            // add series count to row key, if the current file is a series
            // of images
            RowKey rk;
            if (seriesCount > 1) {
                rk = new RowKey(rowKey + "_" + currentSeries);
            } else {
                rk = new RowKey(rowKey);
            }
            return new DefaultRow(rk, rowvalues);

        }

    };

}

From source file:com.flexoodb.common.FlexUtils.java

/**
* obtains an XSL prototype for the object.
*
* @param  title optional title in the XSL prorotype, can be null (ie none).
* @param  config configuration for class type.
* @param  obj the object containing the elements that will be used to populate the XSL.
* @param  listtype set to '0' if its not a list type, 1 for regular list and 2 if this is a child list .
* @param  type 0 for non-edit viewing only, 1 to embed viewable contents in editable fields (ie for updating or editing) and 2 for empty fields (ie for new records).
* @param  message default message.//from  w  ww  . ja  va  2 s  . co  m
* @param  parentclass parentclassname for reference.
* @return XSL string.
* @see Hashtable
*@see Element
*/
public String getXSLPrototype(String title, Config config, Object obj, boolean list, int type, String message,
        String parentclass) throws Exception {
    Class c = obj.getClass();

    String simplename = c.getSimpleName();
    simplename = simplename.substring(0, simplename.length() - 4);

    ConfigElement ce = config.getElementConfig(c.getSimpleName());

    Vector ve = retrieveMethods(c, null);
    Method[] m = new Method[ve.size()];
    ve.toArray(m);

    String name, retval;
    String id = null;
    String parentid = null;
    StringBuffer xml = new StringBuffer();
    StringBuffer listheader = new StringBuffer();
    Hashtable fields = getFields(obj);

    Enumeration it = fields.keys();

    if (list) {

        String callname = parentclass == null ? "list" + c.getSimpleName() + ".igx"
                : "get" + c.getSimpleName() + "WithParentID.igx";
        String idref = parentclass == null ? "{../@id}" : "<%var_request[id]%>";

        xml.append("\n\n<xsl:template match=\"records\">\n");
        //xml.append("<div class=\"info\">\n");
        xml.append("<div>\n");

        // must be a child!
        if (parentclass != null) {
            xml.append("<span style=\"font-size:14px;font-weight:bold\">\n");
            xml.append("    <a onClick=\"javascript:linkchangecontent('<%var_context["
                    + parentclass.toLowerCase() + "parent]%>?id=<%var_context[" + parentclass.toLowerCase()
                    + "parentid]%>','contentdyn')\" href=\"#\">\n");
            xml.append("    <%var_context[" + parentclass.toLowerCase() + "parentname]%>\n");
            xml.append("    </a>\n");
            xml.append("</span>\n");

        }

        xml.append("<span style=\"float:right;padding-right:3px\">\n");
        xml.append("\n");
        xml.append("<!-- TOP -->\n");
        xml.append(" <xsl:choose>\n");
        xml.append("      <xsl:when test=\"number(@from) &gt; 0\">\n");
        xml.append("      <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref
                + "&amp;from=0&amp;to=15','contentdyn')\" href=\"#\">\n");
        xml.append("      <img src=\"images/top.png\" alt=\"Top\"/>\n");
        xml.append("      </a> \n");
        xml.append("      </xsl:when>\n");
        xml.append("      <xsl:otherwise>\n");
        xml.append("      <img src=\"images/topg.png\" alt=\"Top\"/>\n");
        xml.append("      </xsl:otherwise>\n");
        xml.append(" </xsl:choose>\n");
        xml.append("\n");
        xml.append("<!-- PREV -->\n");
        xml.append("<xsl:choose>\n");
        xml.append("      <xsl:when test=\"@from &gt; 0\">\n");
        xml.append("         <xsl:choose>\n");
        xml.append("         <xsl:when test=\"(number(@from)-15) &lt; 0\">\n");
        xml.append("         <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref
                + "&amp;from=0&amp;to=15','contentdyn')\" href=\"#\">\n");
        xml.append("         <img src=\"images/prev.png\" alt=\"Previous\"/>\n");
        xml.append("         </a> \n");
        xml.append("         </xsl:when>\n");
        xml.append("         <xsl:otherwise>\n");
        xml.append("         <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref
                + "&amp;from={number(@from)-15}&amp;to={@from}','contentdyn')\" href=\"#\">\n");
        xml.append("         <img src=\"images/prev.png\" alt=\"Previous\"/>\n");
        xml.append("         </a> \n");
        xml.append("         </xsl:otherwise>\n");
        xml.append("         </xsl:choose>\n");
        xml.append("      </xsl:when>\n");
        xml.append("      <xsl:otherwise>\n");
        xml.append("      <img src=\"images/prevg.png\" alt=\"Previous\"/>\n");
        xml.append("      </xsl:otherwise>\n");
        xml.append("</xsl:choose>\n");
        xml.append("<!-- NEXT -->\n");
        xml.append("<xsl:choose>\n");
        xml.append("      <xsl:when test=\"(number(@from)+15) &lt; number(@total)\">\n");
        xml.append("         <xsl:choose>\n");
        xml.append("         <xsl:when test=\"(number(@from)+15) &gt; number(@total)\">\n");
        xml.append("         <a  onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref
                + "&amp;from={number(@from)+15}&amp;to={@total}','contentdyn')\" href=\"#\">\n");
        xml.append("         <img src=\"images/next.png\" alt=\"Next\"/>\n");
        xml.append("         </a> \n");
        xml.append("         </xsl:when>\n");
        xml.append("         <xsl:otherwise>\n");
        xml.append("         <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref
                + "&amp;from={number(@from)+15}&amp;to={number(@from)+30}','contentdyn')\" href=\"#\">\n");
        xml.append("         <img src=\"images/next.png\" alt=\"Next\"/>\n");
        xml.append("         </a> \n");
        xml.append("         </xsl:otherwise>\n");
        xml.append("         </xsl:choose>\n");
        xml.append("      </xsl:when>\n");
        xml.append("      <xsl:otherwise>\n");
        xml.append("      <img src=\"images/nextg.png\" alt=\"Next\"/>\n");
        xml.append("      </xsl:otherwise>\n");
        xml.append("</xsl:choose>\n");
        xml.append("<!-- BOTTOM -->\n");
        xml.append("<xsl:choose>\n");
        xml.append("      <xsl:when test=\"number(@from) &lt; (number(@total)-15)\">\n");
        xml.append("         <xsl:choose>\n");
        xml.append("         <xsl:when test=\"number(@total) &gt; 15\">\n");
        xml.append("         <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref
                + "&amp;from={number(@total)-15}&amp;to={@total}','contentdyn')\" href=\"#\">\n");
        xml.append("         <img src=\"images/bottom.png\" alt=\"Bottom\"/>\n");
        xml.append("         </a> \n");
        xml.append("         </xsl:when>\n");
        xml.append("         <xsl:otherwise>\n");
        xml.append("         <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref
                + "&amp;from={number(@from)+15}&amp;to={number(@from)+30}','contentdyn')\" href=\"#\">\n");
        xml.append("         <img src=\"images/bottom.png\" alt=\"Bottom\"/>\n");
        xml.append("         </a> \n");
        xml.append("         </xsl:otherwise>\n");
        xml.append("         </xsl:choose>\n");
        xml.append("      </xsl:when>\n");
        xml.append("      <xsl:otherwise>\n");
        xml.append("      <img src=\"images/bottomg.png\" alt=\"Bottom\"/>\n");
        xml.append("      </xsl:otherwise>\n");
        xml.append("</xsl:choose>\n");
        xml.append("</span>\n");

        xml.append("<span style=\"float:right;vertical-align:middle;padding-right:3px\">\n");
        xml.append("<xsl:choose>\n");
        xml.append("   <xsl:when test=\"number(@total) &gt; 0\">\n");
        xml.append("    Showing <xsl:value-of select=\"number(@from)+1\"/>\n");
        xml.append(
                "    to <xsl:value-of select=\"number(@from)+number(@returned)\"/> records of <xsl:value-of select=\"@total\"/>\n");
        xml.append("   </xsl:when>\n");
        xml.append("   <xsl:otherwise>\n");
        xml.append("     No Records.\n");
        xml.append("   </xsl:otherwise>\n");
        xml.append("</xsl:choose>\n");
        xml.append("</span>\n");
        xml.append("\n");

        xml.append("</div>\n");
        xml.append("</xsl:template>\n\n");

        xml.append("\n<xsl:template match=\"LIST\">\n");

        /*if (title!=null)
        {
        xml.append("<div class=\"info\"><strong>"+title+"</strong> (found <xsl:value-of select=\"@COUNT\"/> records)</div>\n");
        }*/

        xml.append("<table class=\"sortable\">\n");

        // create the header
        xml.append("          <!-- create the header -->\n");
        xml.append("          <thead><tr>\n");

        if (ce != null) {
            Map cef = ce.getFields();
            Iterator itr = cef.values().iterator();
            while (itr.hasNext()) {
                ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) {
                    xml.append("               <th>" + cfi.label + "</th>\n");
                }
            }
        } else {
            while (it.hasMoreElements()) {
                String f = (String) it.nextElement();
                xml.append("               <th>" + f + "</th>\n");
            }

        }
        xml.append("               <th>Action</th>\n");
        xml.append("          </tr></thead>\n");

        xml.append("          <xsl:apply-templates select=\"flexcontainer/" + c.getSimpleName().toLowerCase()
                + "\"/>\n");
        xml.append("</table>\n");
        xml.append("</xsl:template>\n");

        // create the table contents

        xml.append("<xsl:template match=\"flexcontainer/" + c.getSimpleName().toLowerCase() + "\">");
        xml.append("\n          <!-- create table contents -->\n");
        xml.append("  <xsl:for-each select=\".\">\n");
        xml.append("          <tr>\n");

        if (ce != null) {
            Map cef = ce.getFields();
            Iterator itr = cef.values().iterator();
            while (itr.hasNext()) {
                ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();

                if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type.toLowerCase()) > -1) {
                    if (type == 0) {
                        if (cfi.type.equals("byte[]") || cfi.type.equals("file")
                                || cfi.type.equalsIgnoreCase("base64Binary")) {
                            xml.append("               <td><a href=\"get" + cfi.name + "In" + c.getSimpleName()
                                    + ".igx?id={../@id}\"><xsl:value-of select=\"" + cfi.name.toLowerCase()
                                    + "\"/></a></td>\n");
                        } else {
                            //format-number(units,'###,###,##0.00')
                            if (cfi.type.equalsIgnoreCase("decimal")) {
                                xml.append("               <td><xsl:value-of select=\"format-number("
                                        + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n");
                            } else {
                                xml.append("               <td><xsl:value-of select=\"" + cfi.name.toLowerCase()
                                        + "\"/></td>\n");
                            }
                        }

                    } else if (type == 1) {
                        xml.append("               <td><input class=\"txt\" id=\"text" + cfi.name + "\" name=\""
                                + cfi.name.toLowerCase() + "\" type=\"text\" value=\"{" + cfi.name
                                + "}\"/></td>\n");
                    } else {
                        xml.append("               <td><input class=\"txt\" id=\"text" + cfi.name + "\" name=\""
                                + cfi.name.toLowerCase() + "\" type=\"text\" value=\"\"/></td>\n");
                    }
                }
            }
        } else {
            it = fields.keys();
            while (it.hasMoreElements()) {
                String f = (String) it.nextElement();
                String t = (String) fields.get(f);

                if (type == 0) {
                    if (t.equals("byte[]") || t.equals("base64Binary")) {
                        xml.append("               <td><a href=\"get" + f + "In" + c.getSimpleName()
                                + ".igx?id={../@id}\"><xsl:value-of select=\"" + f.toLowerCase()
                                + "\"/></a></td>\n");
                    } else {
                        //format-number(units,'###,###,##0.00')
                        if (t.equalsIgnoreCase("decimal")) {
                            xml.append("               <td><xsl:value-of select=\"format-number("
                                    + f.toLowerCase() + ",'###,###,##0.00')\"/></td>\n");
                        } else {
                            xml.append("               <td><xsl:value-of select=\"" + f.toLowerCase()
                                    + "\"/></td>\n");
                        }
                    }

                } else if (type == 1) {
                    xml.append("               <td><input class=\"txt\" id=\"text" + f + "\" name=\""
                            + f.toLowerCase() + "\" type=\"text\" value=\"{" + f.toLowerCase()
                            + "}\"/></td>\n");
                } else {
                    xml.append("               <td><input class=\"txt\" id=\"text" + f + "\" name=\""
                            + f.toLowerCase() + "\" type=\"text\" value=\"\"/></td>\n");
                }

            }

        }

        xml.append("               <td>\n");

        /*if (parentclass!=null)
        {
        xml.append("                    <a onClick=\""+(message!=null?"javascript:hidedivDisplay('message');":"")+"javascript:linkchangecontent('get"+c.getSimpleName()+".igx?id={../@id}&amp;do=savecontext&amp;"+parentclass.toLowerCase()+"parent=get"+parentclass+".igx&amp;"+parentclass.toLowerCase()+"parentname="+parentclass+"&amp;"+parentclass.toLowerCase()+"parentid=<%var_request[id]%>','contentdyn')\" href=\"#\">View</a> | \n");
        xml.append("                    <a href=\"javascript:getConfirmation('Are You Sure You Want to Delete this Record?','delete"+c.getSimpleName()+".igx?id={../@id}&amp;do=savecontext&amp;"+parentclass.toLowerCase()+"parent=get"+parentclass+".igx&amp;"+parentclass.toLowerCase()+"parentname="+parentclass+"&amp;"+parentclass.toLowerCase()+"parentid=<%var_request[id]%>','')\">Delete</a>\n");
                
        }
        else
        {*/
        xml.append("                    <a onClick=\""
                + (message != null ? "javascript:hidedivDisplay('message');" : "")
                + "javascript:linkchangecontent('get" + c.getSimpleName()
                + ".igx?id={../@id}','contentdyn')\" href=\"#\">View</a> | <a href=\"javascript:getConfirmation('Are You Sure You Want to Delete this Record?','delete"
                + c.getSimpleName() + ".igx?id={../@id}','')\">Delete</a>\n");
        //}

        xml.append("               </td>\n");
        xml.append("          </tr>\n");
        xml.append("  </xsl:for-each>\n");
        xml.append("</xsl:template>\n");
    } else {

        // for viewing and editing only
        if (type < 2) {
            xml.append("\n<xsl:template match=\"flexcontainer/" + c.getSimpleName().toLowerCase() + "\">\n\n");

            if (parentclass == null) {
                xml.append("<!-- Printer Friendly Version -->\n");
                xml.append("<div align=\"right\">\n");
                xml.append("     <a href=\"javascript:"
                        + (message != null ? "javascript:hidedivDisplay('message');" : "")
                        + "javascript:window.location='get" + c.getSimpleName()
                        + "AsXML.igx?id={../@id}';\"> <img src=\"images/xml.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"XML\"></img></a>\n");
                xml.append("     <a href=\"javascript:" + (message != null ? "hidedivDisplay('message');" : "")
                        + "javascript:printClick('Print " + c.getSimpleName() + "','print" + c.getSimpleName()
                        + "','printlist" + c.getSimpleName()
                        + "')\"> <img src=\"images/printer.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"Print Version\"></img></a>\n");
                xml.append("</div>\n");
                xml.append("\n\n");
            } else {
                xml.append("<!-- Printer Friendly and XML Version, uncomment to enable printing -->\n");
                xml.append("<!-- <div align=\"right\">\n");
                xml.append("     <a href=\"javascript:"
                        + (message != null ? "javascript:hidedivDisplay('message');" : "")
                        + "javascript:window.location='get" + c.getSimpleName()
                        + "AsXML.igx?id={../@id}';\"> <img src=\"images/xml.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"XML\"></img></a>\n");
                xml.append("     <a href=\"javascript:" + (message != null ? "hidedivDisplay('message');" : "")
                        + "javascript:printClick('Print " + c.getSimpleName() + "','print" + c.getSimpleName()
                        + "','printlist" + c.getSimpleName()
                        + "')\"> <img src=\"images/printer.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"Print Version\"></img></a>\n");
                xml.append("</div>\n");
                xml.append("-->\n\n");
                xml.append("<span style=\"font-size:14px;font-weight:bold\">\n");
                xml.append("    <a onClick=\"javascript:linkchangecontent('<%var_context["
                        + parentclass.toLowerCase() + "parent]%>?id=<%var_context[" + parentclass.toLowerCase()
                        + "parentid]%>','contentdyn')\" href=\"#\">\n");
                xml.append("    <%var_context[" + parentclass.toLowerCase() + "parentname]%>\n");
                xml.append("    </a>\n");
                xml.append("</span>\n\n");
            }

            // generate the view prototype first
            xml.append("<!--- START OF view" + c.getSimpleName() + " CODE SEGMENT -->\n");
            xml.append("<div id=\"view" + c.getSimpleName() + "\">\n\n");

            if (message != null) {
                xml.append("<div class=\"info\" id=\"message\"><b>" + message + "</b></div>\n\n");
            }

            xml.append("<fieldset>\n");

            xml.append("<legend>View " + simplename + "</legend>\n");

            xml.append("<div class=\"fieldsetwrap\">\n");

            xml.append("     <div class=\"datafieldwrap\">\n");
            xml.append("     <table class=\"datafield\">\n");

            if (ce != null) {
                Map cef = ce.getFields();

                Iterator itr = cef.values().iterator();
                while (itr.hasNext()) {
                    ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();

                    if (cfi.visible && _types.indexOf(cfi.type) > -1) {
                        if (cfi.type.equals("byte[]") || cfi.type.equals("file")
                                || cfi.type.equals("base64Binary")) {
                            xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                    + ":</td><td class=\"data full\"><a href=\"get" + cfi.name + "In"
                                    + c.getSimpleName() + ".igx?id={../@id}\"><xsl:value-of select=\""
                                    + cfi.name.toLowerCase() + "\"/></a></td></tr>\n");
                        } else {
                            if (cfi.type.equalsIgnoreCase("decimal")) {
                                xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                        + ":</td><td class=\"data full\"><xsl:value-of select=\"format-number("
                                        + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td></tr>\n");
                            } else {
                                xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                        + ":</td><td class=\"data full\"><pre><xsl:value-of select=\""
                                        + cfi.name.toLowerCase() + "\"/></pre></td></tr>\n");
                            }
                        }
                    }
                }
            } else {

                while (it.hasMoreElements()) {
                    String f = (String) it.nextElement();
                    String t = (String) fields.get(f);

                    if (t.equals("byte[]")) {
                        xml.append("          <tr><td class=\"lbl\">" + f
                                + ":</td><td class=\"data full\"><a href=\"get" + f + "In" + c.getSimpleName()
                                + ".igx?id={../@id}\"><xsl:value-of select=\"" + f.toLowerCase()
                                + "\"/></a></td></tr>\n");
                    } else {
                        if (t.equalsIgnoreCase("decimal")) {
                            xml.append("          <tr><td class=\"lbl\">" + f
                                    + ":</td><td class=\"data full\"><xsl:value-of select=\"format-number("
                                    + f.toLowerCase() + ",'###,###,##0.00')\"/></td></tr>\n");
                        } else {
                            xml.append("          <tr><td class=\"lbl\">" + f
                                    + ":</td><td class=\"data full\"><pre><xsl:value-of select=\""
                                    + f.toLowerCase() + "\"/></pre></td></tr>\n");
                        }

                    }
                }

            }

            xml.append("     </table>\n");
            xml.append("     </div>\n");
            xml.append("</div>\n");
            xml.append("</fieldset>\n\n");

            xml.append("<div class=\"btnrow\">\n");
            xml.append("     <input type=\"button\" value=\"Edit\" onClick=\""
                    + (message != null ? "hidedivDisplay('message');" : "") + "hidedivDisplay('view"
                    + c.getSimpleName() + "');showdivDisplay('edit" + c.getSimpleName() + "');\"/>\n");
            xml.append("     <input type=\"button\" value=\"Delete\" onClick=\""
                    + (message != null ? "hidedivDisplay('message');" : "")
                    + "getConfirmation('Are You Sure You Want to Delete this Record?','delete"
                    + c.getSimpleName() + ".igx?id={../@id}','')\"/>\n");
            xml.append("</div>\n\n");
            xml.append("</div>\n");
            xml.append("<div class=\"clear\"></div>\n");
            xml.append("<!--- END OF view" + c.getSimpleName() + " CODE SEGMENT -->\n\n");

        }

        if (type < 2) // if it also requires editing then we include the editing prototype
        {
            // then the editing prototype
            xml.append("<!--- START OF edit" + c.getSimpleName() + " CODE SEGMENT USED FOR EDITING MODE -->\n");
            xml.append("<div class=\"hidden\" id=\"edit" + c.getSimpleName() + "\">\n\n");

            xml.append("<fieldset>\n");

            xml.append("<legend>Edit " + simplename + "</legend>\n");

            xml.append("<div class=\"fieldsetwrap\">\n");

            if (fields.contains("byte[]")) {
                xml.append("\n<form class=\"webform\" id=\"update" + c.getSimpleName().toLowerCase()
                        + "\" name=\"update" + c.getSimpleName().toLowerCase()
                        + "\" method=\"post\" enctype=\"multipart/form-data\" action=\"update"
                        + c.getSimpleName() + ".igx?id={../@id}\">\n");
                xml.append("<input name=\"id\" type=\"hidden\" value=\"{../@id}\"/>\n");
            } else {
                xml.append("\n<form class=\"webform\" id=\"update" + c.getSimpleName().toLowerCase()
                        + "\" name=\"update" + c.getSimpleName().toLowerCase()
                        + "\" method=\"post\" action=\"update" + c.getSimpleName() + ".igx?id={../@id}\">\n");
            }

            xml.append("     <div class=\"datafieldwrap\">\n");
            xml.append("     <table class=\"datafield\">\n");

            it = fields.keys();

            if (ce != null) {
                Map cef = ce.getFields();

                Iterator itr = cef.values().iterator();
                while (itr.hasNext()) {
                    ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();

                    if (cfi.visible && _types.indexOf(cfi.type) > -1) {
                        if (!cfi.editable || !cfi.addable) {
                            xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                    + ":</td><td class=\"data full\"><pre><xsl:value-of select=\""
                                    + cfi.name.toLowerCase() + "\"/></pre></td></tr>\n");
                        } else {
                            if (cfi.type.equalsIgnoreCase("boolean")) {
                                xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                        + ":</td><td class=\"data full\">\n");
                                xml.append("               <select id=\"select" + cfi.name + "\" name=\""
                                        + cfi.name.toLowerCase() + "\">\n");
                                xml.append("                    <option selected=\"\"><xsl:value-of select=\""
                                        + cfi.name.toLowerCase() + "\"/></option>\n");
                                xml.append("                    <option>true</option><option>false</option>\n");
                                xml.append("               </select>");
                                xml.append("          </td></tr>\n");
                            } else if (cfi.type.equalsIgnoreCase("byte[]") || cfi.type.equalsIgnoreCase("file")
                                    || cfi.type.equalsIgnoreCase("base64Binary")) {
                                xml.append(" <xsl:choose>\n");
                                xml.append("    <xsl:when test=\"normalize-space(" + cfi.name.toLowerCase()
                                        + ")\">\n");
                                xml.append("           <tr><td class=\"lbl\">" + cfi.label
                                        + ":</td><td class=\"data full\"><input id=\"file" + cfi.name
                                        + "\" type=\"file\" name=\"" + cfi.name.toLowerCase()
                                        + "\"/><a href=\"get" + cfi.name + "In" + c.getSimpleName()
                                        + ".igx?id={../@id}\"><xsl:value-of select=\"" + cfi.name.toLowerCase()
                                        + "\"/></a> <a onClick=\"getConfirmation('Are you sure you want to remove {"
                                        + cfi.name.toLowerCase() + "}?','del" + cfi.name + "In"
                                        + c.getSimpleName()
                                        + ".igx?id={../@id}','')\" href=\"#\"><img src=\"images/trash.png\" alt=\"Trash\"/></a></td></tr>\n");
                                xml.append("    </xsl:when>\n");
                                xml.append("    <xsl:otherwise>\n");
                                xml.append("           <tr><td class=\"lbl\">" + cfi.label
                                        + ":</td><td class=\"data full\"><input id=\"file" + cfi.name
                                        + "\" type=\"file\" name=\"" + cfi.name.toLowerCase()
                                        + "\"/></td></tr>\n");
                                xml.append("    </xsl:otherwise>\n");
                                xml.append(" </xsl:choose>\n");
                            } else if (cfi.type.equalsIgnoreCase("date")) {
                                xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                        + ":</td><td class=\"data full\"><input class=\"txtdtt\" id=\"calendar"
                                        + cfi.name + "\" type=\"text\" name=\"" + cfi.name.toLowerCase()
                                        + "\"  value=\"{" + cfi.name.toLowerCase()
                                        + "}\"/><a href=\"javascript:NewCssCal('calendar" + cfi.name
                                        + "','yyyymmdd','arrow',false,24,true)\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" alt=\"Pick a date\"/></a></td></tr>\n");
                            } else if (cfi.type.equalsIgnoreCase("dateTime")) {
                                xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                        + ":</td><td class=\"data full\"><input class=\"txtdtt\" id=\"calendar"
                                        + cfi.name + "\" type=\"text\" name=\"" + cfi.name.toLowerCase()
                                        + "\"  value=\"{" + cfi.name.toLowerCase()
                                        + "}\"/><a href=\"javascript:NewCssCal('calendar" + cfi.name
                                        + "','yyyymmdd','arrow',true,24,false)\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" alt=\"Pick a date\"/></a></td></tr>\n");
                            } else if (cfi.type.equalsIgnoreCase("select")) {

                                String options = null;

                                // first we check if the choices is a dynamic one
                                if (cfi.choices.indexOf("Type.") > -1) {
                                    String optionname = null;
                                    String idfield = null;
                                    if (cfi.choices.split("=").length > 1) {
                                        optionname = cfi.choices.split("=")[0] + cfi.choices.split("=")[1];
                                        idfield = cfi.choices.split("=")[0];
                                        options = "                  <option value=\"{" + cfi.name.toLowerCase()
                                                + "}\" selected=\"\">{%dyn_get"
                                                + cfi.choices.substring(0, cfi.choices.indexOf("."))
                                                + optionname + ".igx?id=<xsl:value-of select=\""
                                                + cfi.name.toLowerCase() + "\"/>%}</option>\n";
                                    } else {
                                        optionname = cfi.choices.substring(cfi.choices.indexOf(".") + 1);
                                        options = "                  <option value=\"{" + cfi.name.toLowerCase()
                                                + "}\" selected=\"\"><xsl:value-of select=\""
                                                + cfi.name.toLowerCase() + "\"/></option>\n";
                                    }

                                    //options = options+"<%dyn_get"+cfi.choices.substring(0,cfi.choices.indexOf("."))+cfi.choices.substring(cfi.choices.indexOf(".")+1)+".igx%>";
                                    options = options + "                  <%dyn_"
                                            + cfi.choices.substring(0, cfi.choices.indexOf(".")) + optionname
                                            + "Select.igx%>\n    ";
                                } else {
                                    options = "                  <option selected=\"\"><xsl:value-of select=\""
                                            + cfi.name.toLowerCase() + "\"/></option>\n";
                                    String[] choices = cfi.choices.split(",");
                                    if (choices != null && choices.length > 0) {
                                        for (int i = 0; i < choices.length; i++) {
                                            options = options + "                  <option>" + choices[i]
                                                    + "</option>\n";
                                        }
                                    } else {
                                        options = "                  <option selected=\"\">Active</option>\n                  <option>Suspended</option>\n";
                                    }

                                }

                                xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                        + ":</td><td class=\"data full\">\n");
                                xml.append("              <select id=\"select" + cfi.name + "\" name=\""
                                        + cfi.name.toLowerCase() + "\">\n" + options);
                                xml.append("              </select>\n");
                                xml.append("          </td></tr>\n");

                            } else if (cfi.type.equalsIgnoreCase("textarea")) {
                                xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                        + ":</td><td class=\"data full\"><textarea class=\"ta\" id=\"textarea"
                                        + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\" rows=\""
                                        + cfi.rows + "\" cols=\"" + cfi.columns + "\"><xsl:value-of select=\""
                                        + cfi.name.toLowerCase() + "\"/></textarea></td></tr>\n");
                            } else {
                                if (cfi.maxlength > 0) {
                                    xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                            + ":</td><td class=\"data full\"><input class=\"txt\" id=\"text"
                                            + cfi.name + "\" name=\"" + cfi.name.toLowerCase()
                                            + "\" type=\"text\" value=\"{" + cfi.name.toLowerCase()
                                            + "}\" style=\"width: " + (cfi.maxlength * 10)
                                            + "px;\" maxlength=\"" + cfi.maxlength + "\"/></td></tr>\n");
                                } else {
                                    xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                            + ":</td><td class=\"data full\"><input class=\"txt\" id=\"text"
                                            + cfi.name + "\" name=\"" + cfi.name.toLowerCase()
                                            + "\" type=\"text\" value=\"{" + cfi.name.toLowerCase()
                                            + "}\"/></td></tr>\n");
                                }
                            }

                        }

                    }
                }
            } else {
                while (it.hasMoreElements()) {
                    String f = (String) it.nextElement();
                    String t = (String) fields.get(f);

                    if (t.equalsIgnoreCase("boolean")) {
                        xml.append("          <tr><td class=\"lbl\">" + f
                                + ":</td><td class=\"data full\"><SELECT id=\"select" + f + "\" name=\""
                                + f.toLowerCase() + "\">\n<OPTION SELECTED=\"\"><xsl:value-of select=\""
                                + f.toLowerCase()
                                + "\"/></OPTION>\n<OPTION>true</OPTION>\n<OPTION>false</OPTION>\n</SELECT></td></tr>\n");
                    } else if (t.equalsIgnoreCase("byte[]") || t.equalsIgnoreCase("file")) {
                        xml.append(" <xsl:choose>\n");
                        xml.append("    <xsl:when test=\"" + f.toLowerCase() + "=''\">\n");
                        xml.append("           <tr><td class=\"lbl\">" + f
                                + ":</td><td class=\"data full\"><input id=\"file" + f
                                + "\" type=\"file\" name=\"" + f.toLowerCase() + "\"/></td></tr>\n");
                        xml.append("    </xsl:when>\n");
                        xml.append("    <xsl:otherwise>\n");
                        xml.append("           <tr><td class=\"lbl\">" + f
                                + ":</td><td class=\"data full\"><a href=\"get" + f + "In" + c.getSimpleName()
                                + ".igx?id={../@id}\"><xsl:value-of select=\"" + f.toLowerCase()
                                + "\"/></a>(<a href=\"remove" + f + "In" + c.getSimpleName()
                                + ".igx?id={../@id}\">Remove</a>)<input id=\"file" + f
                                + "\" type=\"file\" name=\"" + f.toLowerCase() + "\"/></td></tr>\n");
                        xml.append("    </xsl:otherwise>\n");
                        xml.append(" </xsl:choose>\n");

                    } else if (t.equalsIgnoreCase("XMLGregorianCalendar")) {
                        xml.append("          <tr><td class=\"lbl\">" + f
                                + ":</td><td class=\"data full\"><input class=\"txtdtt\" id=\"calendar" + f
                                + "\" type=\"text\" name=\"" + f.toLowerCase() + "\"  value=\"{"
                                + f.toLowerCase() + "}\"/><a href=\"javascript:NewCssCal('calendar" + f
                                + "','yyyymmdd','arrow',false,24,true)\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" alt=\"Pick a date\"/></a></td></tr>\n");
                    } else {
                        if (_textfields.indexOf(f.toLowerCase()) > -1) {
                            xml.append("          <tr><td class=\"lbl\">" + f
                                    + ":</td><td class=\"data full\"><textarea class=\"ta\" id=\"textarea" + f
                                    + "\" name=\"" + f.toLowerCase()
                                    + "\" rows=\"5\" cols=\"65\"><xsl:value-of select=\"" + f.toLowerCase()
                                    + "\"/></textarea></td></tr>\n");
                        } else {
                            if (f.equalsIgnoreCase("status")) {
                                xml.append("          <tr><td class=\"lbl\">" + f
                                        + ":</td><td class=\"data full\"><SELECT id=\"select" + f + "\" name=\""
                                        + f.toLowerCase() + "\">\n<OPTION SELECTED=\"\"><xsl:value-of select=\""
                                        + f.toLowerCase()
                                        + "\"/></OPTION>\n<OPTION>Active</OPTION>\n<OPTION>Suspended</OPTION>\n</SELECT></td></tr>\n");
                            } else {

                                xml.append("          <tr><td class=\"lbl\">" + f
                                        + ":</td><td class=\"data full\"><input class=\"txt\" id=\"text" + f
                                        + "\" name=\"" + f.toLowerCase() + "\" type=\"text\" value=\"{"
                                        + f.toLowerCase() + "}\"/></td></tr>\n");
                            }

                        }

                    }

                }
            }

            xml.append("     </table>\n");
            xml.append("     </div>\n\n");
            xml.append(
                    "<input type=\"button\" value=\"Update\" onClick=\"javascript:buttonchangecontent('update"
                            + c.getSimpleName() + ".igx?id={../@id}','update" + c.getSimpleName().toLowerCase()
                            + "','contentdyn')\"/>\n");
            xml.append("</form>\n");
            xml.append("<div class=\"clear\"></div>\n");
            xml.append("</div>\n\n");
            xml.append("</fieldset>\n\n");

            xml.append("<div class=\"btnrow\">\n");
            //xml.append("     <form class=\"inlineform\" method=\"post\" action=\"edit"+c.getSimpleName()+".igx?id={../@id}\">\n");
            xml.append("     <form class=\"inlineform\">\n");
            xml.append(
                    "          <input type=\"button\" value=\"Delete\" onClick=\"getConfirmation('Are You Sure You Want to Delete this Record?','delete"
                            + c.getSimpleName() + ".igx?id={../@id}','')\"/>\n");
            xml.append("     </form>\n");
            xml.append("     <form class=\"inlineform\">\n");
            xml.append("          <input type=\"button\" value=\"Cancel\" onClick=\"hidedivDisplay('edit"
                    + c.getSimpleName() + "');showdivDisplay('view" + c.getSimpleName() + "');\"/>\n");
            xml.append("     </form>\n");
            xml.append("</div>\n\n");
            xml.append("</div>\n");
            xml.append("<div class=\"clear\"></div>\n");
            xml.append("<!--- END OF edit" + c.getSimpleName() + " CODE SEGMENT -->\n\n");

        }

        xml.append("<!--- START OF print" + c.getSimpleName()
                + " LIST SEGMENT USED FOR POP-UP PRINTER FRIENDLY OUTPUT -->\n");
        xml.append("<div class=\"hidden\" id=\"printlist" + c.getSimpleName() + "\">\n\n");

        // then we get the complex types!
        for (int i = 0; i < m.length; i++) {
            name = m[i].getName();
            retval = m[i].getReturnType().getName();

            // what if this is a list?
            if (retval.endsWith("List")) {
                String getter = m[i].getName();
                Method met = c.getMethod(getter, (Class[]) null);
                ParameterizedType t = (ParameterizedType) met.getGenericReturnType();
                Class c1 = (Class) t.getActualTypeArguments()[0];
                String childname = m[i].getName().substring(3);

                childname = childname.substring(0, 1).toUpperCase() + childname.substring(1);

                String clsname = indexable(c1.getSimpleName()) ? "Flex" + c1.getSimpleName()
                        : c1.getSimpleName();

                xml.append("     <!--- START OF print" + childname + " LIST CODE SEGMENT -->\n");
                xml.append("     <div id=\"print" + childname + "\">\n");
                xml.append("     <fieldset>\n");
                xml.append("     <legend>" + childname + " List</legend>\n");
                xml.append("     <div class=\"fieldsetwrap\">\n");
                xml.append("     <table class=\"sortable\">\n");

                ConfigElement ce2 = config.getElementConfig(c1.getSimpleName());
                Map cef = ce2.getFields();

                Iterator itr = cef.values().iterator();
                xml.append("          <thead><tr>\n");
                String sortfield = null;
                while (itr.hasNext()) {
                    ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                    if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) {
                        xml.append("               <th>" + cfi.label + "</th>\n");
                        if (sortfield == null) {
                            sortfield = cfi.name.toLowerCase();
                        }
                    }
                }
                xml.append("          </tr></thead>\n");

                xml.append("          <xsl:for-each select=\"" + c1.getSimpleName().toLowerCase() + "\">\n");
                xml.append("          <xsl:sort select=\"" + sortfield + "\" order=\"descending\"/>\n");

                xml.append("          <tr>\n");
                itr = cef.values().iterator();
                while (itr.hasNext()) {
                    ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                    if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) {
                        if (cfi.type.equals("byte[]")) {
                            xml.append("               <td><xsl:value-of select=\"" + cfi.name.toLowerCase()
                                    + "\"/></td>\n");
                        } else {
                            if (cfi.type.equalsIgnoreCase("decimal")) {
                                xml.append("               <td><xsl:value-of select=\"format-number("
                                        + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n");
                            } else {
                                xml.append("               <td><pre><xsl:value-of select=\""
                                        + cfi.name.toLowerCase() + "\"/></pre></td>\n");
                            }
                        }
                    }

                }
                xml.append("          </tr>\n");
                xml.append("          </xsl:for-each>\n");

                xml.append("     </table>\n");

                xml.append("     <div class=\"clear\"></div>\n");
                xml.append("     </div>\n\n");
                xml.append("     </fieldset>\n");
                xml.append("     </div>\n");
                xml.append("     <!--- END OF print" + childname + " LIST CODE SEGMENT -->\n\n");
            } else {
                if ("int,boolean".indexOf(retval) < 0 && !retval.startsWith("java") && !retval.equals("void")
                        && !retval.equals("[B")) {
                    String getter = m[i].getName();
                    Method met = c.getMethod(getter, (Class[]) null);
                    Class c1 = (Class) met.getGenericReturnType();
                    String childname = m[i].getName().substring(3);

                    childname = childname.substring(0, 1).toUpperCase() + childname.substring(1);

                    String clsname = indexable(c1.getSimpleName()) ? "Flex" + c1.getSimpleName()
                            : c1.getSimpleName();

                    xml.append("     <!--- START OF print" + childname + " CHILD CODE SEGMENT -->\n");
                    xml.append("     <div id=\"print" + childname + "\">\n");
                    xml.append("     <fieldset>\n");
                    xml.append("     <legend>" + childname + "</legend>\n");
                    xml.append("     <div class=\"fieldsetwrap\">\n");
                    xml.append("     <table class=\"sortable\">\n");

                    ConfigElement ce2 = config.getElementConfig(c1.getSimpleName());
                    Map cef = ce2.getFields();

                    Iterator itr = cef.values().iterator();
                    xml.append("          <thead><tr>\n");
                    String sortfield = null;
                    while (itr.hasNext()) {
                        ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                        if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) {
                            xml.append("               <th>" + cfi.label + "</th>\n");
                            if (sortfield == null) {
                                sortfield = cfi.name.toLowerCase();
                            }
                        }
                    }
                    xml.append("          </tr></thead>\n");

                    xml.append(
                            "          <xsl:for-each select=\"" + c1.getSimpleName().toLowerCase() + "\">\n");
                    xml.append("          <xsl:sort select=\"" + sortfield + "\" order=\"descending\"/>\n");

                    xml.append("          <tr>\n");
                    itr = cef.values().iterator();
                    while (itr.hasNext()) {
                        ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                        if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) {
                            if (cfi.type.equals("byte[]") || cfi.type.equals("base64Binary")) {
                                xml.append("               <td><xsl:value-of select=\"" + cfi.name.toLowerCase()
                                        + "\"/></td>\n");
                            } else {
                                if (cfi.type.equalsIgnoreCase("decimal")) {
                                    xml.append("               <td><xsl:value-of select=\"format-number("
                                            + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n");
                                } else {
                                    xml.append("               <td><pre><xsl:value-of select=\""
                                            + cfi.name.toLowerCase() + "\"/></pre></td>\n");
                                }

                                //xml.append("               <td><xsl:value-of select=\""+cfi.name.toLowerCase()+"\"/></td>\n");
                            }
                        }

                    }
                    xml.append("          </tr>\n");
                    xml.append("          </xsl:for-each>\n");
                    xml.append("     </table>\n\n");

                    //xml.append("     </xsl:if>\n");
                    xml.append("     <div class=\"clear\"></div>\n");
                    xml.append("     </div>\n");
                    xml.append("     </fieldset>\n");
                    xml.append("     </div>\n");
                    xml.append("     <!--- END OF print" + childname + " CHILD CODE SEGMENT -->\n\n");
                }
            }
        }
        xml.append("</div>\n");
        xml.append("<!--- END OF print" + c.getSimpleName() + " LIST SEGMENT -->\n\n");

        // as well as the print friendly version
        xml.append("<!--- START OF print" + c.getSimpleName() + " CODE SEGMENT -->\n");
        xml.append("<div class=\"hidden\" id=\"print" + c.getSimpleName() + "\">\n");
        xml.append("<!--- dont show the printing and editing divs  -->\n");
        xml.append(
                "<script language=\"JavaScript\">hidedivDisplay('edit" + c.getSimpleName() + "');</script>\n");
        xml.append(
                "<script language=\"JavaScript\">hidedivDisplay('print" + c.getSimpleName() + "');</script>\n");
        xml.append("<script language=\"JavaScript\">hidedivDisplay('printlist" + c.getSimpleName()
                + "');</script>\n");

        xml.append("<fieldset>\n");

        xml.append("<legend>View " + c.getSimpleName().substring(0, c.getSimpleName().length() - 4)
                + "</legend>\n");

        xml.append("<div class=\"fieldsetwrap\">\n");

        xml.append("     <div class=\"datafieldwrap\">\n");
        xml.append("     <table class=\"datafield\">\n");

        if (ce != null) {
            Map cef = ce.getFields();
            Iterator itr = cef.values().iterator();
            while (itr.hasNext()) {
                ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                if (cfi.visible && _types.indexOf(cfi.type) > -1) {
                    if (cfi.type.equalsIgnoreCase("decimal")) {
                        xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                + ":</td><td class=\"data full\"><xsl:value-of select=\"format-number("
                                + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td></tr>\n");
                    } else {
                        xml.append("          <tr><td class=\"lbl\">" + cfi.label
                                + ":</td><td class=\"data full\"><pre><xsl:value-of select=\""
                                + cfi.name.toLowerCase() + "\"/></pre></td></tr>\n");
                    }
                    //xml.append("               <th>"+cfi.label+"</th>\n");
                }
            }
        } else {
            it = fields.keys();

            while (it.hasMoreElements()) {
                String f = (String) it.nextElement();
                String t = (String) fields.get(f);
                if (t.equalsIgnoreCase("decimal")) {
                    xml.append("          <tr><td class=\"lbl\">" + f
                            + ":</td><td class=\"data full\"><xsl:value-of select=\"format-number("
                            + f.toLowerCase() + ",'###,###,##0.00')\"/></td></tr>\n");
                } else {
                    xml.append("          <tr><td class=\"lbl\">" + f
                            + ":</td><td class=\"data full\"><pre><xsl:value-of select=\"" + f.toLowerCase()
                            + "\"/></pre></td></tr>\n");
                }
            }
        }

        xml.append("     </table>\n");
        xml.append("     </div>\n");
        xml.append("</div>\n");
        xml.append("</fieldset>\n");
        xml.append("</div>\n");
        xml.append("<div class=\"clear\"></div>\n");
        xml.append("<!--- END OF print" + c.getSimpleName() + " CODE SEGMENT -->\n\n");

        // if this is a prototype for an empty record
        if (type == 2) {
            System.out.println("NO PROTOTYPE FOR " + c.getSimpleName());
        }

        xml.append("<!--- START OF " + c.getSimpleName() + " LIST SEGMENT -->\n");
        xml.append("<div id=\"list" + c.getSimpleName() + "\">\n\n");

        // then we get the complex types!
        for (int i = 0; i < m.length; i++) {
            name = m[i].getName();
            retval = m[i].getReturnType().getName();

            // what if this is a list?
            if (retval.endsWith("List")) {
                String getter = m[i].getName();
                Method met = c.getMethod(getter, (Class[]) null);
                ParameterizedType t = (ParameterizedType) met.getGenericReturnType();
                Class c1 = (Class) t.getActualTypeArguments()[0];
                String childname = m[i].getName().substring(3);

                childname = childname.substring(0, 1).toUpperCase() + childname.substring(1);

                String clsname = indexable(c1.getSimpleName()) ? "Flex" + c1.getSimpleName()
                        : c1.getSimpleName();

                xml.append("     <!--- START OF " + childname + " LIST CODE SEGMENT -->\n");
                xml.append("     <div id=\"child" + childname + "\">\n");
                xml.append("     <fieldset>\n");
                xml.append("     <legend>" + childname + " List</legend>\n");
                xml.append("     <div class=\"fieldsetwrap\">\n");
                xml.append("     <div style=\"overflow:auto; height:200px;\">\n");
                xml.append("     <table class=\"sortable\">\n");

                ConfigElement ce2 = config.getElementConfig(c1.getSimpleName());
                Map cef = ce2.getFields();

                Iterator itr = cef.values().iterator();
                xml.append("          <thead><tr>\n");
                String sortfield = null;
                while (itr.hasNext()) {
                    ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                    if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) {
                        xml.append("               <th>" + cfi.label + "</th>\n");
                        if (sortfield == null) {
                            sortfield = cfi.name.toLowerCase(); // by default the first column
                        }
                    }
                }
                xml.append("          </tr></thead>\n");

                xml.append("          <xsl:for-each select=\"" + c1.getSimpleName().toLowerCase() + "\">\n");
                xml.append("          <xsl:sort select=\"" + sortfield + "\" order=\"descending\"/>\n");

                xml.append("          <tr>\n");
                itr = cef.values().iterator();
                while (itr.hasNext()) {
                    ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                    if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) {
                        if (cfi.type.equals("byte[]") || cfi.type.equals("base64Binary")) {
                            xml.append("               <td><xsl:value-of select=\"" + cfi.name.toLowerCase()
                                    + "\"/></td>\n");
                        } else {
                            if (cfi.type.equalsIgnoreCase("decimal")) {
                                xml.append("               <td><xsl:value-of select=\"format-number("
                                        + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n");
                            } else {
                                xml.append("               <td><pre><xsl:value-of select=\""
                                        + cfi.name.toLowerCase() + "\"/></pre></td>\n");
                            }
                        }
                    }

                }

                /*Hashtable v = getFields(c1.newInstance());
                Enumeration it2 = v.keys();
                        
                xml.append("          <thead><tr>\n");
                while (it2.hasMoreElements())
                {
                String f2 = (String) it2.nextElement();
                xml.append("               <th>"+f2+"</th>\n");
                }
                xml.append("          </tr></thead>\n");
                        
                it2 = v.keys();
                        
                xml.append("          <xsl:for-each select=\""+childname+"\">\n");
                xml.append("          <tr>\n");
                while (it2.hasMoreElements())
                {
                String f2 = (String) it2.nextElement();
                String t2 = (String) v.get(f2);
                        
                if (t2.equals("byte[]"))
                {
                    xml.append("               <td><xsl:value-of select=\""+f2+"\"/></td>\n");
                }
                else
                {
                    xml.append("               <td><xsl:value-of select=\""+f2+"\"/></td>\n");
                }
                        
                }
                */
                xml.append("          </tr>\n");
                xml.append("          </xsl:for-each>\n");

                xml.append("     </table>\n");
                xml.append("     </div>\n");

                xml.append("     <div id=\"list" + childname + "buttons\">\n\n");
                xml.append("       <input type=\"button\" value=\"View " + childname + " List\"   onClick=\""
                        + (message != null ? "hidedivDisplay('message');" : "")
                        + "javascript:linkchangecontent('get" + clsname
                        + "WithParentID.igx?id={../@id}&amp;do=savecontext&amp;"
                        + c1.getSimpleName().toLowerCase() + "parent=get" + c.getSimpleName() + ".igx&amp;"
                        + c1.getSimpleName().toLowerCase() + "parentname="
                        + c.getSimpleName().substring(0, c.getSimpleName().length() - 4) + "&amp;"
                        + c1.getSimpleName().toLowerCase()
                        + "parentid=<%var_request[id]%>&amp;from=0&amp;to=15','contentdyn')\"/>\n");
                xml.append("       <input type=\"button\" value=\"New " + childname + "\"   onClick=\""
                        + (message != null ? "hidedivDisplay('message');" : "")
                        + "javascript:linkchangecontent('new" + clsname
                        + ".htm?id={../@id}&amp;do=savecontext&amp;" + c1.getSimpleName().toLowerCase()
                        + "parent=get" + c.getSimpleName() + ".igx&amp;" + c1.getSimpleName().toLowerCase()
                        + "parentname=" + c.getSimpleName().substring(0, c.getSimpleName().length() - 4)
                        + "&amp;" + c1.getSimpleName().toLowerCase()
                        + "parentid=<%var_request[id]%>','contentdyn')\"/>\n");
                xml.append("     </div>\n\n");

                xml.append("     <div class=\"clear\"></div>\n");
                xml.append("     </div>\n\n");
                xml.append("     </fieldset>\n");
                xml.append("     </div>\n");
                xml.append("     <!--- END OF " + childname + " LIST CODE SEGMENT -->\n\n");
            } else {
                if ("int,boolean".indexOf(retval) < 0 && !retval.startsWith("java") && !retval.equals("void")
                        && !retval.equals("[B")) {
                    String getter = m[i].getName();
                    Method met = c.getMethod(getter, (Class[]) null);
                    Class c1 = (Class) met.getGenericReturnType();
                    String childname = m[i].getName().substring(3);

                    childname = childname.substring(0, 1).toUpperCase() + childname.substring(1);

                    String clsname = indexable(c1.getSimpleName()) ? "Flex" + c1.getSimpleName()
                            : c1.getSimpleName();

                    xml.append("     <!--- START OF SINGLETON " + childname + " CHILD CODE SEGMENT -->\n");
                    xml.append("     <div id=\"child" + c.getSimpleName() + "\">\n");
                    xml.append("     <fieldset>\n");
                    xml.append("     <legend>" + childname + "</legend>\n");
                    xml.append("     <div class=\"fieldsetwrap\">\n");
                    xml.append("     <div style=\"overflow:auto; height:200px;\">\n");
                    xml.append("     <table class=\"sortable\">\n");

                    ConfigElement ce2 = config.getElementConfig(c1.getSimpleName());
                    Map cef = ce2.getFields();

                    Iterator itr = cef.values().iterator();
                    xml.append("          <thead><tr>\n");

                    String sortfield = null;

                    while (itr.hasNext()) {
                        ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                        if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) {
                            xml.append("               <th>" + cfi.label + "</th>\n");

                            if (sortfield == null) {
                                sortfield = cfi.name.toLowerCase();
                            }
                        }
                    }
                    xml.append("          </tr></thead>\n");

                    xml.append(
                            "          <xsl:for-each select=\"" + c1.getSimpleName().toLowerCase() + "\">\n");
                    xml.append("          <xsl:sort select=\"" + sortfield + "\" order=\"descending\"/>\n");
                    xml.append("          <tr>\n");
                    itr = cef.values().iterator();
                    while (itr.hasNext()) {
                        ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next();
                        if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) {
                            if (cfi.type.equals("byte[]") || cfi.type.equals("base64Binary")) {
                                xml.append("               <td><xsl:value-of select=\"" + cfi.name.toLowerCase()
                                        + "\"/></td>\n");
                            } else {
                                if (cfi.type.equalsIgnoreCase("decimal")) {
                                    xml.append("               <td><xsl:value-of select=\"format-number("
                                            + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n");
                                } else {
                                    xml.append("               <td><pre><xsl:value-of select=\""
                                            + cfi.name.toLowerCase() + "\"/></pre></td>\n");
                                }

                            }
                        }

                    }
                    /*Hashtable v = getFields(c1.newInstance());
                    Enumeration it2 = v.keys();
                            
                    xml.append("          <thead><tr>\n");
                    while (it2.hasMoreElements())
                    {
                    String f2 = (String) it2.nextElement();
                    xml.append("               <th>"+f2+"</th>\n");
                    }
                    xml.append("          </tr></thead>\n");
                            
                    it2 = v.keys();
                            
                    xml.append("          <xsl:for-each select=\""+childname+"\">\n");
                    xml.append("          <tr>\n");
                    while (it2.hasMoreElements())
                    {
                    String f2 = (String) it2.nextElement();
                    String t2 = (String) v.get(f2);
                            
                    if (t2.equals("byte[]"))
                    {
                        xml.append("               <td><xsl:value-of select=\""+f2+"\"/></td>\n");
                    }
                    else
                    {
                        xml.append("               <td><xsl:value-of select=\""+f2+"\"/></td>\n");
                    }
                            
                    }
                    */
                    xml.append("          </tr>\n");
                    xml.append("          </xsl:for-each>\n");
                    xml.append("     </table>\n");
                    xml.append("     </div>\n\n");

                    xml.append("     <div id=\"list" + childname + "buttons\">\n\n");
                    xml.append("       <input type=\"button\" value=\"View " + childname + "\"   onClick=\""
                            + (message != null ? "hidedivDisplay('message');" : "")
                            + "javascript:linkchangecontent('get" + clsname
                            + "WithParentID.igx?id={../@id}&amp;do=savecontext&amp;"
                            + c1.getSimpleName().toLowerCase() + "parent=get" + c.getSimpleName() + ".igx&amp;"
                            + c1.getSimpleName().toLowerCase() + "parentname=" + c.getSimpleName() + "&amp;"
                            + c1.getSimpleName().toLowerCase()
                            + "parentid=<%var_request[id]%>','contentdyn')\"/>\n");
                    xml.append("       <input type=\"button\" value=\"Create " + childname + "\"   onClick=\""
                            + (message != null ? "hidedivDisplay('message');" : "")
                            + "javascript:linkchangecontent('new" + clsname
                            + ".htm?id={../@id}','contentdyn')\"/>\n");
                    xml.append("     </div>\n\n");

                    xml.append("     <div class=\"clear\"></div>\n");
                    xml.append("     </div>\n");
                    xml.append("     </fieldset>\n");
                    xml.append("     </div>\n");
                    xml.append("     <!--- END OF SINGLETON " + childname + " CHILD CODE SEGMENT -->\n\n");
                }
            }
        }

        xml.append("</div>\n");
        xml.append("<!--- END OF " + c.getSimpleName() + " LIST SEGMENT -->\n\n");

        xml.append("</xsl:template>\n\n");

    }

    return xml.toString();

}

From source file:uk.ac.babraham.SeqMonk.ProbeGenerators.MacsPeakCaller.java

public void run() {

    //      for (int i=0;i<selectedChIPStores.length;i++) {
    //         System.err.println("Selcted ChIP="+selectedChIPStores[i]);
    //      }//from   w  ww.ja v  a  2s .c  om
    //      for (int i=0;i<selectedInputStores.length;i++) {
    //         System.err.println("Selcted Input="+selectedInputStores[i]);
    //      }

    // First find the tag offsets between the watson and crick strands

    // Work out the total average coverage for all of the combined ChIP samples
    long totalChIPCoverage = 0;

    for (int i = 0; i < selectedChIPStores.length; i++) {
        totalChIPCoverage += selectedChIPStores[i].getTotalReadLength();
    }

    if (cancel) {
        generationCancelled();
        return;
    }

    double averageChIPCoveragePerBase = totalChIPCoverage / (double) collection.genome().getTotalGenomeLength();

    double lowerCoverage = averageChIPCoveragePerBase * minFoldEnrichment;
    double upperCoverage = averageChIPCoveragePerBase * maxFoldEnrichment;

    System.err.println("Coverage range for high confidence peaks is " + lowerCoverage + " - " + upperCoverage);

    // Now we go through the data to find locations for our high confidence peaks so we can
    // randomly select 1000 of these to use to find the offset between the two strands

    Chromosome[] chromosomes = collection.genome().getAllChromosomes();

    Vector<Probe> potentialHighConfidencePeaks = new Vector<Probe>();

    for (int c = 0; c < chromosomes.length; c++) {

        if (cancel) {
            generationCancelled();
            return;
        }

        // Time for an update
        updateGenerationProgress("Finding high confidence peaks on chromosome " + chromosomes[c].name(), c,
                chromosomes.length);

        Probe lastValidProbe = null;

        for (int startPosition = 1; startPosition < chromosomes[c].length()
                - fragmentSize; startPosition += fragmentSize / 2) {

            // See if we need to quit
            if (cancel) {
                generationCancelled();
                return;
            }

            long totalLength = 0;
            Probe probe = new Probe(chromosomes[c], startPosition, startPosition + fragmentSize);

            for (int s = 0; s < selectedChIPStores.length; s++) {
                long[] reads = selectedChIPStores[s].getReadsForProbe(probe);
                for (int j = 0; j < reads.length; j++) {
                    totalLength += SequenceRead.length(reads[j]);
                }
            }

            if (totalLength >= (lowerCoverage * probe.length())
                    && totalLength <= upperCoverage * probe.length()) {

                // We have a potential high quality peak.

                // See if we can merge it with the last valid probe

                if (lastValidProbe != null
                        && SequenceRead.overlaps(lastValidProbe.packedPosition(), probe.packedPosition())) {

                    lastValidProbe = new Probe(chromosomes[c], lastValidProbe.start(), probe.end());

                } else if (lastValidProbe != null) {

                    // Check that the overall density over the region falls within our limits
                    totalLength = 0;
                    for (int s = 0; s < selectedChIPStores.length; s++) {
                        long[] reads = selectedChIPStores[s].getReadsForProbe(lastValidProbe);
                        for (int j = 0; j < reads.length; j++) {
                            totalLength += SequenceRead.length(reads[j]);
                        }
                    }

                    if (totalLength >= (lowerCoverage * lastValidProbe.length())
                            && totalLength <= upperCoverage * lastValidProbe.length()) {
                        potentialHighConfidencePeaks.add(lastValidProbe);
                    }

                    lastValidProbe = probe;
                } else {
                    lastValidProbe = probe;
                }
            }

        }

        if (lastValidProbe != null) {
            long totalLength = 0;
            for (int s = 0; s < selectedChIPStores.length; s++) {
                long[] reads = selectedChIPStores[s].getReadsForProbe(lastValidProbe);
                for (int j = 0; j < reads.length; j++) {
                    totalLength += SequenceRead.length(reads[j]);
                }
            }

            if (totalLength >= (lowerCoverage * lastValidProbe.length())
                    && totalLength <= upperCoverage * lastValidProbe.length()) {
                potentialHighConfidencePeaks.add(lastValidProbe);
            }
        }
    }

    if (potentialHighConfidencePeaks.size() == 0) {

        JOptionPane.showMessageDialog(SeqMonkApplication.getInstance(), "No high confidence peaks found",
                "Quitting generator", JOptionPane.INFORMATION_MESSAGE);
        generationCancelled();
        return;
    }

    //      System.err.println("Found "+potentialHighConfidencePeaks.size()+" high confidence peaks");

    // Now we select 1000 random probes from this set
    Probe[] highConfidencePeaks = potentialHighConfidencePeaks.toArray(new Probe[0]);

    Collections.shuffle(Arrays.asList(highConfidencePeaks));

    Probe[] randomHighConfidenceProbes = new Probe[Math.min(highConfidencePeaks.length, 1000)];

    for (int i = 0; i < randomHighConfidenceProbes.length; i++) {
        randomHighConfidenceProbes[i] = highConfidencePeaks[i];
    }

    // Now find the average distance between forward / reverse reads in the candidate peaks

    int[] distances = new int[highConfidencePeaks.length];

    // Sort the candidates so we don't do stupid stuff with the cache
    Arrays.sort(randomHighConfidenceProbes);

    for (int p = 0; p < randomHighConfidenceProbes.length; p++) {

        // See if we need to quit
        if (cancel) {
            generationCancelled();
            return;
        }

        distances[p] = getInterStrandDistance(randomHighConfidenceProbes[p], selectedChIPStores);
    }

    int medianInterStrandDistance = (int) SimpleStats.median(distances);

    if (medianInterStrandDistance < 0)
        medianInterStrandDistance = 0;

    //      System.err.println("Median inter strand difference = "+medianInterStrandDistance);

    // Now we find the depth cutoff for overrepresented single tags using a binomial distribution
    int totalReadCount = 0;
    for (int i = 0; i < selectedChIPStores.length; i++) {
        totalReadCount += selectedChIPStores[i].getTotalReadCount();
    }

    BinomialDistribution bin = new BinomialDistribution(totalReadCount,
            1d / collection.genome().getTotalGenomeLength());

    // We want to know what depth has a chance of less than 1^-5
    int redundantThreshold = bin.inverseCumulativeProbability(1 - 0.00001d);

    if (redundantThreshold < 1)
        redundantThreshold = 1;

    //      System.err.println("Redundancy threshold is "+redundantThreshold);

    // Now we construct a poisson distribution to work out the threshold to use for
    // constructing a full candidate peak set.

    updateGenerationProgress("Counting non-redundant reads", 0, 1);

    // To do this we need to get the full non-redundant length from the whole set
    int totalNonRedCount = getNonRedundantReadCount(selectedChIPStores, redundantThreshold);

    //      System.err.println("Total non-redundant sequences is "+totalNonRedCount);

    // We need to know the median read length for the data
    int readLength = 0;
    for (int i = 0; i < selectedChIPStores.length; i++) {
        readLength += selectedChIPStores[i].getTotalReadLength() / selectedChIPStores[i].getTotalReadCount();
    }
    readLength /= selectedChIPStores.length;

    double expectedCountsPerWindow = getExpectedCountPerWindow(totalNonRedCount,
            collection.genome().getTotalGenomeLength(), fragmentSize, readLength);

    PoissonDistribution poisson = new PoissonDistribution(expectedCountsPerWindow);

    int readCountCutoff = poisson.inverseCumulativeProbability(1 - pValue);

    //      System.err.println("Threshold for enrichment in a window is "+readCountCutoff+" reads using a p-value of "+pValue+" and a mean of "+(totalNonRedCount/(collection.genome().getTotalGenomeLength()/(double)fragmentSize)));

    // Now we go back through the whole dataset to do a search for all possible candidate probes 

    // We re-use the peak vector we came up with before.
    potentialHighConfidencePeaks.clear();

    for (int c = 0; c < chromosomes.length; c++) {
        // Time for an update
        updateGenerationProgress("Finding candidate peaks on chromosome " + chromosomes[c].name(), c,
                chromosomes.length);

        Probe lastValidProbe = null;

        for (int startPosition = 1; startPosition < chromosomes[c].length()
                - fragmentSize; startPosition += fragmentSize / 2) {

            // See if we need to quit
            if (cancel) {
                generationCancelled();
                return;
            }

            // We expand the region we're looking at by the inter-strand distance as we're going to
            // be adjusting the read positions
            Probe probe = new Probe(chromosomes[c], startPosition, (startPosition + fragmentSize - 1));

            long[] mergedProbeReads = getReadsFromDataStoreCollection(probe, selectedChIPStores,
                    medianInterStrandDistance);

            mergedProbeReads = deduplicateReads(mergedProbeReads, redundantThreshold);

            SequenceRead.sort(mergedProbeReads);

            int thisProbeOverlapCount = 0;
            for (int i = 0; i < mergedProbeReads.length; i++) {
                if (SequenceRead.overlaps(mergedProbeReads[i], probe.packedPosition())) {
                    ++thisProbeOverlapCount;
                }
            }

            if (thisProbeOverlapCount > readCountCutoff) {

                // We have a potential high quality peak.

                // See if we can merge it with the last valid probe

                if (lastValidProbe != null
                        && SequenceRead.overlaps(lastValidProbe.packedPosition(), probe.packedPosition())) {

                    lastValidProbe = new Probe(chromosomes[c], lastValidProbe.start(), probe.end());

                } else if (lastValidProbe != null) {
                    potentialHighConfidencePeaks.add(lastValidProbe);
                    lastValidProbe = probe;
                } else {
                    lastValidProbe = probe;
                }
            }

        }

        if (lastValidProbe != null) {
            potentialHighConfidencePeaks.add(lastValidProbe);
        }
    }

    // Finally we re-filter the peaks we have using local poisson distributions with densities taken
    // from either the input samples (if there are any), or the local region.  The densities are 
    // estimated over 1,5 and 10kb around the peak and genome wide and the max of these is taken.
    // If there is no input then the 1kb region is not used.

    Probe[] allCandidateProbes = potentialHighConfidencePeaks.toArray(new Probe[0]);

    // Work out which stores we're using to validate against.
    DataStore[] validationStores;
    boolean useInput = false;
    double inputCorrection = 1;

    int validationNonRedCount;

    if (selectedInputStores != null && selectedInputStores.length > 0) {

        // See if we need to quit
        if (cancel) {
            generationCancelled();
            return;
        }

        validationStores = selectedInputStores;
        useInput = true;

        // We also need to work out the total number of nonredundant seqences
        // in the input so we can work out a scaling factor so that the densities
        // for input and chip are comparable.
        validationNonRedCount = getNonRedundantReadCount(validationStores, redundantThreshold);

        inputCorrection = totalNonRedCount / (double) validationNonRedCount;

        System.err.println("From chip=" + totalNonRedCount + " input=" + validationNonRedCount
                + " correction is " + inputCorrection);

    } else {
        validationStores = selectedChIPStores;
        validationNonRedCount = totalNonRedCount;
    }

    Vector<Probe> finalValidatedProbes = new Vector<Probe>();

    for (int p = 0; p < allCandidateProbes.length; p++) {

        // See if we need to quit
        if (cancel) {
            generationCancelled();
            return;
        }

        if (p % 100 == 0) {
            updateGenerationProgress("Validated " + p + " out of " + allCandidateProbes.length + " raw peaks",
                    p, allCandidateProbes.length);
        }

        //         System.err.println("Validating "+allCandidateProbes[p].chromosome()+":"+allCandidateProbes[p].start()+"-"+allCandidateProbes[p].end());

        // We now need to find the maximum read density per 2*bandwidth against which
        // we're going to validate this peak

        // We're going to get all reads within 10kb of the peak, and then we can subselect from there

        int midPoint = allCandidateProbes[p].middle();

        Probe region10kb = new Probe(allCandidateProbes[p].chromosome(), Math.max(midPoint - 5000, 1),
                Math.min(midPoint + 4999, allCandidateProbes[p].chromosome().length()),
                allCandidateProbes[p].strand());
        Probe region5kb = new Probe(allCandidateProbes[p].chromosome(), Math.max(midPoint - 2500, 1),
                Math.min(midPoint + 2499, allCandidateProbes[p].chromosome().length()),
                allCandidateProbes[p].strand());
        Probe region1kb = new Probe(allCandidateProbes[p].chromosome(), Math.max(midPoint - 500, 1),
                Math.min(midPoint + 499, allCandidateProbes[p].chromosome().length()),
                allCandidateProbes[p].strand());

        // Get the probes for the largest region
        long[] thisRegionReads = getReadsFromDataStoreCollection(region10kb, validationStores, 0);

        // Deduplicate so it's a fair comparison
        thisRegionReads = deduplicateReads(thisRegionReads, redundantThreshold); // Should we recalculate the redundant threshold based on the input coverage?

        int region10kbcount = thisRegionReads.length;
        int region5kbcount = 0;
        int region1kbcount = 0;

        // Go through the reads seeing if they fit into the 5 or 1kb regions
        for (int r = 0; r < thisRegionReads.length; r++) {
            if (SequenceRead.overlaps(region5kb.packedPosition(), thisRegionReads[r]))
                ++region5kbcount;
            if (SequenceRead.overlaps(region1kb.packedPosition(), thisRegionReads[r]))
                ++region1kbcount;
        }

        //         System.err.println("Input counts 10kb="+region10kbcount+" 5kb="+region5kbcount+" 1kb="+region1kbcount);

        // Convert to densities per window and ajdust for global coverage

        double globalDensity = getExpectedCountPerWindow(validationNonRedCount,
                collection.genome().getTotalGenomeLength(), allCandidateProbes[p].length(), readLength)
                * inputCorrection;
        double density10kb = getExpectedCountPerWindow(region10kbcount, region10kb.length(),
                allCandidateProbes[p].length(), readLength) * inputCorrection;
        double density5kb = getExpectedCountPerWindow(region5kbcount, region5kb.length(),
                allCandidateProbes[p].length(), readLength) * inputCorrection;
        double density1kb = getExpectedCountPerWindow(region1kbcount, region1kb.length(),
                allCandidateProbes[p].length(), readLength) * inputCorrection;

        // Find the highest density to use for the validation
        double highestDensity = globalDensity;
        if (density10kb > highestDensity)
            highestDensity = density10kb;
        if (density5kb > highestDensity)
            highestDensity = density5kb;
        if (useInput && density1kb > highestDensity)
            highestDensity = density1kb;

        //         System.err.println("Global="+globalDensity+" 10kb="+density10kb+" 5kb="+density5kb+" 1kb="+density1kb+" using="+highestDensity);

        // Construct a poisson distribution with this density
        PoissonDistribution localPoisson = new PoissonDistribution(highestDensity);

        //         System.err.println("Cutoff from global="+(new PoissonDistribution(globalDensity)).inverseCumulativeProbability(1-pValue)+" 10kb="+(new PoissonDistribution(density10kb)).inverseCumulativeProbability(1-pValue)+" 5kb="+(new PoissonDistribution(density5kb)).inverseCumulativeProbability(1-pValue)+" 1kb="+(new PoissonDistribution(density1kb)).inverseCumulativeProbability(1-pValue));
        // Now check to see if the actual count from this peak is enough to still pass
        long[] mergedProbeReads = getReadsFromDataStoreCollection(allCandidateProbes[p], selectedChIPStores,
                medianInterStrandDistance);
        mergedProbeReads = deduplicateReads(mergedProbeReads, redundantThreshold);

        SequenceRead.sort(mergedProbeReads);

        int thisProbeOverlapCount = 0;
        for (int i = 0; i < mergedProbeReads.length; i++) {
            if (SequenceRead.overlaps(mergedProbeReads[i], allCandidateProbes[p].packedPosition())) {
                ++thisProbeOverlapCount;
            }
        }

        //         System.err.println("Read count in ChIP is "+thisProbeOverlapCount);

        if (thisProbeOverlapCount > localPoisson.inverseCumulativeProbability(1 - pValue)) {
            finalValidatedProbes.add(allCandidateProbes[p]);
            //            System.err.println("Adding probe to final set");
        }

    }

    //      System.err.println("From "+allCandidateProbes.length+" candidates "+finalValidatedProbes.size()+" peaks were validated");

    ProbeSet finalSet = new ProbeSet(getDescription(), finalValidatedProbes.toArray(new Probe[0]));

    generationComplete(finalSet);

}

From source file:org.eclipse.swt.examples.fileviewer.FileViewer.java

/**
 * Handles a drop on a dropTarget.//from   w  w w  . j ava  2s. c  om
 * <p>
 * Used in drop().<br>
 * Note event.detail is modified by this method.
 * </p>
 * 
 * @param event
 *            the DropTargetEvent passed as parameter to the drop() method
 * @param targetFile
 *            the File representing the drop target location under
 *            inspection, or null if none
 */
private void dropTargetHandleDrop(DropTargetEvent event, File targetFile) {
    Log.i("");
    // Get dropped data (an array of filenames)
    if (!dropTargetValidate(event, targetFile))
        return;
    final String[] sourceNames = (String[]) event.data;
    if (sourceNames == null)
        event.detail = DND.DROP_NONE;
    if (event.detail == DND.DROP_NONE)
        return;

    // Open progress dialog
    progressDialog = new ProgressDialog(shell,
            (event.detail == DND.DROP_MOVE) ? ProgressDialog.MOVE : ProgressDialog.COPY);
    progressDialog.setTotalWorkUnits(sourceNames.length);
    progressDialog.open();

    // Copy each file
    Vector /* of File */ processedFiles = new Vector();
    for (int i = 0; (i < sourceNames.length) && (!progressDialog.isCancelled()); i++) {
        final File source = new File(sourceNames[i]);
        final File dest = new File(targetFile, source.getName());
        if (source.equals(dest))
            continue; // ignore if in same location

        progressDialog.setDetailFile(source, ProgressDialog.COPY);
        while (!progressDialog.isCancelled()) {
            if (copyFileStructure(source, dest)) {
                processedFiles.add(source);
                break;
            } else if (!progressDialog.isCancelled()) {
                if (event.detail == DND.DROP_MOVE && (!isDragging)) {
                    // It is not possible to notify an external drag source
                    // that a drop
                    // operation was only partially successful. This is
                    // particularly a
                    // problem for DROP_MOVE operations since unless the
                    // source gets
                    // DROP_NONE, it will delete the original data including
                    // bits that
                    // may not have been transferred successfully.
                    MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.RETRY | SWT.CANCEL);
                    box.setText(getResourceString("dialog.FailedCopy.title"));
                    box.setMessage(
                            getResourceString("dialog.FailedCopy.description", new Object[] { source, dest }));
                    int button = box.open();
                    if (button == SWT.CANCEL) {
                        i = sourceNames.length;
                        event.detail = DND.DROP_NONE;
                        break;
                    }
                } else {
                    // We can recover gracefully from errors if the drag
                    // source belongs
                    // to this application since it will look at
                    // processedDropFiles.
                    MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.ABORT | SWT.RETRY | SWT.IGNORE);
                    box.setText(getResourceString("dialog.FailedCopy.title"));
                    box.setMessage(
                            getResourceString("dialog.FailedCopy.description", new Object[] { source, dest }));
                    int button = box.open();
                    if (button == SWT.ABORT)
                        i = sourceNames.length;
                    if (button != SWT.RETRY)
                        break;
                }
            }
            progressDialog.addProgress(1);
        }
    }
    if (isDragging) {
        // Remember exactly which files we processed
        processedDropFiles = ((File[]) processedFiles.toArray(new File[processedFiles.size()]));
    } else {
        progressDialog.close();
        progressDialog = null;
    }
    notifyRefreshFiles(new File[] { targetFile });
}

From source file:it.doqui.index.ecmengine.business.publishing.EcmEnginePublisherBean.java

/**
 * Estrae un insieme ridotto dei metadati di un contenuto da utilizzare nel result set
 * di una ricerca.//from   w  w w  . ja v a  2 s .co  m
 *
 * <p>I metadati estratti da questo metodo sono i seguenti:</p>
 * <ul>
 *  <li>{@code cm:name}: nome del contenuto.</li>
 *  <li>{@code cm:created}: data di creazione.</li>
 *  <li>{@code cm:creator}: creatore.</li>
 *  <li>{@code cm:modified}: data di ultima modifica.</li>
 *  <li>{@code cm:modifier}: autore dell'ultima modifica.</li>
 *  <li>{@code sys:store-identifier}: identificativo dello store.</li>
 *  <li>{@code sys:store-protocol}: protocollo di accesso allo store.</li>
 * </ul>
 *
 * @param props La {@code Map} completa contenente i metadati.
 *
 * @return Un array contenente una parte dei metadati del contenuto.
 */
protected ResultProperty[] translateReducedPropertyMap(Map<QName, Serializable> props) {
    logger.debug("[EcmEnginePublisherBean::translateReducedPropertyMap] BEGIN");

    try {
        Vector<ResultProperty> propVector = new Vector<ResultProperty>(7);

        logger.debug(
                "[EcmEnginePublisherBean::translateReducedPropertyMap] Creazione array metadati ridotto: 7");

        // Ciclo sulle proprieta`

        // cm:name
        ResultProperty propName = new ResultProperty();
        propName.setPrefixedName("cm:name");
        propName.setValues(new String[] { (String) props.get(ContentModel.PROP_NAME) });

        propVector.add(propName);
        propName = null;

        // cm:created
        Date rawCreationDate = (Date) props.get(ContentModel.PROP_CREATED);

        if (rawCreationDate != null) {
            ResultProperty propCreationDate = new ResultProperty();
            propCreationDate.setPrefixedName("cm:created");
            propCreationDate.setValues(new String[] { ISO8601DateFormat.format(rawCreationDate) });

            propVector.add(propCreationDate);
            propCreationDate = null;
            rawCreationDate = null;
        }

        // cm:creator
        String rawCreator = (String) props.get(ContentModel.PROP_CREATOR);

        if (rawCreator != null) {
            ResultProperty propCreator = new ResultProperty();
            propCreator.setPrefixedName("cm:creator");
            propCreator.setValues(new String[] { rawCreator });

            propVector.add(propCreator);
            propCreator = null;
            rawCreator = null;
        }

        // cm:modified
        Date rawModifiedDate = (Date) props.get(ContentModel.PROP_MODIFIED);

        if (rawModifiedDate != null) {
            ResultProperty propModifiedDate = new ResultProperty();
            propModifiedDate.setPrefixedName("cm:modified");
            propModifiedDate.setValues(new String[] { ISO8601DateFormat.format(rawModifiedDate) });

            propVector.add(propModifiedDate);
            propModifiedDate = null;
            rawCreationDate = null;
        }

        // cm:modifier
        String rawModifier = (String) props.get(ContentModel.PROP_MODIFIER);

        if (rawModifier != null) {
            ResultProperty propModifier = new ResultProperty();
            propModifier.setPrefixedName("cm:modifier");
            propModifier.setValues(new String[] { rawCreator });

            propVector.add(propModifier);
            propModifier = null;
            rawModifier = null;
        }

        // sys:store-identifier
        ResultProperty propStoreId = new ResultProperty();
        propStoreId.setPrefixedName("sys:store-identifier");
        propStoreId.setValues(new String[] { (String) props.get(ContentModel.PROP_STORE_IDENTIFIER) });

        propVector.add(propStoreId);
        propStoreId = null;

        // sys:store-protocol
        ResultProperty propStoreProtocol = new ResultProperty();
        propStoreProtocol.setPrefixedName("sys:store-protocol");
        propStoreProtocol.setValues(new String[] { (String) props.get(ContentModel.PROP_STORE_PROTOCOL) });

        propVector.add(propStoreProtocol);
        propStoreProtocol = null;

        return propVector.toArray(new ResultProperty[] {});
    } finally {
        logger.debug("[EcmEnginePublisherBean::translateReducedPropertyMap] END");
    }
}

From source file:org.apache.hadoop.mapred.JobTracker.java

public synchronized TaskReport[] getSetupTaskReports(JobID jobid) throws IOException {
    JobInProgress job = jobs.get(jobid);
    if (job != null) {
        // Check authorization
        aclsManager.checkAccess(job, UserGroupInformation.getCurrentUser(), Operation.VIEW_JOB_DETAILS);
    }//from w  w w .  j  a  v a2  s .  c  om
    if (job == null || !isJobInited(job)) {
        return EMPTY_TASK_REPORTS;
    } else {
        Vector<TaskReport> reports = new Vector<TaskReport>();
        Vector<TaskInProgress> completeTasks = job.reportSetupTIPs(true);
        for (Iterator<TaskInProgress> it = completeTasks.iterator(); it.hasNext();) {
            TaskInProgress tip = it.next();
            reports.add(tip.generateSingleReport());
        }
        Vector<TaskInProgress> incompleteTasks = job.reportSetupTIPs(false);
        for (Iterator<TaskInProgress> it = incompleteTasks.iterator(); it.hasNext();) {
            TaskInProgress tip = it.next();
            reports.add(tip.generateSingleReport());
        }
        return reports.toArray(new TaskReport[reports.size()]);
    }
}

From source file:org.apache.hadoop.mapred.JobTracker.java

public synchronized TaskReport[] getCleanupTaskReports(JobID jobid) throws IOException {
    JobInProgress job = jobs.get(jobid);
    if (job != null) {
        // Check authorization
        aclsManager.checkAccess(job, UserGroupInformation.getCurrentUser(), Operation.VIEW_JOB_DETAILS);
    }//w  w w .  j a v a  2  s .co m
    if (job == null || !isJobInited(job)) {
        return EMPTY_TASK_REPORTS;
    } else {
        Vector<TaskReport> reports = new Vector<TaskReport>();
        Vector<TaskInProgress> completeTasks = job.reportCleanupTIPs(true);
        for (Iterator<TaskInProgress> it = completeTasks.iterator(); it.hasNext();) {
            TaskInProgress tip = it.next();
            reports.add(tip.generateSingleReport());
        }
        Vector<TaskInProgress> incompleteTasks = job.reportCleanupTIPs(false);
        for (Iterator<TaskInProgress> it = incompleteTasks.iterator(); it.hasNext();) {
            TaskInProgress tip = it.next();
            reports.add(tip.generateSingleReport());
        }
        return reports.toArray(new TaskReport[reports.size()]);
    }

}