Example usage for java.util ArrayList isEmpty

List of usage examples for java.util ArrayList isEmpty

Introduction

In this page you can find the example usage for java.util ArrayList isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:uk.ac.soton.itinnovation.sad.service.controllers.QueryController.java

/**
 * Returns data generated during the last plugin run.
 *
 * @return data created by the last SAD job.
 *///  w w  w.ja v  a 2 s.  c  o m
@RequestMapping(method = RequestMethod.GET, value = "/getlastrundata")
@ResponseBody
public JsonResponse getLastRunData() {

    logger.debug("Returning last created job\'s data");

    schedulingService.pushMethodCalledName("/q/getlastrundata");

    ArrayList<SADJobData> jobDataArray = schedulingService.getLastJobData();
    JSONObject response = new JSONObject();

    if ((jobDataArray == null) || (jobDataArray.isEmpty())) {

        response.put("reason", "No data found");

        return new JsonResponse("error", response);

    } else {

        JSONArray dataEntries = new JSONArray();

        JSONObject jsonEntry;
        for (SADJobData entry : jobDataArray) {
            jsonEntry = JSONObject.fromObject(entry.getJsonData());
            jsonEntry.put("collected", entry.getWhenCollected().toString());
            dataEntries.add(jsonEntry);
        }

        response.put("jsonData", dataEntries);
        return new JsonResponse("ok", response);
    }
}

From source file:biblioteca.datos.hibernate.dao.imp.UsuarioDAOImp.java

@Override
@Transactional/* w w  w  .j av a  2s . co m*/
public Usuario validarUsuario(String nombreUsuario, String password) {
    System.out.println("aca entramos al validar usuario de usuariodaoimpl");
    System.out.println("nombreUsuario " + nombreUsuario + " password " + password);
    DetachedCriteria dc = DetachedCriteria.forClass(Usuario.class);
    dc.add(Restrictions.eq("nombreUsu", nombreUsuario));
    dc.add(Restrictions.eq("claveUsu", password));
    System.out.println("usuario " + dc.getAlias());
    System.out.println("aca agregamos restrictions nombreusuario y password deteched criteria");
    ArrayList<Usuario> resu = new ArrayList<Usuario>();
    resu = (ArrayList) getHibernateTemplate().findByCriteria(dc);
    System.out.println("usuariodaoimpl devuelve el array de tipo usuario resu");
    //aqui deberrias poner condigo para ver si resu es null
    //en este caso no se encontraron usuarios con los parametros de otro modo retornas el primer elemento
    if (resu.isEmpty()) {
        System.out.println("Aca devolvemos usuario null");
        return null;
    } else {
        System.out.println("Aca devolvemos usuario get(0)");
        return resu.get(0);
    }
}

From source file:com.agilejava.docbkx.maven.AbstractWebhelpMojo.java

/**
 * DOCUMENT ME!//from w w  w  .j  a  va2  s.com
 *
 * @param result DOCUMENT ME!
 *
 * @throws MojoExecutionException DOCUMENT ME!
 */
