Example usage for java.util Vector remove

List of usage examples for java.util Vector remove

Introduction

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

Prototype

public synchronized E remove(int index) 

Source Link

Document

Removes the element at the specified position in this Vector.

Usage

From source file:oscar.oscarEncounter.oscarMeasurements.util.WriteNewMeasurements.java

static private void preProcess(Vector measures) {
    //fills in required values
    try {/*from w  w w . jav  a  2 s. c o  m*/

        ResultSet rs = null;
        for (int i = 0; i < measures.size(); i++) {
            Hashtable curmeasure = (Hashtable) measures.get(i);
            String type = (String) curmeasure.get("type");
            String measuringInst = (String) curmeasure.get("measuringInstruction");
            String comments = (String) curmeasure.get("comments");
            String dateObserved = (String) curmeasure.get("dateObserved");
            java.util.Date now = UtilDateUtilities.now();
            String dateEntered = UtilDateUtilities.DateToString(now, "yyyy-MM-dd HH:mm:ss");
            String sql;
            if (measuringInst == null || measuringInst.equals("")) {
                sql = "SELECT measuringInstruction FROM measurementType WHERE type='" + type + "'";
                rs = DBHandler.GetSQL(sql);
                if (rs.next()) {
                    measuringInst = oscar.Misc.getString(rs, "measuringInstruction");
                    curmeasure.put("measuringInstruction", measuringInst);
                    rs.close();
                } else {
                    measures.remove(i);
                    i--;
                    rs.close();
                    continue;
                }
            }
            if (comments == null) {
                curmeasure.put("comments", "");
            }
            if (dateObserved == null || dateObserved.equals("")) {
                curmeasure.put("dateObserved", dateEntered);
            }
            curmeasure.put("dateEntered", dateEntered);
        }
    } catch (SQLException sqe) {
        MiscUtils.getLogger().error("Error", sqe);
    }
}

From source file:com.vsquaresystem.safedeals.rawmarketprice.RawMarketPriceService.java

