List of usage examples for java.util Vector elements
public Enumeration<E> elements()
From source file:com.redhat.rhn.frontend.servlets.RhnHttpServletRequest.java
/** * {@inheritDoc}/* w ww .ja v a 2 s .c o m*/ */ public Enumeration<String> getAttributeNames() { Vector<String> tmp = new Vector<String>(); tmp.add(ACTIVE_LANG_ATTR); for (Enumeration<String> e = super.getAttributeNames(); e.hasMoreElements();) { tmp.add(e.nextElement()); } return tmp.elements(); }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Generate a stacked bar graph representing test execution time for each * product area. /*from ww w .j av a 2 s.c o m*/ * * @param builds List of builds * @param suites List of test suites * @param areas List of product areas * * @return Stacked bar chart representing test execution times across all builds */ public static final JFreeChart getAreaTestTimeChart(Vector<CMnDbBuildData> builds, Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) { JFreeChart chart = null; // Collect the total times for each build, organized by area // This hashtable maps a build to the area/time information for that build Hashtable<Integer, Hashtable> buildTotals = new Hashtable<Integer, Hashtable>(); // Generate placeholders for each build so the chart maintains a // format consistent with the other charts that display build information HashSet areaNames = new HashSet(); if (builds != null) { Enumeration buildList = builds.elements(); while (buildList.hasMoreElements()) { CMnDbBuildData build = (CMnDbBuildData) buildList.nextElement(); // Create the empty area list buildTotals.put(new Integer(build.getId()), new Hashtable<String, Long>()); } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if ((suites != null) && (suites.size() > 0)) { // Collect build test numbers for each of the builds in the list Enumeration suiteList = suites.elements(); while (suiteList.hasMoreElements()) { // Process the test summary for the current build CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement(); Integer buildId = new Integer(suite.getParentId()); Long elapsedTime = new Long(suite.getElapsedTime()); // Parse the build information so we can track the time by build Hashtable<String, Long> areaTime = null; if (buildTotals.containsKey(buildId)) { areaTime = (Hashtable) buildTotals.get(buildId); } else { areaTime = new Hashtable<String, Long>(); buildTotals.put(buildId, areaTime); } // Iterate through each product area to determine who owns this suite CMnDbFeatureOwnerData area = null; Iterator iter = areas.iterator(); while (iter.hasNext()) { CMnDbFeatureOwnerData currentArea = (CMnDbFeatureOwnerData) iter.next(); if (currentArea.hasFeature(suite.getGroupName())) { area = currentArea; } } // Add the elapsed time for the current suite to the area total Long totalValue = null; String areaName = area.getDisplayName(); areaNames.add(areaName); if (areaTime.containsKey(areaName)) { Long oldTotal = (Long) areaTime.get(areaName); totalValue = oldTotal + elapsedTime; } else { totalValue = elapsedTime; } areaTime.put(areaName, totalValue); } // while list has elements // Populate the data set with the area times for each build Collections.sort(builds, new CMnBuildIdComparator()); Iterator buildIter = builds.iterator(); while (buildIter.hasNext()) { CMnDbBuildData build = (CMnDbBuildData) buildIter.next(); Integer buildId = new Integer(build.getId()); Hashtable areaTime = (Hashtable) buildTotals.get(buildId); Iterator areaKeys = areaNames.iterator(); while (areaKeys.hasNext()) { String area = (String) areaKeys.next(); Long time = (Long) areaTime.get(area); if (time != null) { // Convert the time from milliseconds to minutes time = time / (1000 * 60); } else { time = new Long(0); } dataset.addValue(time, area, buildId); } } } // if list has elements // API: ChartFactory.createStackedBarChart(title, domainAxisLabel, rangeAxisLabel, dataset, orientation, legend, tooltips, urls) chart = ChartFactory.createStackedBarChart("Automated Tests by Area", "Builds", "Execution Time (min)", dataset, PlotOrientation.VERTICAL, true, true, false); // get a reference to the plot for further customization... CategoryPlot plot = (CategoryPlot) chart.getPlot(); chartFormatter.formatAreaChart(plot, dataset); return chart; }
From source file:org.yestech.jmlnitrate.util.ServletRequestAdaptor.java
public Enumeration getParameterNames() { Vector list = new Vector(); Enumeration rit = getRequest().getParameterNames(); Iterator it = parameters.keySet().iterator(); while (it.hasNext()) { list.add(it.next());/*from w w w .ja v a2s . c o m*/ } while (rit.hasMoreElements()) { list.add(rit.nextElement()); } return list.elements(); }
From source file:org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper.java
/** * Merges 2 enumeration of parameters as one. * * @param params1 the first enumeration. * @param params2 the second enumeration. * @return a single Enumeration of all elements from both Enumerations. *///from w w w. j a v a 2 s .co m protected Enumeration mergeParams(Enumeration params1, Enumeration params2) { Vector temp = new Vector(); while (params1.hasMoreElements()) { temp.add(params1.nextElement()); } while (params2.hasMoreElements()) { temp.add(params2.nextElement()); } return temp.elements(); }
From source file:net.wastl.webmail.xml.XMLUserModel.java
public synchronized void clearWork() { NodeList nl = usermodel.getElementsByTagName("WORK"); if (nl.getLength() > 0) { Element work = (Element) nl.item(0); NodeList nl2 = work.getChildNodes(); Vector<Node> v = new Vector<Node>(); for (int i = 0; i < nl2.getLength(); i++) { v.addElement(nl2.item(i));//from w w w . j a va2 s.c o m } Enumeration<Node> enumVar = v.elements(); while (enumVar.hasMoreElements()) { work.removeChild(enumVar.nextElement()); } invalidateCache(); } }
From source file:org.apache.axis.handlers.soap.MustUnderstandChecker.java
public void invoke(MessageContext msgContext) throws AxisFault { // Do SOAP semantics here if (log.isDebugEnabled()) { log.debug(Messages.getMessage("semanticCheck00")); }// w ww .jav a 2s .com Message msg = msgContext.getCurrentMessage(); if (msg == null) return; // nothing to do if there's no message SOAPEnvelope env = msg.getSOAPEnvelope(); Vector headers = null; if (service != null) { ArrayList acts = service.getActors(); headers = env.getHeadersByActor(acts); } else { headers = env.getHeaders(); } // 1. Check mustUnderstands Vector misunderstoodHeaders = null; Enumeration enumeration = headers.elements(); while (enumeration.hasMoreElements()) { SOAPHeaderElement header = (SOAPHeaderElement) enumeration.nextElement(); // Ignore header, if it is a parameter to the operation if (msgContext != null && msgContext.getOperation() != null) { OperationDesc oper = msgContext.getOperation(); if (oper.getParamByQName(header.getQName()) != null) { continue; } } if (header.getMustUnderstand() && !header.isProcessed()) { if (misunderstoodHeaders == null) misunderstoodHeaders = new Vector(); misunderstoodHeaders.addElement(header); } } SOAPConstants soapConstants = msgContext.getSOAPConstants(); // !!! we should indicate SOAP1.2 compliance via the // MessageContext, not a boolean here.... if (misunderstoodHeaders != null) { AxisFault fault = new AxisFault(soapConstants.getMustunderstandFaultQName(), null, null, null, null, null); StringBuffer whatWasMissUnderstood = new StringBuffer(256); enumeration = misunderstoodHeaders.elements(); while (enumeration.hasMoreElements()) { SOAPHeaderElement badHeader = (SOAPHeaderElement) enumeration.nextElement(); QName badQName = new QName(badHeader.getNamespaceURI(), badHeader.getName()); if (whatWasMissUnderstood.length() != 0) whatWasMissUnderstood.append(", "); whatWasMissUnderstood.append(badQName.toString()); // !!! If SOAP 1.2, insert misunderstood fault headers here if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) { SOAPHeaderElement newHeader = new SOAPHeaderElement(Constants.URI_SOAP12_ENV, Constants.ELEM_NOTUNDERSTOOD); newHeader.addAttribute(null, Constants.ATTR_QNAME, badQName); fault.addHeader(newHeader); } } fault.setFaultString(Messages.getMessage("noUnderstand00", whatWasMissUnderstood.toString())); throw fault; } }
From source file:net.wastl.webmail.xml.XMLMessagePart.java
public Enumeration<XMLMessagePart> getParts() { // Sucking NodeList needs a Vector to store Elements that will be removed! Vector<XMLMessagePart> v = new Vector<XMLMessagePart>(); NodeList parts = part.getChildNodes(); for (int j = 0; j < parts.getLength(); j++) { Element elem = (Element) parts.item(j); if (elem.getTagName().equals("PART")) v.addElement(new XMLMessagePart(elem)); }/*w ww .ja va 2 s .co m*/ return v.elements(); }
From source file:org.twdata.pkgscanner.InternalScanner.java
Collection<ExportPackage> findInUrls(Test test, URL... urls) { // ExportPackageListBuilder weans out duplicates with some smarts final ExportPackageListBuilder exportPackageListBuilder = new ExportPackageListBuilder(); final Vector<URL> list = new Vector<URL>(Arrays.asList(urls)); for (final ExportPackage export : findInPackageWithUrls(test, "", list.elements())) { exportPackageListBuilder.add(export); }//from www .j a v a 2 s. c o m // returns the packages sorted by name return exportPackageListBuilder.getPackageList(); }
From source file:net.officefloor.plugin.servlet.container.ServletConfirmer.java
@Override @SuppressWarnings("unchecked") protected synchronized void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try {/*www.j a v a2 s .c om*/ // Ensure method recorded TestCase.assertTrue("No method recorded", this.invocations.size() > 0); // Iterate over the methods for invocation for (RecordedMethodInvocation invocation : this.invocations) { // Obtain the parameter types Class<?>[] parameterTypes = new Class[invocation.arguments.length]; for (int i = 0; i < parameterTypes.length; i++) { parameterTypes[i] = invocation.arguments[i].getClass(); } // Obtain the method Method method = req.getClass().getMethod(invocation.method.getName(), parameterTypes); // Invoke the method to obtain as last result Object result = method.invoke(req, invocation.arguments); // Take copy of enumeration (stop concurrent access) if (result instanceof Enumeration) { Enumeration<Object> enumeration = (Enumeration<Object>) result; Vector<Object> vector = new Vector<Object>(); while (enumeration.hasMoreElements()) { vector.add(enumeration.nextElement()); } result = vector.elements(); } // Provide the result this.lastResult = result; } } catch (Exception ex) { throw new ServletException(ex); } }
From source file:org.apache.axiom.om.util.ElementHelperTest.java
public void testGetTextAsStreamWithoutCaching() throws Exception { XMLInputFactory factory = XMLInputFactory.newInstance(); if (factory.getClass().getName().equals("com.bea.xml.stream.MXParserFactory")) { // Skip the test on the StAX reference implementation because it // causes an out of memory error return;// w ww.j a v a2 s. c o m } DataSource ds = new RandomDataSource(654321, 64, 128, 20000000); Vector/*<InputStream>*/ v = new Vector/*<InputStream>*/(); v.add(new ByteArrayInputStream("<a>".getBytes("ascii"))); v.add(ds.getInputStream()); v.add(new ByteArrayInputStream("</a>".getBytes("ascii"))); factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); XMLStreamReader reader = factory.createXMLStreamReader(new SequenceInputStream(v.elements()), "ascii"); OMElement element = new StAXOMBuilder(reader).getDocumentElement(); Reader in = ElementHelper.getTextAsStream(element, false); IOTestUtils.compareStreams(new InputStreamReader(ds.getInputStream(), "ascii"), in); }