public void postProcessResult(File result) throws MojoExecutionException {
    super.postProcessResult(result);

    if (getLog().isDebugEnabled())
        getLog().debug("webhelp indexing on: " + targetBaseDir);

    copyTemplate();

    // Creating a DirList with index page excluded, and all other html pages included
    DirList nsiDoc = new DirList(targetBaseDir, new String[] { "ix01.html", "^.*\\.html?$" }, 1);
    //new String[]{"ix01.html","^.*\\.html?$"}

    // topic files listed in the given directory
    ArrayList htmlFiles = nsiDoc.getListFiles();

    if (htmlFiles.isEmpty()) {
        throw new MojoExecutionException("No file *.html listed in: " + targetBaseDir);
    }

    // Get the list of all html files with relative paths
    ArrayList htmlFilesPathRel = nsiDoc.getListFilesRelTo(targetBaseDir.getAbsolutePath());

    if (htmlFilesPathRel == null) {
        throw new MojoExecutionException("No relative html files calculated.");
    }

    // Create the list of the existing html files (index starts at 0)
    searchBaseDir.mkdirs();

    final File htmlList = new File(searchBaseDir, HTML_INFO_LIST);

    WriteJSFiles.WriteHTMLList(htmlList.getAbsolutePath(), htmlFilesPathRel, stemming);

    // Parse each html file to retrieve the words:
    // ------------------------------------------

    // Retrieve the clean-up properties for indexing
    retrieveCleanUpProps();

    SaxHTMLIndex spe = new SaxHTMLIndex(cleanUpStrings, cleanUpChars); // use clean-up props files

    System.setProperty("org.xml.sax.driver", "org.ccil.cowan.tagsoup.Parser");
    System.setProperty("javax.xml.parsers.SAXParserFactory", "org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl");

    if (spe.init(tempDico) == 0) {
        //create a html file description list
        ArrayList filesDescription = new ArrayList();

        String indexerLanguage = getProperty("webhelpIndexerLanguage");
        indexerLanguage = ((indexerLanguage == null) ? "en" : indexerLanguage);
        //TODO: change this when updating webhelpindexer in order to use the new WriteJSFiles.WriteIndex method
        if (getLog().isDebugEnabled())
            getLog().debug("Indexer language is: " + indexerLanguage);

        // parse each html files
        for (int f = 0; f < htmlFiles.size(); f++) {
            File ftemp = (File) htmlFiles.get(f);

            if (getLog().isDebugEnabled())
                getLog().debug("Parsing html file: " + ftemp.getAbsolutePath());

            //tempMap.put(key, value);
            //The HTML file information are added in the list of FileInfoObject
            DocFileInfo docFileInfoTemp = new DocFileInfo(spe.runExtractData(ftemp, indexerLanguage, stemming));

            ftemp = docFileInfoTemp.getFullpath();

            String stemp = ftemp.toString();
            int i = stemp.indexOf(targetBaseDir.getAbsolutePath());

            if (i != 0) {
                System.out.println("the documentation root does not match with the documentation input!");

                return;
            }

            int ad = 1;

            if (stemp.equals(targetBaseDir.getAbsolutePath()))
                ad = 0;

            stemp = stemp.substring(i + targetBaseDir.getAbsolutePath().length() + ad); //i is redundant (i==0 always)
            ftemp = new File(stemp);
            docFileInfoTemp.setFullpath(ftemp);

            filesDescription.add(docFileInfoTemp);
        }

        /*remove empty strings from the map*/
        if (tempDico.containsKey("")) {
            tempDico.remove("");
        }

        // write the index files
        if (tempDico.isEmpty()) {
            throw new MojoExecutionException("No words have been indexed in: " + targetBaseDir);
        }

        File indexFile = new File(searchBaseDir, indexName);
        WriteJSFiles.WriteIndex(indexFile.getAbsolutePath(), tempDico, indexerLanguage);

        // write the html list file with title and shortdesc
        //create the list of the existing html files (index starts at 0)
        File htmlInfoList = new File(searchBaseDir, HTML_INFO_LIST);
        WriteJSFiles.WriteHTMLInfoList(htmlInfoList.getAbsolutePath(), filesDescription);
    } else {
        throw new MojoExecutionException("Parser initialization failed, wrong base dir");
    }
}

From source file:gov.wa.wsdot.android.wsdot.ui.SeattleTrafficAlertsFragment.java

public void onLoadFinished(Loader<ArrayList<SeattleIncidentItem>> loader, ArrayList<SeattleIncidentItem> data) {

    if (!data.isEmpty()) {
        mAdapter.setData(data);/*from   ww  w. j a va 2 s . c  om*/
    } else {
        TextView t = (TextView) mEmptyView;
        t.setText(R.string.no_connection);
        getListView().setEmptyView(mEmptyView);
    }

    swipeRefreshLayout.setRefreshing(false);
}

From source file:org.gephi.datalab.plugin.manipulators.columns.ColumnValuesFrequency.java

