Example usage for java.util Vector elements

List of usage examples for java.util Vector elements

Introduction

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

Prototype

public Enumeration<E> elements() 

Source Link

Document

Returns an enumeration of the components of this vector.

Usage

From source file:org.apache.cocoon.servletservice.ServletServiceContext.java

public Enumeration getInitParameterNames() {
    Vector names = new Vector();

    // add all names of the parent servlet context
    Enumeration enumeration = super.getInitParameterNames();
    while (enumeration.hasMoreElements()) {
        names.add(enumeration.nextElement());
    }//from  w w w .j a  v a 2 s  . co  m

    // add names of the super servlet
    ServletContext superContext = this.getNamedContext(SUPER);
    if (superContext != null) {
        enumeration = superContext.getInitParameterNames();
        while (enumeration.hasMoreElements()) {
            names.add(enumeration.nextElement());
        }
    }

    // add property names of this servlet
    if (this.properties != null) {
        names.addAll(this.properties.keySet());
    }

    return names.elements();
}

From source file:mypackage.FeedlyAPI.java

public void untagMultipleEntries(String tagId, Vector entryIds) throws Exception {
    // Untag multiple entries
    ///*from  w ww  .j a  v  a2s .com*/
    // DELETE /v3/tags/:tagId1,tagId2/:entryId1,entryId2

    // Some info about some api - Google O?[v
    // https://groups.google.com/forum/#!searchin/feedly-cloud/tag/feedly-cloud/Py15TGUVAyA/pIn7kWwKCRoJ

    if (entryIds.size() == 0) {
        throw new Exception("FeedlyAPI::untagMultipleEntries()0");
    }

    String url = getEndpoint("/v3/tags/");

    // tagID
    url += encode(tagId);

    // Separater
    url += "/";

    // entryIds
    for (Enumeration e = entryIds.elements(); e.hasMoreElements();) {
        // URLGR?[hentryId?B
        url += encode((String) e.nextElement());

        // Separater
        if (e.hasMoreElements()) {
            url += ",";
        }
    }

    // O???Aw???s?B
    for (int i = 0; i < NUM_OF_TRIALS; i++) {
        try {
            doDelete(url);
            return;
        } catch (IOException e) {
            continue;
        } catch (Exception e) {
            continue;
        }
    }
    throw new Exception("FeedlyAPI::untagMultipleEntries()1");
}

From source file:com.github.dactiv.common.bundle.BeanResourceBundle.java

/**
 * ?bean?mapkey/* w  w w.j  ava  2  s  .c  o m*/
 */
@Override
public Enumeration<String> getKeys() {

    Vector<String> vector = new Vector<String>();
    PropertyDescriptor[] propertyDescriptors = BeanUtils.getPropertyDescriptors(bean.getClass());
    //???bean
    for (PropertyDescriptor pd : propertyDescriptors) {
        //get/set???
        if ((pd.getWriteMethod() == null) || pd.getReadMethod() == null) {
            continue;
        }

        String key = pd.getName();

        /*
         * ?map?:
         * 1.include
         * 2.?exclude
         * 3.ignoreNullValuetrue,?null
         */
        if (isIncludeProperty(key) && !isExcludeProperty(key)) {

            if (ignoreNullValue && ReflectionUtils.invokeGetterMethod(bean, key) == null) {
                continue;
            }

            vector.addElement(key);
        }
    }

    //?mapkey
    return vector.elements();
}

From source file:com.opensymphony.xwork2.util.finder.ResourceFinder.java

private Enumeration<URL> getResources(String fulluri) throws IOException {
    if (urls == null) {
        return classLoaderInterface.getResources(fulluri);
    }/*  ww w .  ja v a 2s  .  c  o m*/
    Vector<URL> resources = new Vector();
    for (URL url : urls) {
        URL resource = findResource(fulluri, url);
        if (resource != null) {
            resources.add(resource);
        }
    }
    return resources.elements();
}

From source file:JavaTron.AudioTron.java

/**
 * Tell the audiotron to play a file (same as queueFile but clears
 * the playlist first)// www .  ja v  a2s.  com
 *
 * type is the type of file to queue
 * file is the file to queue
 * @param playable A Playable Object - a file, or list
 */
public void playFile(Playable playable) {
    if (!playable.isPlayable()) {
        return;
    }

    Vector list = new Vector();
    list.addElement(playable);
    playFile(list.elements());
}

From source file:org.ecoinformatics.seek.datasource.darwincore.DarwinCoreDataSource.java

/**
 * Remove all ports by setting their container to null. As a side effect,
 * the ports will be unlinked from all relations. This method is
 * write-synchronized on the workspace, and increments its version number.
 *///from  w  w w .  j a  va  2s  .  c  om
private void removeAllOutputPortsExcept(Set l) throws IllegalActionException {
    Vector portNames = getExistingPortNames();
    for (Enumeration e = portNames.elements(); e.hasMoreElements();) {
        String currPortName = (String) e.nextElement();
        TypedIOPort port = (TypedIOPort) this.getPort(currPortName);
        if (port != null && !port.isInput() && !l.contains(currPortName)) {
            try {
                log.debug("Removing port named: " + port.getName());
                port.setContainer(null);
            } catch (Exception ex) {
                throw new IllegalActionException(this, "Error removing port: " + currPortName);
            }

        }
    }

}

