Example usage for java.util Vector clear

List of usage examples for java.util Vector clear

Introduction

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

Prototype

public void clear() 

Source Link

Document

Removes all of the elements from this Vector.

Usage

From source file:edu.ku.brc.specify.ui.db.ResultSetTableModel.java

/**
 * Cleans up internal data members.//from  w  w  w .j  a  va2s.  c  o  m
 */
public void cleanUp() {
    parentERTP = null;
    results = null;
    propertyListener = null;

    for (Vector<Object> list : cache) {
        list.clear();
    }
    cache.clear();

    if (ids != null) {
        ids.clear();
    }

}

From source file:edu.ku.brc.specify.ui.db.ResultSetTableModel.java

/**
 * Clears all the data from the model// w w  w  . j a v  a  2s . c  o  m
 *
 */
public void clear() {
    if (ids != null) {
        ids.clear();
    }

    if (cache != null) {
        for (Vector<Object> row : cache) {
            row.clear();
        }
        cache.clear();
    }
    classNames.clear();
    colNames.clear();

    currentRow = 0;
}

From source file:org.exist.xmlrpc.XmlRpcTest.java

@Test
public void testExecuteQuery() {
    System.out.println("---testExecuteQuery");
    storeData();/*  ww  w  .  j a va 2 s.  co  m*/
    try {
        Vector<Object> params = new Vector<Object>();
        String query = "distinct-values(//para)";
        params.addElement(query.getBytes(UTF_8));
        params.addElement(new Hashtable<Object, Object>());
        XmlRpcClient xmlrpc = getClient();
        System.out.println("Executing query: " + query);
        Integer handle = (Integer) xmlrpc.execute("executeQuery", params);
        Assert.assertNotNull(handle);

        params.clear();
        params.addElement(handle);
        Integer hits = (Integer) xmlrpc.execute("getHits", params);
        Assert.assertNotNull(hits);
        System.out.println("Found: " + hits.intValue());

        Assert.assertEquals(hits.intValue(), 2);

        params.addElement(new Integer(0));
        params.addElement(new Hashtable<Object, Object>());
        byte[] item = (byte[]) xmlrpc.execute("retrieve", params);
        System.out.println(new String(item, "UTF-8"));

        params.clear();
        params.addElement(handle);
        params.addElement(Integer.valueOf(1));
        params.addElement(new Hashtable<Object, Object>());
        item = (byte[]) xmlrpc.execute("retrieve", params);
        System.out.println(new String(item, "UTF-8"));
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}

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

/**
 * Clear the vectors from the class hash.
 *//*from   ww w .  ja  v  a2  s.  co m*/
protected void cleanClassToListHash() {
    for (Class<?> key : classToListHash.keySet()) {
        Vector<UIFieldFormatterIFace> list = classToListHash.get(key);
        list.clear();
    }
    classToListHash.clear();
}

From source file:org.openmrs.web.dwr.DWREncounterService.java

/**
 * Returns a map of results with the values as count of matches and a partial list of the
 * matching locations (depending on values of start and length parameters) while the keys are
 * are 'count' and 'objectList' respectively, if the length parameter is not specified, then all
 * matches will be returned from the start index if specified.
 * // w w w.  ja  v a  2s.c  o m
 * @param phrase is the string used to search for locations
 * @param includeRetired Specifies if retired locations should be returned
 * @param start the beginning index
 * @param length the number of matching encounters to return
 * @param getMatchCount Specifies if the count of matches should be included in the returned map
 * @return a map of results
 * @throws APIException
 * @since 1.8
 */
public Map<String, Object> findCountAndLocations(String phrase, boolean includeRetired, Integer start,
        Integer length, boolean getMatchCount) throws APIException {

    //Map to return
    Map<String, Object> resultsMap = new HashMap<String, Object>();
    Vector<Object> objectList = new Vector<Object>();
    try {
        LocationService es = Context.getLocationService();
        int locationCount = 0;
        if (getMatchCount) {
            locationCount += es.getCountOfLocations(phrase, includeRetired);
        }
        //if we have any matches or this isn't the first ajax call when the caller
        //requests for the count
        if (locationCount > 0 || !getMatchCount) {
            objectList = findBatchOfLocations(phrase, includeRetired, start, length);
        }

        resultsMap.put("count", locationCount);
        resultsMap.put("objectList", objectList);
    } catch (Exception e) {
        log.error("Error while searching for locations", e);
        objectList.clear();
        objectList.add(
                Context.getMessageSourceService().getMessage("Location.search.error") + " - " + e.getMessage());
        resultsMap.put("count", 0);
        resultsMap.put("objectList", objectList);
    }
    return resultsMap;
}

From source file:org.openmrs.module.chartsearch.web.dwr.DWRChartSearchService.java

public Map<String, Object> findObsAndCount(Integer patientId, String phrase, boolean includeRetired,
        List<String> includeClassNames, List<String> excludeClassNames, List<String> includeDatatypeNames,
        List<String> excludeDatatypeNames, Integer start, Integer length, boolean getMatchCount,
        List<String> selectedCategories) throws APIException {
    // Map to return
    Map<String, Object> resultsMap = new HashMap<String, Object>();
    Vector<Object> objectList = new Vector<Object>();

    try {//from  ww w . jav  a2 s  .co m
        long matchCount = 0;
        if (getMatchCount) {
            // get the count of matches
            matchCount += searcher.getDocumentListCount(patientId, phrase);
        }

        // if we have any matches or this isn't the first ajax call when
        // the caller
        // requests for the count
        if (matchCount > 0 || !getMatchCount) {
            objectList.addAll(
                    findBatchOfObs(patientId, phrase, includeRetired, includeClassNames, excludeClassNames,
                            includeDatatypeNames, excludeDatatypeNames, start, length, selectedCategories));
        }

        resultsMap.put("count", matchCount);
        resultsMap.put("objectList", objectList);

    } catch (Exception e) {
        log.error("Error while searching for observations", e);
        objectList.clear();
        objectList
                .add(Context.getMessageSourceService().getMessage("Obs.search.error") + " - " + e.getMessage());
        resultsMap.put("count", 0);
        resultsMap.put("objectList", objectList);
    }

    return resultsMap;
}

From source file:net.sf.l2j.gameserver.model.entity.L2JOneoRusEvents.CTF.java

private static boolean startEventOk() {
    if (_joining || !_teleport || _started)
        return false;
    if (Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE")) {
        if (_teamPlayersCount.contains(0))
            return false;
    } else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE")) {
        Vector<L2PcInstance> playersShuffleTemp = new Vector<L2PcInstance>();
        int loopCount = 0;
        loopCount = _playersShuffle.size();
        for (int i = 0; i < loopCount; i++) {
            if (_playersShuffle != null)
                playersShuffleTemp.add(_playersShuffle.get(i));
        }/*from   ww w. j a  va  2 s.  c  o m*/
        _playersShuffle = playersShuffleTemp;
        playersShuffleTemp.clear();
        // if (_playersShuffle.size() < (_teams.size()*2)){
        // return false;
        // }
    }
    return true;
}

