List of usage examples for java.util ArrayList remove
public boolean remove(Object o)
From source file:Controladores.controladorProjeto.java
@RequestMapping("remove-func-projeto-restrito") public ModelAndView removeFuncProjeto(int id, int projetoId, HttpSession sessao, HttpServletRequest request) throws Exception { ArrayList<Tag> funcProjeto = funcionariosProjeto(sessao); Tag g = pesquisaFuncionarioNoProjeto(id, funcProjeto); Funcionario f = FuncionarioDAO.pesquisaFuncionario(id); Projeto p = ProjetoDAO.pesquisaProjeto(projetoId); if (g != null) { if (g.isIsExisteBD()) { ProjetoDAO.desabilitaFuncionarioProjeto(f, p); }/*from ww w.j a va 2 s . c o m*/ funcProjeto.remove(g); } return listFuncProjeto(funcProjeto); }
From source file:android.databinding.tool.store.SetterStore.java
private static void removeConsumedAttributes(ArrayList<MultiAttributeSetter> matching, String[] attributes) { for (int i = matching.size() - 1; i >= 0; i--) { final MultiAttributeSetter setter = matching.get(i); boolean found = false; for (String attribute : attributes) { if (isInArray(attribute, setter.attributes)) { found = true;// ww w.ja v a2 s . c o m break; } } if (found) { matching.remove(i); } } }
From source file:gov.nih.nci.rembrandt.web.ajax.DynamicReportGenerator.java
public Map removeTmpReporter(String rep) { HttpSession session = ExecutionContext.get().getSession(false); ArrayList al = new ArrayList(); if (session.getAttribute("tmpReporterList") != null) { al = (ArrayList) session.getAttribute("tmpReporterList"); }/*from w w w .j a va 2s .co m*/ al.remove(rep); // nuke it session.setAttribute("tmpReporterList", al); //put back in session String tmpReporters = ""; for (int i = 0; i < al.size(); i++) { tmpReporters += al.get(i) + "<br/>"; } Map results = new HashMap(); results.put("count", al.size()); results.put("elements", tmpReporters); return results; }
From source file:com.wegas.core.rest.ComboController.java
/** * Retrieve/* w ww .j av a 2s .co m*/ * * @param req * @return HTTP 200 with requested data or HTTP forbidden response * @throws IOException */ @GET @Produces({ MediaTypeJs, MediaTypeCss }) @CacheMaxAge(time = 3, unit = TimeUnit.HOURS) public Response index(@Context Request req) throws IOException { try { Ehcache cache = cacheManagerHolder.getInstance().getEhcache(CACHE_NAME); final int hash = this.uriInfo.getRequestUri().getQuery().hashCode(); final Element combo = cache.get(hash); CacheObject comboCache; if (combo != null) { // Get from cache comboCache = (CacheObject) combo.getObjectValue(); } else { // build Cache. //final Set<String> files = this.uriInfo.getQueryParameters().keySet(); // Old version, removed cause query parameters where in the wrong order ArrayList<String> files = new ArrayList<>(); // New version, with parameters in the right order for (String parameter : this.uriInfo.getRequestUri().getQuery().split("&")) { String split = parameter.split("=")[0]; if (split != null) { files.add(split); } } files.remove("v"); files.remove("version"); final String mediaType = (files.iterator().next().endsWith("css")) ? MediaTypeCss : MediaTypeJs; // Select the content-type based on the first file extension comboCache = new CacheObject(this.getCombinedFile(files, mediaType), mediaType); cache.put(new Element(hash, comboCache)); } ResponseBuilder rb = req.evaluatePreconditions(new EntityTag(comboCache.getETag())); if (rb != null) { return rb.tag(comboCache.getETag()).build(); } // MediaType types[] = {"application/json", "application/xml"}; // List<Variant> vars = Variant.mediaTypes(types).add().build(); // Variant var = req.selectVariant(vars); //EntityTag etag = new EntityTag(); //Response.ResponseBuilder responseBuilder = request.evaluatePreconditions(updateTimestamp, etag); return Response.ok(comboCache.getFiles()).type(comboCache.getMediaType()) // .expires(new Date(System.currentTimeMillis() + (1000 * 60 * 60 * 24 * 3))) .tag(new EntityTag(comboCache.getETag())).build(); } catch (WegasForbiddenException ex) { return Response.status(Response.Status.FORBIDDEN).entity(ex.getMessage()).build(); } }
From source file:com.threerings.miso.tools.xml.SimpleMisoSceneRuleSet.java
public void addRuleInstances(String prefix, Digester dig) { // this creates the appropriate instance when we encounter our // prefix tag dig.addRule(prefix, new Rule() { @Override/*from w ww. j a v a 2s . com*/ public void begin(String namespace, String name, Attributes attributes) throws Exception { digester.push(createMisoSceneModel()); } @Override public void end(String namespace, String name) throws Exception { digester.pop(); } }); // set up rules to parse and set our fields dig.addRule(prefix + "/width", new SetFieldRule("width")); dig.addRule(prefix + "/height", new SetFieldRule("height")); dig.addRule(prefix + "/viewwidth", new SetFieldRule("vwidth")); dig.addRule(prefix + "/viewheight", new SetFieldRule("vheight")); dig.addRule(prefix + "/base", new SetFieldRule("baseTileIds")); dig.addObjectCreate(prefix + "/objects", ArrayList.class.getName()); dig.addObjectCreate(prefix + "/objects/object", ObjectInfo.class.getName()); dig.addSetNext(prefix + "/objects/object", "add", Object.class.getName()); dig.addRule(prefix + "/objects/object", new SetPropertyFieldsRule()); dig.addRule(prefix + "/objects", new CallMethodSpecialRule() { @Override public void parseAndSet(String bodyText, Object target) throws Exception { @SuppressWarnings("unchecked") ArrayList<ObjectInfo> ilist = (ArrayList<ObjectInfo>) target; ArrayList<ObjectInfo> ulist = Lists.newArrayList(); SimpleMisoSceneModel model = (SimpleMisoSceneModel) digester.peek(1); // filter interesting and uninteresting into two lists for (int ii = 0; ii < ilist.size(); ii++) { ObjectInfo info = ilist.get(ii); if (!info.isInteresting()) { ilist.remove(ii--); ulist.add(info); } } // now populate the model SimpleMisoSceneModel.populateObjects(model, ilist, ulist); } }); }
From source file:com.runwaysdk.controller.URLConfigurationManager.java
/** * Returns the UriMapping associated with the given uri. This URI is assumed to NOT include the application context path (if there is one). * // ww w . j a v a2 s .c o m * @param uri * @return */ public UriMapping getMapping(String uri) { if (mappings == null) { return null; } if (uri.startsWith("/")) { uri = uri.replaceFirst("/", ""); } // If this is a ControllerMapping, calculate what action it would be referencing. ArrayList<String> uris = new ArrayList<String>(Arrays.asList(uri.split("/"))); String actionUri = ""; if (uris.size() > 1) { uris.remove(0); actionUri = StringUtils.join(uris, "/"); } for (UriMapping mapping : mappings) { if (mapping.handlesUri(uri)) { if (mapping instanceof ControllerMapping) { ActionMapping action = ((ControllerMapping) mapping).getActionAtUri(actionUri); if (action != null) { return action; } } else { return mapping; } } } return null; }
From source file:de.indiplex.javapt.JavAPT.java
private void getDepends(String packagename, ArrayList<String> depends) throws IOException, SQLException { if (packagename.equals("")) { return;/* w w w .jav a 2 s . c o m*/ } if (depends.contains(packagename)) { depends.remove(packagename); depends.add(packagename); return; } DEB deb = hashDEB.get(packagename); if (deb == null) { ResultSet rs = db.getStat() .executeQuery("SELECT name FROM packages WHERE provides LIKE '%" + packagename + "%'"); int i = 0; while (rs.next()) { getDepends(rs.getString("name"), depends); i++; } if (i == 0) { System.out.println("Can't find " + packagename); } return; } depends.add(packagename); String[] deps = deb.depends.split("\\,"); for (String dep : deps) { dep = dep.trim(); getDepends(dep, depends); } }
From source file:com.mtgi.analytics.aop.config.v11.HttpRequestsConfigurationTest.java
/** Test basic logging of a GET request */ @SuppressWarnings("unchecked") @Test// w w w . j a v a2 s .c o m public void testGetRequest() throws Exception { webClient.getPage(baseUrl + "/app/test/path?param1=hello¶m1=world¶m2¶m3=72%3C"); assertNotNull("Servlet was hit", servlet); webClient.getPage( baseUrl + "/app/test/also.traq?param1=hello¶m1=world¶m2¶m3=72%3C&dispatch=dang"); webClient.getPage(baseUrl + "/app/test/also.traq?param1=nodispatch¶m1=world¶m2¶m3=72%3C"); Collection<BehaviorTrackingManagerImpl> managers = servlet.context .getBeansOfType(BehaviorTrackingManager.class).values(); for (BehaviorTrackingManagerImpl m : managers) m.flush(); //first manager only gets events matching supplied filter patterns, and has //a custom event type configured. second manager gets all events. EventKey[] expected = { new EventKey("first", "req", "/app/test/also.traq?dispatch=dang"), new EventKey("first", "req", "/app/test/also.traq"), new EventKey("first", "behavior-tracking", "flush"), new EventKey("second", "http-request", "/app/test/path"), new EventKey("second", "http-request", "/app/test/also.traq"), new EventKey("second", "http-request", "/app/test/also.traq"), new EventKey("second", "behavior-tracking", "flush") }; TestPersister persister = (TestPersister) servlet.context.getBean("persister"); assertEquals("expected events persisted", expected.length, persister.count()); //hash out the events so that we can verify logging. ArrayList<EventKey> events = new ArrayList<EventKey>(); for (BehaviorEvent be : persister.events()) events.add(new EventKey(be)); for (int i = 0; i < expected.length; ++i) assertNotNull("received event[" + i + "] in correct order", events.remove(expected[i])); assertEquals("all receivedevents accounted for", 0, events.size()); }
From source file:com.doublesunflower.android.lockcast.ImageManager.java
/** * Called when something changes in our data set. Cleans up any weak references that * are no longer valid along the way.//w ww. j ava 2 s . c om */ private void notifyObservers() { final ArrayList<WeakReference<DataSetObserver>> observers = mObservers; final int count = observers.size(); for (int i = count - 1; i >= 0; i--) { WeakReference<DataSetObserver> weak = observers.get(i); DataSetObserver obs = weak.get(); if (obs != null) { obs.onChanged(); } else { observers.remove(i); } } }
From source file:edu.usf.cutr.opentripplanner.android.tasks.OTPGeocoding.java
/** * Filters the addresses obtained in geocoding process, removing the * results outside server limits.//from w w w . ja v a2 s. c o m * * @param the list of addresses to filter * @return a new list filtered */ private ArrayList<Address> filterAddressesBBox(ArrayList<Address> addresses) { if (!(addresses == null || addresses.isEmpty())) { ArrayList<Address> addressesFiltered = new ArrayList<Address>(addresses); for (Address address : addressesFiltered) { if (!LocationUtil.checkPointInBoundingBox(new LatLng(address.getLatitude(), address.getLongitude()), selectedServer, OTPApp.CHECK_BOUNDS_ACCEPTABLE_ERROR)) { addressesFiltered.remove(address); } } return addressesFiltered; } return addresses; }