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.seek.ecogrid.AddServicesFromRegistrySearchAction.java

private void addSerivcesVectorToController(EcoGridServicesController controller, Vector serviceList) {
    if (controller != null) {
        if (serviceList != null) {
            int size = serviceList.size();
            for (int i = 0; i < size; i++) {
                EcoGridService service = (EcoGridService) serviceList.elementAt(i);
                try {
                    controller.addService(service);
                } catch (Exception ee) {
                    log.debug("The error adding service is ", ee);
                }/*from www  .  j ava2s.  c  o m*/
            } // for
        } // if
    } // if
}

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

private void refreshDataset() {
    // get the most common wong words, up to 25 of them
    Vector pairs = _analysis.getMostCommonWords();

    // Collections.sort(pairs, new CommonWordComparator());

    for (int i = 0; i < pairs.size(); i++) {
        WordCounterMemory.CommonWord item = (WordCounterMemory.CommonWord) pairs.elementAt(i);

        _dataset.addValue(item.Count, Misc.getString("WORD"), item.Word);
    }/*from   w  ww.ja v  a  2s .  c o  m*/
}

From source file:zoocen.world.java

public double getDifusion(Cell j, int specie) {
    Vector<DifusionStruct> Difusion_Rate = j.getDifusionRate(specie);
    double difusion = 0;
    try {/*from w  ww  . j a  v  a2s .  co m*/
        for (int i = 0; i < Difusion_Rate.size(); i++) {
            DifusionStruct DS = Difusion_Rate.elementAt(i);
            for (int h = 0; h < this.cells.size(); h++) {
                Cell e = this.cells.elementAt(h);
                if (DS.neighbour == e.cellID && j != e) {
                    double N = e.getN(specie) - j.getN(specie);
                    difusion += DS.difusionRate * N;
                }
            }
        }

        return difusion;
    } catch (Exception exception) {
        System.out.println("world.java -->getDifusion()" + exception);
        return difusion;
    }
}

From source file:com.openmeap.json.JSONObjectBuilder.java

private Object[] toTypedArray(Vector list) {
    if (list.isEmpty()) {
        return null;
    }//  w  w w  .  ja v a2 s  .c  o  m
    Object first = list.elementAt(0);
    Object[] ret = null;
    if (first instanceof String) {
        ret = new String[list.size()];
    } else if (first instanceof Double) {
        ret = new Double[list.size()];
    } else if (first instanceof Integer) {
        ret = new Integer[list.size()];
    } else if (first instanceof Long) {
        ret = new Long[list.size()];
    } else if (first instanceof Boolean) {
        ret = new Boolean[list.size()];
    }
    list.copyInto(ret);
    return (Object[]) ret;
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectOtherIdentifiersListener.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 w ww  .j  a  va  2  s .  c  om
        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();
        Vector<String> siteIds = this.setOtherIdsUI.getSiteIds();
        Vector<String> visitNames = this.setOtherIdsUI.getVisitNames();
        for (int i = 0; i < rawFiles.size(); i++) {

            //site identifier
            if (siteIds.elementAt(i).compareTo("") != 0) {
                int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), siteIds.elementAt(i));
                if (columnNumber != -1) {
                    out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tSITE_ID\t\t\n");
                }
            }

            //visit name
            if (visitNames.elementAt(i).compareTo("") != 0) {
                int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), visitNames.elementAt(i));
                if (columnNumber != -1) {
                    out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tVISIT_NAME\t\t\n");
                }
            }
        }
        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("SITE_ID") != 0 && s[3].compareTo("VISIT_NAME") != 0) {
                    out.write(line + "\n");
                }
            }
            br.close();
        } catch (Exception e) {
            this.setOtherIdsUI.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.setOtherIdsUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }

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

From source file:com.globalsight.everest.usermgr.UserLdapHelper.java

/**
 * Get names of the given users, assuming each user must have a name.
 *//*  w  w  w .jav a  2s .  c  om*/
static String[] getNames(Vector p_users) {
    String[] names = null;

    if (p_users != null) {
        int size = p_users.size();
        names = new String[size];

        for (int i = 0; i < size; i++) {
            names[i] = ((User) p_users.elementAt(i)).getUserName();
        }
    }

    return names;
}

From source file:JavaSort.java

public JavaSort() {
    Vector list = new Vector();
    list.add("\u00e4pple");
    list.add("banan");
    list.add("p\u00e4ron");
    list.add("orange");

    // Obtain a Swedish collator
    Collator collate = Collator.getInstance(new Locale("sv", ""));
    Collections.sort(list, collate);

    StringBuffer result = new StringBuffer();
    for (int i = 0; i < list.size(); i++) {
        result.append(list.elementAt(i));
        result.append(" ");
    }//from w  w  w  . j  a v a  2  s  . c om
    add(new JLabel(result.toString()));
}

From source file:com.substanceofcode.twitter.model.Status.java

private String aboutStr(JSONObject user) {
    String accum = "";
    Vector a = aboutVec(user);
    for (int i = 0; i < a.size(); i++) {
        String[] kv = (String[]) a.elementAt(i);
        accum += kv[0] + ": " + kv[1] + "\n\n";
    }/*ww w  .j ava2s .  co m*/
    return accum;
}

From source file:Main.java

private DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir) {
    String curPath = dir.getPath();
    DefaultMutableTreeNode curDir = new DefaultMutableTreeNode(curPath);
    if (curTop != null) {
        curTop.add(curDir);//w  ww .  j a  v  a  2  s . co m
    }
    Vector<String> ol = new Vector<String>();
    String[] tmp = dir.list();
    for (int i = 0; i < tmp.length; i++) {
        ol.addElement(tmp[i]);
    }
    Collections.sort(ol, String.CASE_INSENSITIVE_ORDER);
    File f;
    Vector<Object> files = new Vector<Object>();
    for (int i = 0; i < ol.size(); i++) {
        String thisObject = ol.elementAt(i);
        String newPath;
        if (curPath.equals(".")) {
            newPath = thisObject;
        } else {
            newPath = curPath + File.separator + thisObject;
        }
        if ((f = new File(newPath)).isDirectory()) {
            addNodes(curDir, f);
        } else {
            files.addElement(thisObject);
        }
    }
    for (int fnum = 0; fnum < files.size(); fnum++) {
        curDir.add(new DefaultMutableTreeNode(files.elementAt(fnum)));
    }
    return curDir;
}

From source file:HtmlUtils.java

public String getTableContents(String align, Vector values, int elementCounter) throws IOException {

    StringWriter Cells = new StringWriter();
    String contents = new String();
    int vsize = values.size();

    Cells.write("<TR>");

    for (int i = 0; i < vsize; i++) {
        String value = values.elementAt(i).toString();

        if (i != 0) {
            if (i >= elementCounter) {

                if (i % elementCounter == 0) {
                    Cells.write("</TR>\n\n<TR>");
                }// w ww.ja  v  a2s . c o m
            }
        }

        Cells.write("<TD align=" + align + "> " + value + " </TD> \n");
    }

    Cells.write("</TR>");

    contents = Cells.toString();
    Cells.flush();
    Cells.close();

    return contents;
}