Example usage for java.util Vector elements

List of usage examples for java.util Vector elements

Introduction

In this page you can find the example usage for java.util Vector elements.

Prototype

public Enumeration<E> elements() 

Source Link

Document

Returns an enumeration of the components of this vector.

Usage

From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java

/**
 * Generate a pie graph representing test counts for each product area. 
 *
 * @param   suites   List of test suites
 * @param   areas    List of product areas 
 * //  w ww .  j  a v a  2s .  co m
 * @return  Pie graph representing build execution times across all builds 
 */
public static final JFreeChart getAverageAreaTestTimeChart(Vector<CMnDbBuildData> builds,
        Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) {
    JFreeChart chart = null;

    // Collect the average of all test types 
    Hashtable timeAvg = new Hashtable();

    DefaultPieDataset dataset = new DefaultPieDataset();
    if ((suites != null) && (suites.size() > 0)) {

        // Collect test data for each of the suites in the list 
        Enumeration suiteList = suites.elements();
        while (suiteList.hasMoreElements()) {

            // Process the data for the current suite
            CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement();
            Long elapsedTime = new Long(suite.getElapsedTime() / (1000 * 60));
            CMnDbFeatureOwnerData area = null;

            // Iterate through each product area to determine who owns this suite
            CMnDbFeatureOwnerData currentArea = null;
            Iterator iter = areas.iterator();
            while (iter.hasNext()) {
                currentArea = (CMnDbFeatureOwnerData) iter.next();
                if (currentArea.hasFeature(suite.getGroupName())) {
                    Long avgValue = null;
                    String areaName = currentArea.getDisplayName();
                    if (timeAvg.containsKey(areaName)) {
                        Long oldAvg = (Long) timeAvg.get(areaName);
                        avgValue = oldAvg + elapsedTime;
                    } else {
                        avgValue = elapsedTime;
                    }
                    timeAvg.put(areaName, avgValue);

                }
            }

        } // while list has elements

        // Populate the data set with the average values for each metric
        Enumeration keys = timeAvg.keys();
        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            Long total = (Long) timeAvg.get(key);
            Long avg = new Long(total.longValue() / builds.size());
            dataset.setValue(key, avg);
        }

    } // if list has elements

    // API: ChartFactory.createPieChart(title, data, legend, tooltips, urls)
    chart = ChartFactory.createPieChart("Avg Test Time by Area", dataset, true, true, false);

    // get a reference to the plot for further customization...
    PiePlot plot = (PiePlot) chart.getPlot();
    chartFormatter.formatAreaChart(plot, "min");

    return chart;
}

From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java

/**
 * Generate a pie graph representing test counts for each product area. 
 *
 * @param   suites   List of test suites
 * @param   areas    List of product areas 
 * /*ww  w.  j  a v  a2s. c  o  m*/
 * @return  Pie graph representing build execution times across all builds 
 */
public static final JFreeChart getAverageAreaTestCountChart(Vector<CMnDbBuildData> builds,
        Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) {
    JFreeChart chart = null;

    // Collect the average of all test types 
    Hashtable countAvg = new Hashtable();

    DefaultPieDataset dataset = new DefaultPieDataset();
    if ((suites != null) && (suites.size() > 0)) {

        // Collect test data for each of the suites in the list 
        Enumeration suiteList = suites.elements();
        while (suiteList.hasMoreElements()) {

            // Process the data for the current suite
            CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement();
            Integer testCount = new Integer(suite.getTestCount());
            CMnDbFeatureOwnerData area = null;

            // Iterate through each product area to determine who owns this suite
            CMnDbFeatureOwnerData currentArea = null;
            Iterator iter = areas.iterator();
            while (iter.hasNext()) {
                currentArea = (CMnDbFeatureOwnerData) iter.next();
                if (currentArea.hasFeature(suite.getGroupName())) {
                    Integer avgValue = null;
                    String areaName = currentArea.getDisplayName();
                    if (countAvg.containsKey(areaName)) {
                        Integer oldAvg = (Integer) countAvg.get(areaName);
                        avgValue = oldAvg + testCount;
                    } else {
                        avgValue = testCount;
                    }
                    countAvg.put(areaName, avgValue);

                }
            }

        } // while list has elements

        // Populate the data set with the average values for each metric
        Enumeration keys = countAvg.keys();
        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            Integer total = (Integer) countAvg.get(key);
            Integer avg = new Integer(total.intValue() / builds.size());
            dataset.setValue(key, avg);
        }

    } // if list has elements

    // API: ChartFactory.createPieChart(title, data, legend, tooltips, urls)
    chart = ChartFactory.createPieChart("Avg Test Count by Area", dataset, true, true, false);

    // get a reference to the plot for further customization...
    PiePlot plot = (PiePlot) chart.getPlot();
    chartFormatter.formatAreaChart(plot, "tests");

    return chart;
}

