List of usage examples for java.util Vector elements
public Enumeration<E> elements()
From source file:org.apereo.portal.layout.simple.SimpleLayout.java
@Override public Enumeration getChildIds(String nodeId) throws PortalException { Vector v = new Vector(); IUserLayoutNodeDescription node = getNodeDescription(nodeId); if (node instanceof IUserLayoutFolderDescription) { Element element = layout.getElementById(nodeId); for (Node n = element.getFirstChild(); n != null; n = n.getNextSibling()) { if (n.getNodeType() == Node.ELEMENT_NODE) { Element e = (Element) n; if (e.getAttribute("ID") != null) { v.add(e.getAttribute("ID")); }//from w ww. j a v a 2 s .c o m } } } return v.elements(); }
From source file:org.apache.naming.modules.fs.FileDirContext.java
/** * Enumerates the names bound in the named context, along with the class * names of objects bound to them. The contents of any subcontexts are * not included./* w w w.ja va 2 s. c om*/ * <p> * If a binding is added to or removed from this context, its effect on * an enumeration previously returned is undefined. * * @param name the name of the context to list * @return an enumeration of the names and class names of the bindings in * this context. Each element of the enumeration is of type NameClassPair. * @exception NamingException if a naming exception is encountered */ public NamingEnumeration list(Name nameN) throws NamingException { String name = nameN.toString(); if (log.isDebugEnabled()) log.debug("list " + name); File file = file(name); if (file == null) throw new NamingException(sm.getString("resources.notFound", name)); Vector entries = list(file); return new NamingContextEnumeration(entries.elements(), this, false); }
From source file:org.apache.naming.modules.fs.FileDirContext.java
/** * Enumerates the names bound in the named context, along with the * objects bound to them. The contents of any subcontexts are not * included.//from w w w . j av a2 s .co m * <p> * If a binding is added to or removed from this context, its effect on * an enumeration previously returned is undefined. * * @param name the name of the context to list * @return an enumeration of the bindings in this context. * Each element of the enumeration is of type Binding. * @exception NamingException if a naming exception is encountered */ public NamingEnumeration listBindings(Name nameN) throws NamingException { String name = nameN.toString(); if (log.isDebugEnabled()) log.debug("listBindings " + name); File file = file(name); if (file == null) throw new NamingException(sm.getString("resources.notFound", name)); Vector entries = list(file); return new NamingContextEnumeration(entries.elements(), this, true); }
From source file:org.ops4j.pax.web.service.spi.util.ResourceDelegatingBundleClassLoader.java
protected URL findResource(String name) { Vector<URL> resources = getFromCache(name); if (resources == null) { resources = new Vector<>(); for (Bundle delegate : bundles) { try { URL resource = delegate.getResource(name); if (resource != null) { resources.add(resource); break; }// ww w . j a v a 2s . c om } catch (IllegalStateException exc) { // ignore } } if (!resources.isEmpty()) { addToCache(name, resources); } } Enumeration<URL> elements = resources.elements(); if (elements.hasMoreElements()) { return elements.nextElement(); } return null; }
From source file:org.openadaptor.auxil.connector.jms.JMSReadConnectorTestCase.java
public void testNextMetadata() { Mock mockObjectMessage = new Mock(ObjectMessage.class); Mock mockTextMessage = new Mock(TextMessage.class); // Horrible messy enumeration stuff // JMS getPropertyNames() returns an enumeration you see. Vector names = new Vector(); String key1 = "Key One"; String value1 = "Property One"; names.add(key1);/*from w w w . j a v a 2s . c o m*/ String key2 = "Key Two"; Integer value2 = new Integer(2); names.add(key2); String key3 = "Key Three"; Boolean value3 = new Boolean(false); names.add(key3); Enumeration testEnum = names.elements(); //Inject Metadata Map metadata = new HashMap(); setupConnectExpectations(); testReadConnector.connect(); testReadConnector.setPopulateMetadataFromProperties(true); testReadConnector.setMetadata(metadata); String testTextMessage = "hello World"; messageConsumerMock.expects(once()).method("receive").will(returnValue(mockTextMessage.proxy())); mockTextMessage.expects(once()).method("getJMSMessageID").will(returnValue("TestMessageID Text Message")); mockTextMessage.expects(once()).method("getText").will(returnValue(testTextMessage)); mockTextMessage.expects(once()).method("getPropertyNames").will(returnValue(testEnum)); mockTextMessage.expects(once()).method("getObjectProperty").with(eq(key1)).will(returnValue(value1)); mockTextMessage.expects(once()).method("getObjectProperty").with(eq(key2)).will(returnValue(value2)); mockTextMessage.expects(once()).method("getObjectProperty").with(eq(key3)).will(returnValue(value3)); Object[] nextObjectArray = testReadConnector.next(10); assertTrue("Expected test object", nextObjectArray[0] == testTextMessage); assertTrue(metadata.get(key1).equals(value1)); assertTrue(metadata.get(key2).equals(value2)); assertTrue(metadata.get(key3).equals(value3)); }
From source file:com.ooyala.api.OoyalaAPI.java
/** * Concatenates the key-values of parameters using a separator in between * * @param parameters HashMap with the key-value elements to be concatenated * @param separator The separator (a char) which is added between hash elements * @return the concatenated string//from ww w. j a v a2 s.c om */ private String concatenateParams(HashMap<String, String> parameters, String separator) { Vector<String> keys = new Vector<String>(parameters.keySet()); Collections.sort(keys); String string = ""; for (Enumeration<String> e = keys.elements(); e.hasMoreElements();) { String key = (String) e.nextElement(); String value = (String) parameters.get(key); if (!string.isEmpty()) string += separator; string += key + "=" + value; } return string; }
From source file:org.jolokia.http.AgentServletTest.java
@Test public void simpleGetWithUnsupportedGetParameterMapCall() throws ServletException, IOException { prepareStandardInitialisation();/* w w w. jav a 2s . com*/ StringWriter sw = initRequestResponseMocks(new Runnable() { public void run() { expect(request.getHeader("Origin")).andStubReturn(null); expect(request.getHeader("Referer")).andStubReturn(null); expect(request.getRemoteHost()).andReturn("localhost"); expect(request.getRemoteAddr()).andReturn("127.0.0.1"); expect(request.getRequestURI()).andReturn("/jolokia/"); setupAgentDetailsInitExpectations(); expect(request.getPathInfo()).andReturn(HttpTestUtil.HEAP_MEMORY_GET_REQUEST); expect(request.getParameterMap()).andThrow(new UnsupportedOperationException("")); expect(request.getAttribute(ConfigKey.JAAS_SUBJECT_REQUEST_ATTRIBUTE)).andReturn(null); Vector params = new Vector(); params.add("debug"); expect(request.getParameterNames()).andReturn(params.elements()); expect(request.getParameterValues("debug")).andReturn(new String[] { "false" }); expect(request.getAttribute("subject")).andReturn(null); } }, getStandardResponseSetup()); expect(request.getParameter(ConfigKey.MIME_TYPE.getKeyValue())).andReturn(null); replay(request, response); servlet.doGet(request, response); servlet.destroy(); }
From source file:com.verisign.epp.codec.gen.EPPUtil.java
/** * Determines if one <code>Vector</code> is a subset of another * <code>Vector</code>. If every element in <code>aV1</code> is in * <code>aV2</code> return <code>true</code>; otherwise return * <code>false</code>./*from ww w.j a v a 2 s .c o m*/ * * @param aV1 * Subset <code>Vector</code> to compare against <code>aV2</code> * @param aV2 * Superset <code>Vector</code> to compare against * <code>aV1</code> * @return <code>true</code> if <code>aV1</code> is a subset of * <code>aV2</code>; <code>false</code> otherwise. */ public static boolean vectorSubset(Vector aV1, Vector aV2) { Enumeration v1Enum = aV1.elements(); while (v1Enum.hasMoreElements()) { if (!aV2.contains(v1Enum.nextElement())) { return false; } } return true; }
From source file:com.orange.mmp.context.RequestContext.java
/** * HttpServletRequest getParameterNames delegation method * /*from w w w . ja v a 2 s. c o m*/ * @return The list of available parameters */ @SuppressWarnings("unchecked") public Enumeration<String> getParameterNames() { if (!this.isMultipart) return this.httpServletRequest.getParameterNames(); else if (this.multipartItems != null) { Vector<String> itemNames = new Vector<String>(); for (FileItem item : this.multipartItems) { if (item.isFormField()) itemNames.add(item.getFieldName()); } return itemNames.elements(); } return null; }
From source file:org.ops4j.pax.web.service.spi.util.ResourceDelegatingBundleClassLoader.java
@Override protected Enumeration<URL> findResources(String name) throws IOException { Vector<URL> resources = getFromCache(name); if (resources == null) { resources = new Vector<>(); for (Bundle delegate : bundles) { try { Enumeration<URL> urls = delegate.getResources(name); if (urls != null) { while (urls.hasMoreElements()) { resources.add(urls.nextElement()); }//from w w w .jav a 2 s . com } } catch (IllegalStateException exc) { // ignore } } if (!resources.isEmpty()) { addToCache(name, resources); } } return resources.elements(); }