Example usage for java.lang Integer compareTo

List of usage examples for java.lang Integer compareTo

Introduction

In this page you can find the example usage for java.lang Integer compareTo.

Prototype

public int compareTo(Integer anotherInteger) 

Source Link

Document

Compares two Integer objects numerically.

Usage

From source file:org.nuclos.client.ui.collect.CollectController.java

/**
 * makes sure the given list of selected fields is non-empty. If the list is empty, this method adds one field to it.
 * This is to avoid a seemingly empty search result, which might be irritating to the user.
 * @param clcte//from  w  w w. j a  v  a  2s  .  c o m
 * @param lstclctefSelected
 * @precondition clcte != null
 * @precondition lstclctefSelected != null
 * @postcondition !lstclctefSelected.isEmpty()
 *
 * TODO: Make this protected again.
 */
public void makeSureSelectedFieldsAreNonEmpty(CollectableEntity clcte,
        List<CollectableEntityField> lstclctefSelected) {
    if (lstclctefSelected.isEmpty()) {

        List<String> fieldNames = new ArrayList<String>();
        try {
            List<EntityFieldMetaDataVO> fields = CollectionUtils.sorted(
                    MetaDataClientProvider.getInstance().getAllEntityFieldsByEntity(clcte.getName()).values(),
                    new Comparator<EntityFieldMetaDataVO>() {
                        @Override
                        public int compare(EntityFieldMetaDataVO o1, EntityFieldMetaDataVO o2) {
                            Integer order1 = (o1.getOrder() == null) ? 0 : o1.getOrder();
                            Integer order2 = (o2.getOrder() == null) ? 0 : o2.getOrder();
                            return order1.compareTo(order2);
                        }
                    });

            for (EntityFieldMetaDataVO efMeta : fields) {
                if (StringUtils.isNullOrEmpty(efMeta.getCalcFunction())) {
                    fieldNames.add(efMeta.getField());
                }
            }
        } catch (Exception ex) {
            LOG.warn("No entity fields for entity " + clcte.getName(), ex);
        }
        if (fieldNames.isEmpty()) {
            fieldNames.addAll(clcte.getFieldNames());
        }

        CollectableEntityField sysStateIcon = null;
        CollectableEntityField sysStateNumber = null;
        CollectableEntityField sysStateName = null;

        Set<String> clcteFieldNames = clcte.getFieldNames();
        for (String field : fieldNames) {
            if (!clcteFieldNames.contains(field)) {
                LOG.warn("Field " + field + " in collectable entity " + clcte.getName() + " does not exists");
                continue;
            }

            CollectableEntityField clctef = clcte.getEntityField(field);
            boolean select = true;
            if (NuclosEOField.getByField(field) != null) {
                select = false;
                switch (NuclosEOField.getByField(field)) {
                case STATEICON:
                    sysStateIcon = clctef;
                    break;
                case STATENUMBER:
                    sysStateNumber = clctef;
                    break;
                case STATE:
                    sysStateName = clctef;
                    break;
                }
            }
            if (select) {
                lstclctefSelected.add(clctef);
            }
        }

        if (sysStateIcon != null)
            lstclctefSelected.add(sysStateIcon);
        if (sysStateNumber != null)
            lstclctefSelected.add(sysStateNumber);
        if (sysStateName != null)
            lstclctefSelected.add(sysStateName);

        if (lstclctefSelected.isEmpty()) {
            // show any (the first, random) field:
            if (clcte.getFieldNames().isEmpty()) {
                throw new CommonFatalException(
                        "Die Entit\u00e4t \"" + clcte.getName() + "\" enth\u00e4lt keine Felder.");
            } else {
                final String sRandomFieldName = clcte.getFieldNames().iterator().next();
                lstclctefSelected
                        .add(getResultController().getCollectableEntityFieldForResult(clcte, sRandomFieldName));
            }
        }
    }
}

From source file:org.alfresco.repo.search.impl.lucene.ADMLuceneTest.java

/**
 * @throws Exception//from  ww  w  . ja  va 2s . c o m
 */
