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:DataCharts.Chart.java

public Canvas getCanvas(ArrayList<YearData> locs, String type) {
    try {/* ww w  .  j a v a  2 s. c  o  m*/

        if (locs != null && !locs.isEmpty()) {
            switch (type) {
            case "line":
                this.canvas = new ChartCanvas(LineGraph.createChart(createXYDataset(locs)));
                break;
            case "pie":
                this.canvas = new ChartCanvas(PieGraph.createChart(createPieDataset(locs)));
                break;
            case "bar":
                this.canvas = new ChartCanvas(BarGraph.createChart(createCategoryDataset(locs)));
                break;
            default:
                this.canvas = new ChartCanvas(BarGraph.createChart(createCategoryDataset(locs)));
                break;
            }
        } else {
            this.canvas = new FailedChart();
        }
    } catch (Exception ex) {
        this.canvas = new FailedChart();
        Logger.getLogger(Chart.class.getName()).log(Level.SEVERE, null, ex);
    }
    canvas.setHeight(400);
    canvas.setWidth(600);
    canvas.getWidth();

    return new ChartCanvas(BarGraph.createChart(createCategoryDataset(locs)));

}

From source file:com.thoughtworks.go.server.service.lookups.CommandRepositoryDirectoryWalkerTest.java

@Test
void shouldIgnoreNonXmlFiles() {
    ArrayList results = new ArrayList();
    walker.handleFile(docFile, 0, results);
    assertThat(results.isEmpty()).isTrue();
}

From source file:Main.java

/**
 * Parses a whitespace separated series of name tokens.
 * @param stringValue the full string/*from   www. j a va  2  s .com*/
 * @return a list of each constituent value, or null
 *  if there are no tokens (that is, the string is empty or
 *  all whitespace)
 */
static public List<String> parseNameTokensAsList(String stringValue) {
    if (stringValue == null)
        return null;

    ArrayList<String> list = new ArrayList<String>(5);

    int length = stringValue.length();
    boolean inSpace = true;
    int start = 0;
    for (int i = 0; i < length; i++) {
        char ch = stringValue.charAt(i);

        // We're in whitespace;  if we've just departed
        // a run of non-whitespace, append a string.
        // Now, why do we use the supposedly deprecated "Character.isSpace()"
        // function instead of "isWhitespace"?  We're following XML rules
        // here for the meaning of whitespace, which specifically
        // EXCLUDES general Unicode spaces.
        if (Character.isWhitespace(ch)) {
            if (!inSpace) {
                list.add(stringValue.substring(start, i));
                inSpace = true;
            }
        }
        // We're out of whitespace;  if we've just departed
        // a run of whitespace, start keeping track of this string
        else {
            if (inSpace) {
                start = i;
                inSpace = false;
            }
        }
    }

    if (!inSpace)
        list.add(stringValue.substring(start));

    if (list.isEmpty())
        return null;

    return list;
}

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

public void onLoadFinished(Loader<ArrayList<CameraItem>> loader, ArrayList<CameraItem> data) {
    mLoadingSpinner.setVisibility(View.GONE);

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

From source file:edu.lafayette.metadb.web.search.SearchServlet.java

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*//*w  ww.java  2  s.  c o  m*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    PrintWriter out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), "UTF8"), true);
    JSONObject output = new JSONObject();
    ArrayList<String> tokens = new ArrayList<String>();
    try {
        String options = request.getParameter("search-options");
        String projname = "";
        String query = request.getParameter("query");
        if (options.equals("current"))
            projname = (String) request.getSession(false).getAttribute(Global.SESSION_PROJECT);
        if (query != null && !query.equals("")) {
            ArrayList<Item> resultList = SearchDAO.search(projname, query);
            tokens.addAll(MetaDbHelper.getStringTokens(query));
            output.put("size", resultList.size());
            if (resultList.isEmpty())
                output.put("data", "No entry found with query \"" + query + "\"");
            else
                output.put("data", this.getFormattedResult(resultList, tokens));
        } else {
            output.put("data", "Please type in some keywords");
            output.put("size", 0);
        }
        output.put("queries", tokens);
        out.print(output);
    } catch (Exception e) {
        MetaDbHelper.logEvent(e);
    }
    out.flush();
}

From source file:biblivre3.cataloging.authorities.AuthoritiesBO.java