public String getReportHTML(AttributeTable table, AttributeColumn column,
        Map<Object, Integer> valuesFrequencies, JFreeChart pieChart, Dimension dimension) {
    AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
    int totalValuesCount = ac.getTableRowsCount(table);
    ArrayList<Object> values = new ArrayList<Object>(valuesFrequencies.keySet());

    //Try to sort the values when they are comparable. (All objects of the set will have the same type) and not null:
    if (!values.isEmpty() && values.get(0) instanceof Comparable) {
        Collections.sort(values, new Comparator<Object>() {

            public int compare(Object o1, Object o2) {
                //Check for null objects because some comparables can't handle them (like Float...)
                if (o1 == null) {
                    if (o2 == null) {
                        return 0;
                    } else {
                        return -1;//Null lesser than anything
                    }//from  w w w  .  j  a va  2s.c o  m
                } else if (o2 == null) {
                    if (o1 == null) {
                        return 0;
                    } else {
                        return 1;//Anything greater than null
                    }
                } else {
                    return ((Comparable) o1).compareTo(o2);
                }
            }
        });
    }

    final StringBuilder sb = new StringBuilder();

    sb.append("<html>");
    sb.append(NbBundle.getMessage(ColumnValuesFrequency.class, "ColumnValuesFrequency.report.header",
            HTMLEscape.stringToHTMLString(column.getTitle())));
    sb.append("<hr>");
    sb.append("<ol>");

    for (Object value : values) {
        writeValue(sb, value, valuesFrequencies, totalValuesCount);
    }
    sb.append("</ol>");
    sb.append("<hr>");

    if (!values.isEmpty() && values.size() <= MAX_PIE_CHART_CATEGORIES) {//Do not show pie chart if there are more than 100 different values
        try {
            if (pieChart != null) {
                writePieChart(sb, pieChart, dimension);
            }
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    } else {
        sb.append(NbBundle.getMessage(ColumnValuesFrequency.class,
                "ColumnValuesFrequency.report.piechart.not-shown"));
    }

    sb.append("</html>");
    return sb.toString();
}

From source file:fr.acxio.tools.agia.google.GoogleDriveServiceImpl.java

@Override
public File createPath(String sPath) throws IOException {
    File aResult = null;//from   w  w w . ja v  a 2 s  .  co  m
    if (drive != null) {
        String[] aSubPaths = sPath.split(PATH_SPLIT_REGEX);
        String aParentID = getRootFolderID();
        for (String aSubPath : aSubPaths) {
            if (!aSubPath.isEmpty()) {
                ArrayList<File> aFiles = getChildrenFolders(aParentID, aSubPath);
                if (aFiles.isEmpty()) {
                    aResult = createDirectory(aParentID, aSubPath, null);
                } else {
                    aResult = aFiles.get(0);
                }
                aParentID = aResult.getId();
            }
        }
    }
    return aResult;
}

From source file:administraScan.OrganizaDirectorios.java

public void clasificarCAS() {
    String rutaCAS;//  w w w .ja v a  2s .  c om
    rutaCAS = conf.carpetaCAS + "\\";
    File f = new File(rutaCAS);
    FileUtils Archivos = new FileUtils();
    String curpct = "";
    System.out.println("Archivo Leido en memoria:" + f.list());

    ArrayList<String> names = new ArrayList<>(Arrays.asList(f.list()));
    System.out.println("" + names);
    if (!names.isEmpty()) {
        for (int i = 0; i < names.size(); i++) {
            System.out.println("Voy en :" + names.get(i));
            String curp = (names.get(i).substring(0, 18));
            System.out.println("Curp cortado" + curp);
            curpct = obtenerCT(curp);
            if (curp.equals(""))

            {
                System.out.println("Ya no hay Constancias que mover");
            } else {
                System.out.println("" + curpct);
                String RutaOr = (conf.carpetaCAS + names.get(i).toString());
                String RutaDest = (conf.carpetaCT + curpct + "\\" + curp + "\\");
                System.out.println("" + RutaOr);
                System.out.println("" + RutaDest);

                File origen = new File(RutaOr);
                File destino = new File(RutaDest);
                try {
                    Archivos.moveFileToDirectory(origen, destino, resultado);
                    //Aqu se actualiza la variable

                } catch (IOException E) {
                    E.printStackTrace();
                }
            }
        }
    }
}

From source file:fr.acxio.tools.agia.google.GoogleDriveServiceImpl.java

@Override
public String getFolderId(String sPath) throws IOException {
    String aResult = null;//from  www.  j ava2 s  .c o m
    if (drive != null) {
        String[] aSubPaths = sPath.split(PATH_SPLIT_REGEX);
        int aNbSubPaths = aSubPaths.length;
        int i = 0;
        String aParentID = getRootFolderID();
        while (i < aNbSubPaths) {
            if (!aSubPaths[i].isEmpty()) {
                ArrayList<File> aFiles = getChildrenFolders(aParentID, aSubPaths[i]);
                if (!aFiles.isEmpty()) {
                    aParentID = aFiles.get(0).getId();
                } else {
                    throw new IOException("Folder '" + aSubPaths[i] + "' not found.");
                }
            }
            i++;
        }
        aResult = (aNbSubPaths > 0) ? aParentID : null;
    }
    return aResult;
}

From source file:com.yuntongxun.ecdemo.storage.IMessageSqlManager.java

public static void deleteChattingMessage(long sessionId) {
    while (true) {
        ArrayList<ECMessage> iMessageList = IMessageSqlManager.queryIMessageList(sessionId, 50, null);
        if (iMessageList != null && !iMessageList.isEmpty()) {
            for (ECMessage detail : iMessageList) {
                delSingleMsg(detail.getMsgId());
            }//from   w ww  .j  a  v  a  2  s . com
            continue;
        }
        return;
    }
}

From source file:be.ac.ucl.lfsab1509.llncampus.UCLouvain.java

/**
 * Get the offers list for the academic year given as argument.
 * /*from  w ww.  jav  a 2  s . c  o  m*/
 * @param academicYear
 *            Academic year.
 * @return The offers list for the academic year academicYear or null in case of failure.
 */
public final ArrayList<Offer> getOffers(final int academicYear) {
    if (!connected) {
        Log.d("OFFER", "Not connected");
        return null;
    }

    ArrayList<Offer> offers = new ArrayList<Offer>();
    ArrayList<Offer> allOffers = getOffers();
    if (allOffers == null || allOffers.isEmpty()) {
        Log.e("UCLouvain", "No offer fetched");
        return null;
    }
    for (Offer o : allOffers) {
        if (o.getAcademicYear() == academicYear) {
            offers.add(o);
        }
    }
    return offers;
}