List of usage examples for java.util Vector contains
public boolean contains(Object o)
From source file:EditorPaneExample16.java
public URL[] findLinks(Document doc, String protocol) { Vector links = new Vector(); Vector urlNames = new Vector(); URL baseURL = (URL) doc.getProperty(Document.StreamDescriptionProperty); if (doc instanceof HTMLDocument) { Element elem = doc.getDefaultRootElement(); ElementIterator iterator = new ElementIterator(elem); while ((elem = iterator.next()) != null) { AttributeSet attrs = elem.getAttributes(); Object link = attrs.getAttribute(HTML.Tag.A); if (link instanceof AttributeSet) { Object linkAttr = ((AttributeSet) link).getAttribute(HTML.Attribute.HREF); if (linkAttr instanceof String) { try { URL linkURL = new URL(baseURL, (String) linkAttr); if (protocol == null || protocol.equalsIgnoreCase(linkURL.getProtocol())) { String linkURLName = linkURL.toString(); if (urlNames.contains(linkURLName) == false) { urlNames.addElement(linkURLName); links.addElement(linkURL); }/*from w w w. j a v a 2 s . co m*/ } } catch (MalformedURLException e) { // Ignore invalid links } } } } } URL[] urls = new URL[links.size()]; links.copyInto(urls); links.removeAllElements(); urlNames.removeAllElements(); return urls; }
From source file:org.openflexo.generator.Generator.java
public Vector<CGRepositoryFileResource> refreshConcernedResources( Vector<CGRepositoryFileResource<? extends GeneratedResourceData, IFlexoResourceGenerator, CGFile>> forResources) { Vector<CGRepositoryFileResource> oldConcernedResources = concernedResources; concernedResources = buildGeneratedResourceListForRepository(getProjectGenerator().getRepository()); if (oldConcernedResources != null) { for (CGRepositoryFileResource resource : oldConcernedResources) { if (!concernedResources.contains(resource) && resource.getCGFile() != null) { resource.getCGFile().setMarkedForDeletion(true); }/*from ww w. j a v a 2 s . co m*/ } } for (CGRepositoryFileResource resource : concernedResources) { resource.rebuildDependancies(); } for (CGRepositoryFileResource resource : concernedResources) { if (resource.needsGeneration() && (forResources == null || forResources.contains(resource))) { resource.getDependantResourcesUpToDate(); } } return concernedResources; }
From source file:gate.annotation.AnnotationSetImpl.java
@Override public synchronized void addAnnotationSetListener(AnnotationSetListener l) { @SuppressWarnings("unchecked") Vector<AnnotationSetListener> v = annotationSetListeners == null ? new Vector<AnnotationSetListener>(2) : (Vector<AnnotationSetListener>) annotationSetListeners.clone(); if (!v.contains(l)) { v.addElement(l);//w w w. j av a 2 s. c o m annotationSetListeners = v; } }
From source file:org.wise.portal.presentation.web.controllers.ContactWiseController.java
/** * Set the teachers if the user is a student * @return a vector of teacher user objects that will be used to populate * the teacher drop down in the contact WISE form *///from w w w . j a v a 2 s. c om @ModelAttribute("teachers") public Vector<User> populateTeachers() { //the vector to accumulate the teachers associated with the student Vector<User> teachers = new Vector<User>(); // get the signed in user User user = ControllerUtil.getSignedInUser(); if (user != null) { // get the user details MutableUserDetails userDetails = user.getUserDetails(); //check that the user is a student if (userDetails != null && userDetails instanceof StudentUserDetails) { //get all the runs that this student is in List<Run> runList = runService.getRunList(user); Iterator<Run> runListIterator = runList.iterator(); //loop through all the runs while (runListIterator.hasNext()) { //get a run Run tempRun = runListIterator.next(); //get the owner of the run User owner = tempRun.getOwner(); //add the teacher to the list if they are not already in it if (!teachers.contains(owner)) { //the teacher is not in the list so we will add them teachers.add(owner); } } } } return teachers; }
From source file:org.opencastproject.util.ZipUtilTest.java
@Test public void zipNoRecFileFile() throws Exception { File destFile = new File(destDir, "noRecFileFile.zip"); Vector<String> names = new Vector<String>(); names.add(srcFileName);//from ww w . java 2 s .co m names.add(nestedSrcFileName); File test = ZipUtil.zip(new File[] { srcFile, nestedSrcFile, nestedSrcDir }, destFile, false, ZipUtil.NO_COMPRESSION); Assert.assertTrue(test.exists()); ZipFile zip = new ZipFile(test); Assert.assertEquals(2, zip.size()); Enumeration<? extends ZipEntry> entries = zip.entries(); try { while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); Assert.assertTrue(names.contains(entry.getName())); } } catch (AssertionError ae) { zip.close(); throw ae; } zip.close(); }
From source file:org.opencastproject.util.ZipUtilTest.java
@Test public void zipNoRecFileStr() throws Exception { File destFile = new File(destDir, "noRecFileStr.zip"); Vector<String> names = new Vector<String>(); names.add(srcFileName);/*from ww w .ja v a 2 s . c o m*/ names.add(nestedSrcFileName); File test = ZipUtil.zip(new File[] { srcFile, nestedSrcFile, nestedSrcDir }, destFile.getCanonicalPath(), false, ZipUtil.NO_COMPRESSION); Assert.assertTrue(test.exists()); ZipFile zip = new ZipFile(test); Assert.assertEquals(2, zip.size()); Enumeration<? extends ZipEntry> entries = zip.entries(); try { while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); Assert.assertTrue(names.contains(entry.getName())); } } catch (AssertionError ae) { zip.close(); throw ae; } zip.close(); }
From source file:org.gvsig.framework.web.service.impl.OGCInfoServiceImpl.java
public WMSInfo getCapabilitiesFromWMS(String urlServerWMS, TreeSet<String> listCrs, String format, boolean isCalledByWizard) throws ServerGeoException { WMSInfo wmsInfo = new WMSInfo(); // put url on object WMSInfo wmsInfo.setServiceUrl(urlServerWMS); // Create hashmap to add the layers getted to the WMSInfo object Map<String, org.gvsig.framework.web.ogc.WMSLayer> layersMap = new HashMap<String, org.gvsig.framework.web.ogc.WMSLayer>(); // Create conexion with server WMS try {/*from w w w . j av a 2 s.c o m*/ WMSClient wms = new WMSClient(urlServerWMS); wms.connect(null); // set server information WMSServiceInformation serviceInfo = wms.getServiceInformation(); wmsInfo.setServiceAbstract(serviceInfo.abstr); wmsInfo.setServiceName(serviceInfo.name); wmsInfo.setServiceTitle(serviceInfo.title); // set id of the request wmsinfo (service name + calendar) int hashCode = (serviceInfo.name + Calendar.getInstance()).hashCode(); wmsInfo.setId(hashCode); // get and set version String version = wms.getVersion(); wmsInfo.setVersion(version); // get and set formats Vector formatVector = wms.getFormats(); TreeSet<String> formatSet = new TreeSet<String>(); formatSet.addAll(formatVector); wmsInfo.setFormatsSupported(formatSet); if (StringUtils.isEmpty(format)) { format = getFirstFormatSupported(formatSet); wmsInfo.setFormatSelected(format); } // check format if (isCalledByWizard || (!isCalledByWizard && formatVector.contains(format))) { wmsInfo.setFormatSelected(format); // get root layer WMSLayer rootLayer = wms.getRootLayer(); // get crs (srs) (belong to layer) Vector crsVector = rootLayer.getAllSrs(); // get and set all common crs supported TreeSet<String> crsTreeSet = new TreeSet<String>(); crsTreeSet.addAll(crsVector); wmsInfo.setCrsSupported(crsTreeSet); // Create tree with layer values List<TreeNode> tree = new ArrayList<TreeNode>(); // Create root node ArrayList<WMSLayer> children = rootLayer.getChildren(); TreeNode rootNode = new TreeNode("rootLayer_" + rootLayer.getName()); rootNode.setTitle(rootLayer.getTitle()); if (children.isEmpty()) { rootNode.setFolder(false); } else { rootNode.setFolder(true); rootNode.setExpanded(true); generateWMSChildrenNodes(children, tree, listCrs, rootNode, layersMap, wmsInfo); } // Set childrenLayers paramrootLayer.getChildren() wmsInfo.setChildrenCount(children.size()); // Only register the tree if it has a layer with crs defined if (rootNode.hasChildren()) { tree.add(rootNode); wmsInfo.setLayersTree(tree); } TreeSet<String> selCrs = new TreeSet<String>(); if (listCrs.isEmpty()) { selCrs.addAll(wmsInfo.getCrsSupported()); } else { selCrs.addAll(CollectionUtils.intersection(listCrs, wmsInfo.getCrsSupported())); } wmsInfo.setCrsSelected(selCrs); // Add map that contains info of all layers wmsInfo.setLayers(layersMap); } } catch (Exception exc) { // Show exception in log and create ServerGeoException which is // captured on controller and puts message to ajax response logger.error("Exception on getCapabilitiesFromWMS", exc); throw new ServerGeoException(); } return wmsInfo; }
From source file:org.mahasen.util.SearchUtil.java
/** * @param propertyName/*from w w w. j a v a 2 s.c o m*/ * @param propertyValue * @return * @throws InterruptedException * @throws MahasenException */ private Vector<Id> getSearchResultIds(String propertyName, String propertyValue) throws InterruptedException, MahasenException { Vector<Id> idVector = new Vector<Id>(); // tag search for several tags if (propertyValue.contains("&")) { String values[] = propertyValue.split("\\&"); for (String value : values) { if (idVector.isEmpty()) { Vector<Id> tempResult = mahasenManager.getSearchResults(propertyName, value.trim()); if (tempResult != null) { idVector.addAll(tempResult); } } if (!idVector.isEmpty()) { Stack<Vector<Id>> idVectorSet = new Stack<Vector<Id>>(); idVectorSet.push(idVector); idVectorSet.push(mahasenManager.getSearchResults(propertyName, value.trim())); idVector = getCommonIds(idVectorSet); } } } else if (propertyValue.contains("|")) { String values[] = propertyValue.split("\\|"); for (String value : values) { Vector<Id> tempResult = mahasenManager.getSearchResults(propertyName, value.trim()); if (tempResult != null) { for (Id id : tempResult) { if (!idVector.contains(id)) { idVector.add(id); } } } } } else { idVector = mahasenManager.getSearchResults(propertyName, propertyValue.trim()); } return idVector; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetSubjectsIdListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setSubjectsIdUI.getValues(); Vector<String> samples = this.setSubjectsIdUI.getSamples(); for (String v : values) { if (v.compareTo("") == 0) { this.setSubjectsIdUI.displayMessage("All identifiers have to be set"); return; }/* w w w . ja va 2 s . c om*/ } File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { for (int i = 0; i < samples.size(); i++) { out.write(this.dataType.getStudy().toString() + "\t" + "\t" + values.elementAt(i) + "\t" + samples.elementAt(i) + "\t" + "\t" + "\t" + "\t" + "\t" + "\n"); } } else { try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String subject; if (samples.contains(sample)) { subject = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + fields[1] + "\t" + subject + "\t" + sample + "\t" + fields[4] + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.setSubjectsIdUI.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.delete(); fileDest = new File(this.dataType.getPath() + File.separator + fileName); } else { fileDest = new File(this.dataType.getPath() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping"); } FileUtils.moveFile(file, fileDest); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setSubjectsIdUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setSubjectsIdUI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); UsedFilesPart.sendFilesChanged(dataType); }
From source file:org.openflexo.foundation.ie.IEWOComponent.java
public Vector<IETabWidget> getAllTabWidget(Vector<IETabWidget> reply) { for (IESequenceTab container : getAllTabContainers()) { for (ITabWidget itab : container.getInnerWidgets()) { for (IETabWidget tab : itab.getAllTabs()) { if (!reply.contains(tab)) { reply.add(tab);/* ww w.j a v a 2 s . co m*/ tab.getTabComponentDefinition().getWOComponent().getAllTabWidget(reply); } } } } return reply; }