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:prodoc.DriverRemote.java

/**
 * Retrieves next record of cursor//from   ww  w . ja v  a  2 s.  c o  m
 * @param CursorIdent
 * @return OPD next Record
 * @throws PDException 
 */
@Override
public Record NextRec(Cursor CursorIdent) throws PDException {
    if (PDLog.isDebug())
        PDLog.Debug("DriverRemote.NextRec:" + CursorIdent);
    Vector rs = (Vector) CursorIdent.getResultSet();
    if (rs.isEmpty())
        return (null);
    Record Fields = CursorIdent.getFieldsCur();
    Fields.assignSimil((Record) rs.get(0)); // description and other elemens from atribute not transmitted by performance
    rs.remove(0);
    return (Fields.Copy());
}

From source file:com.ibm.xsp.webdav.resource.DAVResourceDomino.java

public boolean filter() {
    boolean ret = true;
    // // LOGGER.info("Start filter ");
    DAVRepositoryDomino rep = (DAVRepositoryDomino) this.getRepository();
    String filter = rep.getFilter();
    if (filter.equals("")) {
        // LOGGER.info("Filter null");
        return true;
    }//from   ww  w. ja va 2 s . c o  m
    // LOGGER.info("Filter is "+filter);
    Document doc = getDocument();
    if (doc == null) {
        // LOGGER.info("Get Document is null");
        return ret;
    }
    try {
        DAVRepositoryMETA drm = WebDavManager.getManager(null).getRepositoryMeta();
        if (drm == null) {
            return true;
        }
        Base repDoc = (Base) DominoProxy.resolve(drm.getRepositoryConfigLocation());
        if (repDoc != null) {
            // LOGGER.info("Rep internal address not null; has class="+repDoc.getClass().toString());
            Database db = null;
            if (repDoc instanceof Document) {
                // LOGGER.info("rep doc is a Document");
                db = ((Document) repDoc).getParentDatabase();
            }
            if (repDoc instanceof View) {
                // LOGGER.info("repdoc is a view");
                View vw = ((View) repDoc);
                db = (Database) vw.getParent();
            }
            if (db != null) {
                // LOGGER.info("Parent database not null");
                Document docP = db.createDocument();
                // LOGGER.info("Create document parameters...");
                docP.replaceItemValue("Form", "webDavParameters");
                docP.computeWithForm(true, false);
                // LOGGER.info("Compute with form OK!");
                @SuppressWarnings("rawtypes")
                Vector items = docP.getItems();
                for (int i = 0; i < items.size(); i++) {
                    Item itm = (Item) items.get(i);
                    // LOGGER.info("Item "+itm.getName()+"="+itm.getValueString());
                    filter = filter.replaceAll("\\x5B\\x5B" + itm.getName() + "\\x5D\\x5D",
                            "\"" + itm.getValueString() + "\"");
                }
                if (!filter.equals("")) {
                    // LOGGER.info("Filter="+filter);
                    Session ses = DominoProxy.getUserSession();
                    @SuppressWarnings("rawtypes")
                    Vector eval = ses.evaluate(filter, doc);
                    if (eval == null) {
                        return true;
                    }
                    String retS = eval.firstElement().toString().toLowerCase();
                    // LOGGER.info("Evaluate result="+retS);
                    if (retS.equals("1.0")) {
                        // LOGGER.info("Filter pass OK!");
                        return true;
                    } else {
                        // LOGGER.info("Filter didn't pass");
                        return false;
                    }
                }
            }
        }

    } catch (NotesException ne) {
        LOGGER.error("Error on filter;" + ne.getMessage());
        return ret;
    }
    return ret;
}

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

public void printTSV(Vector<Vector<Pair>> points, PrintWriter writer) {
    // Print first line
    for (String m : listAlgo) {
        writer.print("\t" + m);
    }/*from  w  w  w . j a  va 2s  .c o  m*/
    // Print others
    for (int i = 0; i < 100; i += STEP) {
        for (int j = 0; j < size; j++) {
            Pair precrec = points.get(j).get(i);
            writer.println(precrec.getX() + " " + precrec.getY());
        }
    }
    writer.println();
}

From source file:net.java.sen.tools.DictionaryMaker.java