From source file:weka.distributed.hadoop.HadoopJob.java

@Override
public Enumeration<Option> listOptions() {
    Vector<Option> options = new Vector<Option>();
    Enumeration<Option> confOpts = m_mrConfig.listOptions();

    options.addElement(//from  w ww. j  a  v a  2  s  .c  o m
            new Option("\tPath to the weka.jar file", "weka-jar", 1, "-weka-jar <path to weka.jar>"));

    options.addElement(new Option("\tAdditional Weka packages to use.", "weka-packages", 1,
            "-weka-packages <comma-separated list of package names>"));
    options.addElement(new Option("\tLogging interval in seconds (default = 15).", "logging-interval", 1,
            "-logging-interval <seconds>"));
    options.addElement(new Option("\tOutput debug info.", "debug", 0, "-debug"));

    while (confOpts.hasMoreElements()) {
        options.addElement(confOpts.nextElement());
    }

    return options.elements();
}

From source file:fr.inrialpes.exmo.align.cli.GroupEval.java

public void printHTML(Vector<Vector<Object>> result, PrintStream writer) {
    // variables for computing iterative harmonic means
    int expected = 0; // expected so far
    int foundVect[]; // found so far
    int correctVect[]; // correct so far
    long timeVect[]; // time so far
    Formatter formatter = new Formatter(writer);

    fsize = format.length();/*from  w w w  . j av  a  2 s .c o m*/
    // JE: the h-means computation should be put out as well
    // Print the header
    if (embedded != true)
        writer.println("<html><head></head><body>");
    writer.println("<table border='2' frame='sides' rules='groups'>");
    writer.println("<colgroup align='center' />");
    // for each algo <td spancol='2'>name</td>
    for (String m : listAlgo) {
        writer.println("<colgroup align='center' span='" + fsize + "' />");
    }
    // For each file do a
    writer.println("<thead valign='top'><tr><th>algo</th>");
    // for each algo <td spancol='2'>name</td>
    for (String m : listAlgo) {
        writer.println("<th colspan='" + fsize + "'>" + m + "</th>");
    }
    writer.println("</tr></thead><tbody><tr><td>test</td>");
    // for each algo <td>Prec.</td><td>Rec.</td>
    for (String m : listAlgo) {
        for (int i = 0; i < fsize; i++) {
            writer.print("<td>");
            if (format.charAt(i) == 'p') {
                writer.print("Prec.");
            } else if (format.charAt(i) == 'f') {
                writer.print("FMeas.");
            } else if (format.charAt(i) == 'o') {
                writer.print("Over.");
            } else if (format.charAt(i) == 't') {
                writer.print("Time");
            } else if (format.charAt(i) == 'r') {
                writer.print("Rec.");
            }
            writer.println("</td>");
        }
        //writer.println("<td>Prec.</td><td>Rec.</td>");
    }
    writer.println("</tr></tbody><tbody>");
    foundVect = new int[size];
    correctVect = new int[size];
    timeVect = new long[size];
    for (int k = size - 1; k >= 0; k--) {
        foundVect[k] = 0;
        correctVect[k] = 0;
        timeVect[k] = 0;
    }
    // </tr>
    // For each directory <tr>
    boolean colored = false;
    for (Vector<Object> test : result) {
        int nexpected = -1;
        if (colored == true && color != null) {
            colored = false;
            writer.println("<tr bgcolor=\"" + color + "\">");
        } else {
            colored = true;
            writer.println("<tr>");
        }
        ;
        // Print the directory <td>bla</td>
        writer.println("<td>" + (String) test.get(0) + "</td>");
        // For each record print the values <td>bla</td>
        Enumeration<Object> f = test.elements();
        f.nextElement();
        for (int k = 0; f.hasMoreElements(); k++) {
            PRecEvaluator eval = (PRecEvaluator) f.nextElement();
            if (eval != null) {
                // iterative H-means computation
                if (nexpected == -1) {
                    expected += eval.getExpected();
                    nexpected = 0;
                }
                foundVect[k] += eval.getFound();
                correctVect[k] += eval.getCorrect();
                timeVect[k] += eval.getTime();

                for (int i = 0; i < fsize; i++) {
                    writer.print("<td>");
                    if (format.charAt(i) == 'p') {
                        formatter.format("%1.2f", eval.getPrecision());
                    } else if (format.charAt(i) == 'f') {
                        formatter.format("%1.2f", eval.getFmeasure());
                    } else if (format.charAt(i) == 'o') {
                        formatter.format("%1.2f", eval.getOverall());
                    } else if (format.charAt(i) == 't') {
                        if (eval.getTime() == 0) {
                            writer.print("-");
                        } else {
                            formatter.format("%1.2f", eval.getTime());
                        }
                    } else if (format.charAt(i) == 'r') {
                        formatter.format("%1.2f", eval.getRecall());
                    }
                    writer.print("</td>");
                }
            } else {
                for (int i = 0; i < fsize; i++)
                    writer.print("<td>n/a</td>");
            }
        }
        writer.println("</tr>");
    }
    writer.print("<tr bgcolor=\"yellow\"><td>H-mean</td>");
    // Here we are computing a sheer average.
    // While in the column results we print NaN when the returned
    // alignment is empty,
    // here we use the real values, i.e., add 0 to both correctVect and
    // foundVect, so this is OK for computing the average.
    int k = 0;
    // ???
    for (String m : listAlgo) {
        double precision = (double) correctVect[k] / foundVect[k];
        double recall = (double) correctVect[k] / expected;
        for (int i = 0; i < fsize; i++) {
            writer.print("<td>");
            if (format.charAt(i) == 'p') {
                formatter.format("%1.2f", precision);
            } else if (format.charAt(i) == 'f') {
                formatter.format("%1.2f", 2 * precision * recall / (precision + recall));
            } else if (format.charAt(i) == 'o') {
                formatter.format("%1.2f", recall * (2 - (1 / precision)));
            } else if (format.charAt(i) == 't') {
                if (timeVect[k] == 0) {
                    writer.print("-");
                } else {
                    formatter.format("%1.2f", timeVect[k]);
                }
            } else if (format.charAt(i) == 'r') {
                formatter.format("%1.2f", recall);
            }
            writer.println("</td>");
        }
        ;
        k++;
    }
    writer.println("</tr>");
    writer.println("</tbody></table>");
    writer.println("<p><small>n/a: result alignment not provided or not readable<br />");
    writer.println("NaN: division per zero, likely due to empty alignment.</small></p>");
    if (embedded != true)
        writer.println("</body></html>");
}

