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:com.pironet.tda.BeaJDKParserTest.java

/**
 * Test of hasMoreDumps method, of class com.pironet.tda.SunJDKParser.
 *//*from w  ww .j  av a 2  s. com*/
public void testDumpLoad() throws IOException {
    System.out.println("dumpLoad");
    InputStream fis = null;
    DumpParser instance = null;

    try {
        fis = getClass().getResourceAsStream("/data/jrockit_15_dump.txt");
        Map<String, Map<String, String>> dumpMap = new HashMap<>();
        Vector<MutableTreeNode> topNodes = new Vector<>();
        instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);

        assertTrue(instance instanceof BeaJDKParser);

        while (instance.hasMoreDumps()) {
            topNodes.add(instance.parseNext());
        }

        // check if three dumps are in it.
        //assertEquals(3, topNodes.size());
    } finally {
        IOUtils.closeQuietly(instance);
        IOUtils.closeQuietly(fis);
    }
}

From source file:be.fedict.trust.xkms2.WSSecurityServerHandler.java

/**
 * Handles the outbound SOAP message. Adds the WS Security Header containing
 * a signed timestamp, and signed SOAP body.
 *//*ww  w .j  a v  a 2 s .  co m*/
private void handleOutboundDocument(SOAPPart soapPart, SOAPMessageContext soapMessageContext) {

    LOG.debug("handle outbound document");
    ServletContext servletContext = (ServletContext) soapMessageContext.get(MessageContext.SERVLET_CONTEXT);
    TrustService trustService = ServiceConsumerServletContextListener.getTrustService(servletContext);
    WSSecurityConfigEntity wsSecurityConfig = trustService.getWsSecurityConfig();

    if (wsSecurityConfig.isSigning()) {
        LOG.debug("adding WS-Security SOAP header");

        try {
            PrivateKeyEntry privateKeyEntry = KeyStoreUtils.loadPrivateKeyEntry(wsSecurityConfig);
            X509Certificate certificate = (X509Certificate) privateKeyEntry.getCertificate();
            PrivateKey privateKey = privateKeyEntry.getPrivateKey();

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

            WSSecTimestamp wsSecTimeStamp = new WSSecTimestamp();
            wsSecTimeStamp.setTimeToLive(0);
            wsSecTimeStamp.build(soapPart, wsSecHeader);

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

        } catch (WSSecurityException e) {
            trustService.logAudit("WS-Security error: " + e.getMessage());
            throw new RuntimeException("WSS4J error: " + e.getMessage(), e);
        } catch (KeyStoreLoadException e) {
            trustService.logAudit("Load keystore error: " + e.getMessage());
            throw new RuntimeException("Failed to laod keystore: " + e.getMessage(), e);
        }
    }
}

From source file:com.openmeap.json.JSONObjectBuilderTest.java

public void testToJSON() throws Exception {
    RootClass root = new RootClass();
    root.setDoubleValue(Double.valueOf("3.14"));
    root.setLongValue(new Long(Long.parseLong("1000")));
    root.setIntegerValue(new Integer(Integer.parseInt("2000")));
    root.setStringValue("value");
    root.setStringArrayValue(new String[] { "value1", "value2" });
    root.setChild(new BranchClass());
    root.getChild().setTypeOne(Types.TWO);
    root.getChild().setTypeTwo(Types.ONE);
    root.getChild().setString("child_string");

    Hashtable table = new Hashtable();
    table.put("key1", "value1");
    table.put("key2", new Long(1000));
    table.put("key3", new Integer(1000));
    root.setHashTable(table);//from  w  w  w. ja  va  2s  .c  o m

    Vector vector = new Vector();
    vector.add(Long.valueOf(1));
    vector.add(Long.valueOf(2));
    vector.add(Long.valueOf(3));
    root.setVector(vector);

    JSONObjectBuilder builder = new JSONObjectBuilder();
    JSONObject jsonObj = builder.toJSON(root);
    System.out.println(jsonObj.toString());
    Assert.assertEquals(
            "{\"stringValue\":\"value\",\"vector\":[1,2,3],\"integerValue\":2000,"
                    + "\"stringArrayValue\":[\"value1\",\"value2\"],"
                    + "\"hashTable\":{\"key3\":1000,\"key2\":1000,\"key1\":\"value1\"},"
                    + "\"doubleValue\":\"3.14\",\"longValue\":1000,"
                    + "\"child\":{\"string\":\"child_string\",\"typeTwo\":\"ONE\",\"typeOne\":\"TWO\"}}",
            jsonObj.toString());
    RootClass afterRoundTrip = (RootClass) builder.fromJSON(jsonObj, new RootClass());
    Assert.assertEquals(builder.toJSON(afterRoundTrip).toString(), jsonObj.toString());
}

