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:Main.java

/**
 * Get child elements by classname//from w ww.  j  a  v a  2s  .  c  o m
 *
 * @param ele parent element
 * @param cname of elements to find
 */
public static List<Element> getElementsByClass(Element ele, String cname) {
    Vector<Element> list = new Vector();
    NodeList nl = ele.getChildNodes();
    for (int j = 0; j < nl.getLength(); j++) {
        if (nl.item(j).getNodeType() != Node.ELEMENT_NODE)
            continue;
        Element e = (Element) nl.item(j);
        if (e.getAttribute("class").equals(cname))
            list.add(e);
    }
    return (list);
}

From source file:Main.java

public static Vector getSubSection(Vector a_vecInput, int a_iFromIndex, int a_iToIndex)
/*     */ {/*w w  w  .ja  v a 2 s  . c  o m*/
    /* 169 */Vector vecReturn = new Vector();
    /* 170 */for (int i = 0; i < a_iToIndex; i++)
    /*     */ {
        /* 172 */if (i >= a_vecInput.size())
        /*     */ {
            /*     */break;
            /*     */}
        /*     */
        /* 177 */if (i < a_iFromIndex)
            /*     */continue;
        /* 179 */vecReturn.add(a_vecInput.elementAt(i));
        /*     */}
    /*     */
    /* 182 */return vecReturn;
    /*     */}

From source file:com.ery.ertc.estorm.util.DNS.java

/**
 * Returns all the host names associated by the provided nameserver with the address bound to the specified network interface
 * //from  ww w. j  a va2  s . c  o m
 * @param strInterface
 *            The name of the network interface or subinterface to query (e.g. eth0 or eth0:0) or the string "default"
 * @param nameserver
 *            The DNS host name
 * @return A string vector of all host names associated with the IPs tied to the specified interface
 * @throws UnknownHostException
 */
public static String[] getHosts(String strInterface, String nameserver) throws UnknownHostException {
    String[] ips = getIPs(strInterface);
    Vector<String> hosts = new Vector<String>();
    for (int ctr = 0; ctr < ips.length; ctr++)
        try {
            hosts.add(reverseDns(InetAddress.getByName(ips[ctr]), nameserver));
        } catch (Exception e) {
        }

    if (hosts.size() == 0)
        return new String[] { InetAddress.getLocalHost().getCanonicalHostName() };
    else
        return hosts.toArray(new String[] {});
}

From source file:Main.java

public static Vector<Element> getChildElemsByName(String name, Node parent) {
    Vector<Element> v = new Vector<Element>();
    Element E = null;/*from  ww w .  java 2s.c om*/
    for (Node childNode = parent.getFirstChild(); childNode != null; childNode = childNode.getNextSibling()) {
        if (childNode.getNodeType() == Node.ELEMENT_NODE) {
            if (childNode.getNodeName() == name) {
                E = (Element) childNode;
                v.add(E);
            }
        }
    }
    return v;
}

From source file:Main.java

