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:edu.umn.cs.spatialHadoop.operations.Indexer.java

private static void indexLocal(Path inPath, Path outPath, OperationsParams params) throws IOException {
    JobConf job = new JobConf(params);
    String sindex = params.get("sindex");
    Partitioner partitioner = createPartitioner(inPath, outPath, job, sindex);

    // Start reading input file
    Vector<InputSplit> splits = new Vector<InputSplit>();
    final ShapeIterInputFormat inputFormat = new ShapeIterInputFormat();
    FileSystem inFs = inPath.getFileSystem(params);
    FileStatus inFStatus = inFs.getFileStatus(inPath);
    if (inFStatus != null && !inFStatus.isDir()) {
        // One file, retrieve it immediately.
        // This is useful if the input is a hidden file which is automatically
        // skipped by FileInputFormat. We need to plot a hidden file for the case
        // of plotting partition boundaries of a spatial index
        splits.add(new FileSplit(inPath, 0, inFStatus.getLen(), new String[0]));
    } else {/*from  w w w .  j  av a2 s.  com*/
        ShapeIterInputFormat.addInputPath(job, inPath);
        for (InputSplit s : inputFormat.getSplits(job, 1))
            splits.add(s);
    }

    // Copy splits to a final array to be used in parallel
    final FileSplit[] fsplits = splits.toArray(new FileSplit[splits.size()]);
    boolean replicate = job.getBoolean("replicate", false);

    final IndexRecordWriter<Shape> recordWriter = new IndexRecordWriter<Shape>(partitioner, replicate, sindex,
            outPath, params);

    for (FileSplit fsplit : fsplits) {
        RecordReader<Rectangle, Iterable<? extends Shape>> reader = inputFormat.getRecordReader(fsplit, job,
                null);
        Rectangle partitionMBR = reader.createKey();
        Iterable<? extends Shape> shapes = reader.createValue();

        final IntWritable partitionID = new IntWritable();

        while (reader.next(partitionMBR, shapes)) {
            if (replicate) {
                // Replicate each shape to all overlapping partitions
                for (final Shape s : shapes) {
                    partitioner.overlapPartitions(s, new ResultCollector<Integer>() {
                        @Override
                        public void collect(Integer id) {
                            partitionID.set(id);
                            try {
                                recordWriter.write(partitionID, s);
                            } catch (IOException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    });
                }
            } else {
                for (Shape s : shapes) {
                    partitionID.set(partitioner.overlapPartition(s));
                    recordWriter.write(partitionID, s);
                }
            }
        }
        reader.close();
    }

    recordWriter.close(null);
}

From source file:com.symbian.driver.core.controller.tasks.BuildTaskTest.java

public void testDoBuild_RBuild_NoAbldBat() {
    if (!iAbldBat.delete()) {
        fail();//from  www  .j  a va  2s  . c  o  m
    }

    String lPlatform = "armv5";
    String lVariant = "udeb";

    iTDConfig.expects(once()).method("getPreference").with(eq(TDConfig.PLATFORM)).will(returnValue(lPlatform));

    iTDConfig.expects(once()).method("getPreference").with(eq(TDConfig.VARIANT)).will(returnValue(lVariant));

    iExecuteFactoryMock.expects(exactly(2)).method("createExecuteOnHost")
            .with(isA(File.class), isA(String.class)).will(returnValue(iIExecuteOnHostMock.proxy()));

    iIExecuteOnHostMock.expects(exactly(2)).method("doTask").with(eq(true), ANYTHING);

    String[] lFiles = { "testexecute.exe", "testexecute.dll", "file.map", "noensense.blah" };
    String lReturnGetOutput = "";
    for (int i = 0; i < lFiles.length; i++) {
        lReturnGetOutput += "epoc32\\RELEASE\\" + lPlatform.toUpperCase() + "\\" + lVariant.toUpperCase() + "\\"
                + lFiles[i] + "\n";
    }

    iIExecuteOnHostMock.expects(exactly(2)).method("getOutput").will(returnValue(lReturnGetOutput));

    BuildTask lBuildTask = new BuildTask((ExecuteFactory) iExecuteFactoryMock.proxy(),
            (TDConfig) iTDConfig.proxy());

    try {

        Vector lTransferVector = lBuildTask.doBuild(iCWD, true, "mmp");

        if (lTransferVector == null || lTransferVector.size() != 1
                || ((File) lTransferVector.get(0)).getAbsolutePath().indexOf(lFiles[0]) == -1) {
            fail();
        }

    } catch (TimeLimitExceededException lTimeLimitExceededException) {
        lTimeLimitExceededException.printStackTrace();
        fail();
    } catch (IOException e) {
        e.printStackTrace();
        fail();
    } catch (ParseException e) {
        e.printStackTrace();
        fail();
    }
}

From source file:dao.CarryonEntryIdQuery.java

public List run(Connection conn, String loginid) {
    String sqlQuery = "select entryid from carryon where loginid=" + loginid
            + " order by entrydate DESC limit 1";
    try {//from w  w  w .j a va  2 s.com
        PreparedStatement stmt = conn.prepareStatement(sqlQuery);
        ResultSet rs = stmt.executeQuery();

        Vector columnNames = null;
        Photo photo = null;
        List photosList = new ArrayList();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        }

        while (rs.next()) {
            photo = (Photo) eop.newObject(DbConstants.PHOTO);
            for (int j = 0; j < columnNames.size(); j++) {
                photo.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            photosList.add(photo);
        }
        return photosList;
    } catch (Exception e) {
        logger.warn("Error occured while executing CarryonEntryIdQuery run query", e);
        throw new BaseDaoException("Error occured while executing CarryonEntryIdQuery run query " + sqlQuery,
                e);
    }
}

From source file:com.yahoo.messenger.data.json.ClientCapabilityList.java

public void unserializeJSON(JSONArray a) throws JSONException {

    Vector v = new Vector();

    //  Mandatory fields

    for (int i = 0; i < a.length(); i++) {

        JSONObject o = a.getJSONObject(i);
        ClientCapability c = new ClientCapability();
        c.unserializeJSON(o.getJSONObject("clientCapability"));
        v.addElement(c);/*from w  w  w . ja va  2s  . c  o m*/
    }

    clientCapabilities = new ClientCapability[v.size()];
    v.copyInto(clientCapabilities);

}

From source file:edu.uga.cs.fluxbuster.clustering.hierarchicalclustering.DistanceMatrix.java

/**
 * Populate distance matrix from a list of matrix values specified in row
 * major order./*w  w  w  . j a  v a 2s . c  om*/
 * 
 * @param vals
 *            the matrix values
 */
private void populateDistanceMatrix(Vector<Float> vals) {
    int matrixdim = (int) Math.ceil(Math.sqrt(2 * vals.size()));

    int length = matrixdim - 1;
    int start = 0;
    for (int i = 0; i < matrixdim - 1; i++) {
        Vector<Float> row = new Vector<Float>();
        row.addAll(vals.subList(start, start + length));
        distMatrix.add(row);
        start += length;
        length--;
    }
}

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

@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.POST)
public ModelAndView doPost(final HttpServletRequest request) {
    Map<String, Object> model = new HashMap<String, Object>();

    /* Get the params from the form request */
    String dataset_name = request.getParameter("id");
    String[] file_names = request.getParameterValues("child_id");
    String[] file_urls = request.getParameterValues("child_url");
    String goUserName = request.getParameter("goUserName");
    String myProxyServerStr = request.getParameter(GOFORMVIEW_MYPROXY_SERVER);
    String myProxyUserName = request.getParameter(GOFORMVIEW_SRC_MYPROXY_USER);
    String myProxyUserPass = request.getParameter("myProxyUserPass");
    //String goEmail = request.getParameter("goEmail");

    LOG.debug("GOFormView2Controller: dataset_name = " + dataset_name);
    LOG.debug("GOFormView2Controller: file_names = " + file_names);
    LOG.debug("GOFormView2Controller: file_urls = " + file_urls);

    LOG.debug("goUserName: " + goUserName + " " + "myProxyUserName: " + myProxyUserName + " "
            + "myProxyUserPass: " + "*****" + " myProxyServerStr: " + myProxyServerStr);
    System.out.println("goUserName: " + goUserName + " " + "myProxyUserName: " + myProxyUserName + " "
            + "myProxyUserPass: " + "*****" + " myProxyServerStr: " + myProxyServerStr);

    StringBuffer errorStatus = new StringBuffer("Steps leading up to the error are shown below:<br><br>");
    errorStatus.append("Globus Online Username entered: ");
    errorStatus.append(goUserName);//from   w w w . j  a v a 2s  .c  om
    errorStatus.append("<br>MyProxy Username entered: ");
    errorStatus.append(myProxyUserName);
    errorStatus.append("<br>");

    try {
        LOG.debug("Initializing Globus Online Transfer object");

        JGOTransfer transfer = new JGOTransfer(goUserName, myProxyServerStr, myProxyUserName, myProxyUserPass,
                CA_CERTIFICATE_FILE);

        transfer.setVerbose(true);
        transfer.initialize();

        LOG.debug("Globus Online Transfer object Initialize complete");

        errorStatus.append("Globus Online Transfer object Initialize complete<br>");

        String userCertificateFile = transfer.getUserCertificateFile();
        LOG.debug("Retrieved user credential file: " + userCertificateFile);

        LOG.debug("About to retrieve available endpoints");
        Vector<EndpointInfo> endpoints = transfer.listEndpoints();
        LOG.debug("We pulled down " + endpoints.size() + " endpoints");
        errorStatus.append("Endpoints retrieved<br>");

        // Make sure if any of the user's local endpoints are
        // globus connect endpoints, they are listed first
        endpoints = Utils.bringGCEndpointsToTop(goUserName, endpoints);

        if (request.getParameter(GOFORMVIEW_MODEL) != null) {

        } else {
            LOG.debug("Placing all info in the model");
            model.put(GOFORMVIEW_FILE_URLS, file_urls);
            model.put(GOFORMVIEW_FILE_NAMES, file_names);
            model.put(GOFORMVIEW_DATASET_NAME, dataset_name);
            model.put(GOFORMVIEW_USER_CERTIFICATE, userCertificateFile);
            model.put(GOFORMVIEW_GO_USERNAME, goUserName);
            model.put(GOFORMVIEW_SRC_MYPROXY_USER, myProxyUserName);
            model.put(GOFORMVIEW_SRC_MYPROXY_PASS, myProxyUserPass);
            model.put(GOFORMVIEW_MYPROXY_SERVER, myProxyServerStr);

            String[] endPointNames = getDestinationEndpointNames(endpoints);
            String[] endPointInfos = constructEndpointInfos(endpoints);

            LOG.debug("Retrieved an array of " + endPointNames.length + " Endpoint names");
            LOG.debug("Retrieved an array of " + endPointInfos.length + " EndpointInfo strings");

            model.put(GOFORMVIEW_ENDPOINTS, endPointNames);
            model.put(GOFORMVIEW_ENDPOINTINFOS, endPointInfos);

            LOG.debug("All info placed in the model!");
        }
    } catch (MyProxyException me) {
        String error = me.toString();
        if (error.contains("invalid password")) {
            error = "We could not start your download because of the following error:<br><br>The password you provided for your ESGF account with username \""
                    + myProxyUserName
                    + "\" is incorrect.<br><br>Please use your browser back button to go to the previous page, and try the request again.";
        } else {
            error = errorStatus.toString() + "<br><b>Main Error:</b><br><br>" + me.toString();
        }
        model.put(GOFORMVIEW_ERROR, "error");
        model.put(GOFORMVIEW_ERROR_MSG, error);
        LOG.error("Failed to initialize Globus Online: " + me);
    } catch (JGOTransferException jgte) {
        String error = jgte.toString();
        if (error.contains(
                "Endpoint List failure: ClientError.AuthenticationFailed(400 Authentication Failed)")) {
            error = "Your Globus Online Account \"" + goUserName
                    + "\" is not linked to the ESGF Portal account.<br><br>Please follow steps in <a href=\"https://github.com/ESGF/esgf.github.io/wiki/ESGF_GO_AccountSetup\">https://github.com/ESGF/esgf.github.io/wiki/ESGF_GO_AccountSetup</a> to link accounts.";
        }
        model.put(GOFORMVIEW_ERROR, "error");
        model.put(GOFORMVIEW_ERROR_MSG, error);
        LOG.error("Failed to initialize Globus Online: " + jgte);
    } catch (Exception e) {
        String error = errorStatus.toString() + "<br><b>Main Error:</b><br><br>" + e.toString();
        model.put(GOFORMVIEW_ERROR, "error");
        model.put(GOFORMVIEW_ERROR_MSG, error);
        LOG.error("Failed to initialize Globus Online: " + e);
        e.printStackTrace();
    }
    return new ModelAndView("goformview2", model);
}

From source file:dao.CarryonHitsQuery.java

/**
 * This constructor is called when the bean makes a 
 * call to query.execute(). /*from ww w . j ava  2 s.  c  om*/
 */
public List run(Connection conn) throws BaseDaoException {

    if (conn == null) {
        return null;
    }

    try {
        PreparedStatement stmt = conn.prepareStatement(
                "select hdlogin.login, carryonhits.loginid,carryonhits.entryid,carryonhits.btitle,carryonhits.hits,carryontag.usertags from carryonhits left join carryontag on carryonhits.loginid=carryontag.ownerid and carryontag.entryid=carryonhits.entryid left join hdlogin on carryonhits.loginid=hdlogin.loginid group by carryonhits.entryid order by hits DESC limit 20");

        if (stmt == null) {
            return null;
        }

        ResultSet rs = stmt.executeQuery();
        Vector columnNames = null;
        Photo photo = null;
        List photoList = new ArrayList();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
            while (rs.next()) {
                photo = (Photo) eop.newObject(DbConstants.PHOTO);
                for (int j = 0; j < columnNames.size(); j++) {
                    photo.setValue((String) columnNames.elementAt(j),
                            (String) rs.getString((String) columnNames.elementAt(j)));
                }
                photoList.add(photo);
            }
        }
        return photoList;
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing carryonhits run query ", e);
    }
}