From source file:com.floreantpos.config.ui.AddPrinterGroupDialog.java

public void setPrinterGroup(PrinterGroup group) {
    this.printerGroup = group;
    tfName.setText(group.getName());//from w ww.  j  av  a2  s  .  c o  m

    chkDefault.setSelected(group.isIsDefault());

    Vector<Printer> selectedPrinters = new Vector<Printer>();
    for (Printer printer : printers) {
        if (printerGroup.getPrinterNames().contains(printer.getVirtualPrinter().getName())) {
            selectedPrinters.add(printer);
        }
    }
    printerList.selectItems(selectedPrinters);

}

From source file:cai.flow.packets.V7_Packet.java

@SuppressWarnings("unchecked")
public Vector getSrcASVector() {
    Vector v = new Vector((int) count, (int) count);

    for (Enumeration flowenum = flows.elements(); flowenum.hasMoreElements();)
        v.add(((V7_Flow) flowenum.nextElement()).getDataSrcAS());

    return v;//w w w . j  av  a2 s.  co m
}

From source file:cai.flow.packets.V7_Packet.java

@SuppressWarnings("unchecked")
public Vector getDstASVector() {
    Vector v = new Vector((int) count, (int) count);

    for (Enumeration flowenum = flows.elements(); flowenum.hasMoreElements();)
        v.add(((V7_Flow) flowenum.nextElement()).getDataDstAS());

    return v;/*  ww  w.j av  a  2s.  c o  m*/
}

From source file:cai.flow.packets.V7_Packet.java

@SuppressWarnings("unchecked")
public Vector getASMatrixVector() {
    Vector v = new Vector((int) count, (int) count);

    for (Enumeration flowenum = flows.elements(); flowenum.hasMoreElements();)
        v.add(((V7_Flow) flowenum.nextElement()).getDataASMatrix());

    return v;//  w  ww.j  a  va  2s .co m
}

From source file:cai.flow.packets.V7_Packet.java

@SuppressWarnings("unchecked")
public Vector getSrcNodeVector() {
    Vector v = new Vector((int) count, (int) count);

    for (Enumeration flowenum = flows.elements(); flowenum.hasMoreElements();)
        v.add(((V7_Flow) flowenum.nextElement()).getDataSrcNode());

    return v;/*from   w  w  w .jav  a  2 s.  c  o m*/
}

From source file:cai.flow.packets.V7_Packet.java

@SuppressWarnings("unchecked")
public Vector getDstNodeVector() {
    Vector v = new Vector((int) count, (int) count);

    for (Enumeration flowenum = flows.elements(); flowenum.hasMoreElements();)
        v.add(((V7_Flow) flowenum.nextElement()).getDataDstNode());

    return v;//  w ww  . ja v a 2  s . c om
}

From source file:cai.flow.packets.V7_Packet.java

@SuppressWarnings("unchecked")
public Vector getHostMatrixVector() {
    Vector v = new Vector((int) count, (int) count);

    for (Enumeration flowenum = flows.elements(); flowenum.hasMoreElements();)
        v.add(((V7_Flow) flowenum.nextElement()).getDataHostMatrix());

    return v;/* w ww.j a  va 2 s .c  o m*/
}