int getIdList(String csv[], Vector result, int parent) {
    result.setSize(ruleList.size());/*from  w  w  w .j a  va  2  s .com*/

    for (int j = 0; j < ruleList.size(); j++)
        result.set(j, new Integer(j));
    //    System.out.println("in:ruleList.size()=" + ruleList.size());
    //    System.out.println("ruleList size="+ruleList.size());
    //    System.out.println("result size="+result.size());
    //    pass

    for (int j = 0; j < csv.length; j++) {
        int k = 0;
        for (int n = 0; n < result.size(); n++) {
            int i = ((Integer) result.get(n)).intValue();
            String rl_ij = ((String[]) ruleList.get(i))[j];
            if ((parent == 0 && csv[j].charAt(0) == '*') || (parent == 1 && rl_ij.charAt(0) == '*')
                    || rl_ij.equals(csv[j])) {

                result.set(k++, result.get(n));
            }
        }
        result.setSize(k);
    }
    return result.size();
}

From source file:de.fhg.fokus.odp.middleware.unittest.xTestCKANGateway.java

/**
 * Test the getRevisions and getUpdatedSets method.
 *///w w  w .  j  a  v  a 2 s  . c om
@Test
public void testGetRevisionsAndGetUpdatesSets() {
    log.fine("########### GET REVISIONS AND UPDATES ###########");
    String revisionsStr = ckanGW.getRevisions("Europe/Berlin", 200000000);
    log.fine(revisionsStr);
    Vector<String> revisionsDetails = ckanGW.getUpdatedDatasets(revisionsStr);
    @SuppressWarnings("unchecked")
    Vector<Map> dataSetDetails = ckanGW.getUpdatedDataSetsDetails(revisionsDetails);
    Vector<Map> categoriesDetails = ckanGW.getUpdatedCategoriesDetails(revisionsDetails);
    for (int i = 0; i < categoriesDetails.size(); i++) {
        log.fine(categoriesDetails.get(i).toString());
    }
    assertTrue(revisionsDetails.size() >= 1);
    assertTrue(dataSetDetails.size() >= 1);
    assertTrue(categoriesDetails.size() >= 1);

}

From source file:fr.gouv.finances.cp.xemelios.importers.batch.BatchRealImporter.java

private ImportContent files(final String extension, final String titreEtat) {
    ImportContent ic = new ImportContent();
    Vector<File> ret = new Vector<File>();
    ret.addAll(files);//from  w  w  w  .  j a  va2 s  .co  m
    // on regarde si l'un des fichiers a importer est un zip
    for (int i = 0; i < ret.size(); i++) {
        if (ret.get(i).getName().toLowerCase().endsWith(".zip")) {
            if (ret.get(i).exists()) {
                ZipFile zf = null;
                try {
                    zf = new ZipFile(ret.get(i));
                    for (Enumeration<? extends ZipEntry> enumer = zf.entries(); enumer.hasMoreElements();) {
                        ZipEntry ze = enumer.nextElement();
                        if (!ze.isDirectory()) {
                            String fileName = ze.getName();
                            String entryName = fileName.toLowerCase();
                            fileName = fileName.replace(File.pathSeparatorChar, '_')
                                    .replace(File.separatorChar, '_').replace(':', '|').replace('\'', '_')
                                    .replace('/', '_');
                            logger.debug(entryName);
                            if (PJRef.isPJ(ze)) {
                                PJRef pj = new PJRef(ze);
                                File tmpFile = pj.writeTmpFile(FileUtils.getTempDir(), zf);
                                ic.pjs.add(pj);
                                filesToDrop.add(tmpFile);
                            } else if ((entryName.endsWith(extension.toLowerCase())
                                    || entryName.endsWith(".xml")) && !fileName.startsWith("_")) {
                                // on decompresse le fichier dans le
                                // repertoire temporaire, comme ca il sera
                                // supprime en quittant
                                InputStream is = zf.getInputStream(ze);
                                BufferedInputStream bis = new BufferedInputStream(is);
                                File output = new File(FileUtils.getTempDir(), fileName);
                                BufferedOutputStream bos = new BufferedOutputStream(
                                        new FileOutputStream(output));
                                byte[] buffer = new byte[1024];
                                int read = bis.read(buffer);
                                while (read > 0) {
                                    bos.write(buffer, 0, read);
                                    read = bis.read(buffer);
                                }
                                bos.flush();
                                bos.close();
                                bis.close();
                                ic.filesToImport.add(output);
                                filesToDrop.add(output);
                            }
                        }
                    }
                    zf.close();
                } catch (ZipException zEx) {
                    System.out.println(
                            "Le fichier " + ret.get(i).getName() + " n'est pas une archive ZIP valide.");
                } catch (IOException ioEx) {
                    ioEx.printStackTrace();
                } finally {
                    if (zf != null) {
                        try {
                            zf.close();
                        } catch (Throwable t) {
                        }
                    }
                }
            }
        } else if (ret.get(i).getName().toLowerCase().endsWith(".gz")) {
            try {
                String fileName = ret.get(i).getName();
                fileName = fileName.substring(0, fileName.length() - 3);
                File output = new File(FileUtils.getTempDir(), fileName);
                GZIPInputStream gis = new GZIPInputStream(new FileInputStream(ret.get(i)));
                BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(output));
                byte[] buffer = new byte[1024];
                int read = gis.read(buffer);
                while (read > 0) {
                    bos.write(buffer, 0, read);
                    read = gis.read(buffer);
                }
                bos.flush();
                bos.close();
                gis.close();
                ic.filesToImport.add(output);
                filesToDrop.add(output);
            } catch (IOException ioEx) {
                // nothing to do
            }
        } else {
            ic.filesToImport.add(ret.get(i));
            // dans ce cas l, on ne le supprime pas
        }
    }
    return ic;
}