public void testSort() throws Exception {
    Collator collator = Collator.getInstance(I18NUtil.getLocale());

    luceneFTS.pause();
    buildBaseIndex();
    runBaseTests();

    ADMLuceneSearcherImpl searcher = buildSearcher();

    SearchParameters sp = new SearchParameters();
    sp.addStore(rootNodeRef.getStoreRef());
    sp.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp.setQuery("PATH:\"//.\"");
    sp.addSort("ID", true);
    ResultSet results = searcher.query(sp);

    String current = null;
    for (ResultSetRow row : results) {
        String id = row.getNodeRef().getId();

        if (current != null) {
            if (collator.compare(current, id) > 0) {
                fail();
            }
        }
        current = id;
    }
    results.close();

    SearchParameters sp2 = new SearchParameters();
    sp2.addStore(rootNodeRef.getStoreRef());
    sp2.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp2.setQuery("PATH:\"//.\"");
    sp2.addSort("ID", false);
    results = searcher.query(sp2);

    current = null;
    for (ResultSetRow row : results) {
        String id = row.getNodeRef().getId();
        if (current != null) {
            if (collator.compare(current, id) < 0) {
                fail();
            }
        }
        current = id;
    }
    results.close();

    luceneFTS.resume();

    SearchParameters sp3 = new SearchParameters();
    sp3.addStore(rootNodeRef.getStoreRef());
    sp3.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp3.setQuery("PATH:\"//.\"");
    sp3.addSort(SearchParameters.SORT_IN_DOCUMENT_ORDER_ASCENDING);
    results = searcher.query(sp3);

    int count = 0;
    for (ResultSetRow row : results) {
        assertEquals(documentOrder[count++], row.getNodeRef());
    }
    results.close();

    SearchParameters sp4 = new SearchParameters();
    sp4.addStore(rootNodeRef.getStoreRef());
    sp4.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp4.setQuery("PATH:\"//.\"");
    sp4.addSort(SearchParameters.SORT_IN_DOCUMENT_ORDER_DESCENDING);
    results = searcher.query(sp4);

    count = 1;
    for (ResultSetRow row : results) {
        assertEquals(documentOrder[documentOrder.length - (count++)], row.getNodeRef());
    }
    results.close();

    SearchParameters sp5 = new SearchParameters();
    sp5.addStore(rootNodeRef.getStoreRef());
    sp5.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp5.setQuery("PATH:\"//.\"");
    sp5.addSort(SearchParameters.SORT_IN_SCORE_ORDER_ASCENDING);
    results = searcher.query(sp5);

    float score = 0;
    for (ResultSetRow row : results) {
        assertTrue(score <= row.getScore());
        score = row.getScore();
    }
    results.close();

    SearchParameters sp6 = new SearchParameters();
    sp6.addStore(rootNodeRef.getStoreRef());
    sp6.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp6.setQuery("PATH:\"//.\"");
    sp6.addSort(SearchParameters.SORT_IN_SCORE_ORDER_DESCENDING);
    results = searcher.query(sp6);

    score = 1.0f;
    for (ResultSetRow row : results) {
        assertTrue(score >= row.getScore());
        score = row.getScore();
    }
    results.close();

    // sort by created date

    SearchParameters sp7 = new SearchParameters();
    sp7.addStore(rootNodeRef.getStoreRef());
    sp7.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp7.setQuery("PATH:\"//.\"");
    sp7.addSort("@" + createdDate.getPrefixedQName(namespacePrefixResolver), true);
    results = searcher.query(sp7);

    Date date = null;
    for (ResultSetRow row : results) {
        Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class,
                nodeService.getProperty(row.getNodeRef(), createdDate));
        // System.out.println(currentBun);
        if (date != null) {
            assertTrue(date.compareTo(currentBun) <= 0);
        }
        date = currentBun;
    }
    results.close();

    SearchParameters sp8 = new SearchParameters();
    sp8.addStore(rootNodeRef.getStoreRef());
    sp8.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp8.setQuery("PATH:\"//.\"");
    sp8.addSort("@" + createdDate, false);
    results = searcher.query(sp8);

    date = null;
    for (ResultSetRow row : results) {
        Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class,
                nodeService.getProperty(row.getNodeRef(), createdDate));
        // System.out.println(currentBun);
        if ((date != null) && (currentBun != null)) {
            assertTrue(date.compareTo(currentBun) >= 0);
        }
        date = currentBun;
    }
    results.close();

    SearchParameters sp_7 = new SearchParameters();
    sp_7.addStore(rootNodeRef.getStoreRef());
    sp_7.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp_7.setQuery("PATH:\"//.\"");
    sp_7.addSort("@" + ContentModel.PROP_MODIFIED, true);
    results = searcher.query(sp_7);

    date = null;
    for (ResultSetRow row : results) {
        Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class,
                nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_MODIFIED));
        if (currentBun != null) {
            Calendar c = new GregorianCalendar();
            c.setTime(currentBun);
            c.set(Calendar.MILLISECOND, 0);
            c.set(Calendar.SECOND, 0);
            c.set(Calendar.MINUTE, 0);
            c.set(Calendar.HOUR_OF_DAY, 0);
            currentBun = c.getTime();
        }
        if ((date != null) && (currentBun != null)) {
            assertTrue(date.compareTo(currentBun) <= 0);
        }
        date = currentBun;
    }
    results.close();

    SearchParameters sp_8 = new SearchParameters();
    sp_8.addStore(rootNodeRef.getStoreRef());
    sp_8.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp_8.setQuery("PATH:\"//.\"");
    sp_8.addSort("@" + ContentModel.PROP_MODIFIED, false);
    results = searcher.query(sp_8);

    date = null;
    for (ResultSetRow row : results) {
        Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class,
                nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_MODIFIED));
        // System.out.println(currentBun);
        if (currentBun != null) {
            Calendar c = new GregorianCalendar();
            c.setTime(currentBun);
            c.set(Calendar.MILLISECOND, 0);
            c.set(Calendar.SECOND, 0);
            c.set(Calendar.MINUTE, 0);
            c.set(Calendar.HOUR_OF_DAY, 0);
            currentBun = c.getTime();
        }

        if ((date != null) && (currentBun != null)) {
            assertTrue(date.compareTo(currentBun) >= 0);
        }
        date = currentBun;
    }
    results.close();

    // sort by double

    SearchParameters sp9 = new SearchParameters();
    sp9.addStore(rootNodeRef.getStoreRef());
    sp9.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp9.setQuery("PATH:\"//.\"");
    sp9.addSort("@" + orderDouble, true);
    results = searcher.query(sp9);

    Double d = null;
    for (ResultSetRow row : results) {
        Double currentBun = DefaultTypeConverter.INSTANCE.convert(Double.class,
                nodeService.getProperty(row.getNodeRef(), orderDouble));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if (d != null) {
            assertTrue(d.compareTo(currentBun) <= 0);
        }
        d = currentBun;
    }
    results.close();

    SearchParameters sp10 = new SearchParameters();
    sp10.addStore(rootNodeRef.getStoreRef());
    sp10.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp10.setQuery("PATH:\"//.\"");
    sp10.addSort("@" + orderDouble, false);
    results = searcher.query(sp10);

    d = null;
    for (ResultSetRow row : results) {
        Double currentBun = DefaultTypeConverter.INSTANCE.convert(Double.class,
                nodeService.getProperty(row.getNodeRef(), orderDouble));
        // System.out.println(currentBun);
        if ((d != null) && (currentBun != null)) {
            assertTrue(d.compareTo(currentBun) >= 0);
        }
        d = currentBun;
    }
    results.close();

    // sort by float

    SearchParameters sp11 = new SearchParameters();
    sp11.addStore(rootNodeRef.getStoreRef());
    sp11.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp11.setQuery("PATH:\"//.\"");
    sp11.addSort("@" + orderFloat, true);
    results = searcher.query(sp11);

    Float f = null;
    for (ResultSetRow row : results) {
        Float currentBun = DefaultTypeConverter.INSTANCE.convert(Float.class,
                nodeService.getProperty(row.getNodeRef(), orderFloat));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if (f != null) {
            assertTrue(f.compareTo(currentBun) <= 0);
        }
        f = currentBun;
    }
    results.close();

    SearchParameters sp12 = new SearchParameters();
    sp12.addStore(rootNodeRef.getStoreRef());
    sp12.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp12.setQuery("PATH:\"//.\"");
    sp12.addSort("@" + orderFloat, false);
    results = searcher.query(sp12);

    f = null;
    for (ResultSetRow row : results) {
        Float currentBun = DefaultTypeConverter.INSTANCE.convert(Float.class,
                nodeService.getProperty(row.getNodeRef(), orderFloat));
        // System.out.println(currentBun);
        if ((f != null) && (currentBun != null)) {
            assertTrue(f.compareTo(currentBun) >= 0);
        }
        f = currentBun;
    }
    results.close();

    // sort by long

    SearchParameters sp13 = new SearchParameters();
    sp13.addStore(rootNodeRef.getStoreRef());
    sp13.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp13.setQuery("PATH:\"//.\"");
    sp13.addSort("@" + orderLong, true);
    results = searcher.query(sp13);

    Long l = null;
    for (ResultSetRow row : results) {
        Long currentBun = DefaultTypeConverter.INSTANCE.convert(Long.class,
                nodeService.getProperty(row.getNodeRef(), orderLong));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if (l != null) {
            assertTrue(l.compareTo(currentBun) <= 0);
        }
        l = currentBun;
    }
    results.close();

    SearchParameters sp14 = new SearchParameters();
    sp14.addStore(rootNodeRef.getStoreRef());
    sp14.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp14.setQuery("PATH:\"//.\"");
    sp14.addSort("@" + orderLong, false);
    results = searcher.query(sp14);

    l = null;
    for (ResultSetRow row : results) {
        Long currentBun = DefaultTypeConverter.INSTANCE.convert(Long.class,
                nodeService.getProperty(row.getNodeRef(), orderLong));
        // System.out.println(currentBun);
        if ((l != null) && (currentBun != null)) {
            assertTrue(l.compareTo(currentBun) >= 0);
        }
        l = currentBun;
    }
    results.close();

    // sort by int

    SearchParameters sp15 = new SearchParameters();
    sp15.addStore(rootNodeRef.getStoreRef());
    sp15.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp15.setQuery("PATH:\"//.\"");
    sp15.addSort("@" + orderInt, true);
    results = searcher.query(sp15);

    Integer i = null;
    for (ResultSetRow row : results) {
        Integer currentBun = DefaultTypeConverter.INSTANCE.convert(Integer.class,
                nodeService.getProperty(row.getNodeRef(), orderInt));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if (i != null) {
            assertTrue(i.compareTo(currentBun) <= 0);
        }
        i = currentBun;
    }
    results.close();

    SearchParameters sp16 = new SearchParameters();
    sp16.addStore(rootNodeRef.getStoreRef());
    sp16.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp16.setQuery("PATH:\"//.\"");
    sp16.addSort("@" + orderInt, false);
    results = searcher.query(sp16);

    i = null;
    for (ResultSetRow row : results) {
        Integer currentBun = DefaultTypeConverter.INSTANCE.convert(Integer.class,
                nodeService.getProperty(row.getNodeRef(), orderInt));
        // System.out.println(currentBun);
        if ((i != null) && (currentBun != null)) {
            assertTrue(i.compareTo(currentBun) >= 0);
        }
        i = currentBun;
    }
    results.close();

    // sort by text

    SearchParameters sp17 = new SearchParameters();
    sp17.addStore(rootNodeRef.getStoreRef());
    sp17.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp17.setQuery("PATH:\"//.\"");
    sp17.addSort("@" + orderText, true);
    results = searcher.query(sp17);

    String text = null;
    for (ResultSetRow row : results) {
        String currentBun = DefaultTypeConverter.INSTANCE.convert(String.class,
                nodeService.getProperty(row.getNodeRef(), orderText));
        // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ " "+currentBun);
        if ((text != null) && (currentBun != null)) {
            assertTrue(collator.compare(text, currentBun) <= 0);
        }
        text = currentBun;
    }
    results.close();

    SearchParameters sp18 = new SearchParameters();
    sp18.addStore(rootNodeRef.getStoreRef());
    sp18.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp18.setQuery("PATH:\"//.\"");
    sp18.addSort("@" + orderText, false);
    results = searcher.query(sp18);

    text = null;
    for (ResultSetRow row : results) {
        String currentBun = DefaultTypeConverter.INSTANCE.convert(String.class,
                nodeService.getProperty(row.getNodeRef(), orderText));
        // System.out.println(currentBun);
        if ((text != null) && (currentBun != null)) {
            assertTrue(collator.compare(text, currentBun) >= 0);
        }
        text = currentBun;
    }
    results.close();

    // sort by content size

    // sort by ML text

    // Locale[] testLocales = new Locale[] { I18NUtil.getLocale(), Locale.ENGLISH, Locale.FRENCH, Locale.CHINESE };
    Locale[] testLocales = new Locale[] { I18NUtil.getLocale(), Locale.ENGLISH, Locale.FRENCH };
    for (Locale testLocale : testLocales) {
        Collator localisedCollator = Collator.getInstance(testLocale);

        SearchParameters sp19 = new SearchParameters();
        sp19.addStore(rootNodeRef.getStoreRef());
        sp19.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp19.setQuery("PATH:\"//.\"");
        sp19.addSort("@" + orderMLText, true);
        sp19.addLocale(testLocale);
        results = searcher.query(sp19);

        text = null;
        for (ResultSetRow row : results) {
            MLText mltext = DefaultTypeConverter.INSTANCE.convert(MLText.class,
                    nodeService.getProperty(row.getNodeRef(), orderMLText));
            if (mltext != null) {
                String currentBun = mltext.getValue(testLocale);
                // System.out.println( (currentBun == null ? "null" : NumericEncoder.encode(currentBun))+ "
                // "+currentBun);
                if ((text != null) && (currentBun != null)) {
                    assertTrue(localisedCollator.compare(text, currentBun) <= 0);
                }
                text = currentBun;
            }
        }
        results.close();

        SearchParameters sp20 = new SearchParameters();
        sp20.addStore(rootNodeRef.getStoreRef());
        sp20.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp20.setQuery("PATH:\"//.\"");
        sp20.addSort("@" + orderMLText, false);
        sp20.addLocale(testLocale);
        results = searcher.query(sp20);

        text = null;
        for (ResultSetRow row : results) {
            MLText mltext = DefaultTypeConverter.INSTANCE.convert(MLText.class,
                    nodeService.getProperty(row.getNodeRef(), orderMLText));
            if (mltext != null) {
                String currentBun = mltext.getValue(testLocale);
                if ((text != null) && (currentBun != null)) {
                    assertTrue(localisedCollator.compare(text, currentBun) >= 0);
                }
                text = currentBun;
            }
        }
        results.close();

    }

    luceneFTS.resume();

    SearchParameters spN = new SearchParameters();
    spN.addStore(rootNodeRef.getStoreRef());
    spN.setLanguage(SearchService.LANGUAGE_LUCENE);
    spN.setQuery("PATH:\"//.\"");
    spN.addSort("cabbage", false);
    results = searcher.query(spN);
    results.close();

    // test sort on unkown properties ALF-4193

    spN = new SearchParameters();
    spN.addStore(rootNodeRef.getStoreRef());
    spN.setLanguage(SearchService.LANGUAGE_LUCENE);
    spN.setQuery("PATH:\"//.\"");
    spN.addSort("PARENT", false);
    results = searcher.query(spN);
    results.close();

    spN = new SearchParameters();
    spN.addStore(rootNodeRef.getStoreRef());
    spN.setLanguage(SearchService.LANGUAGE_LUCENE);
    spN.setQuery("PATH:\"//.\"");
    spN.addSort("@PARENT:PARENT", false);
    results = searcher.query(spN);
    results.close();

    luceneFTS.resume();

    // sort by content size

    SearchParameters sp20 = new SearchParameters();
    sp20.addStore(rootNodeRef.getStoreRef());
    sp20.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp20.setQuery("PATH:\"//.\"");
    sp20.addSort("@" + ContentModel.PROP_CONTENT + ".size", false);
    results = searcher.query(sp20);

    Long size = null;
    for (ResultSetRow row : results) {
        ContentData currentBun = DefaultTypeConverter.INSTANCE.convert(ContentData.class,
                nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_CONTENT));
        // System.out.println(currentBun);
        if ((size != null) && (currentBun != null)) {
            assertTrue(size.compareTo(currentBun.getSize()) >= 0);
        }
        if (currentBun != null) {
            size = currentBun.getSize();
        }
    }
    results.close();

    // sort by content mimetype

    SearchParameters sp21 = new SearchParameters();
    sp21.addStore(rootNodeRef.getStoreRef());
    sp21.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp21.setQuery("PATH:\"//.\"");
    sp21.addSort("@" + ContentModel.PROP_CONTENT + ".mimetype", false);
    results = searcher.query(sp21);

    String mimetype = null;
    for (ResultSetRow row : results) {
        ContentData currentBun = DefaultTypeConverter.INSTANCE.convert(ContentData.class,
                nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_CONTENT));
        // System.out.println(currentBun);
        if ((mimetype != null) && (currentBun != null)) {
            assertTrue(mimetype.compareTo(currentBun.getMimetype()) >= 0);
        }
        if (currentBun != null) {
            mimetype = currentBun.getMimetype();
        }
    }
    results.close();

}

From source file:it.webappcommon.lib.jsf.AbstractPageBase.java

/**
 * Metodo che permette di ordinare, in ordine crescente o decrescente in
 * base ad ascending, un arraylist di oggetti di qualsiasi tipo in base al
 * parametro column. In particolare, con la reflection, viene gestito
 * l'ordinamento per column se essa e' int, long, double, float, boolean,
 * String, Date, Integer. Se non e' di uno di questi tipi, l'ordinamento non
 * fa niente in quanto il compareTo del comparator definito all'interno del
 * metodo ritorna sempre 0. La column, va indicata, come sempre del resto,
 * senza il get o l'is davanti./*from   w w  w .j  a v  a  2 s . c o m*/
 * 
 * @param list
 *            ArrayList da ordinare
 * @param column
 *            Nome della colonna/propriet dell'oggetto in base alla quale
 *            effettuare l'ordinamento
 * @param ascending
 *            Booleano che specifica se l'ordinamento deve essere ascendente
 *            o meno
 */
