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:dao.CollModeratorsListQuery.java

/**
 * This method lists all the moderators for a collabrum
 * @param conn the connection//from w  ww  .  jav a  2s .c o  m
 * @param collabrumId the collabrumid
 * @return HashSet the set that has the list of moderators for these collabrums.
 * @throws BaseDaoException - when error occurs
 **/
public HashSet run(Connection conn, String collabrumId) throws BaseDaoException {

    String sqlQuery = "select distinct CONCAT(hd.fname,' ',hd.lname) AS membername, "
            + "hd.login, hd.loginid, c1.collabrumid, c2.name from colladmin c1, "
            + "hdlogin hd, collabrum c2 where c1.loginid=hd.loginid "
            + "and c1.collabrumid=c2.collabrumid and c1.collabrumid=" + collabrumId + "";
    try {
        PreparedStatement stmt = conn.prepareStatement(sqlQuery);
        ResultSet rs = stmt.executeQuery();
        Vector columnNames = null;
        Collabrum collabrum = null;
        HashSet pendingSet = new HashSet();

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

        while (rs.next()) {
            collabrum = (Collabrum) eop.newObject("collabrum");
            for (int j = 0; j < columnNames.size(); j++) {
                collabrum.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            pendingSet.add(collabrum);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException(
                "Error occured while executing collabrum moderatorslist run query " + sqlQuery, e);
    }
}

From source file:dao.CarryonHitsBizAwareQuery.java

/**
 * This constructor is called when the Collabrum bean makes a 
 * call to query.execute(). After the query is executed, the result set is
 * returned. For each row in the result set, the mapRow method is called by
 * Spring. In the very first call to mapRow() for the first row in the result
 * set, we make a call to RSMD to get columnNames and cache
 * them to a local array in this object. This way, we can avoid multiple calls
 * to RSMD since, spring calls mapRow many times (one per row in result set).
 *
 *//*from w  w  w.  j a v a 2  s .  com*/
public List run(Connection conn, String bid) throws BaseDaoException {

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

    try {
        String query = "select c1.entryid, hdlogin.login, c1.btitle, c1.hits, bid from carryonhits c1, "
                + "hdlogin where hdlogin.bid=" + bid + " and c1.loginid=hdlogin.loginid order by hits DESC";

        PreparedStatement stmt = conn.prepareStatement(query);
        if (stmt == null) {
            return null;
        }
        //rs = stmt.executeQuery("select * from carryonhits order by hits DESC");
        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 carryonhitsbizaware run query ", e);
    }
}

From source file:com.globalsight.everest.workflowmanager.WfStatePostThread.java

@SuppressWarnings("unchecked")
private JSONObject getNotifyMessage(Task p_task, String p_destinationArrow, boolean isDispatch)
        throws Exception {
    String toArrowName = p_destinationArrow;
    JSONObject jsonObj = new JSONObject();
    long jobId = p_task.getJobId();
    if (isDispatch) {
        jsonObj.put("prevActivity", "start");
        WorkflowTaskInstance firstTask = ServerProxy.getWorkflowServer()
                .getWorkflowTaskInstance(p_task.getWorkflow().getId(), p_task.getId());
        jsonObj.put("currActivity", firstTask.getActivityDisplayName());
        Vector<WorkflowArrowInstance> arrows3 = firstTask.getIncomingArrows();
        for (WorkflowArrowInstance arrow3 : arrows3) {
            WorkflowTaskInstance srcNode = (WorkflowTaskInstance) arrow3.getSourceNode();
            if (srcNode.getType() == WorkflowConstants.START) {
                toArrowName = arrow3.getName();
            }/*from   w w  w .j  av  a2  s.  c  o m*/
        }
    } else {
        WorkflowTaskInstance nextTask = ServerProxy.getWorkflowServer().nextNodeInstances(p_task,
                p_destinationArrow, null);
        if (nextTask != null) {
            jsonObj.put("currActivity", nextTask.getActivityDisplayName());
        } else {
            jsonObj.put("currActivity", "exit");
        }
        if (StringUtils.isEmpty(p_destinationArrow)) {
            if (nextTask != null) {
                Vector<WorkflowArrowInstance> arrows = nextTask.getIncomingArrows();
                if (arrows != null && arrows.size() == 1) {
                    toArrowName = arrows.get(0).getName();
                } else {
                    for (WorkflowArrowInstance arrow : arrows) {
                        toArrowName = determineIncomingArrow(arrow, p_task.getId());
                        if (toArrowName != null)
                            break;
                    }
                }
            } else {
                WorkflowTaskInstance currentTask = ServerProxy.getWorkflowServer()
                        .getWorkflowTaskInstance(p_task.getWorkflow().getId(), p_task.getId());
                Vector<WorkflowArrowInstance> arrows2 = currentTask.getOutgoingArrows();
                for (WorkflowArrowInstance arrow2 : arrows2) {
                    toArrowName = determineOutgoingArrow(arrow2);
                    if (toArrowName != null)
                        break;
                }
            }
        }
        jsonObj.put("prevActivity", p_task.getTaskDisplayName());
    }
    jsonObj.put("arrowText", toArrowName);
    jsonObj.put("jobId", jobId);
    jsonObj.put("jobName", p_task.getJobName());
    jsonObj.put("workflowId", p_task.getWorkflow().getIdAsLong());
    jsonObj.put("sourceLocale", p_task.getSourceLocale().toString());
    jsonObj.put("targetLocale", p_task.getTargetLocale().toString());

    return jsonObj;
}

From source file:de.unibayreuth.bayeos.goat.table.OctetMatrixTableModel.java

private void readStream(InputStream in, Vector objekts) throws IOException {
    int von = 0;/*from w  ww  .  j  a  v  a 2s  .co  m*/
    rowCount = 0;
    ObjectInputStream oin = new ObjectInputStream(in);
    try {
        while (true) {
            vonList.add(oin.readInt());
            for (int c = 0; c < objekts.size(); c++) {
                wertList.add(oin.readObject());
            }
            rowCount++;
        }
    } catch (EOFException i) {
        if (logger.isDebugEnabled()) {
            logger.debug("Stream with " + rowCount + " rows red.");
        }
    } catch (ClassNotFoundException e) {
        logger.error(e.getMessage());
    }

}

From source file:com.duroty.lucene.bookmark.BookmarkToLuceneBookmark.java

/**
 * DOCUMENT ME!//from  w  ww.jav  a  2  s.  c  om
 *
 * @param mime DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 * @throws URISyntaxException
 * @throws IOException
 */
public LuceneBookmark parse(String idint, BookmarkObj bookmarkObj) throws URISyntaxException, IOException {
    if ((idint == null) || (bookmarkObj == null)) {
        return null;
    }

    LuceneBookmark luceneBookmark = new LuceneBookmark(idint);

    luceneBookmark.setCacheDate(new Date());

    String comments = null;

    try {
        comments = factory.parse(bookmarkObj.getComments(), "text/html",
                Charset.defaultCharset().displayName());
    } catch (Exception ex) {
        if (ex != null) {
            comments = ex.getMessage();
        }
    }

    luceneBookmark.setComments(comments);

    if (!StringUtils.isBlank(comments)) {
        luceneBookmark.setNotebook(true);
    }

    String url = bookmarkObj.getUrl();
    HttpContent httpContent = new HttpContent(new URL(url));
    MimeType mimeType = httpContent.getContentType();
    String contentType = "text/html";

    if (mimeType != null) {
        contentType = mimeType.getBaseType();
    }

    InputStream inputStream = httpContent.newInputStream();

    if (!StringUtils.isBlank(bookmarkObj.getTitle())) {
        luceneBookmark.setTitle(bookmarkObj.getTitle());
    } else {
        Vector elements = Extractor.getElements(httpContent.newInputStream(), null, "title");

        Text text = null;

        if ((elements != null) && (elements.size() == 1)) {
            Element element = (Element) elements.get(0);
            text = (Text) element.getFirstChild();
        }

        if (text != null) {
            luceneBookmark.setTitle(text.getData());
        } else {
            luceneBookmark.setTitle(url);
        }
    }

    String charset = httpContent.getCharset();

    if (charset == null) {
        charset = Charset.defaultCharset().displayName();
    }

    String contents = null;

    try {
        contents = factory.parse(inputStream, contentType, charset);
    } catch (Exception ex) {
        if (ex != null) {
            contents = ex.getMessage();
        }
    }

    luceneBookmark.setContents(contents);

    luceneBookmark.setDepth(bookmarkObj.getDepth());
    luceneBookmark.setFlagged(bookmarkObj.isFlagged());
    luceneBookmark.setInsertDate(new Date());
    luceneBookmark.setKeywords(bookmarkObj.getKeywords());

    //luceneBookmark.setNotebook(bookmarkObj.isNotebook());
    luceneBookmark.setParent(String.valueOf(bookmarkObj.getParent()));
    luceneBookmark.setUrl(url);
    luceneBookmark.setUrlStr(url);

    return luceneBookmark;
}

From source file:com.clustercontrol.poller.impl.MultipleOidsUtils.java

public Collection<VariableBinding> query(Target target, OID[] rootOids) throws IOException {
    HashMap<OID, VariableBinding> result = new HashMap<OID, VariableBinding>();

    if ((rootOids == null) || (rootOids.length == 0)) {
        throw new IllegalArgumentException("No OIDs specified");
    }/*from w w w  .j ava 2 s. c o  m*/

    PDU request = pduFactory.createPDU(target);
    // Bulk????MaxRepetitions
    if (request.getType() == PDU.GETBULK) {
        // DefaultPDUFactory?????????????PDU??
        request.setMaxRepetitions(this.factory.getMaxRepetitions());
    }

    RootOidAndOidMapping mapping = new RootOidAndOidMapping(rootOids);
    int requestCounter = 0;
    int responseCounter = 0;
    while (!mapping.isEmpty()) {
        ArrayList<OID> oidList = mapping.getOidList();
        log.debug(target.getAddress() + " oidList.size=" + oidList.size());
        RootOidAndOidMapping oldMapping = new RootOidAndOidMapping(mapping);

        PDU response = sendRequest(request, target, oidList);
        requestCounter++;
        if (response == null) {
            log.info(target.getAddress() + " response is null : result.size=" + result.values().size());
            throw new IOException(MessageConstant.MESSAGE_TIME_OUT.getMessage());
        }

        Vector<? extends VariableBinding> vbs = response.getVariableBindings();
        int requestOidSize = request.getVariableBindings().size();//requestOidSize <= oidList.size()

        for (int i = 0; i < vbs.size(); i++) {
            responseCounter++;
            VariableBinding vb = vbs.get(i);
            log.trace("oid=" + vb.getOid() + ", " + vb.toString());

            int colIndex = i % requestOidSize;
            OID oldOid = oidList.get(colIndex);
            OID rootOid = oldMapping.getRootOidByOid(oldOid);
            if (rootOid == null) {
                continue;
            }

            mapping.removeByRootOid(rootOid);

            if (vb.isException()) {
                log.debug("exception " + target.getAddress() + ", " + vb.toString()); // endOfMibView
                continue;
            }

            OID oid = vb.getOid();
            if (!oid.startsWith(rootOid)) {
                continue;
            }

            if (result.containsKey(oid)) {
                continue;
            }

            result.put(oid, vb);
            mapping.put(rootOid, oid);
        }
    }

    // SNMP???????
    String message = target.getAddress() + ", requestCounter=" + requestCounter + ", responseCounter="
            + responseCounter;
    if (requestCounter > 200 || responseCounter > 10000) {
        log.warn(message);
    } else if (requestCounter > 100 || responseCounter > 5000) {
        log.info(message);
    } else {
        log.debug(message);
    }

    return result.values();
}

From source file:bboss.org.apache.velocity.runtime.resource.loader.JarResourceLoader.java

/**
 * Called by Velocity to initialize the loader
 * @param configuration//from  w w w.ja v  a 2  s .  co m
 */
public void init(ExtendedProperties configuration) {
    log.trace("JarResourceLoader : initialization starting.");

    // rest of Velocity engine still use legacy Vector
    // and Hashtable classes. Classes are implicitly
    // synchronized even if we don't need it.
    Vector paths = configuration.getVector("path");
    StringUtils.trimStrings(paths);

    /*
     *  support the old version but deprecate with a log message
     */

    if (paths == null || paths.size() == 0) {
        paths = configuration.getVector("resource.path");
        StringUtils.trimStrings(paths);

        if (paths != null && paths.size() > 0) {
            log.debug("JarResourceLoader : you are using a deprecated configuration"
                    + " property for the JarResourceLoader -> '<name>.resource.loader.resource.path'."
                    + " Please change to the conventional '<name>.resource.loader.path'.");
        }
    }

    if (paths != null) {
        log.debug("JarResourceLoader # of paths : " + paths.size());

        for (int i = 0; i < paths.size(); i++) {
            loadJar((String) paths.get(i));
        }
    }

    log.trace("JarResourceLoader : initialization complete.");
}

From source file:de.nrw.hbz.regal.sync.Syncer.java

void dele(String pidFile) {
    Vector<String> pids;
    pids = readPidlist(pidFile);//from  w w  w . j a v a  2s  . c  o  m
    int size = pids.size();
    for (int i = 0; i < size; i++) {
        logger.info((i + 1) + " / " + size);
        String pid = pids.get(i);
        ingester.delete(pid);
        logger.info((i + 1) + "/" + size + " " + pid + " deleted!\n");
    }
}

From source file:FileTree.java

/** Add nodes from under "dir" into curTop. Highly recursive. */
DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir) {
    String curPath = dir.getPath();
    DefaultMutableTreeNode curDir = new DefaultMutableTreeNode(curPath);
    if (curTop != null) { // should only be null at root
        curTop.add(curDir);/* w  w  w  .j  a v a 2  s  .  c o  m*/
    }
    Vector ol = new Vector();
    String[] tmp = dir.list();
    for (int i = 0; i < tmp.length; i++)
        ol.addElement(tmp[i]);
    Collections.sort(ol, String.CASE_INSENSITIVE_ORDER);
    File f;
    Vector files = new Vector();
    // Make two passes, one for Dirs and one for Files. This is #1.
    for (int i = 0; i < ol.size(); i++) {
        String thisObject = (String) ol.elementAt(i);
        String newPath;
        if (curPath.equals("."))
            newPath = thisObject;
        else
            newPath = curPath + File.separator + thisObject;
        if ((f = new File(newPath)).isDirectory())
            addNodes(curDir, f);
        else
            files.addElement(thisObject);
    }
    // Pass two: for files.
    for (int fnum = 0; fnum < files.size(); fnum++)
        curDir.add(new DefaultMutableTreeNode(files.elementAt(fnum)));
    return curDir;
}

From source file:ArrayDictionary.java

/**
 * Create an ArrayDictionary, contructing the arrays of keys and
 * values from the two given vectors.//  ww w. j a  va 2  s.  co m
 * The two vectors should have the same size.
 * The increment is set to the number of elements.
 * @param keys the vector of keys
 * @param values the vector of values
 */
public ArrayDictionary(Vector keys, Vector values) {
    this(keys, values, values.size());
}