From source file:charts.Chart.java

public static void Histogram(Vector data, int maxvalue, String net) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    int i = 0;/*from  www  .  j a  v  a2  s  . c  o  m*/
    int[] degree = new int[maxvalue];//guarda o grau de cada no
    int value = 0;

    for (i = 0; i < data.size(); i++) {
        value = (Integer) data.get(i);
        degree[value]++;//determina o grau de cada no == quantas vezes ele apareceu na lista.
    }

    int max = Maximum(degree);//pega o grau maximo para gerar o histograma
    int[] vethistogram = new int[max + 1];
    for (i = 0; i < degree.length; i++) {
        vethistogram[degree[i]]++;//para cada ocorrencia do grau, soma um na sua posicao do histograma.
    }

    //codigo para gerar os dados para o grafico MultipleLineChart
    XYDataset[] xydatasets = new XYDataset[1];
    XYSeries serie = new XYSeries("sample");

    XYSeries series2 = new XYSeries("Max Value");

    float maxvaluef = maxvalue;
    for (i = 0; i < max + 1; i++) {
        float nnos = vethistogram[i];
        if (i != 0 && nnos != 0 && net.equalsIgnoreCase("BA")) {
            serie.add(Math.log(i), Math.log(nnos / maxvaluef));
            series2.add(Math.log(i), Math.log(nnos / maxvaluef));
        } else if (net.equalsIgnoreCase("ER")) {
            serie.add(i, nnos / maxvaluef);
            series2.add(i, nnos / maxvaluef);
        }
        //serie.add(i, (nnos/maxvaluef));
        dataset.addValue((Number) vethistogram[i], 0, i);
        //datasets[i].addValue(Md[ lineindex[i] ][c], String.valueOf(c));
    }
    XYSeriesCollection series = new XYSeriesCollection();
    series.addSeries(series2);
    ScatterPlot(series, "Validation Graph - Node Degree Distribution", "log(k)", "log(P(k))");

    xydatasets[0] = new XYSeriesCollection(serie);
    Chart.MultipleLineChart(xydatasets, "Line Chart", "degree", "number of nodes", true, 0, 0);

    Chart.BarChart(dataset, "Histogram of node degree", "samples", "values", true);
}

From source file:imapi.IMAPIClass.java

public void printResultInstances(Hashtable<Float, Vector<ResultSourceTargetPair>> resultInstances) {

    int resultsCounter = 0;
    if (resultInstances.size() == 0) {
        System.out.println("0 results found.");
    } else {//w w w. ja  va  2 s.  c o m

        Vector<Float> sortBySimilarityVec = new Vector<Float>(resultInstances.keySet());
        Collections.sort(sortBySimilarityVec);
        Collections.reverse(sortBySimilarityVec);

        for (int i = 0; i < sortBySimilarityVec.size(); i++) {
            float sim = sortBySimilarityVec.get(i);
            Vector<ResultSourceTargetPair> stPairs = resultInstances.get(sim);
            Collections.sort(stPairs);

            for (int k = 0; k < stPairs.size(); k++) {
                ResultSourceTargetPair resultInfo = stPairs.get(k);
                SourceTargetPair pair = resultInfo.getSourceTargetPair();
                SequenceSimilarityResultVector tripVec = resultInfo.getSimilarityResultsVector();

                System.out.println((++resultsCounter) + ".\t" + Utilities.df.format(sim) + "\t"
                        + pair.getSourceInstance().getSourceName() + "    "
                        + pair.getSourceInstance().getInstanceUri() + "    "
                        + pair.getTargetInstance().getSourceName() + "    "
                        + pair.getTargetInstance().getInstanceUri());

                //check if uri similarity is encoutered

                if (pair.getSourceInstance().getInstanceUri()
                        .equals(pair.getTargetInstance().getInstanceUri())) {
                    System.out.println("\t\t\turi similarity 1\n");
                    continue;
                } else {
                    this.printSimilaritiesData(tripVec);
                }

                System.out.println();

            }
        }
    }

}

