List of usage examples for java.util List remove
E remove(int index);
From source file:gov.nih.nci.cabig.caaers.domain.AbstractIdentifiableDomainObject.java
@Transient public List<Identifier> getSecondaryIdentifiers() { Identifier primary = getPrimaryIdentifier(); List<Identifier> others = new ArrayList<Identifier>(getIdentifiers()); others.remove(primary); return others; }
From source file:net.formicary.remoterun.examples.Server.java
private void sendInput(String line) { StrTokenizer tokenizer = new StrTokenizer(line, ' ', '"'); @SuppressWarnings("unchecked") List<String> tokens = tokenizer.getTokenList(); tokens.remove(0); // first token is the run command long id = Long.parseLong(tokens.remove(0)); String input = StringUtils.join(tokens, ' ').replaceAll("\\\\n", "\n"); Collection<IAgentConnection> connectedClients = remoteRunMaster.getConnectedClients(); if (connectedClients.isEmpty()) { log.error("Unable to send command: no agent connections"); } else {/*from www . java 2s.c om*/ IAgentConnection connection = connectedClients.iterator().next(); RemoteRun.MasterToAgent.Builder builder = RemoteRun.MasterToAgent.newBuilder() .setMessageType(RemoteRun.MasterToAgent.MessageType.STDIN_FRAGMENT).setRequestId(id) .setFragment(ByteString.copyFromUtf8(input)); connection.write(builder.build()); } }
From source file:net.formicary.remoterun.examples.Server.java
private void runCommand(String line) { StrTokenizer tokenizer = new StrTokenizer(line, ' ', '"'); @SuppressWarnings("unchecked") List<String> tokens = tokenizer.getTokenList(); tokens.remove(0); // first token is the run command String command = tokens.remove(0); Collection<IAgentConnection> connectedClients = remoteRunMaster.getConnectedClients(); if (connectedClients.isEmpty()) { log.error("Unable to send command: no agent connections"); } else {// w ww .j a v a 2s . com IAgentConnection connection = connectedClients.iterator().next(); RemoteRun.MasterToAgent.Builder builder = RemoteRun.MasterToAgent.newBuilder() .setMessageType(RemoteRun.MasterToAgent.MessageType.RUN_COMMAND) .setRequestId(RemoteRunMaster.getNextRequestId()); builder.getRunCommandBuilder().setCmd(command).addAllArgs(tokens); connection.write(builder.build()); } }
From source file:com.hippo.ehviewer.client.EhEngine.java
/** * @param image Must be jpeg/*from ww w .j a v a2 s . com*/ */ public static GalleryListParser.Result imageSearch(@Nullable EhClient.Task task, OkHttpClient okHttpClient, File image, boolean uss, boolean osc, boolean se) throws Exception { MultipartBody.Builder builder = new MultipartBody.Builder(); builder.setType(MultipartBody.FORM); builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"sfile\"; filename=\"a.jpg\""), RequestBody.create(MEDIA_TYPE_JPEG, image)); if (uss) { builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"fs_similar\""), RequestBody.create(null, "on")); } if (osc) { builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"fs_covers\""), RequestBody.create(null, "on")); } if (se) { builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"fs_exp\""), RequestBody.create(null, "on")); } builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"f_sfile\""), RequestBody.create(null, "File Search")); String url = EhUrl.getImageSearchUrl(); Log.d(TAG, url); Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()) .post(builder.build()).build(); Call call = okHttpClient.newCall(request); // Put call if (null != task) { task.setCall(call); } String body = null; Headers headers = null; GalleryListParser.Result result; int code = -1; try { Response response = call.execute(); Log.d(TAG, "" + response.request().url().toString()); code = response.code(); headers = response.headers(); body = response.body().string(); result = GalleryListParser.parse(body); } catch (Exception e) { throwException(call, code, headers, body, e); throw e; } // Filter title and uploader List<GalleryInfo> list = result.galleryInfoList; for (int i = 0, n = list.size(); i < n; i++) { GalleryInfo info = list.get(i); if (!sEhFilter.filterTitle(info) || !sEhFilter.filterUploader(info)) { list.remove(i); i--; n--; } } if (list.size() > 0 && (Settings.getShowJpnTitle() || sEhFilter.needCallApi())) { // Fill by api fillGalleryListByApi(task, okHttpClient, list); // Filter tag for (int i = 0, n = list.size(); i < n; i++) { GalleryInfo info = list.get(i); if (!sEhFilter.filterTag(info) || !sEhFilter.filterTagNamespace(info)) { list.remove(i); i--; n--; } } } for (GalleryInfo info : list) { info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb); } return result; }
From source file:org.yardstickframework.report.jfreechart.JFreeChartGraphPlotter.java
/** * @param inFolder Input folder.//from ww w . j a va 2 s . c o m * @return List of folders. */ private static List<File> getFiles(File inFolder) { File[] dirs = inFolder.listFiles(); if (dirs == null || dirs.length == 0) return null; List<File> files = new ArrayList<>(Arrays.asList(dirs)); for (int i = 0; i < files.size();) { if (!files.get(i).isDirectory()) files.remove(i); else i++; } Collections.sort(files, FILE_NAME_COMP); return files; }
From source file:org.appverse.web.showcases.gwtshowcase.backend.services.business.impl.test.UserServiceImplTest.java
@Before public void initialize() throws Exception { // Set first level fields user.setStatus(User.STATUS_ACTIVE); user.setEmail("email"); user.setLastName("lastName"); user.setName("name"); user.setPassword("password"); user.setCreated(new Date()); user.setCreatedBy("test"); // Add collections // We add the 4 regular roles (as we have 5 we remove the extra that will be used later to test // roles additions) List<Role> roleCollection = roleService.loadRoles(); roleCollection.remove(4); user.setRoles(roleCollection);/* w w w . j ava 2 s . com*/ }
From source file:de.thorstenberger.taskmodel.impl.TaskletDistributor.java
/** * Find the constraints and distribute the tasklets among the correctors randomly. * * @param correctors/*from w ww. j a v a 2s .c om*/ * @returns statistics about the number of assigned tasklets per corrector. * @throws TaskApiException */ public Map<String, Integer> distributeAmong(final List<Tasklet> tasklets, final String... correctorIds) throws TaskApiException { // all tasklets that have not been manually corrected yet final Map<String, Integer> statistics = new HashMap<String, Integer>(); for (final String corr : correctorIds) { statistics.put(corr, 0); } final Map<String, List<Tasklet>> possibleAssignments = filterPossibleAssignments(tasklets, correctorIds); final Random r = new Random(); while (isAnyUnassignedTaskletLeft(tasklets)) { boolean noMoreAssignableTasklets = true; for (final String corrector : possibleAssignments.keySet()) { final List<Tasklet> possible = possibleAssignments.get(corrector); if (!possible.isEmpty()) { noMoreAssignableTasklets = false; final Tasklet tasklet = possible.get(r.nextInt(possible.size())); // nobody else may correct this tasklet for (final List<Tasklet> list : possibleAssignments.values()) { list.remove(tasklet); } tasklet.assignToCorrector(corrector); statistics.put(corrector, statistics.get(corrector) + 1); } // System.out.format("Corr: %s, to go: %d\n", corrector, possible.size()); } if (noMoreAssignableTasklets) { break; } } return statistics; }
From source file:com.nec.harvest.junit4.BaseTest.java
protected void assertArrayEqual(Object[] actual, Object... expected) { Assert.assertEquals("The array did not have the expected length", expected.length, actual.length); List<Object> remaining = new LinkedList<Object>(); for (Object o : actual) { remaining.add(o);/* w w w . ja v a 2s . co m*/ } for (Object o : expected) { if (!remaining.remove(o)) Assert.fail("The array did not match the expected results."); } }
From source file:quanlyhocvu.api.mongodb.DAO.DiemDAO.java
public boolean deleteDiemSo(String loaiDiem, String idDiem, Float diemSo) { DiemDTO dto = getDiemById(idDiem);//from w w w. j a va 2 s. c om if (loaiDiem == "DiemKTMieng") { List<Float> tempList = dto.getListDiemKTMieng(); tempList.remove(diemSo); dto.setListDiemKTMieng(tempList); } else if (loaiDiem == "DiemKT15") { List<Float> tempList = dto.getListDiemKT15(); tempList.remove(diemSo); dto.setListDiemKT15(tempList); } else if (loaiDiem == "DiemKT15") { List<Float> tempList = dto.getListDiemKT1Tiet(); tempList.remove(diemSo); dto.setListDiemKT1Tiet(tempList); } else if (loaiDiem == "DiemGiuaKy") { dto.setDiemGiuaKy(-1); } else if (loaiDiem == "DiemCuoiKy") { dto.setDiemCuoiKy(-1); } update(dto); return true; }
From source file:com.orange.spring.cloud.connector.s3.core.service.S3ServiceInfo.java
public String getS3Host() { String host = this.getHost(); if (this.isVirtualHostBuckets()) { List<String> splittedHost = new ArrayList<String>(Arrays.asList(host.split("\\."))); splittedHost.remove(0); host = String.join(".", splittedHost); }/*from w ww .jav a2s . c o m*/ String port = ""; if (this.getPort() != -1) { port += ":" + this.getPort(); } String protocol = this.getProtocol(); return protocol + "://" + host + port; }