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:org.apache.axis2.wsdl.util.WSDL4JImportedWSDLHelper.java

/**
 * The intention of this procedure is to process the imports. When
 * processing the imports the imported documents will be populating the
 * items in the main document recursivley
 *
 * @param wsdl4JDefinition/*from w  w  w  . j a v a  2 s.  c o m*/
 */
public static void processImports(Definition wsdl4JDefinition, List processedDocuments) {

    Map wsdlImports = wsdl4JDefinition.getImports();

    if (null != wsdlImports && !wsdlImports.isEmpty()) {
        Collection importsCollection = wsdlImports.values();
        for (Iterator iterator = importsCollection.iterator(); iterator.hasNext();) {
            Vector values = (Vector) iterator.next();
            for (int i = 0; i < values.size(); i++) {
                Import wsdlImport = (Import) values.elementAt(i);

                if (wsdlImport.getDefinition() != null) {
                    Definition importedDef = wsdlImport.getDefinition();

                    if (importedDef != null) {
                        String key = importedDef.getDocumentBaseURI();
                        if (key == null) {
                            key = importedDef.getTargetNamespace();
                        }
                        // stop recursive imports!
                        if (processedDocuments.contains(key)) {
                            return;
                        }
                        processedDocuments.add(key);

                        processImports(importedDef, processedDocuments);

                        // copy ns
                        Map namespaces = importedDef.getNamespaces();
                        Iterator keys = namespaces.keySet().iterator();
                        while (keys.hasNext()) {
                            Object key2 = keys.next();
                            if (!wsdl4JDefinition.getNamespaces().containsValue(namespaces.get(key2))) {
                                wsdl4JDefinition.getNamespaces().put(key2, namespaces.get(key2));
                            }
                        }

                        wsdl4JDefinition.getNamespaces().putAll(namespaces);
                        // copy types
                        Types t = importedDef.getTypes();
                        if (t != null) {
                            List typesList = t.getExtensibilityElements();
                            for (int j = 0; j < typesList.size(); j++) {
                                Types types = wsdl4JDefinition.getTypes();
                                if (types == null) {
                                    types = wsdl4JDefinition.createTypes();
                                    wsdl4JDefinition.setTypes(types);
                                }
                                types.addExtensibilityElement((ExtensibilityElement) typesList.get(j));

                            }
                        }

                        // add messages
                        Map messagesMap = importedDef.getMessages();
                        wsdl4JDefinition.getMessages().putAll(messagesMap);

                        // add portypes
                        Map porttypeMap = importedDef.getPortTypes();
                        wsdl4JDefinition.getPortTypes().putAll(porttypeMap);

                        // add bindings
                        Map bindingMap = importedDef.getBindings();
                        wsdl4JDefinition.getBindings().putAll(bindingMap);

                        // add services
                        Map serviceMap = importedDef.getServices();
                        wsdl4JDefinition.getServices().putAll(serviceMap);

                        List extElementList = importedDef.getExtensibilityElements();
                        wsdl4JDefinition.getExtensibilityElements().addAll(extElementList);

                    }

                }
            }
        }
    }
}

From source file:ManagerQuery.java

/***************************************************************************
 * Format the Vector of Strings returned by the get*List() methods into a
 * single String. A simple formatting method.
 **************************************************************************/
public static String formatVectorStrings(Vector vec, String leading, int count, String separator) {
    String str = leading;/*from  w  w  w.j a va 2s  . c  om*/

    for (int i = 0; i < vec.size(); i++) {
        str = str + (String) vec.elementAt(i);
        if ((i + 1) == vec.size())
            str = str + "\n";
        else if ((i + 1) % count == 0)
            str = str + "\n" + leading;
        else
            str = str + separator;
    }
    return str;
}

From source file:Main.java

