List of usage examples for java.util ArrayList remove
public boolean remove(Object o)
From source file:IO.Directories.java
/** * Extract all the paths of the files in given directory and its * sub-directories/*from w w w. ja va 2 s . c om*/ * * @param directoryPath path of the destination directory to delete * @return true if the directory was deleted */ public static ArrayList<String> GetDirectoryFilesPaths(String directoryPath) { ArrayList<String> directoryPaths = new ArrayList<>(); try { java.nio.file.Files.walk(Paths.get(directoryPath)).filter(filePath -> Files.IsFile(filePath.toString())) .forEach(filePath -> { directoryPaths.add(filePath.toString()); }); } catch (IOException e) { Console.PrintException(String.format("Error getting files' paths from directory: %s", directoryPath), e); } directoryPaths.remove(directoryPath); return directoryPaths; }
From source file:com.yamin.kk.vlc.Util.java
public static void addCustomDirectory(String path) { SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(VLCApplication.getAppContext()); ArrayList<String> dirs = new ArrayList<String>(Arrays.asList(getCustomDirectories())); dirs.add(path);/*from w ww . ja va 2s .c o m*/ StringBuilder builder = new StringBuilder(); builder.append(dirs.remove(0)); for (String s : dirs) { builder.append(":"); builder.append(s); } SharedPreferences.Editor editor = preferences.edit(); editor.putString("custom_paths", builder.toString()); editor.commit(); }
From source file:io.jxcore.node.jxcore.java
public static void javaCall(ArrayList<Object> params) { if (params.size() < 2 || params.get(0).getClass() != String.class || params.get(params.size() - 1).getClass() != String.class) { Log.e(LOGTAG, "JavaCall recevied an unknown call"); return;/* w w w . j a v a2s. c om*/ } String receiver = params.remove(0).toString(); String callId = params.remove(params.size() - 1).toString(); if (!java_callbacks.containsKey(receiver)) { Log.e(LOGTAG, "JavaCall recevied a call for unknown method " + receiver); return; } java_callbacks.get(receiver).Receiver(params, callId); }
From source file:org.posterita.businesslogic.performanceanalysis.CustomPOSReportManager.java
public static BarChart generateBarChart(Properties ctx, String title, String subtitle, int account_id, Timestamp fromDate, Timestamp toDate, String salesGroup, String priceQtyFilter) throws OperationException { BarChart barChart = new BarChart(); barChart.setTitle(title);/*from w w w .ja v a 2s.c om*/ barChart.setSubtitle(subtitle); //barChart.getDataSetFromSQL(barChartSQL); String barChartSQL = SalesAnalysisReportManager.getBarChartDataSetSQL(ctx, account_id, fromDate, toDate, salesGroup); ArrayList<Object[]> list = ReportManager.getReportData(ctx, barChartSQL, true); DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset(); Object[] header = list.remove(0); String grouping = header[0] + ""; String yLabel = null; if (priceQtyFilter.equalsIgnoreCase(Constants.PRICE)) { String currency = POSTerminalManager.getDefaultSalesCurrency(ctx).getCurSymbol(); //against price for (Object[] obj : list) { String name = (String) obj[0]; BigDecimal price = (BigDecimal) obj[1]; categoryDataset.setValue(price, grouping, name); yLabel = "Value (" + currency + ")"; } } else { //against qty for (Object[] obj : list) { String name = (String) obj[0]; BigDecimal qty = (BigDecimal) obj[2]; categoryDataset.setValue(qty, grouping, name); yLabel = "Quantity"; } } //xLabel = grouping; //--------------------------------------------------------------------------------- barChart.setDataset(categoryDataset); barChart.setIntegerTickUnits(true); //CategoryItemRenderer itemRender = barChart.getChart().getPlot(); //itemRender.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); barChart.setYLabel(yLabel); //barChart.setXLabel(xLabel); barChart.setShowLabels(true); barChart.getChart().setBackgroundPaint(Color.white); return barChart; }
From source file:Main.java
@SuppressWarnings("unchecked") static public LinkedHashMap<Object, Comparable> sortHashMapByValues(HashMap<Object, Comparable> passedMap) { ArrayList mapKeys = new ArrayList(passedMap.keySet()); ArrayList mapValues = new ArrayList(passedMap.values()); Collections.sort(mapValues);// ww w . j ava 2s. c om Collections.sort(mapKeys); LinkedHashMap<Object, Comparable> sortedMap = new LinkedHashMap<Object, Comparable>(); Iterator<Comparable> valueIt = mapValues.iterator(); while (valueIt.hasNext()) { Comparable val = valueIt.next(); Iterator keyIt = mapKeys.iterator(); while (keyIt.hasNext()) { Object key = keyIt.next(); Comparable comp = passedMap.get(key); if (comp.equals(val)) { passedMap.remove(key); mapKeys.remove(key); sortedMap.put(key, val); break; } } } return sortedMap; }
From source file:Main.java
public static List<ByteBuffer> mergeAdjacentBuffers(List<ByteBuffer> paramList) { ArrayList localArrayList = new ArrayList(paramList.size()); Iterator localIterator = paramList.iterator(); while (localIterator.hasNext()) { ByteBuffer localByteBuffer1 = (ByteBuffer) localIterator.next(); int i = -1 + localArrayList.size(); if ((i >= 0) && (localByteBuffer1.hasArray()) && (((ByteBuffer) localArrayList.get(i)).hasArray()) && (localByteBuffer1.array() == ((ByteBuffer) localArrayList.get(i)).array()) && (((ByteBuffer) localArrayList.get(i)).arrayOffset() + ((ByteBuffer) localArrayList.get(i)).limit() == localByteBuffer1.arrayOffset())) { ByteBuffer localByteBuffer3 = (ByteBuffer) localArrayList.remove(i); localArrayList.add(ByteBuffer.wrap(localByteBuffer1.array(), localByteBuffer3.arrayOffset(), localByteBuffer3.limit() + localByteBuffer1.limit()).slice()); } else if ((i >= 0) && ((localByteBuffer1 instanceof MappedByteBuffer)) && ((localArrayList.get(i) instanceof MappedByteBuffer)) && (((ByteBuffer) localArrayList.get(i)) .limit() == ((ByteBuffer) localArrayList.get(i)).capacity() - localByteBuffer1.capacity())) { ByteBuffer localByteBuffer2 = (ByteBuffer) localArrayList.get(i); localByteBuffer2.limit(localByteBuffer1.limit() + localByteBuffer2.limit()); } else {//from w ww. j a va 2 s.com localByteBuffer1.reset(); localArrayList.add(localByteBuffer1); } } return localArrayList; }
From source file:Main.java
public static void removeEntriesWhereMatch(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, ArrayList<ContentValues> compareContentValues, String compareColumnName) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations) { return;/* w w w . jav a2 s . c o m*/ } ArrayList<ContentValues> removeOperations = new ArrayList<ContentValues>(); for (ContentValues restoreCv : restoreOperations) { for (ContentValues compareCv : compareContentValues) { if (restoreCv.containsKey(idColumnName) && compareCv.containsKey(compareColumnName)) { if (restoreCv.getAsLong(idColumnName) == compareCv.getAsLong(compareColumnName)) { removeOperations.add(restoreCv); } } } } for (ContentValues removeCv : removeOperations) { restoreOperations.remove(removeCv); } }
From source file:com.microsoft.tfs.core.clients.build.internal.utils.XamlHelper.java
public static String updateProperties(final String originalXaml, final Properties properties) { final ArrayList keys = new ArrayList(properties.keySet()); final Document document = DOMCreateUtils.parseString(originalXaml); final Element root = document.getDocumentElement(); // first update any properties that we already have final NodeList nodes = root.getElementsByTagName("x:String"); //$NON-NLS-1$ for (int i = 0; i < nodes.getLength(); i++) { final Element element = (Element) nodes.item(i); final String key = element.getAttribute("x:Key"); //$NON-NLS-1$ element.getFirstChild().getNodeValue(); if (properties.containsKey(key)) { keys.remove(key); element.getFirstChild().setNodeValue(properties.getProperty(key)); }/*w ww . j a v a 2 s. com*/ } // now add any new properties to the xaml for (final Iterator it = keys.iterator(); it.hasNext();) { final String key = (String) it.next(); final Element element = DOMUtils.appendChild(root, "x:String"); //$NON-NLS-1$ element.setAttributeNS(XAML_NAMESPACE, "x:Key", key); //$NON-NLS-1$ element.setAttributeNS(XML_NAMESPACE, "xml:space", "preserve"); //$NON-NLS-1$ //$NON-NLS-2$ DOMUtils.appendText(element, properties.getProperty(key)); } return DOMSerializeUtils.toString(root, DOMSerializeUtils.INDENT).trim(); }
From source file:com.nuance.expertassistant.ContentExtractor.java
public static void extract(Document doc) { final Elements links = doc.getElementsByTag("a"); final Elements ps = doc.select("p"); final String title = doc.title(); print("<section id =\"{}\" title =\"" + stripNonValidXMLCharacters(doc.title()) + "\">"); final Elements elements = doc.select("*"); final ArrayList<String> openHeaderList = new ArrayList<String>(); for (final Element element : elements) { if (element.ownText() == null || element.ownText().isEmpty() || element.ownText().trim() == "") { } else if (element.tagName().toString().contains("a")) { } else if (element.tagName().contains("h1") && element.text() != null && !element.text().isEmpty()) { if (openHeaderList.contains("h1")) { openHeaderList.remove("h1"); print("</section>"); }/*from w ww . j av a 2s . c om*/ if (openHeaderList.contains("h2")) { openHeaderList.remove("h2"); print("</section>"); } if (openHeaderList.contains("h3")) { openHeaderList.remove("h3"); print("</section>"); } if (openHeaderList.contains("h4")) { openHeaderList.remove("h4"); print("</section>"); } print("<section id =\"{}\" title =\"" + stripNonValidXMLCharacters(element.text()) + "\">"); openHeaderList.add("h1"); } else if (element.tagName().contains("h2") && element.text() != null && !element.text().isEmpty()) { if (openHeaderList.contains("h2")) { openHeaderList.remove("h2"); print("</section>"); } if (openHeaderList.contains("h3")) { openHeaderList.remove("h3"); print("</section>"); } if (openHeaderList.contains("h4")) { openHeaderList.remove("h4"); print("</section>"); } print("<section id =\"{}\" title =\"" + stripNonValidXMLCharacters(element.text()) + "\">"); openHeaderList.add("h2"); } else if (element.tagName().contains("h3") && element.text() != null && !element.text().isEmpty()) { if (openHeaderList.contains("h3")) { openHeaderList.remove("h3"); print("</section>"); } if (openHeaderList.contains("h4")) { openHeaderList.remove("h4"); print("</section>"); } print("<section id =\"{}\" title =\"" + stripNonValidXMLCharacters(element.text()) + "\">"); openHeaderList.add("h3"); } else if (element.tagName().contains("h4") && element.text() != null && !element.text().isEmpty()) { if (openHeaderList.contains("h4")) { openHeaderList.remove("h4"); print("</section>"); } print("<section id =\"{}\" title =\"" + stripNonValidXMLCharacters(element.text()) + "\">"); openHeaderList.add("h4"); } else { print("<para>"); print(stripNonValidXMLCharacters(element.ownText())); print("</para>"); } /* * if (element.tagName().contains("img")) { print("<img src=\"" + * element.attr("src") + "\"></img>"); } */ } if (openHeaderList.contains("h1")) { openHeaderList.remove("h1"); print("</section>"); } if (openHeaderList.contains("h2")) { openHeaderList.remove("h2"); print("</section>"); } if (openHeaderList.contains("h3")) { openHeaderList.remove("h3"); print("</section>"); } if (openHeaderList.contains("h4")) { openHeaderList.remove("h4"); print("</section>"); } print("</section>"); }
From source file:org.bedework.notifier.web.MethodBase.java
/** Return a path, broken into its elements, after "." and ".." are removed. * If the parameter path attempts to go above the root we return null. * * Other than the backslash thing why not use URI? * * @param path String path to be fixed * @return String[] fixed path broken into elements * @throws NoteException on error/* w w w. jav a 2 s . com*/ */ public static List<String> fixPath(final String path) throws NoteException { if (path == null) { return null; } String decoded; try { decoded = URLDecoder.decode(path, "UTF8"); } catch (Throwable t) { throw new NoteException("bad path: " + path); } if (decoded == null) { return (null); } /** Make any backslashes into forward slashes. */ if (decoded.indexOf('\\') >= 0) { decoded = decoded.replace('\\', '/'); } /** Ensure a leading '/' */ if (!decoded.startsWith("/")) { decoded = "/" + decoded; } /** Remove all instances of '//'. */ while (decoded.indexOf("//") >= 0) { decoded = decoded.replaceAll("//", "/"); } /** Somewhere we may have /./ or /../ */ StringTokenizer st = new StringTokenizer(decoded, "/"); ArrayList<String> al = new ArrayList<String>(); while (st.hasMoreTokens()) { String s = st.nextToken(); if (s.equals(".")) { // ignore } else if (s.equals("..")) { // Back up 1 if (al.size() == 0) { // back too far return null; } al.remove(al.size() - 1); } else { al.add(s); } } return al; }