List of usage examples for java.util List remove
E remove(int index);
From source file:net.estinet.gFeatures.Feature.gRanks.gRanks.java
public static List<String> getPermsFile(File f) throws IOException { List<String> perms = Files.readAllLines(Paths.get(f.getPath()), StandardCharsets.UTF_8); for (int i = 0; i < perms.size(); i++) { perms.set(i, perms.get(i).replace("\r", "")); if (perms.get(i).equals("")) { if (i != 0) i--;/*from w ww . j a v a 2s .c o m*/ perms.remove(i); } } return perms; }
From source file:gov.nih.nci.cananolab.util.StringUtils.java
public static String[] removeFromArray(String[] oldArray, String stringToRemove) { List<String> list = new ArrayList<String>(Arrays.asList(oldArray)); list.remove(stringToRemove); return list.toArray(new String[0]); }
From source file:bioLockJ.util.MetadataUtil.java
/** * Process metadata & output some values to output file for verification. * @param data//from w w w .j a v a 2 s . c o m */ private static void processMetadata(final List<List<String>> data) { final int digits = new Integer(data.size()).toString().length(); int rowNum = 0; final Iterator<List<String>> rows = data.iterator(); while (rows.hasNext()) { final List<String> row = trim(rows.next()); String id = row.get(0); row.remove(0); if (rowNum == 0) { id = formatMetaId(id); metaId = id; Log.out.info("Loading METADATA [ID = " + metaId + "] with " + row.size() + " attribute columns"); } if (rowNum < 2) { Log.out.info("Example Metadata Row[" + String.format("%0" + digits + "d", rowNum) + "]: Key(" + id + "): " + row); } metadataMap.put(id, row); rowNum++; } }
From source file:com.twosigma.beakerx.table.serializer.TableDisplayDeSerializer.java
@NotNull private static Object handleIndex(JsonNode n, ObjectMapper mapper, List<List<?>> values, List<String> columns, List<String> classes) throws IOException { List<String> indexName = (List<String>) mapper.readValue(n.get(INDEX_NAME).toString(), List.class); boolean standardIndex = indexName.size() == 1 && indexName.get(0).equals(INDEX); if (standardIndex) { columns.remove(0); classes.remove(0);/*from ww w .j av a 2s. c o m*/ for (List<?> v : values) { v.remove(0); } } else { columns.set(0, join(", ", indexName.stream().map(TableDisplayDeSerializer::convertNullToIndexName) .collect(Collectors.toList()))); } TableDisplay td = new TableDisplay(values, columns, classes); if (!standardIndex) { td.setHasIndex("true"); } return td; }
From source file:io.udvi.amqp.mq.transport.session.CAMQPSessionManager.java
protected static void sessionClosed(CAMQPConnectionKey amqpRemoteConnectionKey, CAMQPSession session, int sessionChannelId) { List<CAMQPSession> sessions = _sessionManager.mappedSessions.get(amqpRemoteConnectionKey); if (sessions == null) { log.error("Could not find sessions for amqpContainerId: " + amqpRemoteConnectionKey); return;// ww w. ja v a 2 s. co m } if (!sessions.remove(session)) { log.error("Could not find session for sessionChannelId: " + sessionChannelId); return; } }
From source file:it.unibas.spicy.model.mapping.rewriting.egds.operators.EGDUtility.java
public static void mergeGroups(VariablePathExpression firstPath, VariablePathExpression secondPath, List<AttributeGroup> attributeGroups) { AttributeGroup firstGroup = EGDUtility.findGroupForPath(firstPath, attributeGroups); AttributeGroup secondGroup = EGDUtility.findGroupForPath(secondPath, attributeGroups); if (firstGroup.equals(secondGroup)) { return;// w w w. j a va2s . c om } attributeGroups.remove(secondGroup); EGDUtility.addPathsToGroup(firstGroup, secondGroup); }
From source file:com.ms.commons.test.tool.util.AutoImportProjectTaskUtil.java
@SuppressWarnings({ "unchecked", "deprecation" }) public static Task wrapAutoImportTask(final File project, final Task oldTask) { InputStream fis = null;/*from www. ja v a 2 s . co m*/ try { fis = new BufferedInputStream(project.toURL().openStream()); SAXBuilder b = new SAXBuilder(); Document document = b.build(fis); List<Element> elements = XPath.selectNodes(document, "/project/build/dependencies/include"); List<String> addList = new ArrayList<String>(importList); if (elements != null) { for (Element ele : elements) { String uri = ele.getAttribute("uri").getValue().trim().toLowerCase(); if (importList.contains(uri)) { addList.remove(uri); } } } if (addList.size() > 0) { System.err.println("Add projects:" + addList); List<Element> testElements = XPath.selectNodes(document, "/project/build[@profile='TEST']/dependencies"); Element testEle; if ((testElements == null) || (testElements.size() == 0)) { Element buildEle = new Element("build"); buildEle.setAttribute("profile", "TEST"); Element filesetsEle = new Element("filesets"); filesetsEle.setAttribute("name", "java.resdirs"); Element excludeEle = new Element("exclude"); excludeEle.setAttribute("fileset", "java.configdir"); filesetsEle.addContent(excludeEle); testEle = new Element("dependencies"); buildEle.addContent(Arrays.asList(filesetsEle, testEle)); ((Element) XPath.selectNodes(document, "/project").get(0)).addContent(buildEle); } else { testEle = testElements.get(0); } for (String add : addList) { Element e = new Element("include"); e.setAttribute("uri", add); testEle.addContent(e); } String newF = project.getAbsolutePath() + ".new"; XMLOutputter xmlOutputter = new XMLOutputter(); Writer writer = new BufferedWriter(new FileWriter(newF)); xmlOutputter.output(document, writer); writer.flush(); FileUtil.closeCloseAbleQuitly(writer); final File newFile = new File(newF); return new Task() { public void finish() { boolean hasError = false; File backUpFile = new File(project.getAbsoluteFile() + ".backup"); try { FileUtils.copyFile(project, backUpFile); FileUtils.copyFile(newFile, project); oldTask.finish(); } catch (Exception e) { hasError = true; e.printStackTrace(); } finally { try { FileUtils.copyFile(backUpFile, project); } catch (IOException e) { hasError = true; e.printStackTrace(); } newFile.delete(); backUpFile.delete(); } if (hasError) { System.exit(-1); } } }; } return oldTask; } catch (Exception e) { throw new RuntimeException(e); } finally { FileUtil.closeCloseAbleQuitly(fis); } }
From source file:Transform.java
public static void multiplePages() throws Exception { InputStream isXML = Transform.class.getResourceAsStream(file("manual.xml")); InputStream isXSL = Transform.class.getResourceAsStream("html-pages.xsl"); StreamSource xsl = new StreamSource(isXSL); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(xsl); Match manual = $(isXML);//from w w w . j a va2s . c om replaceVariables(manual); List<String> ids = manual.find("section").ids(); HashSet<String> uniqueIds = new HashSet<String>(ids); if (ids.size() != uniqueIds.size()) { for (String id : uniqueIds) { ids.remove(id); } throw new Exception("Duplicate section ids found! " + ids); } int blanks = 0, completed = 0; for (Match section : manual.find("section").each()) { Match sections = section.add(section.parents("section")).reverse(); String path = path(StringUtils.join(sections.ids(), "/")); String relativePath = relative(path); String root = root(); File dir = new File(path); dir.mkdirs(); PrintStream stream = System.out; boolean blank = StringUtils.isBlank(section.find("content").text()); if (blank) { blanks++; stream = System.err; } else { completed++; } stream.print("["); stream.print(blank ? " " : "x"); stream.println("] Transforming section " + path); File file = new File(dir, "index.php"); file.delete(); FileOutputStream out = new FileOutputStream(file); Source source = new DOMSource(manual.document()); Result target = new StreamResult(out); transformer.setParameter("sectionID", section.id()); transformer.setParameter("relativePath", relativePath); transformer.setParameter("root", root); transformer.transform(source, target); out.close(); } System.out.println(" Completed sections : " + completed + " / " + (blanks + completed) + " (" + (100 * completed / (blanks + completed)) + "%)"); }
From source file:de.alpharogroup.collections.ListExtensions.java
/** * Removes the first object from the given List. * * @param <T>//from w ww. ja v a2 s . com * the generic type * @param list * the List. * @return Removes and returns the first object from the given List or null if the List is empty * or null. */ public static <T> T removeFirst(final List<T> list) { if (!isEmpty(list) && 0 < list.size()) { return list.remove(0); } return null; }
From source file:de.alpharogroup.collections.ListExtensions.java
/** * Removes the last object from the given List. * * @param <T>// w ww .j a va2s.com * the generic type * @param list * the List. * @return Removes and returns the last object from the given List or null if the List is empty * or null. */ public static <T> T removeLast(final List<T> list) { if (!isEmpty(list) && 0 < list.size()) { return list.remove(list.size() - 1); } return null; }