Example usage for java.util Vector get

List of usage examples for java.util Vector get

Introduction

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

Prototype

public synchronized E get(int index) 

Source Link

Document

Returns the element at the specified position in this Vector.

Usage

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetSubjectsIdListener.java

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setSubjectsIdUI.getValues();
    Vector<String> samples = this.setSubjectsIdUI.getSamples();
    for (String v : values) {
        if (v.compareTo("") == 0) {
            this.setSubjectsIdUI.displayMessage("All identifiers have to be set");
            return;
        }//from w  w  w . ja  v a2 s. c  o m
    }

    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

        File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
        if (stsmf == null) {
            for (int i = 0; i < samples.size(); i++) {
                out.write(this.dataType.getStudy().toString() + "\t" + "\t" + values.elementAt(i) + "\t"
                        + samples.elementAt(i) + "\t" + "\t" + "\t" + "\t" + "\t" + "\n");
            }
        } else {
            try {
                BufferedReader br = new BufferedReader(new FileReader(stsmf));
                String line = br.readLine();
                while ((line = br.readLine()) != null) {
                    String[] fields = line.split("\t", -1);
                    String sample = fields[3];
                    String subject;
                    if (samples.contains(sample)) {
                        subject = values.get(samples.indexOf(sample));
                    } else {
                        br.close();
                        return;
                    }
                    out.write(fields[0] + "\t" + fields[1] + "\t" + subject + "\t" + sample + "\t" + fields[4]
                            + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n");
                }
                br.close();
            } catch (Exception e) {
                this.setSubjectsIdUI.displayMessage("File error: " + e.getLocalizedMessage());
                out.close();
                e.printStackTrace();
            }
        }
        out.close();
        try {
            File fileDest;
            if (stsmf != null) {
                String fileName = stsmf.getName();
                stsmf.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
        } catch (IOException ioe) {
            this.setSubjectsIdUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setSubjectsIdUI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
    UsedFilesPart.sendFilesChanged(dataType);
}

From source file:webServices.RestServiceImpl.java

@POST
@Path("/endpoint/charts/dimensions/{host}/{endpoint}/{port}")
@Consumes({ MediaType.WILDCARD, MediaType.APPLICATION_JSON })
@Produces({ MediaType.TEXT_PLAIN })/*from   www  .j  a v  a 2  s .c o m*/
public String getDimensions(@PathParam("host") String host, @PathParam("endpoint") String endpoint,
        @PathParam("port") int port) throws EndpointCommunicationException {
    Vector<String> results = new Vector<String>();
    String format = "";

    results = endpointStore.getDimensionsNames(host, endpoint.replaceAll("@@@", "/"), port);

    for (int i = 0; i < results.size(); i++) {
        format = format.concat(results.get(i));
        format = format.concat("$");
    }

    return format;
}

From source file:webServices.RestServiceImpl.java

@POST
@Path("/endpoint/charts/measurements/{host}/{endpoint}/{port}")
@Consumes({ MediaType.WILDCARD, MediaType.APPLICATION_JSON })
@Produces({ MediaType.TEXT_PLAIN })/*  w w  w .  j ava  2  s . c  o m*/
public String getMeasurements(@PathParam("host") String host, @PathParam("endpoint") String endpoint,
        @PathParam("port") int port) throws EndpointCommunicationException {
    Vector<String> results = new Vector<String>();
    String format = "";

    results = endpointStore.getMeasureProperties(host, endpoint.replaceAll("@@@", "/"), port);

    for (int i = 0; i < results.size(); i++) {
        format = format.concat(results.get(i));
        format = format.concat("$");
    }

    return format;
}

From source file:webServices.RestServiceImpl.java

@POST
@Path("/endpoint/charts/finalQuery/{host}/{endpoint}/{port}")
@Consumes({ MediaType.TEXT_PLAIN, MediaType.WILDCARD, MediaType.APPLICATION_JSON })
@Produces({ MediaType.TEXT_PLAIN })//from w w w.  j a va2 s.c  o m
public String getChartData(String query, @PathParam("host") String host, @PathParam("endpoint") String endpoint,
        @PathParam("port") int port) throws EndpointCommunicationException {
    Vector<String> results = new Vector<String>();
    String format = "";

    results = endpointStore.getDataForChart(host, endpoint.replaceAll("@@@", "/"), port, query);

    for (int i = 0; i < results.size(); i++) {
        format = format.concat(results.get(i));
        format = format.concat("$");
    }

    return format;
}

From source file:org.powertac.householdcustomer.customers.Village.java

private void fillAggDominantLoads(String type) {

    double[] dominant = new double[VillageConstants.HOURS_OF_DAY];
    double[] nonDominant = new double[VillageConstants.HOURS_OF_DAY];

    Vector<Household> houses = getHouses(type);

    for (int i = 0; i < houses.size(); i++) {
        for (int j = 0; j < VillageConstants.HOURS_OF_DAY; j++) {

            dominant[j] += houses.get(i).getDominantConsumption(j);
            nonDominant[j] += houses.get(i).getNonDominantConsumption(j);

        }/*from  w  w w. j  a va2  s.c om*/
    }

    if (type.equals("NS")) {

        dominantLoadNS = dominant;
        nonDominantLoadNS = nonDominant;

    } else if (type.equals("RaS")) {

        dominantLoadRaS = dominant;
        nonDominantLoadRaS = nonDominant;
    } else if (type.equals("ReS")) {

        dominantLoadReS = dominant;
        nonDominantLoadReS = nonDominant;

    } else {

        dominantLoadSS = dominant;
        nonDominantLoadSS = nonDominant;

    }
}

From source file:edu.ku.brc.specify.dbsupport.SpecifyDeleteHelper.java

/**
 * @param rec/*from ww  w.  java2 s.c o  m*/
 * @return
 */
public boolean isRecordShared(final Class<?> cls, final Integer id) throws SQLException {
    StackItem root = new StackItem(null, null, null);
    getSubTables(root, cls, id, null, null, 0, null, true);
    StackItem s = root.getStack().peek();
    for (StackItem si : s.getStack()) {
        System.out.println(si.getSql() + id);
        Vector<Integer> ids = getIds(si.getSql() + id, -1);
        if (ids != null && ids.size() > 1) {
            return true;
        }
        if (ids != null && ids.size() == 1) {
            if (isRecordShared(si.getTableInfo().getClassObj(), ids.get(0))) {
                return true;
            }
        }
    }
    return false;
}

From source file:edu.ku.brc.specify.tasks.SystemSetupTask.java

/**
 * //from  w  ww  .ja  v  a 2  s .  com
 */
private void showUsersLoggedIn() {
    String sql = " SELECT Name, IsLoggedIn, IsLoggedInReport, LoginCollectionName, LoginDisciplineName FROM specifyuser WHERE IsLoggedIn <> 0";
    Vector<Object[]> dataRows = BasicSQLUtils.query(sql);
    Object[][] data = new Object[dataRows.size()][5];
    for (int i = 0; i < dataRows.size(); i++) {
        data[i] = dataRows.get(i);
    }
    DefaultTableModel model = new DefaultTableModel(data, new Object[] { "User", "Is Logged In",
            "Is Logged In to Report", "Login Collection", "Login Discipline" });
    JTable table = new JTable(model);
    UIHelper.makeTableHeadersCentered(table, true);

    JScrollPane scrollPane = UIHelper.createScrollPane(table);
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    CustomDialog infoDlg = new CustomDialog((Dialog) null, "Users Logged In", true, CustomDialog.OK_BTN, panel);

    infoDlg.setCancelLabel("Close");
    infoDlg.createUI();
    infoDlg.setSize(600, 300);
    infoDlg.setVisible(true);
}

From source file:JavaTron.AudioTron.java

/**
 * Method to execute a POST Request to the Audiotron - JSC
 * /*w  w  w  . j av a2  s. co  m*/
 * @param address - The requested page
 * @param args - The POST data
 * @param parser - A Parser Object fit for parsing the response
 *
 * @return null on success, a string on error.  The string describes
 *         the error.
 *
 * @throws IOException
 */
protected String post(String address, Vector args, Parser parser) throws IOException {
    String ret = null;
    URL url;
    HttpURLConnection conn;
    String formData = new String();

    // Build the POST data
    for (int i = 0; i < args.size(); i += 2) {
        if (showPost) {
            System.out.print("POST: " + args.get(i).toString() + " = ");
            System.out.println(args.get(i + 1).toString());
        }
        formData += URLEncoder.encode(args.get(i).toString(), "UTF-8") + "="
                + URLEncoder.encode(args.get(i + 1).toString(), "UTF-8");
        if (i + 2 != args.size())
            formData += "&";
    }

    // Build the connection Headers and POST the data
    try {
        url = new URL("http://" + getServer() + address);
        if (showAddress || showPost) {
            System.out.println("POST: " + address);
            System.out.println("POST: " + formData);
        }
        conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setRequestProperty("User-Agent", USER_AGENT);

        // Authorization header
        String auth = getUsername() + ":" + getPassword();
        conn.setRequestProperty("Authorization", "Basic " + B64Encode(auth.getBytes()));
        // Debug
        if (showAuth) {
            System.out.println("POST: AUTH: " + auth);
        }
        conn.setRequestProperty("Content Type", "application/x-www-form-urlencoded");
        conn.setRequestProperty("Content-Length", "" + Integer.toString(formData.getBytes().length));
        conn.setRequestProperty("Content-Language", "en-US");
        conn.setUseCaches(false);
        conn.setDoInput(true);
        conn.setDoOutput(true);

        // Send the request to the audiotron
        DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
        wr.writeBytes(formData);
        wr.flush();
        wr.close();

        // Process the Response
        if (conn.getResponseCode() != 200 && conn.getResponseCode() != 302) {
            try {
                ret = conn.getResponseMessage();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            if (ret == null) {
                ret = "Unknown Error";
            }
            if (parser != null) {
                parser.begin(ret);
            }
            return ret;
        }

        isr = new InputStreamReader(conn.getInputStream());

        BufferedReader reader = new BufferedReader(isr);
        String s;

        getBuffer = new StringBuffer();

        if (parser != null) {
            parser.begin(null);
        }

        while ((s = reader.readLine()) != null) {
            if (showGet) {
                System.out.println(s);
            }
            getBuffer.append(s);
            getBuffer.append("\n");
            if (parser == null) {
                //  getBuffer.append(s);
            } else {
                if (!parser.parse(s)) {
                    return "Parse Error";
                }
            }
        }

        if (parser == null && showUnparsedOutput) {
            System.out.println(getBuffer);
        }
        if (parser != null) {
            parser.end(false);
        }
    } catch (MalformedURLException mue) {
        mue.printStackTrace();
    } catch (IOException ioe) {
        // if this happens, call the parse method if there is a parser
        // with a null value to indicate an error
        if (parser != null) {
            parser.end(true);
        }
        throw (ioe);
    } finally {
        try {
            isr.close();
        } catch (Exception e) {
            // this is ok
        }
    }

    return ret;
}

From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java

private void getFilesinFoldersToDownload(OCFile parentDirectory, List<OCFile> filesToDownload,
        int sharedIndicator) {
    Vector<OCFile> list = getStorageManager().getDirectoryContent(parentDirectory);
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).isDirectory()) {
            getFilesinFoldersToDownload(list.get(i), filesToDownload, sharedIndicator);
        } else if (!list.get(i).isDown()) {
            filesToDownload.add(list.get(i));
            if (sharedIndicator == 1) {
                shareNotifier.setContentText("File " + list.get(i).getFileName() + " was shared with you");
                notificationManager.notify(i, shareNotifier.build());
            }//from w w w. j av  a  2 s . c om
        }
    }
}

From source file:webServices.RestServiceImpl.java

@POST
@Path("/endpoint/discover/{host}/{endpoint}/{port}")
@Consumes({ MediaType.TEXT_PLAIN, MediaType.WILDCARD, MediaType.APPLICATION_JSON })
@Produces({ MediaType.TEXT_PLAIN })//from w  w  w .  j  a v a  2  s.  c om
public String getExploreDescribe(String classURI, @PathParam("host") String host,
        @PathParam("endpoint") String endpoint, @PathParam("port") int port)
        throws EndpointCommunicationException {
    Vector<String> results = new Vector<String>();
    String format = "";
    results = endpointStore.getExploreDescribe(host, endpoint.replaceAll("@@@", "/"), port, classURI);

    if (results != null) {
        for (int i = 0; i < results.size(); i++) {
            format = format.concat(results.get(i));
            format = format.concat("$");
        }
    }

    return format;
}