Example usage for java.util Vector Vector

List of usage examples for java.util Vector Vector

Introduction

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

Prototype

public Vector() 

Source Link

Document

Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero.

Usage

From source file:fr.univrouen.poste.services.ExcelParser.java

public List<List<String>> getCells(InputStream xslFileInput) {

    List<List<String>> cellVectorHolder = new Vector<List<String>>();

    try {//from w  w  w .ja v a  2s . com

        POIFSFileSystem fileSystem = new POIFSFileSystem(xslFileInput);
        HSSFWorkbook workBook = new HSSFWorkbook(fileSystem);
        HSSFSheet sheet = workBook.getSheetAt(0);
        Iterator<Row> rowIter = sheet.rowIterator();

        while (rowIter.hasNext()) {
            HSSFRow myRow = (HSSFRow) rowIter.next();
            List<String> cellStoreVector = new Vector<String>();
            // take care of blank cell !
            // @see http://stackoverflow.com/questions/4929646/how-to-get-an-excel-blank-cell-value-in-apache-poi
            int max = myRow.getLastCellNum();
            for (int i = 0; i < max; i++) {
                HSSFCell myCell = (HSSFCell) myRow.getCell(i, Row.CREATE_NULL_AS_BLANK);
                if (Cell.CELL_TYPE_STRING == myCell.getCellType())
                    cellStoreVector.add(myCell.getStringCellValue());
                else if ((Cell.CELL_TYPE_NUMERIC == myCell.getCellType()))
                    cellStoreVector.add(Long.toString(new Double(myCell.getNumericCellValue()).longValue()));
                else if ((Cell.CELL_TYPE_BLANK == myCell.getCellType()))
                    cellStoreVector.add("");
                else {
                    logger.debug("This cell is not numeric or string ... : " + myCell + " \n ... cellType : "
                            + myCell.getCellType());
                    cellStoreVector.add("");
                }
            }
            cellVectorHolder.add(cellStoreVector);
        }
    } catch (Exception e) {
        logger.error("Error during parsing the XSL File", e);
        throw new RuntimeException("Error during parsing the XSL File", e);
    }

    return cellVectorHolder;
}

From source file:Main.java

/**
 * getStringListFromXPath/*w ww . j  ava 2s .com*/
 * Gets a list of strings from an xml.
 * @param rootNode The root node to perform the listExpression on. 
 * @param listExpression Evaluated on the rootNode, gets a NodeList.
 * @return A list of the text contents of the nodes returned by evaluating the listExpression.
 */
public static List<String> getStringListFromXPath(Node rootNode, XPath xpath, String listExpression) {
    synchronized (xpath) {
        if (rootNode instanceof Document)
            rootNode = ((Document) rootNode).getDocumentElement();
        Vector<String> result = new Vector<String>();
        try {
            NodeList nodes = (NodeList) xpath.evaluate(listExpression, rootNode, XPathConstants.NODESET);
            for (int i = 0; i < nodes.getLength(); i++) {
                result.addElement(nodes.item(i).getTextContent());
            }
        } catch (Exception e) {
            System.err.println("Error evaluating xpath expression: " + listExpression);
            e.printStackTrace();
        }
        return result;
    }
}

From source file:com.kappaware.logtrawler.ipmatcher.IpMatcherImpl.java

public void setRange(String range) throws ConfigurationException {
    this.range = range;
    if ("*".equals(range.trim())) {
        this.passThrough = true;
    } else {//from  w  ww . j a v a 2  s  .  c om
        segments = new Vector<IpSegment>();
        String[] ranges = range.split("\\s+");
        for (int i = 0; i < ranges.length; i++) {
            segments.add(new IpSegment(ranges[i].trim()));
        }
    }
}

From source file:edu.ku.brc.af.ui.weblink.WebLinkDef.java

/**
 * // w ww. j av a2 s.c o  m
 */
public WebLinkDef() {
    this(null, null, null, null);
    this.args = new Vector<WebLinkDefArg>();
    this.usedByList = new Vector<WebLinkUsedBy>();
}

From source file:net.sourceforge.jabm.report.PayoffMap.java

public void initialise() {
    payoffs = new LinkedHashMap<Strategy, StatisticalSummary>();
    strategyIndex = new Vector<Strategy>();
    for (Strategy strategy : strategies) {
        strategyIndex.add(strategy);/*from w w  w . ja va 2  s. c o  m*/
        payoffs.put(strategy, createStatisticalSummary(strategy));
    }
}