From source file:org.esgf.globusonline.GOauthView3Controller.java

private String[] constructEndpointInfos(Vector<EndpointInfo> endpoints) {
    int numEndpoints = endpoints.size();
    String[] endPointNames = new String[numEndpoints];

    for (int i = 0; i < numEndpoints; i++) {
        // we encode this in a string as follows
        // EPNAME^^HOSTS^^MYPROXYSERVER^^ISGLOBUSCONNECT
        endPointNames[i] = endpoints.get(i).getEPName() + "^^" + endpoints.get(i).getHosts() + "^^"
                + endpoints.get(i).getMyproxyServer() + "^^" + endpoints.get(i).isGlobusConnect();
    }/*from  w w  w.  j  a  v a 2 s .c om*/
    return endPointNames;
}

From source file:edu.ku.brc.specify.toycode.L18NStringResApp.java

/**
 * @param file/*from  w w w.j  a  v  a2  s .com*/
 */
protected void copyNewLines(final File file) {
    String dirName = RES_PATH + "values-" + destLocale.getLanguage();
    String dstPath = dirName + File.separator + file.getName();

    try {
        List<String> srcLines = (List<String>) FileUtils.readLines(file, "UTF8");
        Vector<String> dstLines = new Vector<String>(
                (List<String>) FileUtils.readLines(new File(dstPath), "UTF8"));

        int dstCnt = 0;
        for (int i = 0; i < srcLines.size(); i++) {

            String srcLine = srcLines.get(i);
            String dstLine = dstLines.get(dstCnt++);

            if (StringUtils.contains(srcLine, "<?xml") && StringUtils.contains(dstLine, "<?xml"))
                continue;
            if (StringUtils.contains(srcLine, "<res") && StringUtils.contains(dstLine, "<res"))
                continue;
            if (StringUtils.contains(srcLine, "</res") && StringUtils.contains(dstLine, "</res"))
                continue;

            srcLine = StringUtils.replace(srcLine, "\\ \'", "\\\'");
            srcLine = StringUtils.replace(srcLine, "s \\\'", "s\\\'");

            dstLine = StringUtils.replace(dstLine, "\\ \'", "\\\'");
            dstLine = StringUtils.replace(dstLine, "s \\ \'", "s\\\'");

            System.out.println("--- [" + srcLine + "][" + dstLine + "] -- ");

            if (srcLine.equals(dstLine))
                continue;

            boolean isSrcComment = StringUtils.contains(srcLine, "<!--");
            boolean isDstComment = StringUtils.contains(dstLine, "<!--");

            String srcKey = !isSrcComment ? getKey(srcLine) : "";
            String dstKey = !isDstComment ? getKey(dstLine) : "";

            if (srcKey != null && dstKey != null && srcKey.equals(dstKey) && srcKey.length() > 0)
                continue;

            dstLines.insertElementAt(srcLine, dstCnt++);
        }

        System.out.println("----------------------------");
        for (int i = 0; i < srcLines.size(); i++) {
            String srcLine = srcLines.get(i);
            String dstLine = dstLines.get(i);

            srcLine = StringUtils.replace(srcLine, "\\ \'", "\\\'");
            srcLine = StringUtils.replace(srcLine, "s \\\'", "s\\\'");

            dstLine = StringUtils.replace(dstLine, "\\ \'", "\\\'");
            dstLine = StringUtils.replace(dstLine, "s \\ \'", "s\\\'");

            System.out.println("--- [" + srcLine + "] " + srcLine.length() + "  [" + dstLine + "] "
                    + dstLine.length() + " -- ");
        }

    } catch (IOException e) {
        e.printStackTrace();
    }
}