List of usage examples for java.util ArrayList contains
public boolean contains(Object o)
From source file:cc.flydev.launcher.InstallShortcutReceiver.java
public static void removeFromInstallQueue(SharedPreferences sharedPrefs, ArrayList<String> packageNames) { synchronized (sLock) { Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) { Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames); }//from w w w . j a v a 2 s. co m if (strings != null) { Set<String> newStrings = new HashSet<String>(strings); Iterator<String> newStringsIter = newStrings.iterator(); while (newStringsIter.hasNext()) { String json = newStringsIter.next(); try { JSONObject object = (JSONObject) new JSONTokener(json).nextValue(); Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0); String pn = launchIntent.getPackage(); if (pn == null) { pn = launchIntent.getComponent().getPackageName(); } if (packageNames.contains(pn)) { newStringsIter.remove(); } } catch (org.json.JSONException e) { Log.d(TAG, "Exception reading shortcut to remove: " + e); } catch (java.net.URISyntaxException e) { Log.d(TAG, "Exception reading shortcut to remove: " + e); } } sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>(newStrings)).commit(); } } }
From source file:com.zd.vpn.fragments.AboutFragment.java
private Pair<String, String> getSkuTitle(final String sku, String title, String price, ArrayList<String> ownedSkus) { String text;//from w ww. j av a 2 s.co m if (ownedSkus.contains(sku)) return new Pair<String, String>(getString(R.string.thanks_for_donation, price), null); if (price.contains("") || price.contains("\u20ac")) { text = title; } else { text = String.format(Locale.getDefault(), "%s (%s)", title, price); } //return text; return new Pair<String, String>(price, sku); }
From source file:alpha.portal.webapp.controller.CaseFormControllerTest.java
/** * Test delete.//from www.j a v a2s. co m * * @throws Exception * the exception */ @Test public void testDelete() throws Exception { MockHttpServletRequest request = this.newGet("/caseform"); request.setParameter("caseId", CaseFormControllerTest.caseId); request.setRemoteUser("admin"); final ModelAndView mv = this.form.showForm(this.filters, request, new MockHttpServletResponse()); final AlphaCase myCase = (AlphaCase) mv.getModel().get("case"); request = this.newPost("/caseform"); request.setRemoteUser("admin"); request.addParameter("delete", ""); final BindingResult errors = new DataBinder(myCase).getBindingResult(); final String view = this.form.deleteCase(myCase, errors, request); Assert.assertEquals(this.form.getCancelView(), view); Assert.assertNotNull(request.getSession().getAttribute("successMessages")); final Locale locale = request.getLocale(); final ArrayList<Object> msgs = (ArrayList<Object>) request.getSession().getAttribute("successMessages"); Assert.assertTrue(msgs.contains(this.form.getText("case.deleted", locale))); Assert.assertFalse(this.caseManager.exists(CaseFormControllerTest.caseId)); }
From source file:org.cds06.speleograph.data.fileio.SpeleoFileWriter.java
private Integer writeHeaders(List<Series> series, Integer[][] columns) { ArrayList<NumberAxis> axes = new ArrayList<>(); for (Series s : series) { NumberAxis axis = s.getAxis();// w ww . jav a2s . c om if (axes.contains(axis)) continue; axes.add(axis); int id = axes.indexOf(axis); boolean typeAxis = axis.equals(s.getType().getAxis()); try { write("axis", Integer.toString(id), '"' + axis.getLabel() + '"', DecimalFormat.getInstance().format(axis.getLowerBound()), DecimalFormat.getInstance().format(axis.getUpperBound()), "type:" + (typeAxis ? "1" : "0")); } catch (Exception e) { log.error("Can not write axis to file", e); } } write("date", "", Integer.toString(allocatedColumns), "d/M/y H:m:s"); allocatedColumns++; for (Series s : series) { String[] seriesDescriptor = { Integer.toString(allocatedColumns), s.getType().getName(), s.getType().getUnit() }; if (s.isMinMax()) { seriesDescriptor = ArrayUtils.add(seriesDescriptor, "min-max:1"); // NON-NLS seriesDescriptor = ArrayUtils.add(seriesDescriptor, "min:" + Integer.toString(allocatedColumns)); // NON-NLS seriesDescriptor = ArrayUtils.add(seriesDescriptor, "max:" + Integer.toString(allocatedColumns + 1)); // NON-NLS columns[series.indexOf(s)] = new Integer[] { allocatedColumns, allocatedColumns + 1 }; allocatedColumns++; allocatedColumns++; } else { columns[series.indexOf(s)] = new Integer[] { allocatedColumns }; allocatedColumns++; } if (s.isShow()) seriesDescriptor = ArrayUtils.add(seriesDescriptor, "show:1"); // NON-NLS if (s.getColor() != null) seriesDescriptor = ArrayUtils.add(seriesDescriptor, "color:" + s.getColor().getRGB()); // NON-NLS if (s.isMinMax()) seriesDescriptor = ArrayUtils.add(seriesDescriptor, "stepped:1"); // NON-NLS if (s.getStyle() != null) { seriesDescriptor = ArrayUtils.add(seriesDescriptor, "style:" + s.getStyle().toString()); // NON-NLS } if (s.isNameHumanSet()) { seriesDescriptor = ArrayUtils.add(seriesDescriptor, "name:" + s.getName()); // NON-NLS } seriesDescriptor = ArrayUtils.add(seriesDescriptor, "axis:" + axes.indexOf(s.getAxis())); write(seriesDescriptor); } return allocatedColumns; }
From source file:alpha.portal.webapp.controller.CaseFormControllerTest.java
/** * Test add.//from w w w .j ava 2 s . c o m * * @throws Exception * the exception */ @Test public void testAdd() throws Exception { MockHttpServletRequest request = this.newGet("/caseform"); request.setRemoteUser("admin"); final ModelAndView mv = this.form.showForm(this.filters, request, new MockHttpServletResponse()); request = this.newPost("/caseform"); request.setRemoteUser("admin"); final AlphaCase aCase = (AlphaCase) mv.getModel().get("case"); aCase.setName("test case which does not exist yet"); final BindingResult errors = new DataBinder(aCase).getBindingResult(); final String view = this.form.addCase(aCase, errors, request, new MockHttpServletResponse()); final List<AlphaCase> dbCases = this.caseManager.findByName(aCase.getName()); Assert.assertNotNull(dbCases); Assert.assertTrue(dbCases.size() >= 1); final AlphaCase dbCase = dbCases.get(0); Assert.assertNotNull(dbCase); Assert.assertEquals("redirect:/caseform?caseId=" + dbCase.getCaseId(), view); Assert.assertFalse(errors.hasErrors()); Assert.assertNotNull(request.getSession().getAttribute("successMessages")); final Locale locale = request.getLocale(); final ArrayList<Object> msgs = (ArrayList<Object>) request.getSession().getAttribute("successMessages"); Assert.assertTrue(msgs.contains(this.form.getText("case.added", locale))); }
From source file:jeplus.TRNSYSWinTools.java
public static boolean cleanupWorkDir(String workdir, boolean keepeplus, boolean keepjeplus, boolean keepdir, String filesToDelete, String printers) { boolean success = true; // Create the directory File dir = new File(workdir); ArrayList<String> jeplus = TRNSYSTask.getjeplusfiles(); TRNSYSTask.setjeplusfile(TRNSYSConfig.getTRNSYSDefDCK()); if (dir.exists()) { if (!keepdir) { File[] files = dir.listFiles(); for (File file : files) { file.delete();//from w ww.ja va2 s .co m } success = dir.delete(); } else { if (!keepjeplus) { File[] files = dir.listFiles(); for (File file : files) { if ((jeplus.contains(file.getName())) && (!file.getName().contains(TRNSYSConfig.getTRNSYSDefLST()))) { success &= file.delete(); } } } if (!keepeplus) { File[] files = dir.listFiles(); for (File file : files) { if ((!jeplus.contains(file.getName())) && (!getPrintersFunc(printers).contains(file.getName().toLowerCase())) && (!file.getName().contains(TRNSYSConfig.getTRNSYSDefLST()))) { success &= file.delete(); } } } if (filesToDelete != null) { String[] patterns = filesToDelete.split("\\s*[,;: ]\\s*"); OrFileFilter filter = new OrFileFilter(); for (String pattern : patterns) { filter.addFileFilter(new WildcardFileFilter(pattern)); } File[] files = dir.listFiles((FileFilter) filter); for (File file : files) { success &= file.delete(); } } } } return success; }
From source file:cn.itcast.fredck.FCKeditor.uploader.SimpleUploaderServlet.java
/** * Helper function to verify if a file extension is allowed or not allowed. *///ww w . j a v a2 s . c om private boolean extIsAllowed(String fileType, String ext) { ext = ext.toLowerCase(); ArrayList allowList = (ArrayList) allowedExtensions.get(fileType); ArrayList denyList = (ArrayList) deniedExtensions.get(fileType); if (allowList.size() == 0) if (denyList.contains(ext)) return false; else return true; if (denyList.size() == 0) if (allowList.contains(ext)) return true; else return false; return false; }
From source file:alpha.portal.webapp.controller.CaseFormControllerTest.java
/** * Test edit./*from w w w .ja va2s. c o m*/ * * @throws Exception * the exception */ @Test public void testEdit() throws Exception { MockHttpServletRequest request = this.newGet("/caseform"); request.setParameter("caseId", CaseFormControllerTest.caseId); request.setRemoteUser("admin"); final ModelAndView mv = this.form.showForm(this.filters, request, new MockHttpServletResponse()); Assert.assertEquals("caseform", mv.getViewName()); final AlphaCase aCase = (AlphaCase) mv.getModel().get("case"); AlphaCase dbCase = this.caseManager.get(CaseFormControllerTest.caseId); Assert.assertEquals(dbCase, aCase); Assert.assertEquals(dbCase.getAlphaCards(), mv.getModel().get("cards")); Assert.assertEquals(dbCase.getListOfParticipants(), mv.getModel().get("participants")); request = this.newPost("/caseform"); request.setRemoteUser("admin"); aCase.setName("test case with a new name"); final BindingResult errors = new DataBinder(aCase).getBindingResult(); final String view = this.form.saveCase(aCase, errors, request, new MockHttpServletResponse()); Assert.assertEquals("redirect:/caseform?caseId=" + aCase.getCaseId(), view); Assert.assertFalse(errors.hasErrors()); Assert.assertNotNull(request.getSession().getAttribute("successMessages")); final Locale locale = request.getLocale(); final ArrayList<Object> msgs = (ArrayList<Object>) request.getSession().getAttribute("successMessages"); Assert.assertTrue(msgs.contains(this.form.getText("case.updated", locale))); dbCase = this.caseManager.get(CaseFormControllerTest.caseId); /* FIXME: something is broken (return structure is an empty thing) */ // Assert.assertEquals(dbCase, aCase); }
From source file:lu.lippmann.cdb.graph.GraphUtil.java
/** * //from w ww . j a v a 2 s .c o m * @param graph * @return */ public static boolean isGraphCyclic(final Graph<CNode, CEdge> graph) { boolean cycle = false; ArrayList<CNode> alreadyVisited = new ArrayList<CNode>(); ArrayList<CNode> criticalList = new ArrayList<CNode>(); Iterator<CNode> e = graph.getVertices().iterator(); CNode tmpNode = null; while (e.hasNext() && !cycle) { tmpNode = e.next(); if (!alreadyVisited.contains(tmpNode)) { cycle = visit(graph, tmpNode, criticalList); } alreadyVisited.add(tmpNode); } return cycle; }
From source file:com.useeasy.auction.util.upload.SimpleUploaderServlet.java
/** * Helper function to verify if a file extension is allowed or not allowed. *///from ww w . j a v a 2 s . c om private boolean extIsAllowed(String fileType, String ext) { ext = ext.toLowerCase(); ArrayList allowList = (ArrayList) allowedExtensions.get(fileType); ArrayList denyList = (ArrayList) deniedExtensions.get(fileType); if (allowList.size() == 0) if (denyList.contains(ext)) return false; else return true; if (denyList.size() == 0) if (allowList.contains(ext)) return true; else return false; return false; }