From source file:gsn.http.ac.MyDataSourceCandidateWaitingListServlet.java

/******************************************************************************************************/

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    // Get the session
    HttpSession session = req.getSession();
    ConnectToDB ctdb = null;/*w  w w .ja  va2  s .c om*/

    User user = (User) session.getAttribute("user");
    if (user == null) {
        this.redirectToLogin(req, res);
    } else {
        this.checkSessionScheme(req, res);
        if (user.isAdmin() == false) {
            res.sendError(WebConstants.ACCESS_DENIED, "Access denied.");
        } else {
            this.printHeader(out);
            this.printLayoutMastHead(out, user);
            this.printLayoutContent(out);
            try {
                ctdb = new ConnectToDB();
                Vector v = ctdb.getDataSourceCandidates();
                if (v.size() == 0) {
                    out.println("<p><B>There is no entry in the waiting list !</p></B>");
                }
                for (int i = 0; i < v.size(); i++) {
                    //printForm(out,(DataSource)(v.get(i)));
                    printNewEntry(out, (DataSource) (v.get(i)));
                }
            } catch (Exception e) {
                out.println("<p><B>Can not print the form !</p></B>");
                logger.error("ERROR IN doGet");
                logger.error(e.getMessage(), e);
            } finally {
                if (ctdb != null) {
                    ctdb.closeStatement();
                    ctdb.closeConnection();
                }
            }
            this.printLayoutFooter(out);
        }

    }

}

