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:com.concursive.connect.indexer.jobs.IndexerJob.java

public void execute(JobExecutionContext context) throws JobExecutionException {
    SchedulerContext schedulerContext = null;
    try {/* w  ww .  jav a 2 s  .  c  o  m*/
        schedulerContext = context.getScheduler().getContext();
        // Determine the indexer service
        IIndexerService indexer = IndexerFactory.getInstance().getIndexerService();
        if (indexer == null) {
            throw (new JobExecutionException("Indexer Configuration error: No indexer defined."));
        }
        // Determine if the indexer job can run
        boolean canExecute = true;
        ServletContext servletContext = (ServletContext) schedulerContext.get("ServletContext");
        if (servletContext != null) {
            // If used in a servlet environment, make sure the indexer is initialized
            canExecute = "true".equals(servletContext.getAttribute(Constants.DIRECTORY_INDEX_INITIALIZED));
        }
        // Execute the indexer
        if (canExecute) {
            Vector eventList = (Vector) schedulerContext.get(INDEX_ARRAY);
            if (eventList.size() > 0) {
                LOG.debug("Indexing data... " + eventList.size());
                indexer.obtainWriterLock();
                try {
                    while (eventList.size() > 0) {
                        IndexEvent indexEvent = (IndexEvent) eventList.get(0);
                        if (indexEvent.getAction() == IndexEvent.ADD) {
                            // The object was either added or updated
                            indexer.indexAddItem(indexEvent.getItem());
                        } else if (indexEvent.getAction() == IndexEvent.DELETE) {
                            // Delete the item and related data
                            indexer.indexDeleteItem(indexEvent.getItem());
                        }
                        eventList.remove(0);
                    }
                } catch (Exception e) {
                    LOG.error("Indexing error", e);
                    throw new JobExecutionException(e.getMessage());
                } finally {
                    indexer.releaseWriterLock();
                }
            }
        }
    } catch (Exception e) {
        LOG.error("Indexing job error", e);
        throw new JobExecutionException(e.getMessage());
    }
}

From source file:io.calq.android.analytics.ApiDispatcher.java

/**
 * Builds a payload based on the batch content.
 *//*www  . j  a  v  a  2  s . co  m*/
private StringEntity buildPayload(Vector<QueuedApiCall> batch) throws UnsupportedEncodingException {
    // Single item?
    if (batch.size() == 1) {
        return new StringEntity(batch.firstElement().getPayload(), "UTF-8");
    } else {
        StringBuilder payload = new StringBuilder();
        payload.append("[");
        for (int n = 0; n < batch.size(); n++) {
            if (n > 0) {
                payload.append(",");
            }
            QueuedApiCall apiCall = batch.get(n);
            payload.append(apiCall.getPayload());
        }
        payload.append("]");
        return new StringEntity(payload.toString(), "UTF-8");
    }
}

From source file:eionet.gdem.qa.ListQAScriptsMethodTest.java

@Test
public void testListConversionsXQueryResult() throws Exception {

    ListQueriesMethod qas = new ListQueriesMethod();
    // get all queries (xqueries, xml schemas, xslts)
    Vector listQaResult = qas
            .listQAScripts("http://biodiversity.eionet.europa.eu/schemas/dir9243eec/generalreport.xsd");
    assertTrue(listQaResult.size() == 2);

    Vector ht = (Vector) listQaResult.get(0);

    assertEquals(ht.get(0), "48");
    assertEquals(ht.get(1), "Article 17 - General report species check");
    assertEquals(ht.get(3), "20");
}

From source file:com.orange.atk.graphAnalyser.GraphMarker.java

/**
 * draw marker/*from   w ww. ja  v  a  2 s.c  o m*/
 */
public final synchronized void drawMarker() {
    setMarkerPosition();
    Vector<Action> listActions = Vectaction;
    for (int i = 0; i < listActions.size(); i++) {
        Action action = listActions.get(i);
        if (action.getMarker() != null)
            xyplot.addDomainMarker(action.getMarker());
        else
            Logger.getLogger(this.getClass())
                    .debug("Erreur ActionName:" + action.getActionName() + " Remove MsgType "
                            + action.getMsgType() + " StartTime " + action.getStartTime() + " EndTime "
                            + action.getEndTime());

        if (action.getAnnotation() != null)
            xyplot.addAnnotation(action.getAnnotation());
        else
            Logger.getLogger(this.getClass())
                    .debug("Erreur ActionName:" + action.getActionName() + " Remove MsgType "
                            + action.getMsgType() + " StartTime " + action.getStartTime() + " EndTime "
                            + action.getEndTime());
    }
    isActivate = true;

}

From source file:jasmine.imaging.shapes.RadiusChart.java

