Example usage for java.util Vector add

List of usage examples for java.util Vector add

Introduction

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

Prototype

public synchronized boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this Vector.

Usage

From source file:be.e_contract.mycarenet.sts.WSSecuritySOAPHandler.java

private void handleOutboundMessage(SOAPMessageContext context) throws WSSecurityException {
    LOG.debug("adding WS-Security header");
    SOAPMessage soapMessage = context.getMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    WSSecHeader wsSecHeader = new WSSecHeader();
    wsSecHeader.insertSecurityHeader(soapPart);

    WSSecTimestamp wsSecTimeStamp = new WSSecTimestamp();
    wsSecTimeStamp.setTimeToLive(60);/*from www.  ja  va2  s .  c  o  m*/
    wsSecTimeStamp.build(soapPart, wsSecHeader);

    WSSecurityCrypto crypto = new WSSecurityCrypto(this.privateKey, this.certificate);
    WSSConfig wssConfig = new WSSConfig();
    wssConfig.setWsiBSPCompliant(false);
    WSSecSignature sign = new WSSecSignature(wssConfig);
    sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
    sign.prepare(soapPart, crypto, wsSecHeader);
    String bstId = sign.getBSTTokenId();
    sign.appendBSTElementToHeader(wsSecHeader);
    Vector<WSEncryptionPart> signParts = new Vector<WSEncryptionPart>();
    SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(soapPart.getDocumentElement());
    signParts.add(new WSEncryptionPart(soapConstants.getBodyQName().getLocalPart(),
            soapConstants.getEnvelopeURI(), "Content"));
    signParts.add(new WSEncryptionPart(bstId));
    signParts.add(new WSEncryptionPart(wsSecTimeStamp.getId()));
    List<Reference> referenceList = sign.addReferencesToSign(signParts, wsSecHeader);
    sign.computeSignature(referenceList, false, null);
}

From source file:gsn.vsensor.TestStreamExporterVirtualSensor.java

public void testLogStatementIntoMySQLDB() {
    StreamExporterVirtualSensor vs = new StreamExporterVirtualSensor();
    // configure parameters
    ArrayList<KeyValue> params = new ArrayList<KeyValue>();
    params.add(new KeyValueImp(StreamExporterVirtualSensor.PARAM_URL, url));
    params.add(new KeyValueImp(StreamExporterVirtualSensor.PARAM_USER, user));
    params.add(new KeyValueImp(StreamExporterVirtualSensor.PARAM_PASSWD, passwd));
    config.setMainClassInitialParams(params);
    vs.setVirtualSensorConfiguration(config);
    vs.initialize();/*from  w w  w .  jav  a  2s  .  co  m*/

    // configure datastream
    Vector<DataField> fieldTypes = new Vector<DataField>();
    Object[] data = null;

    for (String type : DataTypes.TYPE_NAMES)
        fieldTypes.add(new DataField(type, type, type));
    int i = 0;
    for (Object value : DataTypes.TYPE_SAMPLE_VALUES)
        data[i++] = value;

    long timeStamp = new Date().getTime();
    StreamElement streamElement = new StreamElement(fieldTypes.toArray(new DataField[] {}),
            (Serializable[]) data, timeStamp);

    // give datastream to vs
    vs.dataAvailable(streamName, streamElement);

    // clean up and control
    boolean result = true;
    try {
        DriverManager.registerDriver(new com.mysql.jdbc.Driver());
        Connection connection = DriverManager.getConnection(url, user, passwd);
        Statement statement = connection.createStatement();
        statement.execute("SELECT * FROM " + streamName);
        System.out.println("result" + result);
        result = statement.getResultSet().last();
        System.out.println("result" + result);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        result = false;
    }
    assertTrue(result);
}

From source file:api.v2.LabdooClient.java

/**
 * Call user.login//w ww  .  ja va 2  s .c  om
 * 
 * @param username
 *            user name
 * @param password
 *            password
 * @return Map with details of login user (response.get("user")) and login
 *         session-name and session-id that are used internally to construct
 *         the Cookie used by following calls.
 * @throws Exception
 *             if operation fail
 */
// TODO clean comments
public Map login(String username, String password) throws Exception {
    Vector<Object> params = new Vector<Object>();
    params.add(username);
    params.add(password);
    Map response = (Map) client.execute(METHOD_USER_LOGIN, params);

    cookie = response.get("session_name") + "=" + response.get("sessid");
    XmlRpcTransportFactory factory = new XmlRpcSunHttpTransportFactory(client) {
        public XmlRpcTransport getTransport() {
            return new XmlRpcSunHttpTransport(client) {
                @Override
                protected void initHttpHeaders(XmlRpcRequest request) throws XmlRpcClientException {
                    super.initHttpHeaders(request);
                    setRequestHeader("Cookie", cookie);
                }
            };
        }
    };
    client.setTransportFactory(factory);

    return response;
}

From source file:gsn.http.ac.ParameterSet.java