private static String getXPathFromVector(Vector path) {
    StringBuffer strBuf = new StringBuffer();
    int length = path.size();

    for (int i = 0; i < length; i++) {
        Node tempNode = (Node) path.elementAt(i);
        short nodeType = getNodeType(tempNode);
        String targetValue = getValue(tempNode, nodeType);
        int position = 1;

        tempNode = getPreviousTypedNode(tempNode, nodeType);

        while (tempNode != null) {
            if (nodeType == Node.ELEMENT_NODE) {
                if (getValue(tempNode, nodeType).equals(targetValue)) {
                    position++;/*from  w  ww.ja  va 2s.  co m*/
                }
            } else {
                position++;
            }

            tempNode = getPreviousTypedNode(tempNode, nodeType);
        }

        boolean hasMatchingSiblings = (position > 1);

        if (!hasMatchingSiblings) {
            tempNode = (Node) path.elementAt(i);
            tempNode = getNextTypedNode(tempNode, nodeType);

            while (!hasMatchingSiblings && tempNode != null) {
                if (nodeType == Node.ELEMENT_NODE) {
                    if (getValue(tempNode, nodeType).equals(targetValue)) {
                        hasMatchingSiblings = true;
                    } else {
                        tempNode = getNextTypedNode(tempNode, nodeType);
                    }
                } else {
                    hasMatchingSiblings = true;
                }
            }
        }

        String step;

        switch (nodeType) {
        case Node.TEXT_NODE:
            step = "text()";
            break;
        case Node.PROCESSING_INSTRUCTION_NODE:
            step = "processing-instruction()";
            break;
        default:
            step = targetValue;
            break;
        }

        if (step != null && step.length() > 0) {
            strBuf.append('/' + step);
        }

        if (hasMatchingSiblings) {
            strBuf.append("[" + position + "]");
        }
    }

    return strBuf.toString();
}

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

/**
 * Returns proxy name. //  ww w  . j  a va 2 s.  co m
 *
 * @deprecated Only works for Globus legacy proxies.
 */
public static int checkProxyName(X509Cert cert) {
    int rs = -1;
    DistinguishedName subject = dupName(cert.getSubjectName());
    Vector subjectDN = subject.getName();
    Vector lastAva = (Vector) subjectDN.elementAt(subjectDN.size() - 1);
    String[] ava = (String[]) lastAva.elementAt(0);

    if (ava[0].equalsIgnoreCase("CN")) {
        if (ava[1].equalsIgnoreCase("proxy")) {
            rs = GSIConstants.GSI_2_PROXY;
        } else if (ava[1].equalsIgnoreCase("limited proxy")) {
            rs = GSIConstants.GSI_2_LIMITED_PROXY;
        }

        if (rs != -1) {
            Vector nameDN = dupName(cert.getIssuerName()).getName();
            nameDN.addElement(lastAva);
            X509Name newName = new X509Name(nameDN);

            return (Arrays.equals(subject.getNameDER(), newName.getNameDER())) ? rs : -1;
        }
    }

    return rs;
}

From source file:Main.java

private static String[] filter(String[] p_array, boolean p_includeComments) {
    String[] result = p_array;/*  w w  w  .  j a va  2  s  . co  m*/
    if (!p_includeComments) {
        Vector v = new Vector();
        for (int i = 0; i < p_array.length; i++) {
            String s = p_array[i];
            if (s.indexOf("<!--") < 0) {
                v.addElement(s);
            }
        }
        result = new String[v.size()];
        for (int i = 0; i < v.size(); i++) {
            result[i] = (String) v.elementAt(i);
        }
    }
    return result;
}

From source file:Main.java

/**
 * Method getDropDownOptions./*from ww  w .j  a  va 2  s.  c o m*/
 *
 * @param vector         Vector
 * @param valueGetter    String
 * @param textGetter     String
 * @param selectedValues Vector
 * @return String
 * @throws NoSuchMethodException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 */
public static String getDropDownOptions(Vector vector, String valueGetter, String textGetter,
        Vector selectedValues) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    Hashtable selectedValuesHashtable = new Hashtable(selectedValues.size());

    for (int i = 0; i < selectedValues.size(); i++) {
        selectedValuesHashtable.put(selectedValues.elementAt(i).toString(), "");

    }

    StringBuffer dropDownOptions = new StringBuffer("");
    String optionValue = null;
    String optionText = null;
    Class[] clsParms = new Class[0];
    Object[] objParms = new Object[0];
    Method getterMethod = null;

    Object vectorElement = null;

    for (int i = 0; i < vector.size(); i++) {
        vectorElement = vector.elementAt(i);
        getterMethod = vectorElement.getClass().getMethod(valueGetter, clsParms);
        optionValue = getterMethod.invoke(vectorElement, objParms).toString();
        getterMethod = vectorElement.getClass().getMethod(textGetter, clsParms);
        optionText = getterMethod.invoke(vectorElement, objParms).toString();

        dropDownOptions.append("<option value=\"" + optionValue + "\"");

        if (selectedValuesHashtable.containsKey(optionValue)) {
            dropDownOptions.append(" selected");
        }

        dropDownOptions.append(">" + optionText);
    }

    return dropDownOptions.toString();
}

