List of usage examples for java.util ArrayList isEmpty
public boolean isEmpty()
From source file:org.khmeracademy.btb.auc.pojo.controller.Brand_controller.java
@RequestMapping(value = "/get-all", method = RequestMethod.GET, produces = "application/json") @ApiImplicitParams({ @ApiImplicitParam(name = "page", paramType = "query", defaultValue = "1"), @ApiImplicitParam(name = "limit", paramType = "query", defaultValue = "10"), @ApiImplicitParam(name = "name", paramType = "query", defaultValue = "") }) @ResponseBody//from w ww . j a v a 2 s . c o m public ResponseEntity<Map<String, Object>> findAll(@ApiIgnore AuctionFilter filter, @ApiIgnore Pagination pagination) { Map<String, Object> map = new HashMap<String, Object>(); try { pagination.setTotalCount(bra_service.count(filter)); ArrayList<Brand> auction = (ArrayList<Brand>) bra_service.findAll(filter, pagination); if (!auction.isEmpty()) { map.put("DATA", auction); map.put("STATUS", true); map.put("MESSAGE", "DATA FOUND!"); map.put("PAGINATION", pagination); } else { map.put("STATUS", true); map.put("MESSAGE", "DATA NOT FOUND"); } } catch (Exception e) { map.put("STATUS", false); map.put("MESSAGE", "Error!"); e.printStackTrace(); } return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK); }
From source file:com.zoterodroid.syncadapter.CitationSyncAdapter.java
private void InsertCitations(Account account, SyncResult syncResult) throws AuthenticationException, IOException { AccountManager am = AccountManager.get(mContext); String userid = am.getUserData(account, Constants.PREFS_AUTH_USER_ID); Log.d("userid", userid); String username = account.name; ArrayList<Citation> addCitationList = new ArrayList<Citation>(); Log.d("CitationSync", "In Citation Load"); addCitationList = ZoteroApi.getAllCitations(null, account, userid, mContext); if (!addCitationList.isEmpty()) { for (Citation b : addCitationList) { CitationManager.AddCitation(b, username, mContext); }/*from w ww .j a v a 2s. co m*/ } }
From source file:uk.ac.soton.itinnovation.sad.service.controllers.ExecutionsController.java
/** * Returns all executions on the service, url mapping: /executions * * @return all executions as JSON// w ww .jav a2 s .c o m */ @RequestMapping(method = RequestMethod.GET) @ResponseBody public JsonResponse getExecutions() { logger.debug("Returning all executions"); schedulingService.pushMethodCalledName("executions"); long startTime = System.currentTimeMillis(); try { JSONObject response = new JSONObject(); ArrayList<SADJobExecution> allExecutions = schedulingService.getExecutions(); if (allExecutions.isEmpty()) { logger.debug("No executions were found."); response.put("message", "No executions were found."); return new JsonResponse("error", response); } else { int allExecutionsSize = allExecutions.size(); response.put("num", allExecutionsSize); JSONArray allExecutionsAsJsonArray = new JSONArray(); JSONObject executionAsJson; Timestamp tempTimestamp; for (SADJobExecution execution : allExecutions) { executionAsJson = new JSONObject(); executionAsJson.put("DatabaseId", execution.getCountID()); executionAsJson.put("ID", execution.getId()); executionAsJson.put("SADJobID", execution.getSADJobID()); executionAsJson.put("Description", execution.getDescription()); executionAsJson.put("Status", execution.getStatus()); tempTimestamp = execution.getWhenStarted(); if (tempTimestamp == null) { executionAsJson.put("WhenStarted_as_string", ""); executionAsJson.put("WhenStarted_in_msec", ""); } else { executionAsJson.put("WhenStarted_as_string", tempTimestamp.toString()); executionAsJson.put("WhenStarted_in_msec", tempTimestamp.getTime()); } tempTimestamp = execution.getWhenFinished(); if (tempTimestamp == null) { executionAsJson.put("WhenFinished_as_string", ""); executionAsJson.put("WhenFinished_in_msec", ""); } else { executionAsJson.put("WhenFinished_as_string", tempTimestamp.toString()); executionAsJson.put("WhenFinished_in_msec", tempTimestamp.getTime()); } allExecutionsAsJsonArray.add(executionAsJson); } if (allExecutionsSize < 2) { logger.debug("Returning " + allExecutions.size() + " execution"); } else { logger.debug("Returning " + allExecutions.size() + " executions"); } response.put("list", allExecutionsAsJsonArray); return new JsonResponse("ok", response); } } catch (Throwable ex) { return new JsonResponse("error", Util.dealWithException("Failed to return all executions", ex, logger)); } finally { schedulingService.pushTimeSpent(Long.toString(System.currentTimeMillis() - startTime)); } }
From source file:com.kamike.divide.KamiInsert.java
@Override public ArrayList<KamiTable> findTables() { ///*from w ww. ja va 2 s.c o m*/ ArrayList<KamiTable> ret = new ArrayList<>(); Date now = new Date(System.currentTimeMillis()); KamiDatabaseReader databaseReader = new KamiDatabaseReader(); KamiTableReader tableReader = new KamiTableReader(); Transaction ts = new Transaction(); KamiTableWriter tableWriter = new KamiTableWriter(ts); tableWriter.closeFull(); ts.save(); ts = null; ArrayList<KamiTable> tables = tableReader.findForInsert(this.tableName, copyNum); if (tables.isEmpty()) { //?N //? lock.lock(); try { ArrayList<KamiTable> confirmTables = tableReader.findForInsert(this.tableName, copyNum); if (confirmTables.isEmpty()) { ArrayList<KamiDatabase> databases = databaseReader.findBalanced(copyNum); for (KamiDatabase db : databases) { KamiTable t = new KamiTable(); t.setId(UUID.randomUUID().toString()); t.setAlive(true); t.setBeginDate(now); t.setExpectedSize(50000); t.setCreateDate(now); t.setClosed(false); t.setCurrentSize(1); t.setDatabaseId(db.getId()); t.setEndDate(now); t.setName(this.tableName); t.setDatabaseType(db.getType()); t.setRealName( this.tableName + "_" + FastDateFormat.getInstance("yyyyMMddHHmmss").format(now)); t.setUpdateDate(now); //? Transaction createTableTranscation = new KamiTransaction(db.getId()); GenericCreator<T> tableCreator = creator(createTableTranscation, db.getDbName()); tableCreator.init(t.getRealName()); createTableTranscation.save(); ret.add(t); //?? Transaction localTs = new Transaction(); //? KamiTableWriter createTableWriter = new KamiTableWriter(localTs); createTableWriter.add(t); KamiDatabaseWriter databaseWriter = new KamiDatabaseWriter(localTs); db.setUpdateDate(now); databaseWriter.edit(db); localTs.save(); databaseWriter = null; localTs = null; } } else { for (KamiTable confirmTable : confirmTables) { Transaction addts = new Transaction(); KamiTableWriter addTableWriter = new KamiTableWriter(addts); addTableWriter.increaseSize(confirmTable.getId()); addts.save(); addts = null; addTableWriter = null; ret.add(confirmTable); } } } finally { lock.unlock(); } } else { //? for (KamiTable confirmTable : tables) { Transaction addts = new Transaction(); KamiTableWriter addTableWriter = new KamiTableWriter(addts); addTableWriter.increaseSize(confirmTable.getId()); addts.save(); addts = null; addTableWriter = null; ret.add(confirmTable); } } return ret; }
From source file:edu.mit.media.funf.funftowotk.MainPipeline.java
public Boolean checkValidData(Bundle data) { String probe = data.getString("PROBE").replace(SettingsActivity.probe_prefix, ""); if (probe.equals("CallLogProbe")) { ArrayList calls = (ArrayList) data.get("CALLS"); if (calls.isEmpty()) { //Log.i("DataLog",calls.toString()); return false; }/*from w ww .j ava 2 s .c o m*/ } else if (probe.equals("SMSProbe")) { ArrayList messages = (ArrayList) data.get("MESSAGES"); if (messages.isEmpty()) { //Log.i("DataLog",messages.toString()); return false; } } return true; }
From source file:net.sf.jabref.openoffice.BstWrapper.java
private Map<String, String> parseResult(String result) { Map<String, String> map = new HashMap<>(); // Look through for instances of \bibitem : Matcher m = BstWrapper.bibitemTag.matcher(result); ArrayList<Integer> indices = new ArrayList<>(); ArrayList<Integer> endIndices = new ArrayList<>(); ArrayList<String> keys = new ArrayList<>(); while (m.find()) { if (!indices.isEmpty()) { endIndices.add(m.start());/*from w ww . jav a2s .co m*/ } LOGGER.debug(m.start() + " " + m.end()); String tag = m.group(); String key = tag.substring(9, tag.length() - 1); indices.add(m.end()); keys.add(key); } int lastI = result.lastIndexOf("\\end{thebibliography}"); if ((lastI > 0) && (lastI > indices.get(indices.size() - 1))) { endIndices.add(lastI); } for (int i = 0; i < keys.size(); i++) { String key = keys.get(i); int index = indices.get(i); int endIndex = endIndices.get(i); String part = result.substring(index, endIndex); map.put(key, formatter.format(part.trim().replaceAll("\\\\newblock ", " "))); } return map; }
From source file:com.funambol.transport.http.server.Sync4jServlet.java
/** * Format the list of Ext objects to be printed as a Property * Example: X-funambol-smartslow,X-foo[val1,val2,val3],X-pippo[val] * @param exts//from w w w . j ava 2 s .c o m * @return */ static private String formatExtListAsProperties(ArrayList exts) { if (exts == null) { return ""; } StringBuilder formattedExtList = new StringBuilder(""); for (Iterator iterExtList = exts.iterator(); iterExtList.hasNext();) { Ext ext = (Ext) iterExtList.next(); if (ext == null || ext.getXNam().length() == 0) { continue; } if (formattedExtList.length() > 0) { formattedExtList.append(","); } String xnam = ext.getXNam(); xnam = xnam.replace("[", "\\[").replace("]", "\\]").replace(",", "\\,"); formattedExtList.append(xnam); ArrayList xvalList = ext.getXVal(); if (xvalList != null && !xvalList.isEmpty()) { formattedExtList.append("["); for (int i = 0; i < xvalList.size(); i++) { String xval = (String) xvalList.get(i); if (xval != null && xval.length() > 0) { if (i > 0) { formattedExtList.append(","); } xval = xval.replace("[", "\\[").replace("]", "\\]").replace(",", "\\,"); formattedExtList.append(xval); } } formattedExtList.append("]"); } } return formattedExtList.toString(); }
From source file:org.khmeracademy.btb.auc.pojo.controller.Product_owner_controller.java
@RequestMapping(value = "/get-all", method = RequestMethod.GET, produces = "application/json") @ApiImplicitParams({ @ApiImplicitParam(name = "page", paramType = "query", defaultValue = "1"), @ApiImplicitParam(name = "limit", paramType = "query", defaultValue = "10"), @ApiImplicitParam(name = "name", paramType = "query", defaultValue = "") }) @ResponseBody/*from w w w.j av a2s .co m*/ public ResponseEntity<Map<String, Object>> findAll(@ApiIgnore AuctionFilter filter, @ApiIgnore Pagination pagination) { Map<String, Object> map = new HashMap<String, Object>(); try { pagination.setTotalCount(pro_owner_service.count(filter)); ArrayList<Product_Owner> auction = (ArrayList<Product_Owner>) pro_owner_service.findAll(filter, pagination); if (!auction.isEmpty()) { map.put("DATA", auction); map.put("STATUS", true); map.put("MESSAGE", "DATA FOUND!"); map.put("PAGINATION", pagination); } else { map.put("STATUS", true); map.put("MESSAGE", "DATA NOT FOUND"); } } catch (Exception e) { map.put("STATUS", false); map.put("MESSAGE", "Error!"); e.printStackTrace(); } return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK); }
From source file:com.sixwonders.courtkiosk.CheckInActivity.java
@Override public void processFinish(String callType, Object objectResult) { if (StringUtils.equalsIgnoreCase("auth", callType)) { ArrayList<Citation> citations = CitationAdapter.adaptCitationData((ArrayList<JSONObject>) objectResult); if (citations.isEmpty()) { //TODO: tell user info could not be found! Toast.makeText(this, "No court date found!", Toast.LENGTH_LONG).show(); } else {//from w w w .j a va 2s . c om openCompleteRegistrationActivity(citations.get(0)); } } }
From source file:org.khmeracademy.btb.auc.pojo.controller.Product_Controller.java
@RequestMapping(value = "/get-all", method = RequestMethod.GET, produces = "application/json") @ApiImplicitParams({ @ApiImplicitParam(name = "page", paramType = "query", defaultValue = "1"), @ApiImplicitParam(name = "limit", paramType = "query", defaultValue = "10"), @ApiImplicitParam(name = "name", paramType = "query", defaultValue = ""), @ApiImplicitParam(name = "brandId", paramType = "query", defaultValue = "") }) @ResponseBody/* w w w . j a v a 2 s . c om*/ public ResponseEntity<Map<String, Object>> findAll(@ApiIgnore AuctionFilter filter, @ApiIgnore Pagination pagination) { Map<String, Object> map = new HashMap<String, Object>(); try { pagination.setTotalCount(pro_service.countProduct()); ArrayList<Product> pro = (ArrayList<Product>) pro_service.findAll(filter, pagination); if (!pro.isEmpty()) { map.put("DATA", pro); map.put("STATUS", true); map.put("MESSAGE", "DATA FOUND!"); map.put("PAGINATION", pagination); } else { map.put("STATUS", true); map.put("MESSAGE", "DATA NOT FOUND"); } } catch (Exception e) { map.put("STATUS", false); map.put("MESSAGE", "Error!"); e.printStackTrace(); } return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK); }