Example usage for java.util Vector get

List of usage examples for java.util Vector get

Introduction

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

Prototype

public synchronized E get(int index) 

Source Link

Document

Returns the element at the specified position in this Vector.

Usage

From source file:net.sf.ginp.commands.SelectCollection.java

/**
 *  Called when a Start tag is processed.
 *
 *@param  model   Description of the Parameter
 *@param  params  Description of the Parameter
 */// w  w w  .  ja  v a 2  s.  co  m
public final void action(final GinpModel model, final Vector params) {
    String id = "";

    for (int i = 0; i < params.size(); i++) {
        CommandParameter param = (CommandParameter) params.get(i);

        if (param.getName().equals("id")) {
            id = param.getValue();
        }
    }

    int idNum = 0;

    try {
        idNum = (new Integer(id)).intValue();
    } catch (Exception ex) {
        log.error(ex);
        idNum = 0;
    }

    if (model.setCurrectCollection(idNum)) {
        model.setCurrentPage(Configuration.getCollectionPageName());
        model.getCollection().setPath("/");
        model.setPageOffset(0);
        model.setPagePosition(0);
    }
}

From source file:corner.util.VectorUtilsTest.java

public void testSubmVectorList() {
    Vector<String> v1 = new Vector<String>();
    v1.add("1");//from w  w w  . ja  va 2s  . c  o m
    v1.add("2");

    Vector<String> v2 = new Vector<String>();
    v2.add("1");
    v2.add("2");

    List<Vector<String>> list = new ArrayList<Vector<String>>();
    list.add(v1);
    list.add(v2);
    Vector<Double> r = VectorUtils.sumList(list);
    assertTrue(2 == r.get(0));
}

From source file:eionet.gdem.web.struts.hosts.ListHostsAction.java

@Override
public ActionForward execute(ActionMapping map, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse httpServletResponse) {
    ActionErrors errors = new ActionErrors();
    List result = new ArrayList();

    try {/*ww  w.  j  ava2  s.c o  m*/
        if (checkPermission(request, Names.ACL_HOST_PATH, "v")) {
            Vector list = hostDao.getHosts(null);
            for (int i = 0; i < list.size(); i++) {
                Hashtable host = (Hashtable) list.get(i);
                HostDto h = new HostDto();
                h.setId((String) host.get("host_id"));
                h.setHostname((String) host.get("host_name"));
                h.setUsername((String) host.get("user_name"));
                result.add(h);
            }
        } else {
            errors.add(ActionMessages.GLOBAL_MESSAGE,
                    new ActionMessage("error.vnoperm", translate(map, request, "label.hosts")));
        }
    } catch (Exception e) {
        LOGGER.error("", e);
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.exception.unknown"));
    }

    if (errors.size() > 0) {
        request.getSession().setAttribute("dcm.errors", errors);
    }
    request.setAttribute("hosts.list", result);

    return map.findForward("success");

}

From source file:net.sf.ginp.commands.ShowPicture.java

/**
 *  PicCollection id (colid) and path (path) should be sent in the
 *  parameters so that the model is not out of sync with browser.
 *  This can happen due to use of the Back Button.
 *
 * @param  model   Description of the Parameter
 * @param  params  Description of the Parameter
 *///from ww w.  j  a v a2  s  . co m
public final void action(final GinpModel model, final Vector params) {
    String name = "";
    String path = null;

    for (int i = 0; i < params.size(); i++) {
        CommandParameter param = (CommandParameter) params.get(i);

        if (param.getName().equals("name")) {
            name = param.getValue();
        } else if (param.getName().equals("colid")) {
            try {
                int id = (new Integer(param.getValue())).intValue();
                model.setCurrectCollection(id);
            } catch (Exception ex) {
                log.error(ex);
            }
        } else if (param.getName().equals("path")) {
            path = param.getValue();
        }
    }

    if (path != null) {
        model.getCollection().setPath(path);
    }

    model.setCurrentPage(Configuration.getPicturePageName() + "?name=" + name);
}

From source file:com.greenpepper.repository.FileSystemRepositoryTest.java

@SuppressWarnings("unchecked")
private void assertNamesInHierarchy(Hashtable branch, List<String> names) {
    for (Object o : branch.keySet()) {
        String name = (String) o;
        Vector child = (Vector) branch.get(name);
        assertTrue(names.contains(child.get(0)));
        assertNamesInHierarchy((Hashtable) child.get(3), names);
    }//  w w w.  j  a v  a  2s . c o  m
}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.shared.interfaces.PriceChart.java