public boolean saveExcelToDatabase() throws IOException {

    Vector dataHolder = read();
    rawMarketPriceDAL.truncateAll();/*from w w  w  .j ava2s  .co  m*/
    dataHolder.remove(0);

    RawMarketPrice rawMarketPrice = new RawMarketPrice();
    String id = "";
    String cityId = "";
    String locationName = "";
    String year = "";
    String month = "";
    String mpAgriLandLowest = "";
    String mpAgriLandHighest = "";
    String mpPlotLowest = "";
    String mpPlotHighest = "";
    String mpResidentialLowest = "";
    String mpResidentialHighest = "";
    String mpCommercialLowest = "";
    String mpCommercialHighest = "";
    String sdZoneId = "";
    String locationTypeId = "";
    String locationCategories = "";
    String description = "";
    String majorApproachRoad = "";
    String sourceOfWater = "";
    String publicTransport = "";
    String advantage = "";
    String disadvantage = "";
    String population = "";
    String migrationRate = "";
    String isCommercialCenter = "";
    System.out.println(dataHolder);
    DataFormatter formatter = new DataFormatter();
    for (Iterator iterator = dataHolder.iterator(); iterator.hasNext();) {
        List list = (List) iterator.next();
        logger.info("list", list);
        cityId = list.get(1).toString();
        locationName = list.get(2).toString();
        year = list.get(3).toString();
        month = list.get(4).toString();
        mpAgriLandLowest = list.get(5).toString();
        mpAgriLandHighest = list.get(6).toString();
        mpPlotLowest = list.get(7).toString();
        mpPlotHighest = list.get(8).toString();
        mpResidentialLowest = list.get(9).toString();
        mpResidentialHighest = list.get(10).toString();
        mpCommercialLowest = list.get(11).toString();
        mpCommercialHighest = list.get(12).toString();
        sdZoneId = list.get(13).toString();
        locationTypeId = list.get(14).toString();
        locationCategories = list.get(15).toString();
        description = list.get(16).toString();
        majorApproachRoad = list.get(17).toString();
        sourceOfWater = list.get(18).toString();
        publicTransport = list.get(19).toString();
        advantage = list.get(20).toString();
        disadvantage = list.get(21).toString();
        population = list.get(22).toString();
        migrationRate = list.get(23).toString();
        isCommercialCenter = list.get(24).toString();
        List<String> strList = new ArrayList<String>(Arrays.asList(locationCategories.split(",")));
        List<Integer> numberList = new ArrayList<Integer>();
        for (String number : strList) {
            numberList.add(Integer.parseInt(number));
        }

        try {
            rawMarketPrice.setCityId(Integer.parseInt(cityId));
            rawMarketPrice.setLocationName(locationName);
            rawMarketPrice.setYear(Integer.parseInt(year));
            rawMarketPrice.setMonth(Integer.parseInt(month));
            rawMarketPrice.setMpAgriLandLowest(Double.parseDouble(mpAgriLandLowest));
            rawMarketPrice.setMpAgriLandHighest(Double.parseDouble(mpAgriLandHighest));
            rawMarketPrice.setMpPlotLowest(Double.parseDouble(mpPlotLowest));
            rawMarketPrice.setMpPlotHighest(Double.parseDouble(mpPlotHighest));
            rawMarketPrice.setMpResidentialLowest(Double.parseDouble(mpResidentialLowest));
            rawMarketPrice.setMpResidentialHighest(Double.parseDouble(mpResidentialHighest));
            rawMarketPrice.setMpCommercialLowest(Double.parseDouble(mpCommercialLowest));
            rawMarketPrice.setMpCommercialHighest(Double.parseDouble(mpCommercialHighest));
            rawMarketPrice.setSafedealZoneId(Integer.parseInt(sdZoneId));
            rawMarketPrice.setLocationTypeId(Integer.parseInt(locationTypeId));
            rawMarketPrice.setLocationCategories(numberList);
            rawMarketPrice.setDescription(description);
            rawMarketPrice.setMajorApproachRoad(majorApproachRoad);
            rawMarketPrice.setSourceOfWater(sourceOfWater);
            rawMarketPrice.setPublicTransport(publicTransport);
            rawMarketPrice.setAdvantage(advantage);
            rawMarketPrice.setDisadvantage(disadvantage);
            rawMarketPrice.setPopulation(Integer.parseInt(population));
            rawMarketPrice.setMigrationRate(Integer.parseInt(migrationRate));
            rawMarketPrice.setIsCommercialCenter((Boolean.parseBoolean(isCommercialCenter)));
            rawMarketPriceDAL.insert(rawMarketPrice);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    File excelFile = attachmentUtils
            .getDirectoryByAttachmentType(AttachmentUtils.AttachmentType.RAW_MARKET_PRICE);
    FileUtils.cleanDirectory(excelFile);
    return true;

}

From source file:org.openflexo.foundation.ie.widget.IETabWidget.java

/**
 * Overrides getSpecificActionListForThatClass
 * //from   ww w .j  a va2 s. c o m
 * @see org.openflexo.foundation.ie.widget.IEWidget#getSpecificActionListForThatClass()
 */
@Override
protected Vector<FlexoActionType> getSpecificActionListForThatClass() {
    Vector<FlexoActionType> returned = super.getSpecificActionListForThatClass();
    returned.add(AddTab.actionType);
    returned.add(MoveTabLeft.actionType);
    returned.add(MoveTabRight.actionType);
    returned.remove(SuroundWithRepetition.actionType);
    return returned;
}

From source file:org.kepler.ssh.LocalDelete.java

/**
 * Recursively traverse the directories looking for matches on each level to
 * the relevant part of the mask. Matched files will be deleted. Matched
 * directories will be deleted only if 'recursive' is true.
 *//*from  w ww  .  j  a va  2  s  .co  m*/
private boolean delete(File node, Vector masks, boolean recursive) {

    if (isDebugging)
        log.debug(">>> " + node.getPath() + " with masks length = " + masks.size() + ": " + masks.toString());

    // the query is for a single file/dir --> it will be deleted now
    if (masks.isEmpty()) {
        return deleteNode(node, recursive, "Delete ");
    }

    // handle the case where path is not a directory but something else
    if (!node.isDirectory()) {
        if (node.isFile()) {
            // single file
            // this file cannot match the rest of the query mask
            return true; // this is not an error, just skip
        } else {
            // wildcardless mask referred to a non-existing file/dir
            log.error("Path " + node.getPath() + " is not a directory!");
            return false;
        }
    }

    // path refers to an existing dir.
    // Let's list its content with the appropriate mask
    String localMask = null;
    Vector restMask = (Vector) masks.clone();
    if (!masks.isEmpty()) {
        localMask = (String) masks.firstElement(); // first element as local
        // mask
        restMask.remove(0); // the rest
    }

    boolean result = true; // will become false if at least one file removal
    // fails

    // handle special masks . and .. separately
    if (localMask.equals(".") || localMask.equals("..")) {

        // we just need to call this method again with the next mask
        File newNode = new File(node, localMask);
        if (isDebugging)
            log.debug("Special case of " + localMask + " --> Call delete() with " + newNode.getPath());
        result = delete(newNode, restMask, recursive);

    } else {
        // meaningful mask... so list the directory and recursively traverse
        // directories
        MyLocalFilter localFilter = new MyLocalFilter(localMask);

        // Get files matching the localMask in the dir 'node'
        File[] files = node.listFiles(localFilter);

        if (isDebugging)
            log.debug("Found " + files.length + " matching files in " + node);

        for (int i = 0; i < files.length; i++) {
            // recursive call with the rest of the masks
            boolean succ = delete(files[i], restMask, recursive);
            if (!succ && isDebugging)
                log.debug("Failed removal of " + files[i].getPath());
            result = result && succ;
        }
    }

    if (isDebugging)
        log.debug("<<< " + node.getPath());
    return result;
}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.UpdateServ.java

/** Retrieves the next update in the queue of the given client. Returns a NO_UPDATE_RESPONSE if there
 *  are no updates in the given client's queue. The Response that is returned is removed permanently
 *  from the queue *//*from w w w . j  av a 2 s .c o m*/
protected Response dequeueUpdate(int dbId) {
    Integer clientInt = new Integer(dbId);

    if (!updateQueues.containsKey(clientInt)) {
        log.warn("Cannot dequeue update for client " + dbId + " -- this client is not in any session!");
        return new Response(Response.INVALID_SESSION_RESPONSE);
    }

    Vector queue = (Vector) updateQueues.get(clientInt);

    if (queue.size() < 1)
        return new Response(Response.NO_UPDATE_RESPONSE);
    else {
        Response res = (Response) queue.remove(0);
        return (Response) res;
    }
}

From source file:javazoom.jlgui.player.amp.playlist.BasePlaylist.java

/**
 * Shuffles items in the playlist randomly
 *///from ww  w . j  a  v a 2s.  c o m
public void shuffle() {
    int size = _playlist.size();
    if (size < 2) {
        return;
    }
    Vector v = _playlist;
    _playlist = new Vector(size);
    while ((size = v.size()) > 0) {
        _playlist.addElement(v.remove((int) (Math.random() * size)));
    }
    begin();
}

From source file:com.otisbean.keyring.Ring.java

/**
 * @return Ordered list of category names, without the "All" pseudo-category,
 * and with "Unfiled" at the top.// ww  w.j  a  v a2 s.co m
 */
public Vector<String> getCategories() {
    Vector<String> cats = new Vector<String>(categoriesByName.keySet());
    cats.remove("All");
    cats.remove("Unfiled");
    cats.add(0, "Unfiled");
    return cats;
}

From source file:org.lockss.devtools.TestRunKbartReport.java

/**
 * A class that reads the output file, summarises it and runs various tests.
 *///from ww  w  . ja  v a  2 s  .  com
private void checkOutputFile(Reader r) {
    BufferedReader reader = new BufferedReader(r);
    int numberLines = 0;
    String outputHeader = null;
    try {
        outputHeader = reader.readLine();
        numberLines = 1;
        String s;
        while ((s = reader.readLine()) != null) {
            // Get the header from the first line
            //if (numberLines==0) outputHeader = s;
            numberLines++;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    // Count empty and duplicate lines in the input
    int numEmptyLines = 0;
    int numDuplicateLines = 0;
    Vector<String> lineList = new Vector<String>(Arrays.asList(lines));
    for (String line : lines) {
        if (StringUtils.isEmpty(line))
            numEmptyLines++;
        else {
            // If not empty, check ifthe line is a duplicate
            lineList.remove(line);
            if (lineList.contains(line))
                numDuplicateLines++;
        }
    }
    ;

    // Number of entries
    assertEquals(lines.length - numEmptyLines - numDuplicateLines, numberLines);

    // Setup the expected output header line
    Vector<String> labels = new Vector<String>(columnOrdering.getOrderedLabels());
    if (hideEmptyColumns) {
        // The expected output header is the list of col names from input header,
        // plus any constant-valued cols specified in the Ordering.

        // Only keep the columns specified in the input, as the rest will be
        // empty. The list of input cols comes from splitting the original
        // header on commas and trimming each token.
        // Additionally, expect a missing column from the original inputs.
        labels.retainAll(new ArrayList<String>() {
            {
                // retain labels from the input header
                for (String s : Arrays.asList(StringUtils.split(header, ","))) {
                    add(StringUtils.trim(s).toLowerCase());
                }
                // retain non-field labels from the ordering
                for (String s : columnOrdering.getNonFieldColumnLabels()) {
                    add(s);
                    //add(s.indexOf(" ")>=0 ? String.format("\"%s\"", s) : s);
                }
                // Also add title_url as it is filled in automatically by the exporter
                add(KbartTitle.Field.TITLE_URL.getLabel());
            }
        }
        //Arrays.asList(StringUtils.split(header.replace(" ", ""), ","))
        );
        labels.remove(emptyColumnLabel.toLowerCase());
    }
    if (showTdbStatus) {
        // expect an extra column
        // TODO this is not implemented yet, we need to add the extra column label
    }

    String expectedHeader = StringUtils.join(labels, ",");
    // Header should be equivalent to the defined field ordering
    //assertEquals(expectedHeader.toLowerCase(), outputHeader.toLowerCase());
    // NOTE the utf output includes a BOM, which screws up comparison
    // Also remove quotes added by CVS output rules (this is a quick kludge)
    outputHeader = outputHeader.replaceAll("\"", "");
    System.out.format("Output %s\nExpected %s\n", outputHeader, expectedHeader);
    assertTrue(outputHeader.toLowerCase().endsWith(expectedHeader.toLowerCase()));

    // TODO record ordering should be alphabetical by title, or first column

}

From source file:org.nimbustools.messaging.gt4_0_elastic.v2008_05_05.image.defaults.DefaultRepository.java

protected FileListing[] listFilesImpl(String ownerID, String[] nameScoped, String[] ownerScoped)
        throws Exception {

    if (ownerID == null) {
        throw new CannotTranslateException("Cannot contact repository " + "without owner ID");
    }/*from   ww w  .j  a v  a 2 s.c  om*/

    final String directoryURLstr = this.getBaseDirectory() + "/" + ownerID + "/";

    final GlobusURL listdir = new GlobusURL(directoryURLstr);

    final GridFTPClient client = new GridFTPClient(listdir.getHost(), listdir.getPort());

    final String idauthz = this.getIdAuthz();
    if (idauthz == null) {
        client.setAuthorization(HostAuthorization.getInstance());
    } else {
        final IdentityAuthorization idA = new IdentityAuthorization(idauthz);
        client.setAuthorization(idA);
    }

    client.authenticate(null);
    client.setType(Session.TYPE_ASCII);
    client.setPassive();
    client.setLocalActive();
    client.changeDir(listdir.getPath());
    final Vector v = client.mlsd(null);
    int len = v.size();
    final ArrayList files = new ArrayList(len);
    while (!v.isEmpty()) {
        final MlsxEntry f = (MlsxEntry) v.remove(0);
        if (f == null) {
            continue; // *** SKIP ***
        }

        final String fileName = f.getFileName();
        if (fileName == null) {
            continue; // *** SKIP ***
        }

        if (fileName.equals(".")) {
            len -= 1;
            continue; // *** SKIP ***
        }
        if (fileName.equals("..")) {
            len -= 1;
            continue; // *** SKIP ***
        }

        if (nameScoped == null || nameScoped.length == 0) {
            final FileListing listing = this.getOneListing(f, ownerScoped);
            if (listing != null) {
                files.add(listing);
            }
        } else {

            for (int i = 0; i < nameScoped.length; i++) {
                if (fileName.equals(nameScoped[i])) {
                    final FileListing listing = this.getOneListing(f, ownerScoped);
                    if (listing != null) {
                        files.add(listing);
                    }
                    break; // assuming unique file names..
                }
            }
        }
    }

    client.close();

    return (FileListing[]) files.toArray(new FileListing[files.size()]);
}

From source file:org.energy_home.jemma.ah.internal.zigbee.ZigBeeDeviceImpl.java

public boolean removeListener(short clusterId, int side, ZigBeeDeviceListener listener) {
    synchronized (lock) {
        Hashtable listenersList = null;
        if (side == ZclServiceCluster.CLIENT_SIDE) {
            listenersList = listenersListClientSide;
        } else if (side == ZclServiceCluster.SERVER_SIDE) {
            listenersList = listenersListServerSide;
        } else {//from  w  w w  .  jav  a 2s.  c  o  m
            return false;
        }

        Vector listeners = (Vector) listenersList.get(new Short(clusterId));
        if (listeners != null) {
            return listeners.remove(listener);
        }
        return false;
    }
}