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.ecoinformatics.emltest.SaxValidateTest.java

/**
 * Test if XML documents are valid with respect to their schemas.
 *//*w ww . j a  v a  2 s .c o m*/
public void testSchemaValid() {
    SAXValidate test = new SAXValidate(true);
    assertTrue(test != null);

    File testDir = new File(TEST_DIR);
    Vector fileList = getXmlFiles(testDir);

    for (int i = 0; i < fileList.size(); i++) {
        File testFile = (File) fileList.elementAt(i);
        try {
            System.err.println("Validating file: " + testFile.getName());
            FileReader reader = new FileReader(testFile);
            String namespace = EMLParserServlet.findNamespace(reader);
            reader.close();
            test.runTest(new FileReader(testFile), namespace);
        } catch (Exception e) {
            if (e instanceof SAXParseException) {
                SAXParseException spe = (SAXParseException) e;
                System.err.println("Error on line: " + spe.getLineNumber());
            }
            e.printStackTrace(System.err);
            fail("Document NOT valid!\n\n" + e.getClass().getName() + "(" + e.getMessage() + ")");
        }
    }
}

From source file:org.eclipse.wst.xsl.xalan.debugger.XalanRootStyleFrame.java

private void fillGlobals(TracerEvent event) {
    VariableStack vs = event.m_processor.getXPathContext().getVarStack();
    StylesheetRoot sr = event.m_styleNode.getStylesheetRoot();
    Vector vars = sr.getVariablesAndParamsComposed();
    variables = new HashMap(vars.size());
    globals = new ArrayList(vars.size());
    int i = vars.size();
    while (--i >= 0) {
        ElemVariable variable = (ElemVariable) vars.elementAt(i);
        XalanVariable xvar = new XalanVariable(this, vs, Variable.GLOBAL_SCOPE, i, variable);
        addVariable(xvar);//from   ww  w.  j a v  a 2  s  . c  om
        globals.add(xvar);
    }
}

From source file:aplicacion.herramientas.conexion.ftp.test.JakartaFtpWrapper.java

/** Convert a Vector to a delimited String */
private String vectorToString(Vector v, String delim) {
    StringBuffer sb = new StringBuffer();
    String s = "";
    for (int i = 0; i < v.size(); i++) {
        sb.append(s).append((String) v.elementAt(i));
        s = delim;//  ww  w.  j a v  a2 s.  c  om
    }
    return sb.toString();
}

From source file:hermes.browser.model.PropertySetTableModel.java

public List getProperties() throws JAXBException {
    List list = new ArrayList();

    for (Iterator iter = rows.iterator(); iter.hasNext();) {
        Vector row = (Vector) iter.next();

        String key = (String) row.elementAt(0);
        String value = (String) row.elementAt(1);

        if (key != null && !key.equals("")) {
            PropertyConfig pConfig = HermesBrowser.getConfigDAO().getFactory().createPropertyConfig();

            pConfig.setName(key);//  w  w w  .  j a v  a  2 s. co  m
            pConfig.setValue(value);

            list.add(pConfig);
        } else {
            iter.remove();
        }
    }

    return list;
}

From source file:hermes.browser.model.PropertySetTableModel.java

public void setBean(Object bean)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    beanProperties = new TreeMap(BeanUtils.describe(bean));

    for (Iterator iter = ignore.iterator(); iter.hasNext();) {
        beanProperties.remove((iter.next()));
    }//w w  w .  jav a 2 s  . c o m

    for (Iterator iter = rows.iterator(); iter.hasNext();) {
        Vector row = (Vector) iter.next();

        String propertyName = (String) row.elementAt(0);

        if (propertyName == null || propertyName.equals("") || !isValidProperty(propertyName)) {
            log.debug(
                    propertyName + " is not a valid property for " + bean.getClass().getName() + " - removed");

            iter.remove();
        }
    }

    fireTableDataChanged();
}

From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedAAView.java

private void refreshDataset() {
    Vector<StringInt> artists = _analysis.getMostPlayedArtists();
    _artistDataset.clear();/*from w ww.java 2s.  c o m*/
    for (int i = 0; i < artists.size(); i++) {
        StringInt artist = artists.elementAt(i);
        _artistDataset.addValue(artist.IntVal, Misc.getString("ARTISTS"), artist.StringVal);
    }

    Vector<StringInt> albums = _analysis.getMostPlayedAlbums();
    _albumDataset.clear();
    for (int i = 0; i < albums.size(); i++) {
        StringInt album = albums.elementAt(i);
        _albumDataset.addValue(album.IntVal, Misc.getString("ALBUMS"),
                album.StringVal.replace(Album.Separator, " " + Misc.getString("BY") + " "));
    }
}

