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:edu.ucsb.nceas.metacattest.UploadIPCCDataTest.java

private void updateEML(boolean originalDataFileIncorrect) {

    // Get eml document first
    Vector list = getDocumentList();
    //If list is not empty, goes through every document by handleSingleEML method -
    //1. It will read the eml from Metacat.
    // 2. Get online URL information from eml document by DOM parser.
    // 3. Base on the URL information, this program will find the data file in
    // the direcotry which contains the srb data file.
    // 4. It will generate docid for the data file
    // 5. At last upload the download srb data file to Metacat with assigned docid.
    // 6. Modify the eml document with the new URL information (pointing to
    // knb) and new version number in eml.
    // 7.Update it to a new version in Metacat.

    if (list != null && !list.isEmpty()) {
        int size = list.size();
        for (int i = 0; i < size; i++) {
            String docid = null;// w  w  w  .j  av  a2 s  .  c  om
            try {
                docid = (String) list.elementAt(i);
                String dataId = handleSingleEML(docid, originalDataFileIncorrect);
                String message = "Successfully update eml " + docid + " with data id " + dataId;
                writeLog(log, message);
            } catch (Exception e) {
                System.err.println("Failed to handle eml document " + docid + " since " + e.getMessage());
                String message = "failed to update eml " + docid + "\n " + e.getMessage();
                writeLog(error, message);
            }
        }
    } else {
        System.err.println("There is no EML document to handle");
    }

}

From source file:edu.umd.cfar.lamp.viper.util.StringHelp.java

/**
 * Get the characters from a bracketed list that are not in brackets.
 * Returns a string if the input contains characters 
 * between brackets//  w  w  w .ja  va 2  s. c  o  m
 * such as the ... in the following:
 * <pre>
 *   ... [ foo ] ... [1.2 1.2] ... [hi] ...
 * </pre>
 * If there isn't anything outside the brackets, it returns null.
 *
 * @param line The String to check.
 * @return The text outside brackets, or <code>null</code> if there
 *    is no such text.
 */
public static String getExtraTextOutsideBrackets(String line) {
    Vector stringList = new Vector();
    boolean justEntered = false;
    int startPos = 0;

    int bracketCount = 0;
    for (int i = 0; i < line.length(); i++) {
        char c = line.charAt(i);
        if (c == '[') {
            bracketCount++;
            if (bracketCount != 0) {
                String str = line.substring(startPos, i);
                str = str.trim();
                if (str.length() > 0)
                    stringList.addElement(str);
            }
        } else if (c == ']') {
            bracketCount--;
            if (bracketCount == 0)
                justEntered = true;
        } else if (bracketCount == 0) {
            if (justEntered) {
                justEntered = false;
                startPos = i;
            }
        }
    }
    if (!justEntered) {
        String str = line.substring(startPos);
        str = str.trim();
        if (str.length() > 0)
            stringList.addElement(str);
    }
    if (stringList.size() == 0)
        return (null);
    else {
        int size = stringList.size();
        String temp = (String) stringList.elementAt(0);
        for (int i = 1; i < size; i++) {
            String temp2 = (String) stringList.elementAt(i);
            temp += ", " + temp2;
        }
        return (temp);
    }
}

From source file:gov.nih.nci.evs.reportwriter.utils.SimpleSearchUtils.java

