List of usage examples for java.util Vector contains
public boolean contains(Object o)
From source file:org.opencastproject.util.ZipUtilTest.java
@Test public void zipRecFileStr() throws Exception { String destFilePath = destDir.getCanonicalPath() + File.separator + "recFileStr.zip"; Vector<String> names = new Vector<String>(); names.add(srcFileName);/*w ww . j a va 2 s . c o m*/ names.add(nestedSrcDirName + File.separator); names.add(nestedSrcDirName + File.separator + nestedSrcFileName); File test = ZipUtil.zip(srcDir.listFiles(), destFilePath, true, ZipUtil.NO_COMPRESSION); Assert.assertTrue(test.exists()); ZipFile zip = new ZipFile(test); Assert.assertEquals(3, zip.size()); Enumeration<? extends ZipEntry> entries = zip.entries(); try { while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); // The 'replace' method is used because the filesystem directory separator may not be the same as the Zip // files's Assert.assertTrue(names.contains(entry.getName().replace('/', File.separatorChar))); } } catch (AssertionError ae) { zip.close(); throw ae; } zip.close(); }
From source file:org.openbravo.erpCommon.utility.Utility.java
/** * Returns a Vector<String> composed by the comma separated elements in String s * /*from ww w. j av a 2 s .c o m*/ * @param s * @return the list of String obtained by converting the comma delimited String */ public static Vector<String> getStringVector(String s) { final Vector<String> v = new Vector<String>(); final StringTokenizer st = new StringTokenizer(s, ",", false); while (st.hasMoreTokens()) { final String token = st.nextToken().trim(); if (!v.contains(token)) v.add(token); } return v; }
From source file:com.duroty.application.bookmark.manager.BookmarkManager.java
/** * DOCUMENT ME!/*ww w .jav a2 s . c om*/ * * @param repositoryName DOCUMENT ME! * * @return DOCUMENT ME! * * @throws SearchException DOCUMENT ME! * @throws BookmarkException DOCUMENT ME! */ public Vector getKeywordsNotebook(String repositoryName) throws SearchException, BookmarkException { Vector keywords = new Vector(); String lucenePath = ""; if (!defaultLucenePath.endsWith(File.separator)) { lucenePath = defaultLucenePath + File.separator + repositoryName + File.separator + Constants.BOOKMARK_LUCENE_BOOKMARK; } else { lucenePath = defaultLucenePath + repositoryName + File.separator + Constants.BOOKMARK_LUCENE_BOOKMARK; } Searcher searcher = null; try { searcher = BookmarkIndexer.getSearcher(lucenePath); Query query = SimpleQueryParser.parse("notebook:true", new KeywordAnalyzer()); Hits hits = searcher.search(query); if (hits != null) { for (int i = 0; i < hits.length(); i++) { Document doc = hits.doc(i); String[] auxk = doc.getValues(Field_keywords); if (auxk != null) { for (int j = 0; j < auxk.length; j++) { if ((auxk[j] != null) && !auxk[j].trim().equals("") && !keywords.contains(auxk[j])) { keywords.addElement(auxk[j].toLowerCase()); } } } } } Collections.sort(keywords); } catch (IOException e) { throw new SearchException(e); } catch (Exception e) { throw new SearchException(e); } finally { if (searcher != null) { try { searcher.close(); } catch (IOException e) { } } } return keywords; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.BarCharts.java
/** * Use for slider: limits the categories visualization from cat selected to cat selected+numberscatsVisualization. * /*from w ww . j a v a 2 s . c o m*/ * @param dataset the dataset * @param categories the categories * @param catSelected the cat selected * @param numberCatsVisualization the number cats visualization * * @return the dataset */ public Dataset filterDataset(Dataset dataset, HashMap categories, int catSelected, int numberCatsVisualization) { logger.debug("IN"); DefaultCategoryDataset catDataset = (DefaultCategoryDataset) dataset; int numCats = categories.size(); Vector visCat = new Vector(); // from the choice point to min(chose point+interval, end point) //int startPoint=((catSelected-1)*numberCatsVisualization)+1; int startPoint = catSelected; int endPoint; if ((startPoint + numberCatsVisualization - 1) <= (categories.size())) endPoint = startPoint + numberCatsVisualization - 1; else endPoint = categories.size(); for (int i = (startPoint); i <= endPoint; i++) { String name = (String) categories.get(new Integer(i)); visCat.add(name); } List columns = new Vector(catDataset.getColumnKeys()); for (Iterator iterator = columns.iterator(); iterator.hasNext();) { String col = (String) iterator.next(); if (!(visCat.contains(col))) { catDataset.removeColumn(col); } } logger.debug("OUT"); return catDataset; }
From source file:userinterface.graph.Graph.java
public void moveUp(java.util.Vector<SeriesKey> keys) { synchronized (seriesCollection) { XYSeries[] newOrder = new XYSeries[seriesCollection.getSeriesCount()]; java.util.Vector<XYSeries> moveUpSet = new java.util.Vector<XYSeries>(); for (int i = 0; i < newOrder.length; i++) newOrder[i] = seriesCollection.getSeries(i); for (SeriesKey key : keys) { if (keyToSeries.containsKey(key)) moveUpSet.add(keyToSeries.get(key)); }//from w w w . ja va 2 s .c o m for (int i = 1; i < newOrder.length; i++) { if (moveUpSet.contains(newOrder[i])) { XYSeries tmp = newOrder[i]; newOrder[i] = newOrder[i - 1]; newOrder[i - 1] = tmp; } } XYSeriesCollection newCollection = new XYSeriesCollection(); for (int i = 0; i < newOrder.length; i++) newCollection.addSeries(newOrder[i]); plot.setDataset(newCollection); this.seriesCollection = newCollection; this.seriesList.updateSeriesList(); } }
From source file:userinterface.graph.Graph.java
public void moveDown(java.util.Vector<SeriesKey> keys) { synchronized (seriesCollection) { XYSeries[] newOrder = new XYSeries[seriesCollection.getSeriesCount()]; java.util.Vector<XYSeries> moveDownSet = new java.util.Vector<XYSeries>(); for (int i = 0; i < newOrder.length; i++) newOrder[i] = seriesCollection.getSeries(i); for (SeriesKey key : keys) { if (keyToSeries.containsKey(key)) moveDownSet.add(keyToSeries.get(key)); }//from w w w . j ava 2s . com for (int i = newOrder.length - 2; i >= 0; i--) { if (moveDownSet.contains(newOrder[i])) { XYSeries tmp = newOrder[i]; newOrder[i] = newOrder[i + 1]; newOrder[i + 1] = tmp; } } XYSeriesCollection newCollection = new XYSeriesCollection(); for (int i = 0; i < newOrder.length; i++) newCollection.addSeries(newOrder[i]); plot.setDataset(newCollection); this.seriesCollection = newCollection; this.seriesList.updateSeriesList(); } }
From source file:org.agnitas.beans.impl.MailingImpl.java
@Override public List<String> cleanupDynTags(Vector<String> keep) { Vector<String> remove = new Vector<String>(); String tmp = null;//from www. j a v a 2s.c o m // first find keys which should be removed Iterator<String> it = this.dynTags.keySet().iterator(); while (it.hasNext()) { tmp = it.next(); if (!keep.contains(tmp)) { remove.add(tmp); } } // now remove them! Enumeration<String> e = remove.elements(); while (e.hasMoreElements()) { dynTags.remove(e.nextElement()); } return remove; }
From source file:org.agnitas.beans.impl.MailingImpl.java
@Override public void cleanupTrackableLinks(Vector<String> keep) { Vector<String> remove = new Vector<String>(); String tmp = null;/*w ww . java2 s .c om*/ // first find keys which should be removed Iterator<String> it = this.trackableLinks.keySet().iterator(); while (it.hasNext()) { tmp = it.next(); if (!keep.contains(tmp)) { remove.add(tmp); } } // now remove them! Enumeration<String> e = remove.elements(); while (e.hasMoreElements()) { this.trackableLinks.remove(e.nextElement()); } }
From source file:com.l2jfree.gameserver.handler.admincommands.AdminSortMultisellItems.java
private Vector<L2Item> sortItemsByType(Vector<L2Item> items) { Vector<L2Item> newList = new Vector<L2Item>(); for (L2WeaponType type : L2WeaponType.values()) { if (type == null) continue; for (L2Item item : items) { if (item == null) continue; else if (!(item instanceof com.l2jfree.gameserver.model.items.templates.L2Weapon)) continue; L2WeaponType weaponType = ((com.l2jfree.gameserver.model.items.templates.L2Weapon) item) .getItemType();//from ww w . j a v a2s .co m try { if (weaponType == type && !newList.contains(item)) { newList.add(item); } } catch (Exception e) { continue; } } } for (L2Item item : items) { if (!newList.contains(item)) newList.add(item); } return newList; }
From source file:org.agnitas.beans.impl.MailingImpl.java
@Override public void cleanupMailingComponents(Vector<String> keep) { Vector<String> remove = new Vector<String>(); MailingComponent tmp = null;/*from www .j a va2 s. c o m*/ // first find keys which should be removed Iterator<MailingComponent> it = this.components.values().iterator(); while (it.hasNext()) { tmp = it.next(); if (tmp.getType() == MailingComponent.TYPE_IMAGE && !keep.contains(tmp.getComponentName())) { remove.add(tmp.getComponentName()); } } // now remove them! Enumeration<String> e = remove.elements(); while (e.hasMoreElements()) { this.components.remove(e.nextElement()); } }