public void sort(List list, final String column, final boolean ascending) {
    // TODO: Gestione di property a pi livelli: ad esempio
    // ElementBL.element.nome
    Comparator comparator = null;

    if ((column != null) && (!column.equals("")) && (list != null) && (list.size() > 0)) {

        final Class item_class = list.get(0).getClass();

        comparator = new Comparator() {

            public int compare(Object o1, Object o2) {

                PropertyDescriptor column_descriptor = null;
                Method read_method = null;
                Object obj1 = null;
                Object obj2 = null;
                Object resInvoke1 = null;
                Object resInvoke2 = null;
                Date date1 = null;
                Date date2 = null;
                String str1 = null;
                String str2 = null;
                Integer Int1 = null;
                Integer Int2 = null;
                Double Double1 = null;
                Double Double2 = null;
                Float Float1 = null;
                Float Float2 = null;
                int returnValue = 0;

                try {

                    if ((column == null) || (o1 == null) || (o2 == null)) {

                        /*
                         * In caso di non specificazione della colonna o di
                         * uno dei due oggetti ritorna 0, facendo in modo
                         * che l'ordinamento non ha alcun effetto
                         */
                        returnValue = 0;

                    } else {

                        /*
                         * Tenta di ottenere un property descriptor a
                         * partire dalla colonna
                         */
                        try {

                            column_descriptor = new PropertyDescriptor(column, item_class);
                            read_method = column_descriptor.getReadMethod();

                        } catch (Exception e) {

                            read_method = null;

                        }

                        if (read_method != null) {

                            obj1 = item_class.cast(o1);
                            obj2 = item_class.cast(o2);

                            /*
                             * Viene gestito l'ordinamento per String,
                             * Boolean, int
                             */
                            if (read_method.getReturnType() == int.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo primitivo int">
                                /*
                                 * Variabili di tipo primitivo e'
                                 * impossibile che siano NULL
                                 */
                                str1 = read_method.invoke(obj1).toString();
                                str2 = read_method.invoke(obj2).toString();

                                int int1 = Integer.parseInt(str1);
                                int int2 = Integer.parseInt(str2);

                                if (ascending) {

                                    if (int1 < int2) {
                                        returnValue = -1;
                                    } else if (int1 > int2) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                } else {

                                    if (int1 > int2) {
                                        returnValue = -1;
                                    } else if (int1 < int2) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            } else if (read_method.getReturnType() == long.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo primitivo long">
                                /*
                                 * Variabili di tipo primitivo e'
                                 * impossibile che siano NULL
                                 */
                                str1 = read_method.invoke(obj1).toString();
                                str2 = read_method.invoke(obj2).toString();

                                long lng1 = Long.parseLong(str1);
                                long lng2 = Long.parseLong(str2);

                                if (ascending) {

                                    if (lng1 < lng2) {
                                        returnValue = -1;
                                    } else if (lng1 > lng2) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                } else {

                                    if (lng1 > lng2) {
                                        returnValue = -1;
                                    } else if (lng1 < lng2) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            } else if (read_method.getReturnType() == double.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo primitivo double">
                                /*
                                 * Variabili di tipo primitivo e'
                                 * impossibile che siano NULL
                                 */
                                str1 = read_method.invoke(obj1).toString();
                                str2 = read_method.invoke(obj2).toString();

                                double dbl1 = Double.parseDouble(str1);
                                double dbl2 = Double.parseDouble(str2);

                                if (ascending) {

                                    if (dbl1 < dbl2) {
                                        returnValue = -1;
                                    } else if (dbl1 > dbl2) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                } else {

                                    if (dbl1 > dbl2) {
                                        returnValue = -1;
                                    } else if (dbl1 < dbl2) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            } else if (read_method.getReturnType() == float.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo primitivo float">
                                /*
                                 * Variabili di tipo primitivo e'
                                 * impossibile che siano NULL
                                 */
                                str1 = read_method.invoke(obj1).toString();
                                str2 = read_method.invoke(obj2).toString();

                                float flt1 = Float.parseFloat(str1);
                                float flt2 = Float.parseFloat(str2);

                                if (ascending) {

                                    if (flt1 < flt2) {
                                        returnValue = -1;
                                    } else if (flt1 > flt2) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                } else {

                                    if (flt1 > flt2) {
                                        returnValue = -1;
                                    } else if (flt1 < flt2) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            } else if (read_method.getReturnType() == Float.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo object Float">
                                /*
                                 * Variabili di tipo object e' impossibile
                                 * che siano NULL
                                 */
                                /*
                                 * Pu essere che la propriet degli
                                 * oggetti sia NULL. In quel caso il
                                 * toString() genera errore se non gestito.
                                 * Se resInvoke1 oppure resInvoke2 sono
                                 * NULL, anche le rispettive conversioni in
                                 * interi lo devono essere
                                 */
                                resInvoke1 = read_method.invoke(obj1);
                                resInvoke2 = read_method.invoke(obj2);
                                if (resInvoke1 != null) {
                                    Float1 = (Float) resInvoke1;
                                }
                                if (resInvoke2 != null) {
                                    Float2 = (Float) resInvoke2;
                                }

                                if (ascending) {

                                    if ((Float1 != null) && (Float2 != null)) {
                                        returnValue = Float1.compareTo(Float2);
                                    } else if ((Float1 == null) && (Float2 != null)) {
                                        returnValue = -1;
                                    } else if ((Float1 != null) && (Float2 == null)) {
                                        returnValue = 1;
                                    } else if ((Float1 == null) && (Float2 == null)) {
                                        returnValue = 0;
                                    }

                                } else {

                                    if ((Float1 != null) && (Float2 != null)) {
                                        returnValue = Float2.compareTo(Float1);
                                    } else if ((Float1 != null) && (Float2 == null)) {
                                        returnValue = -1;
                                    } else if ((Float1 == null) && (Float2 != null)) {
                                        returnValue = 1;
                                    } else if ((Float1 == null) && (Float2 == null)) {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            } else if (read_method.getReturnType() == boolean.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo primitivo boolean">
                                /*
                                 * Variabili di tipo primitivo e'
                                 * impossibile che siano NULL
                                 */
                                str1 = read_method.invoke(obj1).toString();
                                str2 = read_method.invoke(obj2).toString();

                                boolean bool1 = Boolean.parseBoolean(str1);
                                boolean bool2 = Boolean.parseBoolean(str2);

                                if (ascending) {

                                    if ((!bool1) && (bool2)) {
                                        returnValue = -1;
                                    } else if ((bool1) && (!bool2)) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                } else {

                                    if ((bool1) && (!bool2)) {
                                        returnValue = -1;
                                    } else if ((!bool1) && (bool2)) {
                                        returnValue = 1;
                                    } else {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            } else if (read_method.getReturnType() == String.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo object String">
                                /*
                                 * Pu essere che la propriet degli
                                 * oggetti sia NULL. In quel caso il
                                 * toString() genera errore se non gestito.
                                 * Se resInvoke1
                                 * 
                                 * oppure resInvoke2 sono NULL, anche le
                                 * rispettive conversioni in stringa lo
                                 * devono essere
                                 */
                                resInvoke1 = read_method.invoke(obj1);
                                resInvoke2 = read_method.invoke(obj2);
                                if (resInvoke1 != null) {
                                    str1 = resInvoke1.toString().toUpperCase();
                                }
                                if (resInvoke2 != null) {
                                    str2 = resInvoke2.toString().toUpperCase();
                                }

                                if (ascending) {

                                    if ((str1 != null) && (str2 != null)) {
                                        returnValue = str1.compareTo(str2);
                                    } else if ((str1 == null) && (str2 != null)) {
                                        returnValue = -1;
                                    } else if ((str1 != null) && (str2 == null)) {
                                        returnValue = 1;
                                    } else if ((str1 == null) && (str2 == null)) {
                                        returnValue = 0;
                                    }

                                } else {

                                    if ((str1 != null) && (str2 != null)) {
                                        returnValue = str2.compareTo(str1);
                                    } else if ((str1 != null) && (str2 == null)) {
                                        returnValue = -1;
                                    } else if ((str1 == null) && (str2 != null)) {
                                        returnValue = 1;
                                    } else if ((str1 == null) && (str2 == null)) {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            } else if (read_method.getReturnType() == Date.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo object Date">
                                /*
                                 * Pu essere che la propriet degli
                                 * oggetti sia NULL. In quel caso il
                                 * toString() genera errore se non gestito.
                                 * Se resInvoke1 oppure resInvoke2 sono
                                 * NULL, anche le rispettive conversioni in
                                 * date lo devono essere
                                 */
                                resInvoke1 = read_method.invoke(obj1);
                                resInvoke2 = read_method.invoke(obj2);
                                if (resInvoke1 != null) {
                                    date1 = (Date) resInvoke1;
                                }
                                if (resInvoke2 != null) {
                                    date2 = (Date) resInvoke2;
                                }

                                if (ascending) {

                                    if ((date1 != null) && (date2 != null)) {
                                        returnValue = date1.compareTo(date2);
                                    } else if ((date1 == null) && (date2 != null)) {
                                        returnValue = -1;
                                    } else if ((date1 != null) && (date2 == null)) {
                                        returnValue = 1;
                                    } else if ((date1 == null) && (date2 == null)) {
                                        returnValue = 0;
                                    }

                                } else {

                                    if ((date1 != null) && (date2 != null)) {
                                        returnValue = date2.compareTo(date1);
                                    } else if ((date1 != null) && (date2 == null)) {
                                        returnValue = -1;
                                    } else if ((date1 == null) && (date2 != null)) {
                                        returnValue = 1;
                                    } else if ((date1 == null) && (date2 == null)) {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            } else if (read_method.getReturnType() == Integer.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo object Integer">
                                /*
                                 * Pu essere che la propriet degli
                                 * oggetti sia NULL. In quel caso il
                                 * toString() genera errore se non gestito.
                                 * Se resInvoke1 oppure resInvoke2 sono
                                 * NULL, anche le rispettive conversioni in
                                 * interi lo devono essere
                                 */
                                resInvoke1 = read_method.invoke(obj1);
                                resInvoke2 = read_method.invoke(obj2);
                                if (resInvoke1 != null) {
                                    Int1 = (Integer) resInvoke1;
                                }
                                if (resInvoke2 != null) {
                                    Int2 = (Integer) resInvoke2;
                                }

                                if (ascending) {

                                    if ((Int1 != null) && (Int2 != null)) {
                                        returnValue = Int1.compareTo(Int2);
                                    } else if ((Int1 == null) && (Int2 != null)) {
                                        returnValue = -1;
                                    } else if ((Int1 != null) && (Int2 == null)) {
                                        returnValue = 1;
                                    } else if ((Int1 == null) && (Int2 == null)) {
                                        returnValue = 0;
                                    }

                                } else {

                                    if ((Int1 != null) && (Int2 != null)) {
                                        returnValue = Int2.compareTo(Int1);
                                    } else if ((Int1 != null) && (Int2 == null)) {
                                        returnValue = -1;
                                    } else if ((Int1 == null) && (Int2 != null)) {
                                        returnValue = 1;
                                    } else if ((Int1 == null) && (Int2 == null)) {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            } else if (read_method.getReturnType() == Double.class) {

                                // <editor-fold defaultstate="collapsed"
                                // desc="Gestione tipo object Double">
                                /*
                                 * Pu essere che la propriet degli
                                 * oggetti sia NULL. In quel caso il
                                 * toString() genera errore se non gestito.
                                 * Se resInvoke1 oppure resInvoke2 sono
                                 * NULL, anche le rispettive conversioni in
                                 * interi lo devono essere
                                 */
                                resInvoke1 = read_method.invoke(obj1);
                                resInvoke2 = read_method.invoke(obj2);
                                if (resInvoke1 != null) {
                                    Double1 = (Double) resInvoke1;
                                }
                                if (resInvoke2 != null) {
                                    Double2 = (Double) resInvoke2;
                                }

                                if (ascending) {

                                    if ((Double1 != null) && (Double2 != null)) {
                                        returnValue = Double1.compareTo(Double2);
                                    } else if ((Double1 == null) && (Double2 != null)) {
                                        returnValue = -1;
                                    } else if ((Double1 != null) && (Double2 == null)) {
                                        returnValue = 1;
                                    } else if ((Double1 == null) && (Double2 == null)) {
                                        returnValue = 0;
                                    }

                                } else {

                                    if ((Double1 != null) && (Double2 != null)) {
                                        returnValue = Double2.compareTo(Double1);
                                    } else if ((Double1 != null) && (Double2 == null)) {
                                        returnValue = -1;
                                    } else if ((Double1 == null) && (Double2 != null)) {
                                        returnValue = 1;
                                    } else if ((Double1 == null) && (Double2 == null)) {
                                        returnValue = 0;
                                    }

                                }
                                // </editor-fold>

                            }

                        } else {

                            /*
                             * Nel caso in cui non ci sia il metodo get
                             * della colonna passata, ritorna 0, facendo in
                             * modo che l'ordinamento non ha alcun effetto
                             */
                            returnValue = 0;

                        }

                    }

                } catch (Exception e) {

                    /*
                     * In caso d'errore in Comparator ritorna 0, facendo in
                     * modo che l'ordinamento non ha alcun effetto
                     */

                    returnValue = 0;

                } finally {

                    /* Clean-up oggetti */
                    column_descriptor = null;
                    read_method = null;
                    obj1 = null;
                    obj2 = null;
                    resInvoke1 = null;
                    resInvoke2 = null;
                    date1 = null;
                    date2 = null;
                    str1 = null;
                    str2 = null;
                    Int1 = null;
                    Int2 = null;
                    Float1 = null;
                    Float2 = null;

                }

                return returnValue;

            }
        };

        if (comparator != null) {
            Collections.sort(list, comparator);
        }

    }

    comparator = null;

}

From source file:org.fhaes.analysis.FHInterval.java

/**
 * Actually perform the analysis./*from w ww  .  j  a v  a2  s  . c  om*/
 */
@SuppressWarnings("deprecation")
private void doAnalysis() {

    log.debug("INPUT PARAMETERS");
    log.debug("inputFileArray = " + inputFileArray);
    log.debug("analyissType = " + analysisType);
    log.debug("startYear = " + startYear);
    log.debug("endYear = " + endYear);
    log.debug("fireFilterType = " + fireFilterType);
    log.debug("filterValue = " + filterValue);
    log.debug("includeIncomplete = " + includeIncomplete);
    log.debug("alphaLevel = " + alphaLevel);

    boolean highway = true;

    ArrayList<FHX2FileReader> myReader = new ArrayList<FHX2FileReader>();
    Integer minFirstYear = new Integer(9999);
    Integer maxLastYear = new Integer(0);

    String savePath = new String();
    savePath = inputFileArray[0].getAbsolutePath();

    for (int i = 0; i < inputFileArray.length; i++) {
        myReader.add(new FHX2FileReader(inputFileArray[i]));

        /*
         * set the beginning year accounting for the filter
         */
        if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_EVENT)) {
            // myReader.get(i).makeClimate2d();
            if (startYear == 0 && highway) {
                if (myReader.get(i).getFirstFireYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstFireYear();
                }
            } else if (startYear != 0 && highway) {
                if (myReader.get(i).getFirstYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstYear();
                }
            }
            if (startYear != 0) {
                minFirstYear = startYear;
                // minFirstYear = minFirstYear+1;
            }
        } else if (eventTypeToProcess.equals(EventTypeToProcess.INJURY_EVENT)) {
            // myReader.get(i).makeClimate2dII();
            if (startYear == 0 && highway) {
                if (myReader.get(i).getFirstInjuryYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstInjuryYear();
                }
            } else if (startYear != 0 && highway) {
                if (myReader.get(i).getFirstYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstYear();
                }
            }
            if (startYear != 0) {
                minFirstYear = startYear;
                // minFirstYear = minFirstYear+1;
            }
        } else if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_AND_INJURY_EVENT)) {
            // myReader.get(i).makeClimate2dII();
            if (startYear == 0 && highway) {
                if (myReader.get(i).getFirstIndicatorYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstIndicatorYear();
                }
            } else if (startYear != 0 && highway) {
                if (myReader.get(i).getFirstYear() < minFirstYear) {
                    minFirstYear = myReader.get(i).getFirstYear();
                }
            }
            if (startYear != 0) {
                minFirstYear = startYear;
                // minFirstYear = minFirstYear+1;
            }
        } else {
            log.error("Unsupported event type caught");
        }
        /*
         * Set the last year accounting for the filter
         */
        if (myReader.get(i).getLastYear() > maxLastYear) {
            maxLastYear = myReader.get(i).getLastYear();
        }
        if (endYear != 0) {
            maxLastYear = endYear;
        }
    } // end of i loop

    log.debug("the input filelength is " + inputFileArray.length);
    log.debug("The FIRST FIRE YEAR is " + minFirstYear);
    log.debug("The LAST YEAR is " + maxLastYear);
    log.debug("Minimum and Maximum years are " + minFirstYear + " " + maxLastYear);
    /*
     * set the format for the output of the numbers to 2 decimal formats
     */
    DecimalFormat twoPlace = new DecimalFormat("0.00");
    DecimalFormat threePlace = new DecimalFormat("0.000");

    /*
     * Calculate the listYears the common years where the files will be analyzed
     */
    ArrayList<Integer> listYears = new ArrayList<Integer>();
    for (int i = 0; i < maxLastYear - minFirstYear + 1; i++) {
        listYears.add(minFirstYear + i);
    }
    /*
     * create arraylist need for the Interval Analysis
     */

    ArrayList<ArrayList<Integer>> climateMatrixSite = new ArrayList<ArrayList<Integer>>();
    ArrayList<ArrayList<Double>> filterMatrix = new ArrayList<ArrayList<Double>>();
    ArrayList<Integer> climateVector = new ArrayList<Integer>();
    ArrayList<ArrayList<Double>> climateVectorFilter2 = new ArrayList<ArrayList<Double>>();
    // ArrayList<Double> fireintervalspersite = new ArrayList<Double>();
    ArrayList<Integer> climateVectorActualSite = null;
    ArrayList<Double> filterVectorActual = null;
    ArrayList<Integer> climateYear = new ArrayList<Integer>();
    ArrayList<Integer> minSampleFilter = null;
    ArrayList<Double> percentOfRecordingfilter = null;
    Double[] Dfireintervalspersite;
    double[] dfireintervalspersite;
    String[] statsparam = new String[22];
    if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_EVENT)) {
        statsparam[0] = "Total intervals";
        statsparam[1] = "Mean fire interval";
        statsparam[2] = "Median fire interval";
        statsparam[3] = "Standard deviation";
        statsparam[4] = "Fire frequency";
        statsparam[5] = "Coefficient of variation";
        statsparam[6] = "Skewness";
        statsparam[7] = "Kurtosis";
        statsparam[8] = "Minimum fire interval";
        statsparam[9] = "Maximum fire interval";
        statsparam[10] = "Weibull scale parameter";
        statsparam[11] = "Weibull shape parameter";
        statsparam[12] = "Weibull mean";
        statsparam[13] = "Weibull median";
        statsparam[14] = "Weibull mode";
        statsparam[15] = "Weibull standard deviation";
        statsparam[16] = "Weibull fire frequency";
        statsparam[17] = "Weibull skewness";
        statsparam[18] = "Lower exceedance interval";
        statsparam[19] = "Upper exceedance interval";
        statsparam[20] = "Significantly short interval upper bound";
        statsparam[21] = "Significantly long interval lower bound";
    } else if (eventTypeToProcess.equals(EventTypeToProcess.INJURY_EVENT)) {
        statsparam[0] = "Total intervals";
        statsparam[1] = "Mean indicator interval";
        statsparam[2] = "Median indicator interval";
        statsparam[3] = "Standard deviation";
        statsparam[4] = "Indicator frequency";
        statsparam[5] = "Coefficient of variation";
        statsparam[6] = "Skewness";
        statsparam[7] = "Kurtosis";
        statsparam[8] = "Minimum fire interval";
        statsparam[9] = "Maximum indicator interval";
        statsparam[10] = "Weibull scale parameter";
        statsparam[11] = "Weibull shape parameter";
        statsparam[12] = "Weibull mean";
        statsparam[13] = "Weibull median";
        statsparam[14] = "Weibull mode";
        statsparam[15] = "Weibull standard deviation";
        statsparam[16] = "Weibull indicator frequency";
        statsparam[17] = "Weibull skewness";
        statsparam[18] = "Lower exceedance interval";
        statsparam[19] = "Upper exceedance interval";
        statsparam[20] = "Significantly short interval upper bound";
        statsparam[21] = "Significantly long interval lower bound";
    } else if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_AND_INJURY_EVENT)) {
        statsparam[0] = "Total intervals";
        statsparam[1] = "Mean fire and other indicator interval";
        statsparam[2] = "Median fire and other indicator interval";
        statsparam[3] = "Standard deviation";
        statsparam[4] = "Fire and other indicator frequency";
        statsparam[5] = "Coefficient of variation";
        statsparam[6] = "Skewness";
        statsparam[7] = "Kurtosis";
        statsparam[8] = "Minimum fire and other indicator interval";
        statsparam[9] = "Maximum fire interval";
        statsparam[10] = "Weibull scale parameter";
        statsparam[11] = "Weibull shape parameter";
        statsparam[12] = "Weibull mean";
        statsparam[13] = "Weibull median";
        statsparam[14] = "Weibull mode";
        statsparam[15] = "Weibull standard deviation";
        statsparam[16] = "Weibull indicator frequency";
        statsparam[17] = "Weibull skewness";
        statsparam[18] = "Lower exceedance interval";
        statsparam[19] = "Upper exceedance interval";
        statsparam[20] = "Significantly short interval upper bound";
        statsparam[21] = "Significantly long interval lower bound";
    } else {

        log.error("Unsupported event type caught");
    }

    double[] fixvalt = { 0.999, 0.99, 0.975, 0.95, 0.9, 0.875, 0.8, 0.75, 0.7, 0.667, 0.5, 0.333, 0.3, 0.25,
            0.2, 0.125, 0.1, 0.05, 0.025, 0.01, 0.001 };

    double[][] ExceeProbcomp = new double[fixvalt.length][myReader.size()];
    double[][] ExceeProbsample = new double[fixvalt.length][myReader.size()];
    // log.debug("the size of statsparam is " +
    // statsparam.length);
    double[][] summaryComp = new double[statsparam.length][myReader.size()];
    double[] numberOfintervalscomp = new double[myReader.size()];
    // ArrayList<ArrayList<Integer>>();
    // ArrayList<ArrayList<Integer>> FIyearperSample = new
    // ArrayList<ArrayList<Integer>>();
    ArrayList<Integer> FyearperSampletemp;
    ArrayList<Integer> FIyearperSampletemp;
    // ArrayList<Double> fireintervalspersample = new
    double[] numberOfintervalssamp = new double[myReader.size()];
    double[][] summarySample = new double[statsparam.length][myReader.size()];
    Double[] Dfireintervalspersample;
    double[] dfireintervalspersample;
    /*
     * Set up either of the two filters two create the binary matrix on the case of composite analysis there are two possible filters:
     * Number of fires and percentage of scarred trees.
     */
    Integer firesFilter1 = new Integer(0);
    Double firesFilter2 = new Double(0);
    if (fireFilterType.equals(FireFilterType.NUMBER_OF_EVENTS)) {
        if (filterValue != 1)
            firesFilter1 = filterValue.intValue();
        // log.debug("number of fires is selected is: "+
        // firesFilter1);
    } else if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_ALL_TREES)) {
        if (filterValue != 1)
            firesFilter2 = filterValue / 100.0;
        // log.debug("percentage of fires is selected is: "+
        // firesFilter2);
    } else if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_RECORDING)) {
        if (filterValue != 1)
            firesFilter2 = filterValue / 100.0;
        // TODO ELENA TO CHECK
    } else {
        log.error("Unknown FireFilterType");
        return;
    }

    boolean[] enoughIntComp = new boolean[myReader.size()];
    boolean[] enoughIntSamp = new boolean[myReader.size()];
    // NEW FOR ELENA
    log.debug("Sample depth filter type = " + sampleDepthFilterType);
    log.debug("Sample depth value = " + sampleDepthFilterValue);

    // if (sampleDepthFilterType.equals(SampleDepthFilterType.MIN_NUM_SAMPLES))
    // {
    // // TODO ELENA
    // }
    // else if (sampleDepthFilterType.equals(SampleDepthFilterType.MIN_NUM_RECORDER_SAMPLES))
    // {
    // // TODO ELENA
    // }
    /*
     * start processing each file individually: The analysis can be done by either tree (by sample/non-binary) or by site
     * (composite/binary). by tree the box selected is: jCheckTree. by site the box selected is:
     */
    for (int i = 0; i < myReader.size(); i++) {
        log.debug("  Starting to Process file : " + myReader.get(i).getName());

        /*
         * get the vector Year containing the vector of year of a given fhx file load it into the array list climateYear.
         */

        climateYear = myReader.get(i).getYearArray();

        // new stuff
        // Create filter based on min number of samples/recorder samples
        int[] depths = null;
        if (sampleDepthFilterType.equals(SampleDepthFilterType.MIN_NUM_SAMPLES)) {
            depths = myReader.get(i).getSampleDepths();
            log.debug("MIN_NUM_SAMPLES ");
        } else if (sampleDepthFilterType.equals(SampleDepthFilterType.MIN_NUM_RECORDER_SAMPLES)) {
            depths = myReader.get(i).getRecordingDepths(eventTypeToProcess);
            log.debug(" MIN_NUM_RECORDER_SAMPLES");
        } else {
            log.error("Unknown sample depth filter type.");
            return;
        }
        minSampleFilter = new ArrayList<Integer>();
        for (int ij = 0; ij < listYears.size(); ij++) {
            if (climateYear.indexOf(listYears.get(ij)) == -1) {
                minSampleFilter.add(-1);
            } else {
                // log.debug("the sample depth is "
                // + myReader.get(i).getSampleDepths()[climateYear.indexOf(listYearsComp.get(ij))]);
                minSampleFilter.add(new Integer(depths[climateYear.indexOf(listYears.get(ij))]));
            }
            // log.debug(" " + minSampleFilter.get(ij));
        }

        // end new stuff

        /*
         * get filter matrix for each file.
         * 
         * filters2d matrix composed of the 3 filters number of fires (total capital letter per row) total number of tree (total lower
         * case letter plus bars counting only after a fire) percent of scared trees total fires/total trees
         */

        // climateVectorFilter2 = myReader.get(i).getFilterArrays(eventTypeToProcess);
        /*
         * More new stuff
         */
        if (filterValue != 1) {
            /*
             * get both matrices:
             * 
             * 2. filters2d matrix composed of the 3 filters number of fires (total capital letter per row) total number of tree (total
             * lower case letter plus bars counting only after a fire) percent of scared trees total fires/total trees
             */

            climateVectorFilter2 = myReader.get(i).getFilterArrays(eventTypeToProcess);

            /*
             * if by tree analysis is selected create two matrices (array list) 1. filterMatrix containing the three filter vectors only
             * in between common years (so using the listYearComp array list subset of the years vector) 2. climateMatrix 2 dimensional
             * array list containing binary matrices restricted to the listYear list.
             */
            if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_RECORDING)) {
                percentOfRecordingfilter = new ArrayList<Double>();

                for (int ij = 0; ij < listYears.size(); ij++) {

                    if (climateYear.indexOf(listYears.get(ij)) == -1) {
                        percentOfRecordingfilter.add(-1.0);
                    } else {
                        if (myReader.get(i).getRecordingDepths(eventTypeToProcess)[climateYear
                                .indexOf(listYears.get(ij))] != 0) {
                            percentOfRecordingfilter.add(new Double(
                                    climateVectorFilter2.get(0).get(climateYear.indexOf(listYears.get(ij)))
                                            / myReader.get(i).getRecordingDepths(eventTypeToProcess)[climateYear
                                                    .indexOf(listYears.get(ij))]));
                        } else {
                            percentOfRecordingfilter.add(-99.0);
                        }
                    }
                    log.debug("PERCENTAGE_OF_RECORDING is: " + percentOfRecordingfilter.get(ij));
                }
            } else {
                for (int ik = 0; ik < 3; ik++) {
                    log.debug("filter number is: " + ik);
                    filterVectorActual = new ArrayList<Double>();
                    for (int ij = 0; ij < listYears.size(); ij++) { // log.debug(" climateYear.indexOf(listYearsComp.get(j))" +
                                                                    // climateYear.indexOf(listYearsComp.get(ij)));
                                                                    // if(ik==0){log.debug("number of fires
                                                                    // "+climateVectorFilter2.get(0).get(climateYear.indexOf(listYears.get(ij)))+" year
                                                                    // "+listYearsComp.get(ij));}
                        if (climateYear.indexOf(listYears.get(ij)) == -1) {
                            filterVectorActual.add(-1.0);
                        } else {
                            filterVectorActual.add(new Double(
                                    climateVectorFilter2.get(ik).get(climateYear.indexOf(listYears.get(ij)))));
                        }
                        if (ik == 2) {
                            log.debug("filteperc  " + filterVectorActual.get(ij));
                        }
                    }
                    // log.debug("size of filterVectorActual is : "+filterVectorActual.size());
                    filterMatrix.add(filterVectorActual);
                    // if(ik==0){log.debug("filters is: "+filter);
                }
            } // end of if-else percentageofrecording
              // log.debug("size of the FilterMatrix is" + filterMatrix.size());

        } // end of if filters not equal to 1
        /*
         * end of more new stuff
         */
        /*
         * 
         * 1. Create the filterMatrix containing the tree filter vectors only in between common years (so using the listYearComp array
         * list subset of the years vector)
         */
        // for (int ik = 0; ik < 3; ik++)
        // {
        // filterVectorActual = new ArrayList<Double>();
        // for (int ij = 0; ij < listYears.size(); ij++)
        // {
        // if (climateYear.indexOf(listYears.get(ij)) == -1)
        // {
        // filterVectorActual.add(-1.0);
        // }
        // else
        // {
        // filterVectorActual.add(new Double(climateVectorFilter2.get(ik).get(climateYear.indexOf(listYears.get(ij)))));
        // }

        // }
        /*
         * ArrayList filterMatrix containes the filter matrix for each of the files
         */
        // filterMatrix.add(filterVectorActual);
        // }//end of creating the filter matrix.

        /*
         * get matrix climate binary matrix by site (binary analysis) if Composite is selected.
         */
        // if ((doComposite)&&(!jTextOfFires.getText().equals("1"))){
        if (analysisType.equals(AnalysisType.COMPOSITE)) {
            log.debug("inside the comp");
            // System.out.println("inside the comp " + " working on file "+ myReader.get(i).getName() );

            if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_EVENT)) {
                climateVector = myReader.get(i).getFireEventsArray();
            } else if (eventTypeToProcess.equals(EventTypeToProcess.INJURY_EVENT)) {
                climateVector = myReader.get(i).getOtherInjuriesArray();
            } else if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_AND_INJURY_EVENT)) {
                climateVector = myReader.get(i).getFiresAndInjuriesArray();
            } else {

                log.error("Unsupported event type caught");
            }

            climateVectorActualSite = new ArrayList<Integer>();

            for (int j = 0; j < listYears.size(); j++) {

                if (climateYear.indexOf(listYears.get(j)) == -1) {
                    climateVectorActualSite.add(-1);
                } else {
                    if (minSampleFilter.get(j).intValue() >= sampleDepthFilterValue.intValue()) {
                        if (filterValue != 1) {
                            if (fireFilterType.equals(FireFilterType.NUMBER_OF_EVENTS)) {
                                // log.debug("fire filter: "+firesFilter1+" year is: "+listYears.get(j)
                                // +" fires: "+filterMatrix.get(3*i).get(j)+" climatevector:
                                // "+climateVector.get(climateYear.indexOf(listYears.get(j))));
                                if ((filterMatrix.get(3 * i).get(j) < firesFilter1)
                                        && (climateVector.get(climateYear.indexOf(listYears.get(j)))) != -1.0) {
                                    climateVectorActualSite.add(0);
                                } else {
                                    climateVectorActualSite
                                            .add(climateVector.get(climateYear.indexOf(listYears.get(j))));
                                }
                            } else if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_ALL_TREES)) {
                                // log.debug("percent of fires is selected is: "+
                                // firesFilter2+" "+climateVector.get(climateYear.indexOf(listYearsComp.get(j))));
                                // log.debug("the filter percent of fires is"+filterMatrix.get((3*i+2)).get(j));
                                if ((filterMatrix.get(3 * i + 2).get(j) == -99)) {
                                    climateVectorActualSite.add(-1);
                                } else {
                                    if ((filterMatrix.get(3 * i + 2).get(j) < firesFilter2) && ((climateVector
                                            .get(climateYear.indexOf(listYears.get(j)))) != -1.0)) {
                                        climateVectorActualSite.add(0);
                                    } else {
                                        climateVectorActualSite
                                                .add(climateVector.get(climateYear.indexOf(listYears.get(j))));
                                    }
                                }
                            } else if (fireFilterType.equals(FireFilterType.PERCENTAGE_OF_RECORDING)) {

                                // TODO
                                // ELENA TO IMPLEMENT
                                if (percentOfRecordingfilter.get(j) == -99) {
                                    climateVectorActualSite.add(-1);
                                } else {
                                    if ((percentOfRecordingfilter.get(j) < firesFilter2) && ((climateVector
                                            .get(climateYear.indexOf(listYears.get(j)))) != -1.0)) {
                                        climateVectorActualSite.add(0);
                                    } else {
                                        climateVectorActualSite
                                                .add(climateVector.get(climateYear.indexOf(listYears.get(j))));
                                    }
                                }

                            } else {
                                log.error("Unknown FireFilterType");
                                return;
                            }

                        } // end of if filter not equal to 1
                        else {
                            climateVectorActualSite
                                    .add(climateVector.get(climateYear.indexOf(listYears.get(j))));
                        } // end of else of if filter not equal to 1
                    } // end of if the filter minsampedepth
                    else {
                        // log.debug("j is " + j + "minSampleFilter is " + minSampleFilter.get(j));
                        climateVectorActualSite.add(-1);

                    }
                } // end else 645 to 721
            } // end of j loop listyears (420-459)
            /*
             * climateMatrixSite has the composite information taking in consideration both the filters and common years
             */
            climateMatrixSite.add(climateVectorActualSite);

            /*
             * Must get the years with Fires from the climateMatrixSite which has been filter already
             */
            ArrayList<Double> fireintervalspersite = new ArrayList<Double>();
            ArrayList<Integer> yearsWithFires = new ArrayList<Integer>();
            for (int ij = 0; ij < listYears.size(); ij++) {
                if (climateMatrixSite.get(i).get(ij) == 1) {
                    yearsWithFires.add(listYears.get(ij));
                    log.debug("year with fires " + listYears.get(ij));
                }
            }

            /*
             * check that the number of years with fires is bigger of equal than 3 if so make the fire intervals else the test can not
             * be run and report NA
             */
            // new swich
            if (yearsWithFires.size() != 0) {
                if (includeIncomplete) {
                    if (maxLastYear.compareTo(yearsWithFires.get(yearsWithFires.size() - 1)) != 0) {
                        log.debug("here");
                        numberOfintervalscomp[i] = yearsWithFires.size();
                    } else {
                        numberOfintervalscomp[i] = yearsWithFires.size() - 1;
                    }
                } else {
                    numberOfintervalscomp[i] = yearsWithFires.size() - 1;
                }
            }
            log.debug("number of invervlas in comp is: " + numberOfintervalscomp[i]);
            // end of new switch
            if (numberOfintervalscomp[i] >= 3) {
                enoughIntComp[i] = true;
                ArrayList<Integer> fireIntervals = generateFireIntervals(yearsWithFires);
                for (int ij = 0; ij < fireIntervals.size(); ij++) {
                    // log.debug("fire intervals are: "+
                    // test1.getFireIntervals().get(ij));
                    fireintervalspersite.add(fireIntervals.get(ij) * 1.0);
                }

                /*
                 * Add extra interval if include incomplete is selected. the interval goes from the last fire scar year to the last year
                 * of the fire history.
                 */
                if (includeIncomplete) {
                    double includeinterval = maxLastYear - yearsWithFires.get(yearsWithFires.size() - 1);
                    if (includeinterval > 0) {
                        fireintervalspersite.add(includeinterval);
                        System.out.println("the last year is " + maxLastYear + "the last year with fire is "
                                + yearsWithFires.get(yearsWithFires.size() - 1));
                        log.debug("the included interval is " + includeinterval);
                    }
                }
                log.debug("FireintervalsPerSite =" + fireintervalspersite);
                /*
                 * Get the normal statistics for the fire intervals add the values to the stats and then call them for the stats
                 */
                DescriptiveStatistics stats = new DescriptiveStatistics();
                Dfireintervalspersite = new Double[fireintervalspersite.size()];
                Dfireintervalspersite = fireintervalspersite.toArray(Dfireintervalspersite);
                dfireintervalspersite = new double[fireintervalspersite.size()];
                // summaryComp = new
                // double[statsparam.length][myReader.size()];
                for (int ik = 0; ik < fireintervalspersite.size(); ik++) {
                    stats.addValue(Dfireintervalspersite[ik].doubleValue());
                    dfireintervalspersite[ik] = Dfireintervalspersite[ik].doubleValue();
                }
                /*
                 * load the Summary Analysis for the Composite fire intervals
                 */
                summaryComp[0][i] = fireintervalspersite.size();
                // double mean = stats.getMean();
                summaryComp[1][i] = stats.getMean();
                // double median =
                // StatUtils.percentile(dfireintervalspersite, 50);
                summaryComp[2][i] = StatUtils.percentile(dfireintervalspersite, 50);
                // double std = stats.getStandardDeviation();
                summaryComp[3][i] = stats.getStandardDeviation();
                // double skew = stats.getSkewness();
                summaryComp[4][i] = 1.0 / summaryComp[1][i];
                summaryComp[5][i] = summaryComp[3][i] / summaryComp[1][i];
                summaryComp[6][i] = stats.getSkewness();
                // double kurt = stats.getKurtosis();
                if (numberOfintervalscomp[i] == 3) {
                    summaryComp[7][i] = -99;
                } else {
                    summaryComp[7][i] = stats.getKurtosis();
                }
                // log.debug("nomean \t\t nostd \t\t nokurt \t noskew \t\t nomedian");
                // log.debug(twoPlace.format(mean)+"\t\t"+twoPlace.format(std)+"\t\t"+twoPlace.format(kurt)+"\t\t"+twoPlace.format(skew)+"\t\t"+twoPlace.format(median));

                Weibull weibull = new Weibull(fireintervalspersite);

                ArrayList<Double> weibullProb = weibull.getWeibullProbability(fireintervalspersite);
                ArrayList<Double> siglonglowbound = new ArrayList<Double>();
                ArrayList<Double> sigshortupbound = new ArrayList<Double>();
                log.debug("the weibull probability of first element is " + weibullProb.get(0));
                log.debug("the index  the size of the interval is " + weibullProb.indexOf(weibullProb.get(0)));
                for (int ij = 0; ij < weibullProb.size() - 1; ij++) {
                    if (weibullProb.get(ij) <= alphaLevel) {
                        siglonglowbound.add(fireintervalspersite.get(ij));

                    }
                    if (weibullProb.get(ij) >= (1 - alphaLevel)) {
                        sigshortupbound.add(fireintervalspersite.get(ij));

                    }

                }

                summaryComp[10][i] = weibull.getScale();
                summaryComp[11][i] = weibull.getShape();
                summaryComp[12][i] = weibull.getMean();
                summaryComp[13][i] = weibull.getMedian();
                summaryComp[14][i] = weibull.getMode();
                summaryComp[15][i] = weibull.getSigma();
                summaryComp[16][i] = 1.0 / summaryComp[13][i];
                summaryComp[17][i] = weibull.getSkew();
                summaryComp[18][i] = weibull.getExceedenceProbability2()[0];
                summaryComp[19][i] = weibull.getExceedenceProbability2()[1];
                Collections.sort(sigshortupbound);
                log.debug("siglonglowbound is " + siglonglowbound);
                try {
                    summaryComp[20][i] = sigshortupbound.get(sigshortupbound.size() - 1);
                } catch (Exception e) {
                    summaryComp[20][i] = Double.NaN;
                }
                Collections.sort(siglonglowbound);

                try {
                    summaryComp[21][i] = siglonglowbound.get(0);
                } catch (Exception e) {
                    summaryComp[21][i] = Double.NaN;
                }
                log.debug("sigshortupbound is " + sigshortupbound);
                Collections.sort(fireintervalspersite);
                summaryComp[8][i] = fireintervalspersite.get(0);
                summaryComp[9][i] = fireintervalspersite.get(fireintervalspersite.size() - 1);
                // log.debug("shape \t\t scale \t\t median ");
                // log.debug(twoPlace.format(test1.Weibull_Parameters(fireintervalspersite)[0])+"\t\t"+twoPlace.format(test1.Weibull_Parameters(fireintervalspersite)[1])+"\t\t"+twoPlace.format(test1.weibull_median(test1.Weibull_Parameters(fireintervalspersite))));
                // log.debug("mean \t\t sigma \t\t mode \t\t skewness");
                // log.debug(twoPlace.format(test1.weibull_mean(test1.Weibull_Parameters(fireintervalspersite)))+"\t\t"+twoPlace.format(test1.weibull_sigma(test1.Weibull_Parameters(fireintervalspersite)))+"\t\t"+twoPlace.format(test1.weibull_mode(test1.Weibull_Parameters(fireintervalspersite)))+"\t\t"+twoPlace.format(test1.weibull_skew(test1.Weibull_Parameters(fireintervalspersite))));
                // log.debug("maxhazard \t\t lei \t\t uei ");
                // log.debug(twoPlace.format(test1.maxhazard_int(test1.Weibull_Parameters(fireintervalspersite)))+"\t\t"+twoPlace.format(test1.weibull_lowuppexcint(test1.Weibull_Parameters(fireintervalspersite))[0])+"\t\t"+twoPlace.format(test1.weibull_lowuppexcint(test1.Weibull_Parameters(fireintervalspersite))[1]));
                // log.debug("the size of YearWith Fires is "+YearsWithFires.size());
                System.out.println("the size of the prb exdc is " + weibull.getExceedenceProbability().length);
                for (int kk = 0; kk < weibull.getExceedenceProbability().length; kk++) {
                    ExceeProbcomp[kk][i] = weibull.getExceedenceProbability()[kk];
                    // log.debug("file "+i+"Exce probability "+
                    // ExceeProbcomp[kk][i]);
                }
            } // end of if enoughIntComp
            else {
                enoughIntComp[i] = false;
            }
        } // end the if composite is selected
        /*
         * starting the process for the sample mode.
         */
        if (analysisType.equals(AnalysisType.SAMPLE)) {
            log.debug("I am in sample ");

            ArrayList<Double> fireintervalspersample = new ArrayList<Double>();
            FIyearperSampletemp = new ArrayList<Integer>();
            // FyearperSampletemp = new ArrayList<Integer>();
            for (int k = 0; k < myReader.get(i).getNumberOfSeries(); k++) {

                log.debug("Parsing file index " + i + ", series number " + (k + 1));
                FyearperSampletemp = new ArrayList<Integer>();
                // log.debug("the size of the years of the file is:"+
                // myReader.get(i).getYear().size());
                // log.debug("years with fires in sample "+k +
                // "years are ");
                // for (int j = 0; j < myReader.get(i).getYearArray().size(); j++)
                for (int j = 0; j < listYears.size(); j++) {
                    // log.debug("the size climate2d is "+myReader.get(i).getClimate2d().get(k).get(j));
                    if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_EVENT)) {
                        if (climateYear.indexOf(listYears.get(j)) != -1) {
                            if (myReader.get(i).getClimate2d().get(k)
                                    .get(climateYear.indexOf(listYears.get(j))) == 1) {
                                // FyearperSampletemp.add((j + myReader.get(i).getFirstYear()));
                                FyearperSampletemp.add(listYears.get(j));
                            }
                        }

                    }
                    // {
                    // if ((myReader.get(i).getClimate2d().get(k).get(j) == 1))
                    // {
                    // / log.debug("I here inside ==1 "+
                    // / j+" "+myReader.get(i).getFirstYear());
                    // / int temp=j+myReader.get(i).getFirstYear();
                    // / log.debug((j+myReader.get(i).getFirstYear()));
                    // /// FyearperSampletemp.add((j + myReader.get(i).getFirstYear()));
                    // }
                    // }
                    else if (eventTypeToProcess.equals(EventTypeToProcess.INJURY_EVENT)) {
                        if (climateYear.indexOf(listYears.get(j)) != -1) {
                            if (myReader.get(i).getClimate2dII().get(k)
                                    .get(climateYear.indexOf(listYears.get(j))) == 1) {
                                FyearperSampletemp.add(listYears.get(j));
                            }
                        }
                        // if ((myReader.get(i).getClimate2dII().get(k).get(j) == 1))
                        // {
                        // FyearperSampletemp.add((j + myReader.get(i).getFirstYear()));
                        // }
                    } else if (eventTypeToProcess.equals(EventTypeToProcess.FIRE_AND_INJURY_EVENT)) {
                        if (climateYear.indexOf(listYears.get(j)) != -1) {
                            if (myReader.get(i).getClimate2dIII().get(k)
                                    .get(climateYear.indexOf(listYears.get(j))) == 1) {
                                FyearperSampletemp.add(listYears.get(j));
                            }
                        }
                        // if ((myReader.get(i).getClimate2dIII().get(k).get(j) == 1))
                        // {
                        // FyearperSampletemp.add((j + myReader.get(i).getFirstYear()));
                        // }
                    } else {

                        log.error("Unsupported event type caught");
                    }

                } // / end of the loop for listYears in common (finish loading the fire year per sample
                log.debug(
                        "series number " + (k + 1) + " FyearperSampletemp.size() " + FyearperSampletemp.size());
                if (FyearperSampletemp.size() != 0) {
                    if (includeIncomplete) {
                        if (maxLastYear.compareTo(FyearperSampletemp.get(FyearperSampletemp.size() - 1)) != 0) {
                            numberOfintervalssamp[i] = numberOfintervalssamp[i] + FyearperSampletemp.size();
                        }
                    } else {
                        numberOfintervalssamp[i] = numberOfintervalssamp[i] + (FyearperSampletemp.size() - 1);
                    }
                }
                log.debug("series number: " + (k + 1) + " number of intervals " + numberOfintervalssamp[i]);
                // new
                if ((FyearperSampletemp.size() == 1) && (includeIncomplete)) {
                    log.debug("last index per sample is " + myReader.get(i).getLastYearIndexPerSample()[k]);
                    log.debug("first year per sample is " + myReader.get(i).getFirstYear());
                    log.debug("maxLastyear is " + maxLastYear);
                    // if (maxLastYear != FyearperSampletemp.get(FyearperSampletemp.size() - 1))
                    if (maxLastYear.compareTo(FyearperSampletemp.get(FyearperSampletemp.size() - 1)) != 0) {
                        log.debug("I am in not equal ");
                        log.debug(
                                "last year in the sample  is " + (myReader.get(i).getLastYearIndexPerSample()[k]
                                        + myReader.get(i).getFirstYear()));
                        log.debug("maxLastyear is " + maxLastYear);
                        log.debug("the last fire year in the sample "
                                + FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                        if (maxLastYear <= (myReader.get(i).getLastYearIndexPerSample()[k]
                                + myReader.get(i).getFirstYear())) {
                            Integer temp = ((maxLastYear)
                                    - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            // int temp1 = maxLastYear.intValue() - FyearperSampletemp.get(FyearperSampletemp.size() - 1).intValue();
                            log.debug("in less than or equal to ");
                            // temp = (maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1);
                            log.debug("the resta temp is " + temp);
                            // FIyearperSampletemp.add(((maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1)));
                            if ((maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1) > 0) {
                                FIyearperSampletemp.add(
                                        (maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                                log.debug("the fire intervals for sample " + k + " is "
                                        + FIyearperSampletemp.get(0));
                            }
                            // FIyearperSampletemp.add(temp);
                            // log.debug("the fire intervals for sample " + k + " is " + FIyearperSampletemp.get(0));
                        } else {
                            log.debug("in else ");
                            FIyearperSampletemp.add((myReader.get(i).getLastYearIndexPerSample()[k]
                                    + myReader.get(i).getFirstYear())
                                    - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            log.debug("fire intervals for sample " + k + " is " + FIyearperSampletemp.get(0));
                        }
                        // FIyearperSampletemp.add((myReader.get(i).getFirstYear() + myReader.get(i).getLastYearIndexPerSample()[k])
                        // - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                    }
                    // log.debug("fire intervals for sample " + k + " is " + FIyearperSampletemp.get(0));
                } // end of if one fire year and includelastyear so we have at least one interval in a given series.
                  // endofnew
                if ((FyearperSampletemp.size() >= 2)) {
                    log.debug("Series number is " + (k + 1));
                    for (int jk = 0; jk < FyearperSampletemp.size() - 1; jk++) {
                        // FIyearperSampletemp.add(FyearperSample.get(k).get(jk+1)
                        // - FyearperSample.get(k).get(jk));
                        log.debug("FyearperSampletemp is " + FyearperSampletemp.get(jk));
                        if ((FyearperSampletemp.get(jk + 1) - FyearperSampletemp.get(jk)) > 0) {
                            FIyearperSampletemp
                                    .add(FyearperSampletemp.get(jk + 1) - FyearperSampletemp.get(jk));
                        }
                        // FIyearperSampletemp.add(FyearperSampletemp.get(jk+1)
                        // - FyearperSampletemp.get(jk));
                        log.debug("fire intervals for sample " + k + " is " + FIyearperSampletemp.get(jk));
                        // fisumtemp= fisumtemp +
                        // FIyearperSampletemp.get(jk).intValue();
                    }
                    if (includeIncomplete) {
                        // if (maxLastYear != FyearperSampletemp.get(FyearperSampletemp.size() - 1))
                        if (maxLastYear.compareTo(FyearperSampletemp.get(FyearperSampletemp.size() - 1)) != 0)
                        // if ((myReader.get(i).getLastYearIndexPerSample()[k] + myReader.get(i).getFirstYear()) != FyearperSampletemp
                        // .get(FyearperSampletemp.size() - 1))
                        {
                            if (maxLastYear <= (myReader.get(i).getLastYearIndexPerSample()[k]
                                    + myReader.get(i).getFirstYear())) {
                                if (((maxLastYear)
                                        - FyearperSampletemp.get(FyearperSampletemp.size() - 1)) > 0) {
                                    FIyearperSampletemp.add(((maxLastYear)
                                            - FyearperSampletemp.get(FyearperSampletemp.size() - 1)));
                                }
                            } else {
                                FIyearperSampletemp.add((myReader.get(i).getLastYearIndexPerSample()[k]
                                        + myReader.get(i).getFirstYear())
                                        - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            }
                            // log.debug("the sample number is "+k+
                            // " the size of the fyearpersampletemp is "+
                            // FyearperSampletemp.size() );
                            // log.debug("the last year per sample is "
                            // + (myReader.get(i).getLastYearIndexPerSample()[k] + myReader.get(i).getFirstYear()));
                            // log.debug(" the last fire year per sample " + FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            // FIyearperSampletemp.add((maxLastYear) - FyearperSampletemp.get(FyearperSampletemp.size() - 1));
                            // log.debug("the last intrval in included is on is   "
                            // + FIyearperSampletemp.get(FIyearperSampletemp.size() - 1));
                        }
                    }
                } // end of if at least 2 fier years so we have at least one interval in a given series.
                log.debug("size of FIyearperSampletemp " + FIyearperSampletemp.size() + "  at series is :"
                        + (k + 1));
                // FIyearperSampletemp.size()+
                // " X "+FIyearperSampletemp.get(0).size());

            } // end of the loop for number of series.
              // log.debug("size of FIyearperSample "+
              // FIyearperSampletemp.size());
            for (int j = 0; j < FIyearperSampletemp.size(); j++) {
                fireintervalspersample.add(FIyearperSampletemp.get(j) * 1.0);
            }
            /*
             * Get the normal statistics for the fire intervals add the values to the stats and then call them for the stats
             */
            if (fireintervalspersample.size() >= 3) {
                enoughIntSamp[i] = true;
                DescriptiveStatistics stasample = new DescriptiveStatistics();
                Dfireintervalspersample = new Double[fireintervalspersample.size()];
                Dfireintervalspersample = fireintervalspersample.toArray(Dfireintervalspersample);
                dfireintervalspersample = new double[fireintervalspersample.size()];
                // summarySample = new
                // double[statsparam.length][myReader.size()];
                for (int ik = 0; ik < fireintervalspersample.size(); ik++) {
                    stasample.addValue(Dfireintervalspersample[ik].doubleValue());
                    dfireintervalspersample[ik] = Dfireintervalspersample[ik].doubleValue();
                    log.debug("the " + ik + " fire interval is " + dfireintervalspersample[ik]);
                }
                log.debug("the size for dfireintervalspersample is " + dfireintervalspersample.length);

                // ADDED BY PETE
                if (dfireintervalspersample.length == 0)
                    continue;

                /*
                 * load the Summary Analysis for the Sample fire intervals
                 */
                summarySample[0][i] = fireintervalspersample.size();
                // double mean = stats.getMean();
                summarySample[1][i] = stasample.getMean();
                log.debug("mean sample is " + stasample.getMean());
                // double median =
                // StatUtils.percentile(dfireintervalspersite, 50);
                summarySample[2][i] = StatUtils.percentile(dfireintervalspersample, 50);
                log.debug("summarySample[2][] " + i + " " + summarySample[2][i]);
                // double std = stats.getStandardDeviation();
                summarySample[3][i] = stasample.getStandardDeviation();
                log.debug("summarySample[3][] " + i + " " + summarySample[3][i]);
                // double skew = stats.getSkewness();
                summarySample[4][i] = 1.0 / summarySample[1][i];
                log.debug("summarySample[4][] " + i + " " + summarySample[4][i]);
                summarySample[5][i] = summarySample[3][i] / summarySample[1][i];
                log.debug("summarySample[5][] " + i + " " + summarySample[5][i]);
                summarySample[6][i] = stasample.getSkewness();
                log.debug("summarySample[6][] " + i + " " + summarySample[6][i]);
                // double kurt = stats.getKurtosis();
                if (numberOfintervalssamp[i] == 3) {
                    summarySample[7][i] = -99;
                } else {
                    summarySample[7][i] = stasample.getKurtosis();
                }
                // summarySample[7][i] = stasample.getKurtosis();
                log.debug("summarySample[7][] " + i + " " + summarySample[7][i]);
                // log.debug("nomean \t\t nostd \t\t nokurt \t noskew \t\t nomedian");
                // log.debug(twoPlace.format(mean)+"\t\t"+twoPlace.format(std)+"\t\t"+twoPlace.format(kurt)+"\t\t"+twoPlace.format(skew)+"\t\t"+twoPlace.format(median));

                Weibull weibull = new Weibull(fireintervalspersample);

                //
                ArrayList<Double> weibullProb = weibull.getWeibullProbability(fireintervalspersample);
                ArrayList<Double> siglonglowbound = new ArrayList<Double>();
                ArrayList<Double> sigshortupbound = new ArrayList<Double>();
                log.debug("the weibull probability of first element is " + weibullProb.get(0));
                log.debug("the index  the size of the interval is " + weibullProb.indexOf(weibullProb.get(0)));
                for (int ij = 0; ij < weibullProb.size() - 1; ij++) {
                    if (weibullProb.get(ij) <= alphaLevel) {
                        siglonglowbound.add(fireintervalspersample.get(ij));

                    }
                    if (weibullProb.get(ij) >= (1 - alphaLevel)) {
                        sigshortupbound.add(fireintervalspersample.get(ij));

                    }

                }

                //

                summarySample[10][i] = weibull.getScale();
                log.debug("summarySample[10][] " + i + " " + summarySample[10][i]);
                summarySample[11][i] = weibull.getShape();
                log.debug("summarySample[11][] " + i + " " + summarySample[11][i]);
                summarySample[12][i] = weibull.getMean();
                summarySample[13][i] = weibull.getMedian();
                summarySample[14][i] = weibull.getMode();
                summarySample[15][i] = weibull.getSigma();
                summarySample[16][i] = 1.0 / summarySample[13][i];
                summarySample[17][i] = weibull.getSkew();
                summarySample[18][i] = weibull.getExceedenceProbability2()[0];
                summarySample[19][i] = weibull.getExceedenceProbability2()[1];
                Collections.sort(sigshortupbound);
                log.debug("siglonglowbound is " + siglonglowbound);
                try {
                    summarySample[20][i] = sigshortupbound.get(sigshortupbound.size() - 1);
                } catch (Exception e) {
                    summarySample[20][i] = Double.NaN;
                }
                Collections.sort(siglonglowbound);

                try {
                    summarySample[21][i] = siglonglowbound.get(0);
                } catch (Exception e) {
                    summarySample[21][i] = Double.NaN;
                }
                log.debug("sigshortupbound is " + sigshortupbound);

                Collections.sort(fireintervalspersample);

                try {
                    summarySample[8][i] = fireintervalspersample.get(0);
                } catch (Exception ex) {
                    log.error("Index out of bounds exception caught: ");
                    log.error("    summarySample[8][i] = fireintervalspersample.get(0)");
                    ex.printStackTrace();
                }
                summarySample[9][i] = fireintervalspersample.get(fireintervalspersample.size() - 1);
                // log.debug("shape \t\t scale \t\t median ");
                // log.debug(twoPlace.format(test2.Weibull_Parameters(fireintervalspersample)[0])+"\t\t"+twoPlace.format(test2.Weibull_Parameters(fireintervalspersample)[1])+"\t\t"+twoPlace.format(test2.weibull_median(test1.Weibull_Parameters(fireintervalspersample))));
                // log.debug("mean \t\t sigma \t\t mode \t\t skewness");
                // log.debug(twoPlace.format(test1.weibull_mean(test2.Weibull_Parameters(fireintervalspersample)))+"\t\t"+twoPlace.format(test1.weibull_sigma(test2.Weibull_Parameters(fireintervalspersample)))+"\t\t"+twoPlace.format(test2.weibull_mode(test1.Weibull_Parameters(fireintervalspersample)))+"\t\t"+twoPlace.format(test1.weibull_skew(test2.Weibull_Parameters(fireintervalspersample))));
                // log.debug("maxhazard \t\t lei \t\t uei ");
                // log.debug(twoPlace.format(test2.maxhazard_int(test2.Weibull_Parameters(fireintervalspersample)))+"\t\t"+twoPlace.format(test2.weibull_lowuppexcint(test2.Weibull_Parameters(fireintervalspersample))[0])+"\t\t"+twoPlace.format(test2.weibull_lowuppexcint(test2.Weibull_Parameters(fireintervalspersample))[1]));
                // log.debug("the size of YearWith Fires is "+YearsWithFires.size());
                // log.debug("the size of the prb exdc is
                // "+test2.weibull_Exprob(test2.Weibull_Parameters(fireintervalspersample)).length);
                System.out.println(
                        "the size of the prb exdc sample  is " + weibull.getExceedenceProbability().length);
                for (int kk = 0; kk < weibull.getExceedenceProbability().length; kk++) {
                    ExceeProbsample[kk][i] = weibull.getExceedenceProbability()[kk];
                    log.debug("file " + i + " Exce probability " + ExceeProbsample[kk][i]);
                    // log.debug("the size is "+ExceeProbsample.length);
                }
            } // end of if at least 4 fireintervals
            else {
                enoughIntSamp[i] = false;
            }
        } // end of if jRadioSample selected.
          // log.debug("the size of exceeprobsample is "ExceeProbsample.length+" X "+ExceeProbsample[0].length);
    } // end of i readering each file loop do loop (354-1185)
    /*
     * 
     */
    // log.debug("size of the climateMatrixSite is "+climateMatrixSite.size()+" X "+climateMatrixSite.get(0).size());
    // for (int j = 0; j < listYears.size(); j++){
    // log.debug(climateMatrixSite.get(0).get(j) + " " +
    // listYears.get(j));
    // }
    // setCursor(Cursor.getDefaultCursor());
    /*
     * create JFileChooser object to generate a browsing capabilities
     */
    JFileChooser fileBrowse = new JFileChooser();

    fileBrowse = new JFileChooser(savePath.substring(0, savePath.lastIndexOf(File.separator)));
    /*
     * set multiselect on (even though we don't need it)
     */
    fileBrowse.setMultiSelectionEnabled(true);
    /*
     * set file and folder directive
     */
    fileBrowse.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    /*
     * set file type: coma delimited file csv
     */
    //
    FileFilter filter1 = new CSVFileFilter();
    fileBrowse.setFileFilter(filter1);
    /*
     * set dialog text: select the name and location of the matrix files
     */
    fileBrowse.setDialogTitle("Select the name and location of the Stats Summary file:");

    /*
     * create the writer object for each of the files to be created
     */
    Writer wr;
    Writer wrWDE;
    Writer wrSample;
    Writer wrWDESample;
    /*
     * set delimiter in this case we are using comas ","
     */
    String delim = ",";

    /*
     * Start writing information into the files
     */
    try {
        if (analysisType.equals(AnalysisType.COMPOSITE)) {
            wr = new BufferedWriter(new FileWriter(summaryFile));
            wrWDE = new BufferedWriter(new FileWriter(exceedenceFile));
            /*
             * write the heading to the files
             */
            String buffer = "";

            buffer = buffer + "Composite Parameters" + delim;
            for (int i = 0; i < inputFileArray.length; i++) {
                buffer = buffer + inputFileArray[i].getLabel() + delim;
            }
            ;
            wr.write(buffer.substring(0, buffer.length() - 1) + System.getProperty("line.separator"));

            buffer = "";
            for (int j = 0; j < statsparam.length; j++) {
                buffer = buffer + statsparam[j] + delim;

                for (int k = 0; k < inputFileArray.length; k++) {
                    if (j == 0) {
                        if (numberOfintervalscomp[k] < 3) {
                            buffer = buffer + twoPlace.format(numberOfintervalscomp[k]) + delim;
                        } else {
                            buffer = buffer + twoPlace.format(summaryComp[0][k]) + delim;
                        }

                    } else {
                        if (enoughIntComp[k]) {
                            if (summaryComp[j][k] == -99) {
                                buffer = buffer + "" + delim;
                            } else {
                                buffer = buffer + twoPlace.format(summaryComp[j][k]) + delim;
                            }
                        } else {
                            buffer = buffer + "" + delim;
                        }
                    }
                } // end of k loop filearray

                wr.write(buffer.substring(0, buffer.length() - 1) + System.getProperty("line.separator"));
                buffer = "";
            } // end of j loop Stats
              // wr.close();
              //
              //
              // wrWDE = new BufferedWriter(new
              // FileWriter(outputWDExceeTable));
              /*
               * write the heading to the files
               */

            buffer = "";
            wrWDE.write("Exceedence Prob" + delim);
            for (int i = 0; i < inputFileArray.length; i++) {
                buffer = buffer + inputFileArray[i].getLabel() + delim;
            }
            wrWDE.write(buffer.substring(0, buffer.length() - 1) + System.getProperty("line.separator"));
            buffer = "";

            for (int j = 0; j < fixvalt.length; j++) {
                buffer = buffer + threePlace.format(fixvalt[j]) + delim;

                for (int k = 0; k < inputFileArray.length; k++) {
                    if (enoughIntComp[k]) {
                        buffer = buffer + twoPlace.format(ExceeProbcomp[j][k]) + delim;
                    } else {
                        buffer = buffer + "" + delim;
                    }
                }
                wrWDE.write(buffer.substring(0, buffer.length() - 1) + System.getProperty("line.separator"));
                buffer = "";
            }

            wr.close();
            wrWDE.close();

        } // end of if jRadioComp is selecte
        if (analysisType.equals(AnalysisType.SAMPLE)) {
            wrSample = new BufferedWriter(new FileWriter(summaryFile));
            wrWDESample = new BufferedWriter(new FileWriter(exceedenceFile));
            /*
             * write the heading to the files
             */
            wrSample.write("Sample Parameters" + delim);
            for (int i = 0; i < inputFileArray.length; i++) {
                wrSample.write(inputFileArray[i].getLabel() + delim);
            }
            wrSample.write(System.getProperty("line.separator"));
            for (int j = 0; j < statsparam.length; j++) {
                wrSample.write(statsparam[j] + delim);
                for (int k = 0; k < inputFileArray.length; k++) {
                    if (j == 0) {
                        if (numberOfintervalssamp[k] < 3) {
                            wrSample.write(twoPlace.format(numberOfintervalssamp[k]) + delim);
                        } else {
                            wrSample.write(twoPlace.format(summarySample[0][k]) + delim);
                        }

                    } else {
                        if (enoughIntSamp[k]) {
                            if (summarySample[j][k] == -99) {
                                wrSample.write("" + delim);
                            } else {
                                wrSample.write(twoPlace.format(summarySample[j][k]) + delim);
                            }
                        } else {
                            wrSample.write("" + delim);
                        }
                    }
                } // end of k loop file array
                wrSample.write(System.getProperty("line.separator"));
            } // end of loop j loop stats
              // wrSample.close();
              //
              //
              // log.debug("the size is "+fixvalt.length+" X "+inputFile.length);
              // wrWDESample = new BufferedWriter(new
              // FileWriter(outputWDExceeTablesample));
              /*
               * write the heading to the files
               */
            wrWDESample.write("Exceedence Prob" + delim);
            for (int i = 0; i < inputFileArray.length; i++) {
                wrWDESample.write(inputFileArray[i].getLabel() + delim);
            }
            wrWDESample.write(System.getProperty("line.separator"));
            for (int j = 0; j < fixvalt.length; j++) {
                wrWDESample.write(threePlace.format(fixvalt[j]) + delim);
                for (int k = 0; k < inputFileArray.length; k++) {
                    // System.out.print(ExceeProbcomp[j][k]+delim);
                    if (enoughIntSamp[k]) {
                        wrWDESample.write(twoPlace.format(ExceeProbsample[j][k]) + delim);
                    } else {
                        wrWDESample.write("" + delim);
                    }

                }
                // System.out.print(System.getProperty("line.separator"));
                wrWDESample.write(System.getProperty("line.separator"));
            }
            wrSample.close();
            wrWDESample.close();
        } // end of jradiosample

    } // end of Try
    catch (IOException ex) {
        ex.printStackTrace();
    } finally {

    }

}