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:org.wyona.yanel.servlet.communication.HttpRequest.java

/**
 * Gets the field names of all file upload fields.
 * @return enumeration of field names// w w w  .  j  av  a  2s  . com
 */
public Enumeration getFileNames() {
    if (!isMultipartRequest()) {
        return null;
    }
    Vector parameterNames = new Vector();
    Iterator iter = this.items.iterator();
    while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();
        if (!item.isFormField()) {
            parameterNames.addElement(item.getFieldName());
        }
    }
    return parameterNames.elements();
}

From source file:org.apache.solr.servlet.SolrRequestParserTest.java

License:asdf

@Test
public void testAddHttpRequestToContext() throws Exception {
    HttpServletRequest request = getMock("/solr/select", null, -1);
    expect(request.getMethod()).andReturn("GET").anyTimes();
    expect(request.getQueryString()).andReturn("q=title:solr").anyTimes();
    Map<String, String> headers = new HashMap<>();
    headers.put("X-Forwarded-For", "10.0.0.1");
    expect(request.getHeaderNames()).andReturn(new Vector<>(headers.keySet()).elements()).anyTimes();
    for (Map.Entry<String, String> entry : headers.entrySet()) {
        Vector<String> v = new Vector<>();
        v.add(entry.getValue());// w  w w.  j av a 2  s  .c o  m
        expect(request.getHeaders(entry.getKey())).andReturn(v.elements()).anyTimes();
    }
    replay(request);

    SolrRequestParsers parsers = new SolrRequestParsers(h.getCore().getSolrConfig());
    assertFalse(parsers.isAddRequestHeadersToContext());
    SolrQueryRequest solrReq = parsers.parse(h.getCore(), "/select", request);
    assertFalse(solrReq.getContext().containsKey("httpRequest"));

    parsers.setAddRequestHeadersToContext(true);
    solrReq = parsers.parse(h.getCore(), "/select", request);
    assertEquals(request, solrReq.getContext().get("httpRequest"));
    assertEquals("10.0.0.1", ((HttpServletRequest) solrReq.getContext().get("httpRequest"))
            .getHeaders("X-Forwarded-For").nextElement());

}

From source file:net.cellcloud.http.CrossOriginHttpServletRequest.java

@Override
public Enumeration<String> getParameterNames() {
    if (null == this.parameters) {
        return null;
    }/*from w  w w  . j  a v  a 2s.  co m*/

    String[] names = JSONObject.getNames(this.parameters);
    Vector<String> list = new Vector<String>();
    for (String n : names) {
        list.add(n);
    }
    return list.elements();
}

From source file:com.monarchapis.driver.analytics.MonarchV1AnalyticsHandlerTest.java

@Before
public void setup() {
    OperationNameHolder.remove();//ww w  .  ja  v  a  2  s . co  m
    ErrorHolder.remove();
    ClaimsHolder.remove();
    objectData = null;

    Reference reference = new Reference();
    reference.setId("test");
    reference.setName("test");
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setService(Optional.of(reference));
    serviceInfo.setProvider(Optional.of(reference));
    when(serviceInfoResolver.getServiceInfo(anyString())).thenReturn(serviceInfo);

    final Vector<String> headerNames = new Vector<String>();
    headerNames.add("test1");
    headerNames.add("test2");
    when(request.getRequestURI()).thenReturn("/test");
    when(request.getHeaderNames()).thenAnswer(new Answer<Enumeration<String>>() {
        @Override
        public Enumeration<String> answer(InvocationOnMock invocation) throws Throwable {
            return headerNames.elements();
        }
    });
    when(request.getHeader("test1")).thenReturn("value1");
    when(request.getHeader("test2")).thenReturn("value2");

    when(analyticsApi.getEventsResource()).thenReturn(eventsResource);

    doAnswer(new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            MonarchV1AnalyticsHandlerTest.this.objectData = invocation.getArgumentAt(1, ObjectData.class);
            return null;
        }
    }).when(eventsResource).collectEvent(anyString(), any(ObjectData.class));
}

From source file:fr.inrialpes.exmo.align.cli.WGroupEval.java