public static Document removeFromRootElement(Document document, String nodeName, String attributeName,
        String attributeValue) {//from w  w  w  .j  a va 2 s.  com
    try {
        Element rootElement = document.getDocumentElement();

        NodeList nl = document.getElementsByTagName(nodeName);
        Vector<Node> deletedNodes = new Vector<Node>();

        for (int i = 0; i < nl.getLength(); i++) {
            Node node = nl.item(i);
            String noteAttributeValue = node.getAttributes().getNamedItem(attributeName).getNodeValue();

            if (noteAttributeValue.equals(attributeValue)) {
                deletedNodes.add(node);
            }

        }

        for (Node deletedNode : deletedNodes) {
            rootElement.removeChild(deletedNode);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return document;
}

From source file:CreateNewTable.java

private static Vector getDataTypes(Connection con) throws SQLException {
    String structName = null, distinctName = null, javaName = null;

    // create a vector of class DataType initialized with
    // the SQL code, the SQL type name, and two null entries
    // for the local type name and the creation parameter(s)

    Vector dataTypes = new Vector();
    dataTypes.add(new DataType(java.sql.Types.BIT, "BIT"));
    dataTypes.add(new DataType(java.sql.Types.TINYINT, "TINYINT"));
    dataTypes.add(new DataType(java.sql.Types.SMALLINT, "SMALLINT"));
    dataTypes.add(new DataType(java.sql.Types.INTEGER, "INTEGER"));
    dataTypes.add(new DataType(java.sql.Types.BIGINT, "BIGINT"));
    dataTypes.add(new DataType(java.sql.Types.FLOAT, "FLOAT"));
    dataTypes.add(new DataType(java.sql.Types.REAL, "REAL"));
    dataTypes.add(new DataType(java.sql.Types.DOUBLE, "DOUBLE"));
    dataTypes.add(new DataType(java.sql.Types.NUMERIC, "NUMERIC"));
    dataTypes.add(new DataType(java.sql.Types.DECIMAL, "DECIMAL"));
    dataTypes.add(new DataType(java.sql.Types.CHAR, "CHAR"));
    dataTypes.add(new DataType(java.sql.Types.VARCHAR, "VARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARCHAR, "LONGVARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.DATE, "DATE"));
    dataTypes.add(new DataType(java.sql.Types.TIME, "TIME"));
    dataTypes.add(new DataType(java.sql.Types.TIMESTAMP, "TIMESTAMP"));
    dataTypes.add(new DataType(java.sql.Types.BINARY, "BINARY"));
    dataTypes.add(new DataType(java.sql.Types.VARBINARY, "VARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARBINARY, "LONGVARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.NULL, "NULL"));
    dataTypes.add(new DataType(java.sql.Types.OTHER, "OTHER"));
    dataTypes.add(new DataType(java.sql.Types.BLOB, "BLOB"));
    dataTypes.add(new DataType(java.sql.Types.CLOB, "CLOB"));

    DatabaseMetaData dbmd = con.getMetaData();
    ResultSet rs = dbmd.getTypeInfo();
    while (rs.next()) {
        int codeNumber = rs.getInt("DATA_TYPE");
        String dbmsName = rs.getString("TYPE_NAME");
        String createParams = rs.getString("CREATE_PARAMS");

        if (codeNumber == Types.STRUCT && structName == null)
            structName = dbmsName;/*from  ww  w . j a v a2 s  . com*/
        else if (codeNumber == Types.DISTINCT && distinctName == null)
            distinctName = dbmsName;
        else if (codeNumber == Types.JAVA_OBJECT && javaName == null)
            javaName = dbmsName;
        else {
            for (int i = 0; i < dataTypes.size(); i++) {
                // find entry that matches the SQL code, 
                // and if local type and params are not already set,
                // set them
                DataType type = (DataType) dataTypes.get(i);
                if (type.getCode() == codeNumber) {
                    type.setLocalTypeAndParams(dbmsName, createParams);
                }
            }
        }
    }

    int[] types = { Types.STRUCT, Types.DISTINCT, Types.JAVA_OBJECT };
    rs = dbmd.getUDTs(null, "%", "%", types);
    while (rs.next()) {
        String typeName = null;
        DataType dataType = null;

        if (dbmd.isCatalogAtStart())
            typeName = rs.getString(1) + dbmd.getCatalogSeparator() + rs.getString(2) + "." + rs.getString(3);
        else
            typeName = rs.getString(2) + "." + rs.getString(3) + dbmd.getCatalogSeparator() + rs.getString(1);

        switch (rs.getInt(5)) {
        case Types.STRUCT:
            dataType = new DataType(Types.STRUCT, typeName);
            dataType.setLocalTypeAndParams(structName, null);
            break;
        case Types.DISTINCT:
            dataType = new DataType(Types.DISTINCT, typeName);
            dataType.setLocalTypeAndParams(distinctName, null);
            break;
        case Types.JAVA_OBJECT:
            dataType = new DataType(Types.JAVA_OBJECT, typeName);
            dataType.setLocalTypeAndParams(javaName, null);
            break;
        }
        dataTypes.add(dataType);
    }

    return dataTypes;
}

From source file:Main.java

public static Vector<Element> getChildElemsByName(final String name, final Node parent) {
    Vector<Element> v = new Vector<Element>();
    Element elem = null;//from   w  w  w  . j  a v  a  2 s . c  o  m
    for (Node childNode = parent.getFirstChild(); childNode != null; childNode = childNode.getNextSibling()) {
        if (childNode.getNodeType() == Node.ELEMENT_NODE) {
            if (childNode.getNodeName() == name) {
                elem = (Element) childNode;
                v.add(elem);
            }
        }
    }
    return v;
}

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

/**
 * Create a chart representing an arbitrary collection of name/value pairs. 
 * The data is passed in as a hashtable where the key is the name and the  
 * value is the number items. //from w  w  w . j  a  va 2s .  c  o m
 */
public static final JFreeChart getBarChart(Hashtable<String, Integer> data, String title, String nameLabel,
        String valueLabel) {
    JFreeChart chart = null;

    // Sort the data by name
    Vector<String> names = new Vector<String>();
    Enumeration nameList = data.keys();
    while (nameList.hasMoreElements()) {
        names.add((String) nameList.nextElement());
    }
    Collections.sort(names);

    // Populate the dataset with data
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Iterator keyIter = names.iterator();
    while (keyIter.hasNext()) {
        String name = (String) keyIter.next();
        Integer value = data.get(name);
        dataset.addValue(value, valueLabel, name);
    }

    // Create the chart
    chart = ChartFactory.createBarChart(title, /*title*/
            nameLabel, /*categoryAxisLabel*/
            valueLabel, /*valueAxisLabel*/
            dataset, /*dataset*/
            PlotOrientation.VERTICAL, /*orientation*/
            false, /*legend*/
            false, /*tooltips*/
            false /*urls*/
    );

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

    // Set the chart colors
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    final GradientPaint gp = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue);
    renderer.setSeriesPaint(0, gp);

    // Set the label orientation
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    return chart;
}

From source file:com.subgraph.vega.internal.http.proxy.ssl.CertificateCreator.java

private static CertificateExtensions getCertificateExtensions(PublicKey pubKey, PublicKey caPubKey)
        throws IOException {
    CertificateExtensions ext = new CertificateExtensions();

    ext.set(SubjectKeyIdentifierExtension.NAME,
            new SubjectKeyIdentifierExtension(new KeyIdentifier(pubKey).getIdentifier()));

    ext.set(AuthorityKeyIdentifierExtension.NAME,
            new AuthorityKeyIdentifierExtension(new KeyIdentifier(caPubKey), null, null));

    // Basic Constraints
    ext.set(BasicConstraintsExtension.NAME,
            new BasicConstraintsExtension(/* isCritical */true, /* isCA */false, /* pathLen */5));

    // Netscape Cert Type Extension
    boolean[] ncteOk = new boolean[8];
    ncteOk[0] = true; // SSL_CLIENT
    ncteOk[1] = true; // SSL_SERVER
    NetscapeCertTypeExtension ncte = new NetscapeCertTypeExtension(ncteOk);
    ncte = new NetscapeCertTypeExtension(false, ncte.getExtensionValue());
    ext.set(NetscapeCertTypeExtension.NAME, ncte);

    // Key Usage Extension
    boolean[] kueOk = new boolean[9];
    kueOk[0] = true;/*from ww  w. jav  a  2 s. c o  m*/
    kueOk[2] = true;
    // "digitalSignature", // (0),
    // "nonRepudiation", // (1)
    // "keyEncipherment", // (2),
    // "dataEncipherment", // (3),
    // "keyAgreement", // (4),
    // "keyCertSign", // (5),
    // "cRLSign", // (6),
    // "encipherOnly", // (7),
    // "decipherOnly", // (8)
    // "contentCommitment" // also (1)
    KeyUsageExtension kue = new KeyUsageExtension(kueOk);
    ext.set(KeyUsageExtension.NAME, kue);

    // Extended Key Usage Extension
    int[] serverAuthOidData = { 1, 3, 6, 1, 5, 5, 7, 3, 1 };
    ObjectIdentifier serverAuthOid = new ObjectIdentifier(serverAuthOidData);
    int[] clientAuthOidData = { 1, 3, 6, 1, 5, 5, 7, 3, 2 };
    ObjectIdentifier clientAuthOid = new ObjectIdentifier(clientAuthOidData);
    Vector<ObjectIdentifier> v = new Vector<ObjectIdentifier>();
    v.add(serverAuthOid);
    v.add(clientAuthOid);
    ExtendedKeyUsageExtension ekue = new ExtendedKeyUsageExtension(false, v);
    ext.set(ExtendedKeyUsageExtension.NAME, ekue);

    return ext;
}

From source file:Main.java

@SuppressWarnings("unchecked")
public final static Vector subElementList(Element superEle, String subName) {
    Vector v = new Vector();
    NodeList list = superEle.getChildNodes();
    if (list == null) {
        return null;
    }/*ww w .jav a 2  s  .  c  o m*/

    for (int i = 0; i < list.getLength(); i++) {
        Node node = list.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            if (node.getNodeName().equals(subName)) {
                v.add(node);
            }
        }
    }
    return v;
}