public RadiusChart(Vector<Double> values) {

    super();//w  ww.j a v  a  2 s . c  o m

    DefaultCategoryDataset series = new DefaultCategoryDataset();

    for (int i = 0; i < values.size(); i++) {
        series.addValue(values.elementAt(i), "row1", String.valueOf(i));
    }

    setTitle("Radius Change");

    chart = new JLabel();
    getContentPane().add(chart);

    setSize(320, 240);
    setVisible(true);

    myChart = ChartFactory.createLineChart(null, null, null, series, PlotOrientation.VERTICAL, false, false,
            false);

    addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            if (myChart != null)
                updateChart();
        }
    });

}

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;/*from  w w w .  j  a v a 2  s.  c o m*/
    }
    return sb.toString();
}

From source file:edu.umn.cs.spatialHadoop.nasa.SpatioAggregateQueries.java

/**
 * Performs a spatio-temporal aggregate query on an indexed directory
 * @param inFile// w w w . j a  v a 2 s . c  om
 * @param params
 * @throws ParseException 
 * @throws IOException 
 * @throws InterruptedException 
 */
public static long selectionQuery(Path inFile, final ResultCollector<NASAPoint> output, OperationsParams params)
        throws ParseException, IOException, InterruptedException {
    // 1- Find matching temporal partitions
    final FileSystem fs = inFile.getFileSystem(params);
    Vector<Path> matchingPartitions = selectTemporalPartitions(inFile, params);

    // 2- Find the matching tile and the position in that tile
    final Point queryPoint = (Point) params.getShape("point");
    final double userQueryLon = queryPoint.x;
    final double userQueryLat = queryPoint.y;
    // Convert query point from lat/lng space to Sinusoidal space
    double cosPhiRad = Math.cos(queryPoint.y * Math.PI / 180);
    double projectedX = queryPoint.x * cosPhiRad;
    queryPoint.x = (projectedX + 180.0) / 10.0;
    queryPoint.y = (90.0 - queryPoint.y) / 10.0;
    final int h = (int) Math.floor(queryPoint.x);
    final int v = (int) Math.floor(queryPoint.y);
    final String tileID = String.format("h%02dv%02d", h, v);
    PathFilter rangeFilter = new PathFilter() {
        @Override
        public boolean accept(Path p) {
            return p.getName().indexOf(tileID) >= 0;
        }
    };

    final Vector<Path> allMatchingFiles = new Vector<Path>();

    for (Path matchingPartition : matchingPartitions) {
        // Select all matching files
        FileStatus[] matchingFiles = fs.listStatus(matchingPartition, rangeFilter);
        for (FileStatus matchingFile : matchingFiles) {
            allMatchingFiles.add(matchingFile.getPath());
        }
    }

    // All matching files are supposed to have the same resolution
    final int resolution = AggregateQuadTree.getResolution(fs, allMatchingFiles.get(0));

    final java.awt.Point queryInMatchingTile = new java.awt.Point();
    queryInMatchingTile.x = (int) Math.floor((queryPoint.x - h) * resolution);
    queryInMatchingTile.y = (int) Math.floor((queryPoint.y - v) * resolution);

    // 3- Query all matching files in parallel
    List<Long> threadsResults = Parallel.forEach(allMatchingFiles.size(), new RunnableRange<Long>() {
        @Override
        public Long run(int i1, int i2) {
            ResultCollector<AggregateQuadTree.PointValue> internalOutput = output == null ? null
                    : new ResultCollector<AggregateQuadTree.PointValue>() {
                        NASAPoint middleValue = new NASAPoint(userQueryLon, userQueryLat, 0, 0);

                        @Override
                        public void collect(AggregateQuadTree.PointValue value) {
                            middleValue.value = value.value;
                            middleValue.timestamp = value.timestamp;
                            output.collect(middleValue);
                        }
                    };

            long numOfResults = 0;
            for (int i_file = i1; i_file < i2; i_file++) {
                try {
                    Path matchingFile = allMatchingFiles.get(i_file);
                    java.awt.Rectangle query = new java.awt.Rectangle(queryInMatchingTile.x,
                            queryInMatchingTile.y, 1, 1);
                    AggregateQuadTree.selectionQuery(fs, matchingFile, query, internalOutput);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return numOfResults;
        }
    });
    long totalResults = 0;
    for (long result : threadsResults) {
        totalResults += result;
    }
    return totalResults;
}

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 w ww. j a v  a 2 s .c om*/
        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:com.globalsight.everest.usermgr.UserLdapHelper.java

/**
 * Get names of the given users, assuming each user must have a name.
 *//*w  ww. j a  v a 2  s.  co  m*/
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:com.vsquaresystem.safedeals.marketprice.MarketPriceService.java

public Boolean checkExistingData() throws IOException {
    Vector checkCellVectorHolder = read();
    int excelSize = checkCellVectorHolder.size() - 1;
    List<MarketPrice> rs = marketPriceDAL.getAll();
    JFrame parent = new JFrame();
    Boolean val;
    int listSize = rs.size();
    if (excelSize == listSize || excelSize > listSize) {
        val = true;
    } else {//from w  ww.j  av a 2s. c  o m
        System.out.println("No selected");
        val = false;
    }

    return val;
}