Example usage for java.util Vector iterator

List of usage examples for java.util Vector iterator

Introduction

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

Prototype

public synchronized Iterator<E> iterator() 

Source Link

Document

Returns an iterator over the elements in this list in proper sequence.

Usage

From source file:br.org.indt.ndg.client.Service.java

private SResult getSResult(SurveyXML surveyXml, ResultXml resultXml) {
    SResult sResult = new SResult();
    for (CategoryAnswer c : resultXml.getCategories().values()) {
        SCategory sCategory = new SCategory();
        sCategory.setId(c.getId());//from w  ww  .  j a  v  a  2 s  .  c  o m
        sCategory.setName(c.getName());

        Iterator<String> subCatIterator = c.getSubCategories().keySet().iterator();

        while (subCatIterator.hasNext()) {

            String subCatId = subCatIterator.next();
            Vector<Field> fields = c.getSubCategories().get(subCatId);

            Iterator<Field> fieldIterator = fields.iterator();

            while (fieldIterator.hasNext()) {
                Field field = fieldIterator.next();
                SField sField = new SField();
                sField.setCategoryId(field.getCategoryId());
                sField.setId(field.getId());
                sField.setDescription(
                        surveyXml.getField(field.getCategoryId(), field.getId()).getDescription());
                sField.setXmlType(field.getXmlType());
                String value = null;
                if (field.getFieldType() == FieldType.STR) {
                    value = field.getValue() == null ? "" : field.getValue();
                } else if (field.getFieldType() == FieldType.DATE) {
                    value = field.getValue() == null ? "" : Resources.toDate(Long.parseLong(field.getValue()));
                } else if (field.getFieldType() == FieldType.TIME) {
                    value = field.getValue() == null ? ""
                            : Resources.toTime(field.getValue(), field.getConvention());
                } else if (field.getFieldType() == FieldType.INT) {
                    value = field.getValue() == null ? "0" : field.getValue();
                } else if (field.getFieldType() == FieldType.DECIMAL) {
                    value = field.getValue() == null ? "0" : field.getValue();
                } else if (field.getFieldType() == FieldType.CHOICE) {
                    StringBuffer tmp = new StringBuffer();
                    for (Item item : field.getChoice().getItems()) {
                        String s = surveyXml.getItemValue(field.getCategoryId(), field.getId(),
                                item.getIndex());
                        if (s != null)
                            tmp.append(s.trim());

                        if (item.getValue() != null) {
                            if (s != null)
                                tmp.append(": ");
                            tmp.append(item.getValue());
                        }
                        tmp.append("\n");
                    }
                    value = tmp.toString() == null ? "" : tmp.toString().trim();
                } else if (field.getFieldType() == FieldType.IMAGE) {
                    sField.setImages(field.getImages());
                }
                sField.setValue(value);
                sCategory.addField(subCatId, sField);
            }
        } //while
        sResult.addCategory(c.getId(), sCategory);
    }
    return sResult;
}

From source file:cn.labthink.ReadAccess060.java

