Example usage for java.util Vector elementAt

List of usage examples for java.util Vector elementAt

Introduction

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

Prototype

public synchronized E elementAt(int index) 

Source Link

Document

Returns the component at the specified index.

Usage

From source file:Main.java

/**
 * Returns an array containing the element objects in the provided node list.
 * /*  w w  w. j  a  va2  s. c om*/
 * @param nodeList The DOM node objects to extract elements from.
 * @return The array of DOM elements found in the node list.
 */
@SuppressWarnings("unchecked")
public static Element[] getElementsOfNodeList(NodeList nodeList) {
    Element[] ret = null;
    @SuppressWarnings("rawtypes")
    Vector v = new Vector();

    for (int n = 0; n < nodeList.getLength(); n++) {
        Node item = nodeList.item(n);

        if (item.getNodeType() == Node.ELEMENT_NODE) {
            v.addElement(item);
        }
    }

    ret = new Element[v.size()];

    for (int n = 0; n < ret.length; n++) {
        ret[n] = (Element) v.elementAt(n);
    }

    return ret;
}

From source file:Main.java

static public Element[] findChildElements(Node first, Node last, String name) {
    Vector v = new Vector();
    while (first != last) {
        if (first.getNodeType() == Node.ELEMENT_NODE) {
            if (first.getNodeName().equals(name))
                v.addElement(first);/*  www . j  a  v a  2 s  . c om*/
        }
        first = first.getNextSibling();
    }
    Element array[] = new Element[v.size()];
    for (int i = 0; i < array.length; ++i) {
        array[i] = (Element) v.elementAt(i);
    }
    return array;
}

From source file:Main.java

public static Vector getSubSection(Vector a_vecInput, int a_iFromIndex, int a_iToIndex)
/*     */ {//ww  w.j a  v a 2 s. c om
    /* 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:org.globus.gsi.ptls.PureTLSUtil.java

/**
 * Returns the Globus formatted representation of the
 * subject DN of the specified DN.//ww  w  .j  a va 2 s  .  com
 *
 * @param subject the DN
 * @return the Globus formatted representation of the 
 *         subject DN.
 */
public static String toGlobusID(DistinguishedName subject) {
    Vector dn = subject.getName();
    int len = dn.size();
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < len; i++) {
        Vector rdn = (Vector) dn.elementAt(i);
        // checks only first ava entry
        String[] ava = (String[]) rdn.elementAt(0);
        buf.append('/').append(ava[0]).append('=').append(ava[1]);
    }
    return buf.toString();
}

From source file:FileUtil.java

public static boolean areVectorsEqual(Vector a, Vector b) {
    if (a.size() != b.size()) {
        return false;
    }//  ww w . j a  v a  2s .c  o m

    int i = 0;
    int vectorSize = a.size();
    boolean identical = true;

    for (i = 0; i < vectorSize; i++) {
        if (!(a.elementAt(i).toString().equalsIgnoreCase(b.elementAt(i).toString()))) {
            identical = false;
        }
    }

    return identical;
}

From source file:Main.java

/**
 * Method getHashMapFromVector.//from  w  w  w  . j  a v a  2s.c  o  m
 * @param vector Vector
 * @param keyGetter String
 * @return HashMap
 * @throws NoSuchMethodException
 * @throws Exception
 * @throws IllegalAccessException
 */
public static HashMap getHashMapFromVector(Vector vector, String keyGetter)
        throws NoSuchMethodException, Exception, IllegalAccessException {
    HashMap hashMap = new HashMap(vector.size());

    Object vectorElement = null;
    Object keyObject = null;
    Method keyGetterMethod = null;
    Class[] clsParms = new Class[0];
    Object[] objParms = new Object[0];

    for (int i = 0; i < vector.size(); i++) {
        vectorElement = vector.elementAt(i);

        if (vectorElement != null) {
            keyGetterMethod = vectorElement.getClass().getMethod(keyGetter, clsParms);
            keyObject = keyGetterMethod.invoke(vectorElement, objParms);
        } else {
            keyObject = null;
        }

        hashMap.put(keyObject, vectorElement);
    }

    return hashMap;
}

From source file:FileUtil.java

public static Vector removeDuplicates(Vector a, Vector b) {

    int i = 0;/* w w w. ja v  a 2s .  c  o  m*/
    int j = 0;
    boolean present = true;
    Vector v = new Vector();

    for (i = 0; i < a.size(); i++) {
        present = false;
        for (j = 0; j < b.size(); j++) {
            if (a.elementAt(i).toString().equalsIgnoreCase(b.elementAt(j).toString())) {
                present = true;
            }
        }
        if (!(present)) {
            v.addElement(a.elementAt(i));
        }
    }

    return v;
}

From source file:FileUtil.java

public static Vector removeDuplicates(Vector s) {
    int i = 0;//  w  w w. j a  va 2  s  .c  om
    int j = 0;
    boolean duplicates = false;

    Vector v = new Vector();

    for (i = 0; i < s.size(); i++) {
        duplicates = false;
        for (j = (i + 1); j < s.size(); j++) {
            if (s.elementAt(i).toString().equalsIgnoreCase(s.elementAt(j).toString())) {
                duplicates = true;
            }

        }
        if (duplicates == false) {
            v.addElement(s.elementAt(i).toString().trim());
        }

    }

    return v;
}

From source file:Main.java

/**
 * Method getHashtableFromVector.//from w w w .jav  a  2 s  .co  m
 * @param vector Vector
 * @param keyGetter String
 * @return Hashtable
 * @throws NoSuchMethodException
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 */
public static Hashtable getHashtableFromVector(Vector vector, String keyGetter)
        throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    Hashtable hashtable = new Hashtable(vector.size());

    Object vectorElement = null;
    Object keyObject = null;
    Method keyGetterMethod = null;
    Class[] clsParms = new Class[0];
    Object[] objParms = new Object[0];

    for (int i = 0; i < vector.size(); i++) {
        vectorElement = vector.elementAt(i);
        keyGetterMethod = vectorElement.getClass().getMethod(keyGetter, clsParms);
        keyObject = keyGetterMethod.invoke(vectorElement, objParms);

        hashtable.put(keyObject, vectorElement);
    }

    return hashtable;
}

From source file:org.globus.gsi.ptls.PureTLSUtil.java

/**
 * Converts a Vector of X509Cert objects into a standard
 * Java X509 certificate array (in the reverse order).
 *
 * @param chain the Vector of X509Cert objects to convert.
 * @return the converted X509 certificate array
 * @exception GeneralSecurityException if conversion fails.
 *///w  ww . ja  va  2  s . c om
public static X509Certificate[] certificateChainToArray(Vector chain) throws GeneralSecurityException {
    int size = chain.size();
    X509Certificate[] certs = new X509Certificate[size];
    for (int i = 0; i < size; i++) {
        certs[i] = convertCert((X509Cert) chain.elementAt(size - 1 - i));
    }
    return certs;
}