From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedDGView.java

private void refreshDataset() {

    Vector<StringInt> decades = _analysis.getMostPlayedDecades();
    _decadeDataset.clear();//  w  ww.j  av a  2s  .c  o  m
    for (int i = 0; i < decades.size(); i++) {
        StringInt decade = decades.elementAt(i);
        _decadeDataset.addValue(decade.IntVal, Misc.getString("DECADE"), decade.StringVal);
    }

    Vector<StringInt> genres = _analysis.getMostPlayedGenres();
    _genreDataset.clear();
    for (int i = 0; i < genres.size(); i++) {
        StringInt genre = genres.elementAt(i);
        _genreDataset.addValue(genre.IntVal, Misc.getString("ARTISTS"), genre.StringVal);
    }
}

From source file:FileUtil.java

public void vectorToFile(Vector v, String fileName) {
    for (int i = 0; i < v.size(); i++) {
        writeToFile(fileName, (String) v.elementAt(i), true, true);
    }/*from   w  w  w .  j av a2s.  co  m*/
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectIdentifiersListener.java

@Override
public void handleEvent(Event event) {
    //write in a new file
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".columns.tmp");
    try {//from  ww  w  . j  a  va2  s. co m
        Vector<String> subjectIds = this.setSubjectsIdUI.getSubjectIds();
        for (String s : subjectIds) {
            if (s.compareTo("") == 0) {
                this.setSubjectsIdUI.displayMessage("Subjects identifier columns have to be choosen");
                return;
            }
        }

        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n");

        //subject identifier
        Vector<File> rawFiles = ((ClinicalData) this.dataType).getRawFiles();
        for (int i = 0; i < rawFiles.size(); i++) {
            int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), subjectIds.elementAt(i));
            if (columnNumber != -1) {
                out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tSUBJ_ID\t\t\n");
            }
        }
        if (((ClinicalData) this.dataType).getCMF() == null) {
            out.close();
            File fileDest = new File(this.dataType.getPath().toString() + File.separator
                    + this.dataType.getStudy().toString() + ".columns");
            FileUtils.moveFile(file, fileDest);
            ((ClinicalData) this.dataType).setCMF(fileDest);
            WorkPart.updateSteps();
        } else {
            try {
                BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF()));
                String line = br.readLine();
                while ((line = br.readLine()) != null) {
                    String[] s = line.split("\t", -1);
                    if (s[3].compareTo("SUBJ_ID") != 0) {
                        out.write(line + "\n");
                    }
                }
                br.close();
            } catch (Exception e) {
                this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage());
                e.printStackTrace();
                out.close();
            }
            out.close();
            try {
                String fileName = ((ClinicalData) this.dataType).getCMF().getName();
                ((ClinicalData) this.dataType).getCMF().delete();
                File fileDest = new File(this.dataType.getPath() + File.separator + fileName);
                FileUtils.moveFile(file, fileDest);
                ((ClinicalData) this.dataType).setCMF(fileDest);
            } catch (IOException ioe) {
                this.setSubjectsIdUI.displayMessage("File errorrror: " + ioe.getLocalizedMessage());
                return;
            }

        }
    } catch (Exception e) {
        this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setSubjectsIdUI.displayMessage("Column mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
    UsedFilesPart.sendFilesChanged(dataType);
}

From source file:org.apache.tomcat.util.IntrospectionUtils.java

public static String[] findVoidSetters(Class c) {
    Method m[] = findMethods(c);//  w w  w .  j a va  2  s .com
    if (m == null)
        return null;
    Vector v = new Vector();
    for (int i = 0; i < m.length; i++) {
        if (m[i].getName().startsWith("set") && m[i].getParameterTypes().length == 0) {
            String arg = m[i].getName().substring(3);
            v.addElement(unCapitalize(arg));
        }
    }
    String s[] = new String[v.size()];
    for (int i = 0; i < s.length; i++) {
        s[i] = (String) v.elementAt(i);
    }
    return s;
}