/** Parses the securities Vector into the price chart */
public void setSecurities(Vector securities) {
    for (int i = 0; i < securities.size(); i++) {
        Vector secVect = (Vector) securities.get(i);
        String name = (String) secVect.get(0);

        addSecurity(name);//from  w  ww .  ja  va  2 s  .  c  o  m
        for (int j = 1; j < secVect.size(); j++) {
            float[] point = (float[]) secVect.get(j);
            addPoint(name, point[0], point[1]);
        }
    }
}

From source file:info.novatec.testit.livingdoc.repository.FileSystemRepositoryTest.java

@SuppressWarnings("unchecked")
private void assertNamesInHierarchy(Hashtable<Object, Object> branch, List<String> names) {
    Iterator<Object> iter = branch.keySet().iterator();
    while (iter.hasNext()) {
        String name = (String) iter.next();
        Vector<Object> child = (Vector<Object>) branch.get(name);
        assertTrue(names.contains(child.get(0)));
        assertNamesInHierarchy((Hashtable<Object, Object>) child.get(3), names);
    }//from w w w . j a  va  2 s  . c o  m
}

From source file:eionet.gdem.qa.ListQAScriptsMethodTest.java

/**
 * Tests that the result of listQAScripts method contains the right data as defined in seed xml file.
 *//*  w w  w .j av  a2  s  .c  om*/
@Test
public void testListConversionsXSDResult() throws Exception {

    XQueryService qm = new XQueryService();

    Vector listQaResult = qm.listQAScripts("http://cdrtest.eionet.eu.int/xmlexports/dir9243eec/schema.xsd");
    assertTrue(listQaResult.size() == 1);
    Vector resultQuery = (Vector) listQaResult.get(0);

    assertEquals(resultQuery.get(0), String.valueOf(Constants.JOB_VALIDATION));
    assertEquals(resultQuery.get(2), "");
    assertEquals(resultQuery.get(3), String.valueOf(ListQueriesMethod.VALIDATION_UPPER_LIMIT));
}

From source file:com.bt.aloha.batchtest.v2.TestRunner.java

@SuppressWarnings("unchecked")
public ResultTotals run() {
    log.info("= Summary =============================================================");
    log.info("Number of scenario runs: " + testRunnerConfig.getNumberOfRuns());
    log.info("Number of scenario types: " + scenarioBeanNameAndWeightMap.size());
    log.info("Size of executor pool (core): " + taskExecutor.getCorePoolSize());
    log.info("Size of executor pool (max): " + taskExecutor.getMaxPoolSize());

    Vector v = (Vector) applicationContext.getBean("allScenarioLifecycleListeners");
    if (v != null && v.get(0) != null)
        log.info("Using Stack Manager of type " + v.get(0).getClass());
    log.info("=======================================================================");

    normalizeWeightsToNumberOfConcurrentStarts();
    CountDownLatch latch = new CountDownLatch(testRunnerConfig.getNumberOfRuns());
    Vector<String> sNames = new Vector<String>();
    for (String s : scenarioBeanNameAndWeightMap.keySet()) {
        Integer weight = scenarioBeanNameAndWeightMap.get(s);
        for (int run = 0; run < weight; run++) {
            sNames.add(s);//w  w w.ja v  a  2s .  c  o  m
        }
    }
    // shuffle names so that they can be executed randomly and not in a prefixed order
    Collections.shuffle(sNames, new Random(System.currentTimeMillis()));

    for (String s : sNames) {
        Scenario scenario = (Scenario) applicationContext.getBean(s);
        // it's a prototype - so has to be extracted from the app ctx every time
        ScenarioRunner sRunner = (ScenarioRunner) applicationContext.getBean("scenarioRunner");
        sRunner.setCountdownLatch(latch);
        sRunner.setScenario(scenario);
        // note that scenario lifecycle listeners (needed for start/stop stack) are set in the app context
        taskExecutor.execute(sRunner);
    }

    taskExecutor.shutdown();
    try {
        // waits for all runners to finish
        latch.await();
    } catch (InterruptedException e) {
        log.warn("Unable to wait for latch to get to 0", e);
    }
    resultLogger.logResultEntries();
    return resultLogger.logResultsSummary();
}

From source file:com.orange.atk.graphAnalyser.GraphMarker.java

/**
* Calculate marker legend position depending of the maximum legend
*//*w  ww  . j  a  v  a2 s. co m*/

public void setMarkerPosition() {
    Vector<Action> listActions = Vectaction;
    for (int i = 0; i < listActions.size(); i++) {
        Action action = listActions.get(i); //remove 
        double XvalueStart = ((double) (action.getStartTime().getTime()));
        double XvalueEnd = ((double) (action.getEndTime().getTime()));

        action.setAnnotation(XvalueStart, color);
        action.setMarker(XvalueStart, XvalueEnd, color);

    }
}