From source file:weka.attributeSelection.BiNormalSeperationEval.java

/**
 * Returns an enumeration describing the available options.
 * @return an enumeration of all the available options.
 **//*  w w w  .  java  2  s . c o  m*/
public Enumeration listOptions() {
    Vector newVector = new Vector(2);
    return newVector.elements();
}

From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java

/**
 * Generate a stacked bar graph representing build execution times across 
 * all builds in the list. // www  .  j  a va2 s . co  m
 *
 * @param   builds  List of builds 
 * 
 * @return  Stacked graph representing build execution times across all builds 
 */
public static final JFreeChart getMetricChart(Vector<CMnDbBuildData> builds) {
    JFreeChart chart = null;

    // Get a list of all possible build metrics
    int[] metricTypes = CMnDbMetricData.getAllTypes();

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    if ((builds != null) && (builds.size() > 0)) {

        // Collect build metrics for each of the builds in the list 
        Collections.sort(builds, new CMnBuildIdComparator());
        Enumeration buildList = builds.elements();
        while (buildList.hasMoreElements()) {

            // Process the build metrics for the current build
            CMnDbBuildData build = (CMnDbBuildData) buildList.nextElement();
            Vector metrics = build.getMetrics();
            if ((metrics != null) && (metrics.size() > 0)) {
                // Sort the list of metrics to ensure they are displayed on the chart in a sensible order
                Collections.sort(metrics, new CMnMetricDateComparator());

                // Collect data for each of the build metrics in the current build 
                Enumeration metricList = metrics.elements();
                while (metricList.hasMoreElements()) {
                    CMnDbMetricData currentMetric = (CMnDbMetricData) metricList.nextElement();
                    // Get elapsed time in "minutes"
                    Long elapsedTime = new Long(currentMetric.getElapsedTime() / (1000 * 60));
                    Integer buildId = new Integer(build.getId());
                    String metricName = CMnDbMetricData.getMetricType(currentMetric.getType());
                    dataset.addValue(elapsedTime, metricName, buildId);

                } // while build has metrics

            } // if has metrics

        } // while list has elements

    } // if list has elements

    // API: ChartFactory.createStackedBarChart(title, domainAxisLabel, rangeAxisLabel, dataset, orientation, legend, tooltips, urls)
    chart = ChartFactory.createStackedBarChart("Build Metrics", "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.formatMetricChart(plot, dataset);

    return chart;
}

From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java

/**
 * Generate a pie graph representing average build execution times across 
 * all builds in the list. // ww w.j  a  va2 s  .  c  o m
 *
 * @param   builds  List of builds 
 * 
 * @return  Pie graph representing build execution times across all builds 
 */
public static final JFreeChart getAverageMetricChart(Vector<CMnDbBuildData> builds) {
    JFreeChart chart = null;

    // Get a list of all possible build metrics
    int[] metricTypes = CMnDbMetricData.getAllTypes();
    Hashtable metricAvg = new Hashtable(metricTypes.length);

    DefaultPieDataset dataset = new DefaultPieDataset();
    if ((builds != null) && (builds.size() > 0)) {

        // Collect build metrics for each of the builds in the list 
        Enumeration buildList = builds.elements();
        while (buildList.hasMoreElements()) {

            // Process the build metrics for the current build
            CMnDbBuildData build = (CMnDbBuildData) buildList.nextElement();
            Vector metrics = build.getMetrics();
            if ((metrics != null) && (metrics.size() > 0)) {
                // Collect data for each of the build metrics in the current build 
                Enumeration metricList = metrics.elements();
                while (metricList.hasMoreElements()) {
                    CMnDbMetricData currentMetric = (CMnDbMetricData) metricList.nextElement();
                    // Get elapsed time in "minutes"
                    Long elapsedTime = new Long(currentMetric.getElapsedTime() / (1000 * 60));
                    String metricName = CMnDbMetricData.getMetricType(currentMetric.getType());
                    Long avgValue = null;
                    if (metricAvg.containsKey(metricName)) {
                        Long oldAvg = (Long) metricAvg.get(metricName);
                        avgValue = oldAvg + elapsedTime;
                    } else {
                        avgValue = elapsedTime;
                    }
                    metricAvg.put(metricName, avgValue);

                } // while build has metrics

            } // if has metrics

        } // while list has elements

        // Populate the data set with the average values for each metric
        Enumeration keys = metricAvg.keys();
        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            Long total = (Long) metricAvg.get(key);
            Long avg = new Long(total.longValue() / (long) builds.size());
            //dataset.setValue(key, (Long) metricAvg.get(key));
            dataset.setValue(key, avg);
        }

    } // if list has elements

    // API: ChartFactory.createPieChart(title, data, legend, tooltips, urls)
    chart = ChartFactory.createPieChart("Average Build Metrics", dataset, true, true, false);

    // get a reference to the plot for further customization...
    PiePlot plot = (PiePlot) chart.getPlot();
    chartFormatter.formatMetricChart(plot, "min");

    return chart;
}