Vector getValuesForParam(String paramname, HttpServletRequest req) {
    String values[] = req.getParameterValues(paramname);
    Vector vector = new Vector();
    if (values != null) {
        for (int i = 0; i < values.length; i++) {
            vector.add(values[i]);
        }// w  w w .  j a  va 2  s  . c  o m
    }
    return vector;

}

From source file:de.unibayreuth.bayeos.goat.table.MassenTableModel.java

public boolean load(ObjektNode objekt, TimeFilter tFilter, StatusFilter sFilter) {
    try {//from w  w  w . j a v a 2  s.  com

        Vector params = new Vector();
        params.add(objekt.getId());
        params.add(tFilter.getVector());
        params.add(sFilter.getVector());
        Vector vReturn = (Vector) xmlClient.execute("MassenTableHandler.getRows", params);
        // Rows als byte[]
        byte[] ba = (byte[]) vReturn.elementAt(1);

        statusList = new ArrayByteList(ba.length / rowLength);
        vonList = new ArrayIntList(ba.length / rowLength);
        wertList = new ArrayDoubleList(ba.length / rowLength);

        ByteBuffer b = ByteBuffer.wrap(ba);
        while (b.hasRemaining()) {
            vonList.add(b.getInt());
            wertList.add((double) b.getFloat());
            statusList.add(b.get());
        }
        vReturn = null;
        logger.debug("MassenTableModel filled with " + getRowCount() + " records.");
        return true;
    } catch (XmlRpcException e) {
        MsgBox.error(e.getMessage());
        return false;
    }
}

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

@Before
public void setup() {
    OperationNameHolder.remove();//  w ww .ja  v a2s  .c  o  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:com.ripariandata.timberwolf.conf4j.ConfigFileParserTest.java

License:asdf

private Configuration mockConfiguration(final Object... settings) {
    if ((settings.length % 2) != 0) {
        return null;
    }//w w w  .  ja va  2 s.c  om

    Configuration config = mock(Configuration.class);

    Vector<String> keys = new Vector<String>();
    for (int i = 0; i < settings.length; i += 2) {
        String key = settings[i].toString();
        keys.add(key);
        when(config.getProperty(key)).thenReturn(settings[i + 1]);
    }
    when(config.getKeys()).thenReturn(keys.iterator());

    return config;
}

From source file:com.bluexml.xforms.controller.alfresco.agents.SystemAgent.java

/**
 * /*from   ww w .java  2  s .  co  m*/
 * @param node
 * @param propertyName
 * @return
 */
public String getNodeProperty(AlfrescoTransaction transaction, NodeRef node, QName propertyName) {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("serviceName", "NodeService");
    parameters.put("methodName", "getProperty");
    Vector<Object> paramList = new Vector<Object>();
    // add parameters to the method in paramList
    paramList.add(node);
    paramList.add(propertyName);
    parameters.put("methodParams", xstream.toXML(paramList));
    String result;
    try {
        result = (String) xstream
                .fromXML(controller.requestString(transaction, parameters, MsgId.INT_WEBSCRIPT_OPCODE_SERVICE));
    } catch (ServletException e) {
        e.printStackTrace();
        return null;
    }
    return result;
}

From source file:com.bluexml.xforms.controller.alfresco.agents.SystemAgent.java

/**
 * /*w  ww .j  av a 2  s  . co m*/
 * @param userName
 * @return
 */
public NodeRef getNodeRefForUser(AlfrescoTransaction transaction, String userName) {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("serviceName", "AuthorityDAO");
    parameters.put("methodName", "getAuthorityNodeRefOrNull");
    Vector<Object> paramList = new Vector<Object>();
    // add parameters to the method in paramList
    paramList.add(userName);
    parameters.put("methodParams", xstream.toXML(paramList));
    NodeRef result;
    try {
        String resultStr = controller.requestString(transaction, parameters,
                MsgId.INT_WEBSCRIPT_OPCODE_SERVICE);
        result = (NodeRef) xstream.fromXML(resultStr);
    } catch (ServletException e) {
        e.printStackTrace();
        return null;
    }
    return result;
}

From source file:de.unibayreuth.bayeos.goat.table.MassenTableModel.java

public boolean updateRow(ObjektNode objektNode, int row, Vector values) {
    boolean bol = false;
    try {//from w w  w  .jav  a2s . co  m

        // get update columns
        java.util.Date new_von = (java.util.Date) values.elementAt(0);
        Double wert = (Double) values.elementAt(1);
        Integer status = (Integer) values.elementAt(2);

        java.util.Date old_von = (java.util.Date) getValueAt(row, 0);

        Vector params = new Vector();
        params.add(objektNode.getId());
        params.add(old_von);
        params.add(status);
        params.add(wert);
        params.add(new_von);

        bol = ((Boolean) xmlClient.execute("MassenTableHandler.updateRow", params)).booleanValue();

        // Update display values 
        setValueAt(new_von, row, 0);
        setValueAt(wert, row, 1);
        setValueAt(new Byte(status.byteValue()), row, 2);
        fireTableDataChanged();

    } catch (XmlRpcException x) {
        MsgBox.error(x.getMessage());
        return false;
    }

    return bol;
}