private void outputexcelCell(Vector columns, Vector data, int cellno) {
    if (outputfile == null) {
        return;/*from   ww w. j a v a 2 s  .  co  m*/
    }
    if (book == null) {
        try {
            //
            book = Workbook.createWorkbook(outputfile);
        } catch (IOException ex) {
            Logger.getLogger(ReadAccess060.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        //?
    }

    try {

        WritableSheet sheet1 = book.createSheet("Cell" + cellno, cellno + 1);// 0
        int count = columns.size();
        for (int i = 0; i < count; i++) {
            Label l = new Label(i, 0, (String) columns.get(i));//i0
            sheet1.addCell(l);
        }
        int irow = 1;
        //            System.out.println("rows:" + data.size());
        for (Iterator it = data.iterator(); it.hasNext();) {
            Vector row = (Vector) it.next();
            for (int i = 0; i < count; i++) {
                Label l = new Label(i, irow, (String) row.get(i));//iirow
                sheet1.addCell(l);
            }
            irow++;
        }
        //            book.write();
        //            book.close();
    } catch (WriteException ex) {
        Logger.getLogger(ReadAccess060.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:cn.labthink.ReadAccess330.java

private void outputexcelCell(Vector columns, Vector data, int cellno) {
    if (outputfile == null) {
        return;//from  w ww. java 2 s. c  o  m
    }
    if (book == null) {
        try {
            //
            book = Workbook.createWorkbook(outputfile);
        } catch (IOException ex) {
            Logger.getLogger(ReadAccess330.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        //?
    }

    try {

        WritableSheet sheet1 = book.createSheet("Cell" + cellno, cellno + 1);// 0
        int count = columns.size();
        for (int i = 0; i < count; i++) {
            Label l = new Label(i, 0, (String) columns.get(i));//i0
            sheet1.addCell(l);
        }
        int irow = 1;
        //            System.out.println("rows:" + data.size());
        for (Iterator it = data.iterator(); it.hasNext();) {
            Vector row = (Vector) it.next();
            for (int i = 0; i < count; i++) {
                Label l = new Label(i, irow, (String) row.get(i));//iirow
                sheet1.addCell(l);
            }
            irow++;
        }
        //            book.write();
        //            book.close();
    } catch (WriteException ex) {
        Logger.getLogger(ReadAccess330.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:org.pentaho.di.job.entries.ssh2get.JobEntrySSH2GET.java

/**
 * copy a directory from the remote host to the local one.
 *
 * @param sourceLocation/* ww w  .ja  v a  2s . c  om*/
 *          the source directory on the remote host
 * @param targetLocation
 *          the target directory on the local host
 * @param sftpClient
 *          is an instance of SFTPv3Client that makes SFTP client connection over SSH-2
 * @return the number of files successfully copied
 * @throws Exception
 */
@SuppressWarnings("unchecked")
private void GetFiles(String sourceLocation, String targetLocation, SFTPv3Client sftpClient, Pattern pattern,
        Job parentJob) throws Exception {

    String sourceFolder = ".";
    if (!Const.isEmpty(sourceLocation)) {
        sourceFolder = sourceLocation + FTPUtils.FILE_SEPARATOR;
    } else {
        sourceFolder += FTPUtils.FILE_SEPARATOR;
    }

    Vector<SFTPv3DirectoryEntry> filelist = sftpClient.ls(sourceFolder);

    if (filelist != null) {
        Iterator<SFTPv3DirectoryEntry> iterator = filelist.iterator();

        while (iterator.hasNext() && !parentJob.isStopped()) {
            SFTPv3DirectoryEntry dirEntry = iterator.next();

            if (dirEntry == null) {
                continue;
            }

            if (dirEntry.filename.equals(".") || dirEntry.filename.equals("..")
                    || isDirectory(sftpClient, sourceFolder + dirEntry.filename)) {
                continue;
            }

            if (getFileWildcard(dirEntry.filename, pattern)) {
                // Copy file from remote host
                copyFile(sourceFolder + dirEntry.filename,
                        targetLocation + FTPUtils.FILE_SEPARATOR + dirEntry.filename, sftpClient);
            }

        }
    }
}

From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java

/**
 * /*w  w  w .  ja va 2  s  . c  om*/
 * Erzeige eine Liste der whrend des Tauchgangs erzeugten Diluents (Robert Wimmer angefragt)
 * 
 * Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * 
 * @author Dirk Marciniak (dirk_marciniak@arcor.de)
 * 
 *         Stand: 03.11.2013
 * @param diveList
 * @return
 */
private Vector<String> getDiluentNamesFromDive(Vector<Integer[]> diveList) {
    Vector<String> retValue = new Vector<String>();
    Vector<Integer[]> diluents = new Vector<Integer[]>();
    // int currN2, currHe;
    //
    // erst mal alle verwendeten Diluents finden
    //
    Iterator<Integer[]> it = diveList.iterator();
    while (it.hasNext()) {
        // erfrage das Diluent des Timestamps
        Integer[] currDive = it.next();
        // berechne das Diluent mit O2/HE
        Integer[] currDiluent = new Integer[] { 0, 0 };
        currDiluent[0] = 100
                - (currDive[LogDerbyDatabaseUtil.HEPERCENT] + currDive[LogDerbyDatabaseUtil.N2PERCENT]);
        currDiluent[1] = currDive[LogDerbyDatabaseUtil.HEPERCENT];
        // ist das Diluent schon in der Liste?
        if (!isDiluentInList(diluents, currDiluent)) {
            // Wenn nicht in der Liste, hinzufgen!
            diluents.add(currDiluent);
        }
    }
    //
    // Jetzt sollten alle Eintrge besarbeitet sein
    //
    // alle Diluents, wenn vorhanden benennen
    it = diluents.iterator();
    while (it.hasNext()) {
        Integer[] dil = it.next();
        retValue.add(GasComputeUnit.getNameForGas(dil[0], dil[1]));
    }
    return (retValue);
}

From source file:net.java.sip.communicator.impl.history.HistoryReaderImpl.java

private QueryResultSet<HistoryRecord> find(Date startDate, Date endDate, String[] keywords, String field,
        boolean caseSensitive) {
    TreeSet<HistoryRecord> result = new TreeSet<HistoryRecord>(new HistoryRecordComparator());

    Vector<String> filelist = filterFilesByDate(this.historyImpl.getFileList(), startDate, endDate);

    double currentProgress = HistorySearchProgressListener.PROGRESS_MINIMUM_VALUE;
    double fileProgressStep = HistorySearchProgressListener.PROGRESS_MAXIMUM_VALUE;

    if (filelist.size() != 0)
        fileProgressStep = HistorySearchProgressListener.PROGRESS_MAXIMUM_VALUE / filelist.size();

    // start progress - minimum value
    fireProgressStateChanged(startDate, endDate, keywords,
            HistorySearchProgressListener.PROGRESS_MINIMUM_VALUE);

    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
    Iterator<String> fileIterator = filelist.iterator();
    while (fileIterator.hasNext()) {
        String filename = fileIterator.next();

        Document doc = this.historyImpl.getDocumentForFile(filename);

        if (doc == null)
            continue;

        NodeList nodes = doc.getElementsByTagName("record");

        double nodesProgressStep = fileProgressStep;

        if (nodes.getLength() != 0)
            nodesProgressStep = fileProgressStep / nodes.getLength();

        Node node;// w  w w .  j ava2s .  c  o m
        for (int i = 0; i < nodes.getLength(); i++) {
            node = nodes.item(i);

            Date timestamp;
            String ts = node.getAttributes().getNamedItem("timestamp").getNodeValue();
            try {
                timestamp = sdf.parse(ts);
            } catch (ParseException e) {
                timestamp = new Date(Long.parseLong(ts));
            }

            if (isInPeriod(timestamp, startDate, endDate)) {
                NodeList propertyNodes = node.getChildNodes();

                HistoryRecord record = filterByKeyword(propertyNodes, timestamp, keywords, field,
                        caseSensitive);

                if (record != null) {
                    result.add(record);
                }
            }

            currentProgress += nodesProgressStep;
            fireProgressStateChanged(startDate, endDate, keywords, (int) currentProgress);
        }
    }

    // if maximum value is not reached fire an event
    if ((int) currentProgress < HistorySearchProgressListener.PROGRESS_MAXIMUM_VALUE) {
        fireProgressStateChanged(startDate, endDate, keywords,
                HistorySearchProgressListener.PROGRESS_MAXIMUM_VALUE);
    }

    return new OrderedQueryResultSet<HistoryRecord>(result);
}

From source file:org.adl.samplerte.server.CourseService.java

/**
 *  This method will return a list of all active courses currently
 *  available in the RTE/*from ww w .  ja  v a  2s.co  m*/
 *  
 * @param iUserID - the current user
 * @param iRegSortType - type of sort for registered courses
 * @param iRegSortOrder - order of sort for registered courses
 * @param iUnregSortType - type of sort for registered courses
 * @param iUnregSortOrder - order of sort for registered courses
 * @return - a Vector of courses
 */
public Vector getManagedCourses(String iUserID, String iRegSortType, String iRegSortOrder,
        String iUnregSortType, String iUnregSortOrder) {
    Vector courseList = new Vector();

    // Get all registered courses
    Vector courses = getCourses(iUserID, iRegSortType, iRegSortOrder);
    Iterator courseIter = courses.iterator();
    while (courseIter.hasNext()) {
        CourseData cd = (CourseData) courseIter.next();

        CourseData statusCd = new CourseData();

        // Check registration status
        cd.mRegistered = true;

        courseList.add(cd);
    }

    // Get all unregistered courses
    Vector unregCourses = getUnregisteredCourses(iUserID, iUnregSortType, iUnregSortOrder);
    Iterator unregIter = unregCourses.iterator();
    while (unregIter.hasNext()) {
        CourseData cd = (CourseData) unregIter.next();

        cd.mRegistered = false;

        courseList.add(cd);
    }

    return courseList;
}

From source file:org.adl.samplerte.server.CourseService.java

/**
 * This method will return a vector of all unregistered courses
 * //from www  . j  av  a2s .  c om
 * @param iUserID - the current user
 * @param iSortType - field to be sorted by
 * @param iSortOrder - order to be sorted by
 * @return a Vector or courses
 */
public Vector getUnregisteredCourses(String iUserID, String iSortType, String iSortOrder) {
    Vector courses = new Vector();
    Vector allCourses = getCourses(iSortType, iSortOrder);
    List regCourses = getRegCourses(iUserID);

    Iterator iter = allCourses.iterator();
    while (iter.hasNext()) {
        CourseData cd = (CourseData) iter.next();
        if (!regCourses.contains(cd.mCourseID)) {
            courses.add(cd);
        }
    }
    return courses;
}

From source file:sos.scheduler.cron.CronConverter.java

private void addDay(final String day, final Element parentDaysElement, final Vector<Element> childElements)
        throws Exception {
    logger.debug("adding day: " + day);
    Element dayElement = parentDaysElement.getOwnerDocument().createElement("day");
    dayElement.setAttribute("day", day);
    Iterator<Element> iter = childElements.iterator();
    while (iter.hasNext()) {
        Element child = iter.next();
        dayElement.appendChild(child.cloneNode(true));
    }//from  w  w w .j  a v  a2  s . c om
    parentDaysElement.appendChild(dayElement);
}

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

public boolean saveExcelToDatabase() throws IOException {

    Vector dataHolder = read();
    rawMarketPriceDAL.truncateAll();/*from   w w w  . jav a2 s .c  o  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;

}