From source file:com.redhat.rhn.frontend.servlets.test.CreateRedirectURITest.java

/**
 *
 *///w  w w .j a  va2 s .c  o m
public final void testExecuteWhenRequestHasParams() throws Exception {
    String paramName = "foo";
    String paramValue = "param value = bar#$%!";

    String expected = "/YourRhn.do?foo=" + URLEncoder.encode(paramValue, "UTF-8") + "&";

    Vector<String> paramNames = new Vector<String>();
    paramNames.add(paramName);

    mockRequest.stubs().method("getParameterNames").will(returnValue(paramNames.elements()));
    mockRequest.stubs().method("getParameter").with(eq(paramName)).will(returnValue(paramValue));

    CreateRedirectURI command = new CreateRedirectURI();
    String redirectURI = command.execute(getMockRequest());

    assertEquals(expected, redirectURI);
}

From source file:com.wxxr.nirvana.json.StrutsMockHttpServletRequest.java

public Enumeration getAttributeNames() {
    Vector v = new Vector();
    v.addAll(attributes.keySet());//from   w  w  w. ja  va  2  s .  com

    return v.elements();
}

From source file:jnode.net.NetworkInterface.java

/**
 * Returns all available addresses of the network interface
 * /*from w w  w.  ja  v a 2 s. com*/
 * If a
 * 
 * @see SecurityManager is available all addresses are checked with
 * @see SecurityManager::checkConnect() if they are available. Only
 *      InetAddresses are returned where the security manager doesn't
 *      thrown an exception.
 * 
 * @return An enumeration of all addresses.
 */
@SuppressWarnings("unchecked")
public Enumeration getInetAddresses() {
    log.debug("getInetAddresses");
    // @vm-specific
    final Vector list = new Vector(VMNetUtils.getAPI().getInetAddresses(device));
    return list.elements();
}

From source file:org.skyscreamer.nevado.jms.NevadoConnectionMetaData.java

public Enumeration getJMSXPropertyNames() throws JMSException {
    List<JMSXProperty> propertyList = JMSXProperty.getSupportedProperties();
    Vector<String> propertyNames = new Vector<String>(propertyList.size());
    for (JMSXProperty property : propertyList) {
        propertyNames.add(property.name());
    }/*from   w  ww  .  j  av a 2 s . c o m*/
    return propertyNames.elements();
}

From source file:org.apache.webdav.lib.WebdavState.java

/**
 * Get locks//w ww.  ja  v a 2s .c  om
 *
 * @param uri Uri
 * @return Enumeration of lock tokens
 * @deprecated
 */
public Enumeration getLocks(String uri) {

    Vector result = new Vector();
    String lockToken = getLock(uri);
    if (lockToken != null)
        result.addElement(lockToken);
    return result.elements();

}