From source file:com.autoparts.buyers.activity.InquiryModelActivity.java

public void setData(ResponseModel responseModel) {

    //        {/* w  w  w  . j a  va 2 s . c om*/
    //                "bandid":"?(int)",
    //                "nam":"???",
    //                "pic":"url",
    //                "first":"?"
    //        }

    Vector<HashMap<String, Object>> maps = responseModel.getMaps();
    for (int i = 0; i < maps.size(); i++) {
        HashMap<String, Object> map = maps.get(i);
        String bandid = (String) map.get("bandid");
        String nam = (String) map.get("nam");
        String pic = (String) map.get("pic");
        String first = (String) map.get("first");
        CommonLetterModel commonLetterModel = new CommonLetterModel();

        commonLetterModel.setUser_id(bandid);
        commonLetterModel.setUser_image(pic);
        commonLetterModel.setUser_name(nam);
        if (TextUtils.isEmpty(first)) {
            first = "#";
        }
        commonLetterModel.setUser_key(first);
        mList.add(commonLetterModel);
    }

    mList = contactUtils.getListKey(mList);
    mIndexer = contactUtils.getmIndexer();
    actionsAdapter.setData(mList);
    actionsAdapter.notifyDataSetChanged();
}

From source file:edu.ku.brc.af.ui.forms.MenuSwitcherPanel.java