From source file:com.netscape.kra.StorageKeyUnit.java

/**
 * Returns a list of recovery agent identifiers.
 *//*from   w  ww.ja va  2s  .c o m*/
public Enumeration<String> getAgentIdentifiers() {
    Vector<String> v = new Vector<String>();

    for (int i = 0;; i++) {
        try {
            String uid = mStorageConfig.getString(PROP_UID + i);

            if (uid == null)
                break;
            v.addElement(uid);
        } catch (EBaseException e) {
            break;
        }
    }
    return v.elements();
}

From source file:org.ecoinformatics.seek.datasource.darwincore.DarwinCoreDataSource.java

private void generateTable(ResultsetTypeRecord[] records) {
    _icon.setBusy();/*  ww  w.  j a v a  2 s . c  o m*/
    try {

        // Create a name for this text table which is unique.
        String resName = "DigirTable: " + getSearchData();

        // Ok, now create the table as a "string" table where each row is
        // ROWDELIM
        // and load it into the cache.
        _tableDataCache = (EcogridDataCacheItem) DataCacheManager.getCacheItem(null, resName, DATATABLE,
                EcogridDataCacheItem.class.getName());

        // now create the table entity
        _tableEntity = new Entity(_tableDataCache.getLSID().toString(), resName, "", new Boolean(true),
                Entity.COLUMNMAJOR, records.length);
        _tableEntity.setNumHeaderLines(1);
        _tableEntity.setDelimiter(COLDELIM);
        _tableEntity.setRecordDelimiter(ROWDELIM);

        DBTableNameResolver nameResolver = new DBTableNameResolver();
        try {
            _tableEntity = nameResolver.resolveTableName(_tableEntity);
        } catch (Exception e) {
        }
        String tableName = _tableEntity.getMappedName() + "";

        String tableStr = createTableFromResultset(COLDELIM, records);
        // System.err.println("*** Table[\n"+tableStr+"\n]");
        _tableDataCache.setData(tableStr.getBytes());

        DSTableIFace tableSchema = (DSTableIFace) _resultsetSchemaDef.getTables().elementAt(0);
        Vector columns = tableSchema.getFields();
        Enumeration colEnum = columns.elements();
        while (colEnum.hasMoreElements()) {
            DSTableFieldIFace colDef = (DSTableFieldIFace) colEnum.nextElement();
            org.kepler.objectmanager.data.db.Attribute attr = new org.kepler.objectmanager.data.db.Attribute(
                    colDef.getName(), colDef.getName(), colDef.getDataType());
            _tableEntity.add(attr);
        }

        _tableGenerator = new DBTablesGenerator(_tableEntity, _tableDataCache.getBaseFileName());
        _tableGenerator.run(); // don't do thread

        DSSchemaDef schema = new DSSchemaDef();
        schema.addTable(_tableEntity);
        _schemaDef = schema;
        // right here it is really hard to know if the table has already
        // been generated
        // and whether we need to set the schema for the first time or not
        // So if it is empty, then set it, if not then ignore it
        // if (_schemaAttr.getExpression().length() == 0)
        {
            String schemaDefXML = DBSchemaParserEmitter.emitXML(_schemaDef);
            _ignoreSchemaChange = true;
            _schemaAttr.setExpression(schemaDefXML);
            _ignoreSchemaChange = false;
        }

    } catch (Exception e) {
    }
    _icon.setReady();
}