Example usage for java.util Vector size

List of usage examples for java.util Vector size

Introduction

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

Prototype

public synchronized int size() 

Source Link

Document

Returns the number of components in this vector.

Usage

From source file:net.sf.jdmf.util.MathCalculator.java

/**
 * Calculates the distance between two points in a nD space (assumes that
 * n = firstPoint.size() = secondPoint.size()). 
 * /* w w  w  .  ja va2 s .  c  o m*/
 * @param firstPoint the first point
 * @param secondPoint the second point
 * @return the distance between both points
 */
public Double calculateDistance(Vector<Double> firstPoint, Vector<Double> secondPoint) {
    SumOfSquares sumOfSquares = new SumOfSquares();

    for (int i = 0; i < firstPoint.size(); ++i) {
        sumOfSquares.increment(secondPoint.get(i) - firstPoint.get(i));
    }

    return Math.sqrt(sumOfSquares.getResult());
}

From source file:com.nidhinova.tools.ssh.SFTPClient.java

public void deleteRemoteFolder(String root, String relativepath) throws SftpException {
    this.sftp.cd(this.sftp.getHome());
    this.sftp.cd(root + "/" + relativepath);
    _logger.debug(">cd " + root + "/" + relativepath);
    String pwd = this.sftp.pwd();
    _logger.debug("pwd=" + pwd);
    //delete all files
    Vector<ChannelSftp.LsEntry> files;
    files = this.sftp.ls("*.*");
    _logger.debug("# files = " + (files == null ? "0" : files.size()));

    if (files != null) {
        for (int i = 0; i < files.size(); i++) {
            ChannelSftp.LsEntry file = files.get(i);
            this.sftp.rm(file.getFilename());
            _logger.debug("Deleted file " + file.getFilename());
        }/*from w  ww  .j a v  a  2s.c  o m*/

    }

    //delete the folder      
    String foldername = relativepath.substring(relativepath.lastIndexOf('/') + 1);
    this.sftp.cd("..");
    pwd = this.sftp.pwd();
    this.sftp.rmdir(foldername);
}

From source file:org.alfresco.web.scripts.SlingshotRemoteClient.java

protected boolean hasDocType(String content, String docType, boolean encode) {
    try {//from w  ww.  j  a  v a  2 s.  c o  m
        Parser parser = Parser.createParser(content, "UTF-8");
        PrototypicalNodeFactory factory = new PrototypicalNodeFactory();
        parser.setNodeFactory(factory);
        NodeIterator itr = parser.elements();
        while (itr.hasMoreNodes()) {
            Node node = itr.nextNode();
            if (node instanceof DoctypeTag) {
                // Found the doctype tag, now lets see if can find the searched for doctype attribute.
                DoctypeTag docTypeTag = (DoctypeTag) node;
                Vector<Attribute> attrs = docTypeTag.getAttributesEx();
                if (attrs != null && attrs.size() > 1) {
                    for (Attribute attr : attrs) {
                        String name = attr.getName();
                        if (name != null && name.equalsIgnoreCase(docType)) {
                            return true;
                        }
                    }
                }
            }
        }
    } catch (ParserException e) {
        // Not a valid xml document, return false below
    }
    return false;
}

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>");
                }//from w  ww .  j a v a2s. c om
            }
        }

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

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

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

    return contents;
}

From source file:com.integryst.kdbrowser.objects.SearchHelper.java

public String getSearchResultsJSON(HttpServletRequest request) {
    Vector results = getResults(request);
    JSONObject json = new JSONObject();
    try {//w w  w  .j  a v a2  s.  c o  m
        json.put("folder_id", folderId);
        json.put("count", results.size());
        json.put("items", new JSONArray(results));
        LOG.debug("Returning Search Results for [searchText:" + searchText + ", folderId: " + folderId
                + ", start: " + start_index + ", limit: " + limit + ", options: " + options + "]  results: "
                + results.size() + " objects found");
    } catch (Exception ex) {
        LOG.error("Exception generating search JSON: ", ex);
    }
    return json.toString();
}

From source file:com.jaeksoft.searchlib.parser.IcePdfParser.java