/**
 * Creates a special drop "switcher UI" component for switching between the Viewables in the MultiView.
 * @param mvParentArg the MultiView Parent
 * @param altViewsListArg the Vector of AltViewIFace that will contains the ones in the Drop Down
 * @return the special combobox/*w  ww. java2s .  c o  m*/
 */
protected DropDownButtonStateful createSwitcher(final MultiView mvParentArg,
        final Vector<AltViewIFace> altViewsListArg) {
    DropDownButtonStateful switcher = null;
    List<DropDownMenuInfo> items = new ArrayList<DropDownMenuInfo>(altViewsListArg.size());

    // If we have AltViewIFace then we need to build information for the Switcher Control
    if (altViewsListArg.size() > 0) {
        for (AltViewIFace av : altViewsListArg) {
            String label = null;
            ImageIcon imgIcon = null;
            String toolTip = null;

            // TODO This is Sort of Temporary until I get it all figured out
            // But somehow we need to externalize this, possible have the AltViewIFace Definition
            // define its own icon

            ViewDefIFace viewDef = av.getViewDef();
            boolean isEdit = av.getMode() == AltViewIFace.CreationMode.EDIT;

            if (viewDef != null) {
                if (viewDef.getType() == ViewDefIFace.ViewType.form) {
                    label = getResourceString("Form");
                    imgIcon = IconManager.getImage(isEdit ? "EditForm" : "ViewForm",
                            IconManager.IconSize.Std16);
                    toolTip = getResourceString(isEdit ? "ShowEditViewTT" : "ShowViewTT");

                } else if (viewDef.getType() == ViewDefIFace.ViewType.table
                        || viewDef.getType() == ViewDefIFace.ViewType.formtable) {
                    label = getResourceString("Grid");
                    imgIcon = IconManager.getImage(isEdit ? "SpreadsheetEdit" : "Spreadsheet",
                            IconManager.IconSize.Std16);
                    toolTip = getResourceString("ShowSpreadsheetTT");

                } else {
                    label = getResourceString("Icon");
                    imgIcon = IconManager.getImage("image", IconManager.IconSize.Std16);
                    toolTip = getResourceString("ShowViewTT");
                }
            }

            // Override when Top Level Form
            if (mvParentArg.isTopLevel()) {
                label = getResourceString(isEdit ? "EDIT" : "View");
            }

            items.add(new DropDownMenuInfo(label, imgIcon, toolTip));
        }

        switcher = new DropDownButtonStateful(items);
        switcher.setToolTipText(getResourceString("SwitchViewsTT"));
        switcher.addActionListener(new SwitcherAL(switcher, mvParentArg, altViewsListArg, false));
        switcher.validate();
        switcher.doLayout();
        switcher.setOpaque(false);

        switcherAL = new SwitcherAL(switcher, mvParentArg, altViewsListArg, true);
    }
    return switcher;
}