public ResolvedConceptReferencesIteratorWrapper search(Vector<String> schemes, Vector<String> versions,
        String matchText, int searchOption, String algorithm) throws LBException {

    if (schemes == null || versions == null)
        return null;
    if (schemes.size() != versions.size())
        return null;
    if (schemes.size() == 0)
        return null;
    if (matchText == null)
        return null;
    if (searchOption != BY_CODE && searchOption != BY_NAME)
        return null;
    if (searchOption != BY_CODE && algorithm == null)
        return null;

    LexBIGService lbSvc = null;/* w  ww  .ja  v a  2s  .c  o m*/

    SearchExtension searchExtension = null;
    try {
        lbSvc = new RemoteServerUtil().createLexBIGService();

        if (lbSvc == null) {
            return null;
        }
        searchExtension = (SearchExtension) lbSvc.getGenericExtension("SearchExtension");
    } catch (Exception e) {
        _logger.warn("SearchExtension is not available.");
        return null;
    }

    Set<CodingSchemeReference> includes = new HashSet();

    for (int i = 0; i < schemes.size(); i++) {
        String scheme = (String) schemes.elementAt(i);
        String version = (String) versions.elementAt(i);
        CodingSchemeReference ref = new CodingSchemeReference();
        ref.setCodingScheme(scheme);

        if (version != null) {
            CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
            versionOrTag.setVersion(version);
        }
        includes.add(ref);
    }

    ResolvedConceptReferencesIterator iterator = null;
    try {
        iterator = searchExtension.search(matchText, includes, converToMatchAlgorithm(searchOption, algorithm));
        printNumberOfMatches(iterator);

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    if (iterator != null) {
        return new ResolvedConceptReferencesIteratorWrapper(iterator);
    }
    return null;
}

From source file:gate.annotation.AnnotationSetImpl.java

protected void fireGateEvent(GateEvent e) {
    if (gateListeners != null) {
        Vector<GateListener> listeners = gateListeners;
        int count = listeners.size();
        for (int i = 0; i < count; i++) {
            listeners.elementAt(i).processGateEvent(e);
        }/*from   ww w. j a  v  a2  s  .c o  m*/
    }
}

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

protected DocumentType[] addNewDocType(DocumentType[] currentArray, Vector newTypeVector) {
    int arraySize = currentArray.length;
    int vectorSize = newTypeVector.size();
    int newSize = arraySize + vectorSize;
    DocumentType[] newArray = new DocumentType[newSize];
    // copy the array
    for (int i = 0; i < arraySize; i++) {
        newArray[i] = currentArray[i];// w  w  w.  j  ava2s.  c  o m
    } // for
      // copy the vector
    for (int j = 0; j < vectorSize; j++) {
        newArray[arraySize + j] = (DocumentType) newTypeVector.elementAt(j);
    } // for
    return newArray;
}

From source file:gate.annotation.AnnotationSetImpl.java

protected void fireAnnotationAdded(AnnotationSetEvent e) {
    if (annotationSetListeners != null) {
        Vector<AnnotationSetListener> listeners = annotationSetListeners;
        int count = listeners.size();
        for (int i = 0; i < count; i++) {
            listeners.elementAt(i).annotationAdded(e);
        }//from w  w  w  . ja  v  a 2 s .co m
    }
}

From source file:gate.annotation.AnnotationSetImpl.java

protected void fireAnnotationRemoved(AnnotationSetEvent e) {
    if (annotationSetListeners != null) {
        Vector<AnnotationSetListener> listeners = annotationSetListeners;
        int count = listeners.size();
        for (int i = 0; i < count; i++) {
            listeners.elementAt(i).annotationRemoved(e);
        }/*from   w ww  .ja  v a 2  s. c  o  m*/
    }
}

From source file:gov.nih.nci.evs.browser.utils.SimpleSearchUtils.java

public ResolvedConceptReferencesIteratorWrapper search(Vector<String> schemes, Vector<String> versions,
        String matchText, int searchOption, String algorithm) throws LBException {
    System.out.println("search by " + matchText + ", algorithm: " + algorithm);

    if (schemes == null || versions == null)
        return null;
    if (schemes.size() != versions.size())
        return null;
    if (schemes.size() == 0)
        return null;
    if (matchText == null)
        return null;
    if (searchOption != BY_CODE && searchOption != BY_NAME)
        return null;
    if (searchOption != BY_CODE && algorithm == null)
        return null;

    LexBIGService lbSvc = new RemoteServerUtil().createLexBIGService();

    if (lbSvc == null) {
        return null;
    }//from w  w  w .  j ava  2s . com

    SearchExtension searchExtension = null;
    try {
        searchExtension = (SearchExtension) lbSvc.getGenericExtension("SearchExtension");
    } catch (Exception e) {
        _logger.warn("SearchExtension is not available.");
        return null;
    }

    Set<CodingSchemeReference> includes = new HashSet();

    for (int i = 0; i < schemes.size(); i++) {
        String scheme = (String) schemes.elementAt(i);
        String version = (String) versions.elementAt(i);
        System.out.println("\t" + scheme + " (" + version + ")");
        CodingSchemeReference ref = new CodingSchemeReference();
        ref.setCodingScheme(scheme);

        if (version != null) {
            CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
            versionOrTag.setVersion(version);
        }
        includes.add(ref);
    }

    ResolvedConceptReferencesIterator iterator = null;
    try {
        iterator = searchExtension.search(matchText, includes, converToMatchAlgorithm(searchOption, algorithm));
        printNumberOfMatches(iterator);

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    if (iterator != null) {
        return new ResolvedConceptReferencesIteratorWrapper(iterator);
    }
    return null;
}

From source file:org.apache.tomcat.util.net.puretls.PureTLSSocketFactory.java

private short[] getEnabledCiphers(short[] supportedCiphers) {

    short[] enabledCiphers = null;

    String attrValue = (String) attributes.get("ciphers");
    if (attrValue != null) {
        Vector vec = null;
        int fromIndex = 0;
        int index = attrValue.indexOf(',', fromIndex);
        while (index != -1) {
            String cipher = attrValue.substring(fromIndex, index).trim();
            int cipherValue = SSLPolicyInt.getCipherSuiteNumber(cipher);
            /*//from  w w  w .  j  a  v  a  2s.  c  om
             * Check to see if the requested cipher is among the supported
             * ciphers, i.e., may be enabled
             */
            if (cipherValue >= 0) {
                for (int i = 0; supportedCiphers != null && i < supportedCiphers.length; i++) {

                    if (cipherValue == supportedCiphers[i]) {
                        if (vec == null) {
                            vec = new Vector();
                        }
                        vec.addElement(new Integer(cipherValue));
                        break;
                    }
                }
            }
            fromIndex = index + 1;
            index = attrValue.indexOf(',', fromIndex);
        }

        if (vec != null) {
            int nCipher = vec.size();
            enabledCiphers = new short[nCipher];
            for (int i = 0; i < nCipher; i++) {
                Integer value = (Integer) vec.elementAt(i);
                enabledCiphers[i] = value.shortValue();
            }
        }
    }

    return enabledCiphers;

}

From source file:com.splicemachine.db.impl.sql.compile.TableElementList.java

/**
 * Complain if a generation clause references other generated columns. This
 * is required by the SQL Standard, part 2, section 4.14.8.
 *
 * @param fromList      The FromList in question.
 * @param baseTable  Table descriptor if this is an ALTER TABLE statement.
 * @exception StandardException      Thrown on error
 *///from   www  . j a  v a  2s . co  m
void findIllegalGenerationReferences(FromList fromList, TableDescriptor baseTable) throws StandardException {
    ArrayList generatedColumns = new ArrayList();
    HashSet names = new HashSet();
    int size = size();

    // add in existing generated columns if this is an ALTER TABLE statement
    if (baseTable != null) {
        ColumnDescriptorList cdl = baseTable.getGeneratedColumns();
        int count = cdl.size();
        for (int i = 0; i < count; i++) {
            names.add(cdl.elementAt(i).getColumnName());
        }
    }

    // find all of the generated columns
    for (int index = 0; index < size; index++) {
        ColumnDefinitionNode cdn;
        TableElementNode element = (TableElementNode) elementAt(index);

        if (!(element instanceof ColumnDefinitionNode)) {
            continue;
        }

        cdn = (ColumnDefinitionNode) element;

        if (!cdn.hasGenerationClause()) {
            continue;
        }

        generatedColumns.add(cdn);
        names.add(cdn.getColumnName());
    }

    // now look at their generation clauses to see if they reference one
    // another
    int count = generatedColumns.size();
    for (int i = 0; i < count; i++) {
        ColumnDefinitionNode cdn = (ColumnDefinitionNode) generatedColumns.get(i);
        GenerationClauseNode generationClauseNode = cdn.getGenerationClauseNode();
        Vector referencedColumns = generationClauseNode.findReferencedColumns();
        int refCount = referencedColumns.size();
        for (int j = 0; j < refCount; j++) {
            String name = ((ColumnReference) referencedColumns.elementAt(j)).getColumnName();

            if (name != null) {
                if (names.contains(name)) {
                    throw StandardException.newException(SQLState.LANG_CANT_REFERENCE_GENERATED_COLUMN,
                            cdn.getColumnName());
                }
            }
        }
    }

}