From source file:lambertmrev.conversions.java

public static CartesianOrbit hyp2ele(double[] hyp, Vector<Tracklet> subSet, constraints set,
        TopocentricFrame staF, Frame inertialFrame, TimeScale utc) {
    int N = subSet.size();
    AbsoluteDate year = new AbsoluteDate(Main.YEAR, utc);
    double tof = FastMath.abs(subSet.elementAt(0).getDOY() - subSet.elementAt(N - 1).getDOY()) * 24 * 3600;

    //        System.out.println("RA\t:" + subSet.elementAt(0).getRA() + "\tDEC:\t" + subSet.elementAt(0).getDEC() + "\thyp:\t" + hyp[0]);

    Vector3D geoPos1 = conversions.radec2geo(subSet.elementAt(0), hyp[0], staF, inertialFrame, utc);
    Vector3D geoPos2 = conversions.radec2geo(subSet.elementAt(N - 1), hyp[1], staF, inertialFrame, utc);

    //        System.out.println("x1:\t" + geoPos1.getX() + "\ty1:\t" + geoPos1.getY() + "\tz1:\t" + geoPos1.getZ());

    // define epoch of first tracklet
    AbsoluteDate epoch0 = new AbsoluteDate(year, subSet.elementAt(0).getDOY() * 24 * 3600);

    // perform lambert solver
    Lambert solve = new Lambert();
    solve.lambert_problem(geoPos1, geoPos2, tof, Constants.EIGEN5C_EARTH_MU, Boolean.FALSE, 1);
    RealMatrix v1 = solve.get_v1();//from ww w.j av a2 s.com

    // get the orbital elements at epoch 0
    Vector3D v1vec = new Vector3D(v1.getEntry(0, 0), v1.getEntry(0, 1), v1.getEntry(0, 2));
    PVCoordinates PVgeo1 = new PVCoordinates(geoPos1, v1vec);
    CartesianOrbit orbit = new CartesianOrbit(PVgeo1, inertialFrame, epoch0, Constants.EIGEN5C_EARTH_MU);

    //        System.out.println("a:\t" + orbit.getA() + "\ti:\t" + orbit.getI() + "\te:\t" + orbit.getE());
    return orbit;
}

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

/**
 * Returns the base name of a proxy. Strips all
 * "cn=proxy" or "cn=limited proxy" components.
 *
 * @deprecated Only works with Globus legacy proxies.
 *//*from  w  w  w . j av  a  2  s  .co  m*/
public static X509Name getBase(DistinguishedName name) {
    X509Name nm = dupName(name);
    Vector dn = nm.getName();
    int len = dn.size();
    for (int i = len - 1; i >= 0; i--) {
        Vector rdn = (Vector) dn.elementAt(i);
        // checks only first ava entry
        String[] ava = (String[]) rdn.elementAt(0);
        if (ava[0].equalsIgnoreCase("CN")
                && (ava[1].equalsIgnoreCase("proxy") || ava[1].equalsIgnoreCase("limited proxy"))) {
            dn.removeElementAt(i);
        } else {
            break;
        }
    }
    return new X509Name(dn);
}

From source file:FileUtil.java

public static boolean hasDuplicates(Vector v) {
    int i = 0;//ww w. j av  a  2s.c o m
    int j = 0;
    boolean duplicates = false;

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

        }

    }

    return duplicates;
}

From source file:org.ecoinformatics.seek.ecogrid.DocumentType.java

/**
 * Static method to transform a vector to document type array
 * //from   w w  w  .  ja va2s  .  com
 * @param list
 *            Vector
 * @return DocumentType[]
 */
public static DocumentType[] tranformVectorToArray(Vector list) {
    if (list == null) {
        return null;
    }
    int size = list.size();
    DocumentType[] array = new DocumentType[size];
    for (int i = 0; i < size; i++) {
        array[i] = (DocumentType) list.elementAt(i);
    }
    return array;
}