From source file:edu.ucla.stat.SOCR.analyses.gui.Clustering.java

/**This method defines the specific statistical Analysis to be carried our on the user specified data. ANOVA is done in this case. */
public void doAnalysis() {

    if (dataTable.isEditing())
        dataTable.getCellEditor().stopCellEditing();

    if (!hasExample) {
        JOptionPane.showMessageDialog(this, DATA_MISSING_MESSAGE);
        return;// w  w w  .  ja  v  a2s  . c om
    }

    Data data = new Data();

    String dendroData[][] = new String[dataTable.getRowCount()][dataTable.getColumnCount()];

    for (int k = 0; k < dataTable.getRowCount(); k++)
        for (int j = 0; j < dataTable.getColumnCount(); j++) {

            if (dataTable.getValueAt(k, j) != null && !dataTable.getValueAt(k, j).equals("")) {
                dendroData[k][j] = (String) dataTable.getValueAt(k, j);
            }
        }

    ClusteringData = new LinkedList<String[]>(); // added (for lstdades)

    Vector<String> vectorDataRow = new Vector();

    for (int k = 0; k < dataTable.getRowCount(); k++) {
        for (int j = 0; j < dataTable.getColumnCount(); j++) {
            if (dendroData[k][j] != null && !dendroData[k][j].equals(""))
                vectorDataRow.add(dendroData[k][j]);
        }
        String stringDataRow[] = new String[vectorDataRow.size()];

        for (int i = 0; i < vectorDataRow.size(); i++) {
            stringDataRow[i] = vectorDataRow.get(i);
        }

        if (vectorDataRow.size() != 0) {
            ClusteringData.add(k, stringDataRow); // now exactly same as lstdades
            vectorDataRow.clear();
        }
    }

    f.getPwBtn().doLoad("Calculate");

    resultPanelTextArea.append("Click on DENDROGRAM panel to view the graph"
            + "\nSee SOCR Hierarchical Clustering Activity:\n"
            + "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_AnalysisActivities_HierarchicalClustering");

    /* every one has to have its own, otherwise one Exception spills the whole. */

    /* doGraph is underconstruction thus commented out. annie che 20060314 */
    //if (useGraph)
}

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

/**
 * Clean up internal data//from  w  w w. jav a 2  s.c  o m
 */
public void cleanUp() {
    jc = null;
    exp = null;

    for (FormValidator kid : kids) {
        kid.cleanUp();
    }
    parent = null;

    for (DataChangeNotifier dcn : dcNotifiers.values()) {
        dcn.cleanUp();
    }
    dcNotifiers.clear();

    for (UIValidator uv : validators) {
        uv.cleanUp();
    }
    validators.clear();

    fields.clear();
    labels.clear();

    for (FormValidationRuleIFace rule : formRules) {
        if (rule instanceof RuleExpression) {
            ((RuleExpression) rule).cleanUp();
        }
    }
    formRules.clear();

    for (Vector<Component> list : enableHash.values()) {
        list.clear();
    }
    dcListeners.clear();
    valListeners.clear();
}

From source file:esg.node.connection.ESGConnectionManager.java

public boolean prune() {
    log.trace("prune() ...");
    int pruneCount = 0;
    java.util.Vector<ESGPeer> peers_ = new java.util.Vector<ESGPeer>();
    peers_.addAll(peers.values());/* w  w  w  .  j a  v a2 s  .com*/
    log.trace("Inspecting [" + peers_.size() + "] currently known peers");
    for (ESGPeer peer : peers_) {
        if (peer.equals(defaultPeer))
            log.trace("(default peer)");
        if (!peer.ping()) {
            pruneCount++;
            log.trace("Pruning out unresponsive peer: (" + pruneCount + ") " + peer.getServiceURL());
        }
    }
    log.trace("Total number of pruned peers: [" + pruneCount + "] / [" + peers_.size() + "]");
    peers_.clear();

    peers_.addAll(unavailablePeers.values());
    log.trace("Inspecting [" + peers_.size() + "] currently dead peers");
    for (ESGPeer peer : peers_) {
        log.trace("Purging dead peer: " + peer);
        peer.unregister();
    }

    peers_.clear();
    peers_ = null; //gc niceness...
    log.trace("--> returning " + (pruneCount > 0));
    return (pruneCount > 0);
}