public DTOCollection<AuthorityRecordDTO> autoComplete(String query) {
    DTOCollection<AuthorityRecordDTO> dto = new DTOCollection<AuthorityRecordDTO>();

    try {//from   w w w.j av  a 2s.  c  o m
        String[] searchArray = null;

        if (query != null) {
            searchArray = TextUtils.removeDiacriticals(query).toLowerCase().split("\\s+");
        }

        if (searchArray == null) {
            return dto;
        }

        ArrayList<AuthorityRecordDTO> authorities = dao.search(searchArray, 0, 1000);

        if (!authorities.isEmpty()) {
            for (AuthorityRecordDTO adto : authorities) {
                Record record = MarcUtils.iso2709ToRecord(adto.getIso2709());
                adto.setName(Indexer.listPrimaryAuthor(record));
                adto.setJson(MarcUtils.recordToJson(record));
                dto.add(adto);
            }

            return dto;
        }
    } catch (Exception e) {
        System.out.println("[AUTHBO.autoComplete(..)] Exception: " + e);
    }

    return dto;
}

From source file:com.common.ccupurge.PurgeCronJob.java

@Override
public void run() {
    String fileName = "/tmp/filelist.txt";//change this file name for windows
    String fileNameDone = "/tmp/filelist_done.txt"; //change this file name for windows
    String toMail = eMail;//from   ww w  .  j av a  2s  .  co  m
    String fromMail = "admin@somemail.com";
    if (fromMail.isEmpty() || fromMail == null) {
        fromMail = "admin@somemail.com";
    }
    ArrayList<String> fileLists = null;
    SendRequest request = new SendRequest();
    File purgeList = new File(fileName);
    fileLists = request.getFiles(fileName);
    if (fileLists.isEmpty()) {
        log.info("Nothing to purge");
    } else {
        log.info("PurgeDomain {}", purgeDomain.toString());
        log.info("UserName {}", userName);
        log.info("Password {}", password);
        String result = request.executeCommand(fileLists, purgeDomain.toString().toLowerCase(), userName,
                password);
        log.info(result);
        PurgeResponse response = null;
        log.info("here");
        try {
            response = new PurgeResponse(result);
            log.info("response.isSuccess() {}", response.isSuccess());
            if (response.isSuccess()) {
                log.info("The response object was successfully created");
                boolean emailStatus = sendSuccessEmail(toMail, fromMail, response, null, purgeList);
                if (!emailStatus)
                    log.info("Email not sent.");
                if (request.putToFile(fileLists, fileNameDone)) {
                    if (request.removeList(fileName)) {
                        log.info("DONE!");
                    }
                }
            }
        } catch (ParseException ex) {
            log.error("JSON Parse error {}", ex.getMessage());
            request.sendFailureMail(ex.getMessage());
        } catch (IOException ex) {
            log.error("IO Exception: {}", ex);
            request.sendFailureMail(ex.getMessage());
        }
    }
}

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

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

    if (!data.isEmpty()) {
        mAdapter.setData(data);// w w w.j  av a2 s.com
    } else {
        TextView t = (TextView) mEmptyView;
        t.setText(R.string.no_connection);
        getListView().setEmptyView(mEmptyView);
    }

    swipeRefreshLayout.setRefreshing(false);
}

From source file:edu.teilar.jcrop.service.rest.controller.KObjectsController.java

@RequestMapping(value = ApiUrls.KOBJECT_XMODELS_XGRAPH_BREADTHFIRST_URL, method = RequestMethod.GET)
public ArrayList<KObjectAsTraversable> getBreadthFirstTraversalListOfXGraph(@PathVariable String kobj,
        @PathVariable String xmodel) {

    KObject kobject = kobjectsService.getKObjectByName(kobj);
    ArrayList<KObjectAsTraversable> result = breadthFirstTraverseOfXGraph.traverse(kobject);

    if (result.isEmpty())
        throw new CropResourceNotFoundException(kobj, "BreadthFirst Traverse Of XGraph failure");

    return result;
}

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

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

    if (!data.isEmpty()) {
        adapter.setData(data);//w w  w  .  ja v a2  s.com
    } else {
        TextView t = (TextView) mEmptyView;
        t.setText(R.string.no_connection);
        getListView().setEmptyView(mEmptyView);
    }

    swipeRefreshLayout.setRefreshing(false);
}