public void printTRIANGLE(Vector<Vector<Object>> result, PrintStream writer) {
    // variables for computing iterative harmonic means
    double expected = 0.; // expected so far
    double foundVect[]; // found so far
    double correctFoundVect[]; // correct so far
    double correctExpVect[]; // correct so far
    long timeVect[]; // time so far
    foundVect = new double[size];
    correctFoundVect = new double[size];
    correctExpVect = new double[size];
    timeVect = new long[size];
    for (int k = size - 1; k >= 0; k--) {
        foundVect[k] = 0.;//from   w  w  w .j a v a  2  s . com
        correctFoundVect[k] = 0.;
        correctExpVect[k] = 0.;
        timeVect[k] = 0;
    }
    for (Vector<Object> test : result) {
        double newexpected = -1.;
        Enumeration<Object> f = test.elements();
        // Too bad the first element must be skipped
        f.nextElement();
        for (int k = 0; f.hasMoreElements(); k++) {
            WeightedPREvaluator eval = (WeightedPREvaluator) f.nextElement();
            if (eval != null) {
                // iterative H-means computation
                if (newexpected == -1.) {
                    newexpected = eval.getExpected();
                    expected += newexpected;
                }
                foundVect[k] += eval.getFound();
                correctFoundVect[k] += eval.getCorrectFound();
                correctExpVect[k] += eval.getCorrectExpected();
                timeVect[k] += eval.getTime();
            } else {
                correctExpVect[k] += newexpected;
            }
        }
    }
    writer.println("\\documentclass[11pt]{book}");
    writer.println();
    writer.println("\\usepackage{pgf}");
    writer.println("\\usepackage{tikz}");
    writer.println();
    writer.println("\\begin{document}");
    writer.println("\\date{today}");
    writer.println("");
    writer.println("\n%% Plot generated by GenPlot of alignapi");
    writer.println("\\begin{tikzpicture}[cap=round]");
    writer.println("% Draw grid");
    writer.println("\\draw[step=1cm,very thin,color=gray] (-0.2,-0.2) grid (10.0,9.0);");
    writer.println("\\draw[|-|] (-0,0) -- (10,0);");
    writer.println("%\\draw[dashed,very thin] (0,0) -- (5,8.66) -- (10,0);");
    writer.println("\\draw[dashed,very thin] (10,0) arc (0:60:10cm);");
    writer.println("\\draw[dashed,very thin] (0,0) arc (180:120:10cm);");

    writer.println("\\draw (0,-0.3) node {$recall$}; ");
    writer.println("\\draw (10,-0.3) node {$precision$}; ");
    //writer.println("\\draw (0,-0.3) node {0.}; ");
    //writer.println("\\draw (10,-0.3) node {1.}; ");
    writer.println("% Plots");
    int k = 0;
    for (String m : listAlgo) {
        double precision = 1. - correctFoundVect[k] / foundVect[k];
        double recall = 1. - correctExpVect[k] / expected;
        double prec2 = precision * precision;
        double a = ((prec2 - (recall * recall) + 1) / 2);
        double b = java.lang.Math.sqrt(prec2 - (a * a));
        a = a * 10;
        b = b * 10; //for printing scale 10.
        writer.println("\\draw plot[mark=+,] coordinates {(" + a + "," + b + ")};");
        writer.println("\\draw (" + (a + .01) + "," + (b + .01) + ") node[anchor=south west] {" + m + "};");
        k++;
    }
    writer.println("\\end{tikzpicture}");
    writer.println();
    writer.println("\\end{document}");
}

From source file:org.jtwig.util.render.RenderHttpServletRequest.java

@Override
public Enumeration getParameterNames() {
    Vector<String> vector = new Vector<>();
    vector.addAll(postParameters.keySet());
    vector.addAll(getParameters.keySet());
    return vector.elements();
}

From source file:com.sixt.service.framework.servicetest.mockservice.MockHttpServletRequest.java

@Override
public Enumeration<String> getHeaderNames() {
    Vector<String> retval = new Vector<>();
    for (String line : headers) {
        int index = line.indexOf(':');
        if (index != -1) {
            retval.add(line.substring(0, index).trim());
        }/*from ww  w  . j  ava  2  s  . c om*/
    }
    return retval.elements();
}

From source file:be.fedict.commons.eid.jca.BeIDKeyStore.java

@Override
public Enumeration<String> engineAliases() {
    LOG.debug("engineAliases");
    final Vector<String> aliases = new Vector<String>();
    aliases.add("Authentication");
    aliases.add("Signature");
    aliases.add("CA");
    aliases.add("Root");
    aliases.add("RRN");
    return aliases.elements();
}

From source file:org.unitime.timetable.model.Solution.java