From source file:Main.java

DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir) {
    DefaultMutableTreeNode curDir = new DefaultMutableTreeNode(dir);
    if (curTop != null) {
        curTop.add(curDir);//from  w  w w  . ja v a  2 s . c  o m
    }
    File[] tmp = dir.listFiles();
    Vector<File> ol = new Vector<File>();
    ol.addAll(Arrays.asList(tmp));
    Collections.sort(ol, new Comparator<File>() {
        @Override
        public int compare(File o1, File o2) {
            int result = o1.getName().compareTo(o2.getName());
            if (o1.isDirectory() && o2.isFile()) {
                result = -1;
            } else if (o2.isDirectory() && o1.isFile()) {
                result = 1;
            }
            return result;
        }
    });
    for (int i = 0; i < ol.size(); i++) {
        File file = ol.elementAt(i);
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(file);
        if (file.isDirectory()) {
            addNodes(node, file);
        }
        curDir.add(node);
    }
    return curDir;
}

From source file:com.qwazr.externalizor.SimpleCollection.java

public SimpleCollection() {

    nullList = null;//from ww w.ja v a  2s .co m
    stringList = new ArrayList<>();
    for (int i = 0; i < RandomUtils.nextInt(5, 50); i++)
        stringList.add(RandomStringUtils.randomAscii(8));

    nullSet = null;
    integerSet = new LinkedHashSet<>();
    for (int i = 0; i < RandomUtils.nextInt(5, 50); i++)
        integerSet.add(RandomUtils.nextInt());

    byteList = new Vector<>();
    for (int i = 0; i < RandomUtils.nextInt(5, 50); i++)
        byteList.add((byte) RandomUtils.nextInt(0, 128));

    nullMap = null;
    mapShortLong = new HashMap<>();
    for (int i = 0; i < RandomUtils.nextInt(5, 50); i++)
        mapShortLong.put((short) RandomUtils.nextInt(0, Short.MAX_VALUE), RandomUtils.nextLong());

}

From source file:org.openmrs.module.openhmis.cashier.web.controller.CashierMessageRenderController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView render(HttpServletRequest request) {
    // object to store keys from cashier and backboneforms
    Vector<String> keys = new Vector<String>();

    // locate and retrieve cashier messages
    Locale locale = RequestContextUtils.getLocale(request);
    ResourceBundle resourceBundle = ResourceBundle.getBundle("messages", locale);

    // store cashier message keys in the vector object
    keys.addAll(resourceBundle.keySet());

    // retrieve backboneforms messages
    BackboneMessageRenderController backboneController = new BackboneMessageRenderController();
    ModelAndView modelAndView = backboneController.render(request);

    // store backboneforms message keys in the vector object
    for (Map.Entry<String, Object> messageKeys : modelAndView.getModel().entrySet()) {
        Enumeration<String> messageKey = (Enumeration<String>) messageKeys.getValue();
        while (messageKey.hasMoreElements()) {
            String key = messageKey.nextElement();
            if (!keys.contains(key))
                keys.add(key);// w w w .j  av a 2s  .c  o  m
        }
    }

    return new ModelAndView(CashierWebConstants.MESSAGE_PAGE, "keys", keys.elements());
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.Meter.java

/**
 * Instantiates a new meter.
 */
public Meter() {
    super();
    intervals = new Vector();
}

From source file:com.gc.iotools.fmt.base.TestUtils.java

/**
 * @deprecated//from w ww .  ja va  2s.  co  m
 * @see FileUtils#iterate();
 * @param allowed
 * @return
 * @throws IOException
 */
@Deprecated
public static String[] listFilesIncludingExtension(final String[] allowed) throws IOException {
    final URL fileURL = TestUtils.class.getResource("/testFiles");
    String filePath = URLDecoder.decode(fileURL.getPath(), "UTF-8");
    final File dir = new File(filePath);
    final String[] files = dir.list();
    final Collection<String> goodFiles = new Vector<String>();
    if (!filePath.endsWith(File.separator)) {
        filePath = filePath + File.separator;
    }
    for (final String file : files) {
        for (final String element : allowed) {
            if (file.endsWith(element)) {
                goodFiles.add(filePath + file);
            }
        }
    }
    return goodFiles.toArray(new String[goodFiles.size()]);
}