private void extractImagesForOCR(ParserResultItem result, Document pdf, LanguageEnum lang)
        throws IOException, SearchLibException, InterruptedException {
    OcrManager ocr = ClientCatalog.getOcrManager();
    if (ocr == null || ocr.isDisabled())
        return;/*from w  w  w  .j  a v  a 2s . c o m*/
    HocrPdf hocrPdf = new HocrPdf();
    if (!getFieldMap().isMapped(ParserFieldEnum.ocr_content)
            && !getFieldMap().isMapped(ParserFieldEnum.image_ocr_boxes))
        return;
    int emptyPageImages = 0;
    for (int i = 0; i < pdf.getNumberOfPages(); i++) {
        Vector<?> images = pdf.getPageImages(i);
        if (images == null || images.size() == 0)
            continue;
        float rotation = pdf.getPageTree().getPage(i, null).getTotalRotation(0);
        BufferedImage image = ImageUtils.toBufferedImage(
                pdf.getPageImage(i, GraphicsRenderingHints.PRINT, Page.BOUNDARY_CROPBOX, 0.0f, 4.0F));
        if (ImageUtils.checkIfManyColors(image)) {
            HocrPage hocrPage = hocrPdf.createPage(i, image.getWidth(), image.getHeight());
            hocrPage.addImage(imageOcr(image, 360 - rotation, lang, ocr));
        } else
            emptyPageImages++;
    }
    if (pdf.getNumberOfPages() > 0 && emptyPageImages == pdf.getNumberOfPages())
        throw new SearchLibException("All pages are blank " + pdf.getNumberOfPages());
    if (getFieldMap().isMapped(ParserFieldEnum.image_ocr_boxes))
        hocrPdf.putHocrToParserField(result, ParserFieldEnum.image_ocr_boxes);
    if (getFieldMap().isMapped(ParserFieldEnum.ocr_content))
        hocrPdf.putTextToParserField(result, ParserFieldEnum.ocr_content);
}

From source file:zoocen.world.java

public double getDifusion(Cell j, int specie) {
    Vector<DifusionStruct> Difusion_Rate = j.getDifusionRate(specie);
    double difusion = 0;
    try {//  w w w . j  av  a  2 s  .  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.orange.mmp.mvc.actions.CertifAction.java

/**
 * ACTIONS//from  ww w  .j a  v a  2  s  . c o m
 */

@SuppressWarnings("unchecked")
/* (non-Javadoc)
 * @see com.opensymphony.xwork2.ActionSupport#execute()
 */
@Override
public String execute() throws Exception {
    // List certificates
    try {
        Vector certs = MidletManager.getInstance().getCertificates();
        this.certifList = new ArrayList<X509Certificate>();
        if (certs.size() > 0) {
            for (int i = 0; i < certs.size(); i++) {
                Object aobj[] = (Object[]) (Object[]) certs.elementAt(i);
                X509Certificate thisCert = (X509Certificate) aobj[AppDescriptor.CERT];
                certifList.add(thisCert);
            }
        }
    } catch (Exception e) {
        addActionError(getText("error.certif.list", new String[] { e.getLocalizedMessage() }));
    }

    return super.execute();
}

From source file:com.qframework.core.ServerkoParse.java

public static int parseIntData(Vector<int[]> outdata, String data, int[] offsets) {

    int val = 0;
    int arrcount = 0;
    int offsetcount = 0;
    int[] array = null;
    int currsize = 0;
    StringTokenizer tok = new StringTokenizer(data, ",");
    while (tok.hasMoreTokens()) {
        if (arrcount == 0) {
            currsize = offsets[offsetcount++];
            offsetcount = offsetcount % offsets.length;
            array = new int[currsize];
        }/*from  w ww.ja  v a 2s  . c  o  m*/
        try {
            val = Integer.parseInt(tok.nextToken());
        } catch (NumberFormatException e) {
        }
        array[arrcount++] = val;
        if (arrcount >= currsize) {
            outdata.add(array);
            arrcount = 0;
        }
    }
    return outdata.size();
}

From source file:peakmlviewer.view.IntensityView.java

public void update(int event) {
    graph.clear();/*from   w ww.  ja v a 2  s.c om*/
    if (event != Document.UPDATE_INIT) {
        Document document = getMainWnd().getDocument();
        IPeak peak = document.getCurrentPeak();
        if (peak == null)
            return;
        Vector<IPeak> peaks = IPeak.unpack(peak);

        Header header = document.getHeader();
        for (SetInfo setinfo : header.getSetInfos()) {
            // retrieve all the peaks for this set
            Vector<IPeak> set = IPeak.peaksOfMeasurements(peaks, setinfo.getAllMeasurementIDs());

            // grab the intensities and add to the data
            double intensities[] = new double[set.size()];
            for (int i = 0; i < set.size(); ++i)
                intensities[i] = set.get(i).getIntensity();
            graph.addData(setinfo.getID(), intensities);
        }
    }
}