public static void sendNotification(Solution uncommittedSolution, Solution committedSolution, String puid,
        boolean success, List<String> messages) {
    try {//from w w  w . j  a v a  2  s .  com
        if (ApplicationProperty.EmailNotificationSolutionCommits.isFalse())
            return; //email notification disabled

        Formats.Format<Date> sdf = Formats.getDateFormat(Formats.Pattern.DATE_TIME_STAMP);
        SolverGroup owner = (uncommittedSolution == null ? committedSolution : uncommittedSolution).getOwner();

        String subject = "Solution "
                + (committedSolution != null ? uncommittedSolution != null ? "recommitted" : "committed"
                        : "uncommitted")
                + " for " + owner.getName();

        if (!success) {
            subject = "Failed to "
                    + (committedSolution != null ? uncommittedSolution != null ? "recommit" : "commit"
                            : "uncommit")
                    + " a solution for " + owner.getName();
        }

        String mail = subject;
        mail += "\r\n";
        mail += "\r\n";
        if (messages != null && !messages.isEmpty()) {
            mail += "Message(s): ----------------- \r\n";
            for (String m : messages) {
                mail += m + "\r\n";
            }
            mail += "\r\n";
            mail += "\r\n";
        }
        if (committedSolution != null) {
            mail += "Committed solution info: -------------- \r\n";
            mail += "Created: " + sdf.format(committedSolution.getCreated()) + "\r\n";
            mail += "Owner: " + committedSolution.getOwner().getName() + "\r\n";
            if (committedSolution.getCommitDate() != null)
                mail += "Commited: " + sdf.format(committedSolution.getCommitDate()) + "\r\n";
            if (committedSolution.getNote() != null && committedSolution.getNote().trim().length() > 0)
                mail += "Note: " + committedSolution.getNote() + "\r\n";
            PropertiesInfo globalInfo = (PropertiesInfo) committedSolution.getInfo("GlobalInfo");
            Vector infos = new Vector(globalInfo.keySet());
            Collections.sort(infos, new InfoComparator());
            for (Enumeration e = infos.elements(); e.hasMoreElements();) {
                String key = (String) e.nextElement();
                String value = (String) globalInfo.getProperty(key);
                mail += key + ": " + value + "\r\n";
            }
            mail += "\r\n";
            mail += "\r\n";
        }
        if (uncommittedSolution != null) {
            mail += "Uncommitted solution info: -------------- \r\n";
            mail += "Created: " + sdf.format(uncommittedSolution.getCreated()) + "\r\n";
            mail += "Owner: " + uncommittedSolution.getOwner().getName() + "\r\n";
            if (uncommittedSolution.getNote() != null && uncommittedSolution.getNote().trim().length() > 0)
                mail += "Note: " + uncommittedSolution.getNote() + "\r\n";
            PropertiesInfo globalInfo = (PropertiesInfo) uncommittedSolution.getInfo("GlobalInfo");
            Vector infos = new Vector(globalInfo.keySet());
            Collections.sort(infos, new InfoComparator());
            for (Enumeration e = infos.elements(); e.hasMoreElements();) {
                String key = (String) e.nextElement();
                String value = (String) globalInfo.getProperty(key);
                mail += key + ": " + value + "\r\n";
            }
            mail += "\r\n";
            mail += "\r\n";
        }

        TimetableManager mgr = TimetableManager.findByExternalId(puid);

        mail += "Manager info -------------- \r\n";
        mail += "Name: " + mgr.getName() + "\r\n";
        //mail += "PUID: "+mgr.getPuid()+"\r\n";
        mail += "Email: " + mgr.getEmailAddress() + "\r\n";
        mail += "\r\n";
        mail += "Session info -------------- \r\n";
        mail += "Session Term: " + owner.getSession().getAcademicYearTerm() + "\r\n";
        mail += "Session Initiative: " + owner.getSession().getAcademicInitiative() + "\r\n";
        mail += "Departments (from solver group): \r\n";
        for (Iterator i = owner.getDepartments().iterator(); i.hasNext();) {
            Department d = (Department) i.next();
            mail += "  " + d.getLabel() + "\r\n";
        }
        mail += "\r\n";
        mail += "Application info -------------- \r\n";
        mail += "Version: " + Constants.getVersion() + " (" + Constants.getReleaseDate() + ")\r\n";
        mail += "TimeStamp: " + (new Date());

        Email email = Email.createEmail();
        email.addRecipient(mgr.getEmailAddress(), mgr.getName());
        email.addNotifyCC();
        email.setSubject("UniTime (Solution Commit): " + subject);
        email.setText(mail);
        email.send();
    } catch (Exception e) {
        sLog.error("Unable to send solution commit/uncommit notification, reason: " + e.getMessage(), e);
    }
}

From source file:net.sf.jsptest.compiler.jsp20.mock.MockHttpServletRequest.java

public Enumeration getHeaders(String name) {
    Vector vector = new Vector();
    List values = (List) headers.get(resolveHeaderName(name));
    if (values != null) {
        vector.addAll(values);//from www . ja va2s .  c  o m
    }
    return vector.elements();
}