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:edu.ku.brc.specify.tasks.subpane.wb.ConfigureXLS.java

public void showBadHeadingsMsg(final Vector<Integer> badHeadingIdxs, final Vector<Integer> emptyCols,
        final String title) {
    String colStr = "";
    for (int c = 0; c < badHeadingIdxs.size(); c++) {
        if (c > 0) {
            colStr += c == badHeadingIdxs.size() - 1 ? " and " : ", ";
        }//ww  w. ja v  a 2  s .  c  o  m
        int adjust = 1;
        if (emptyCols != null) {
            for (Integer ec : emptyCols) {
                if (ec <= badHeadingIdxs.get(c)) {
                    adjust--;
                }
            }
            colStr += badHeadingIdxs.get(c) + adjust;
        }
    }
    JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), String.format(getResourceString(
            (badHeadingIdxs.size() == 1 ? "WB_IMPORT_INVALID_COL_HEADER" : "WB_IMPORT_INVALID_COL_HEADERS")),
            colStr), title, JOptionPane.ERROR_MESSAGE);

}

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 .j a  v  a2  s . c om*/
    }
    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:CSVReader.java

public String[] getLine() {
    Vector lineArray = new Vector();
    String token = null;/*from ww w  .  j  a  v a2 s  .  co m*/
    String returnArray[] = null;

    // reading values from line until null comes

    try {
        while (lineArray.size() == 0) {
            while ((token = get()) != null) {
                lineArray.add(token);
            } // end of while
        } // end of while
    } catch (EOFException e) {
        return null;
    } catch (IOException e) {
    }

    returnArray = new String[lineArray.size()];

    for (int ii = 0; ii < lineArray.size(); ii++) {
        returnArray[ii] = lineArray.elementAt(ii).toString();
    } // end of for

    return returnArray;
}

From source file:com.pironet.tda.SunJDKParserTest.java

public void test64BitDumpLoad() throws IOException {
    System.out.println("64BitDumpLoad");
    InputStream fis = null;/*  www.j  ava 2  s .  co m*/
    DumpParser instance = null;

    try {
        fis = getClass().getResourceAsStream("/data/test64bit.log");
        Map<String, Map<String, String>> dumpMap = new HashMap<>();
        Vector<MutableTreeNode> topNodes = new Vector<>();
        instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);

        assertTrue(instance instanceof SunJDKParser);

        while (instance.hasMoreDumps()) {
            topNodes.add(instance.parseNext());
        }

        // check if one dump was found.
        assertEquals(1, topNodes.size());
    } finally {
        IOUtils.closeQuietly(instance);
        IOUtils.closeQuietly(fis);
    }
}

From source file:com.pironet.tda.SunJDKParserTest.java

public void testSAPDumps() throws IOException {
    System.out.println("SAPDumpLoad");
    InputStream fis = null;//from  ww  w .j a  va  2  s  .co m
    DumpParser instance = null;

    try {
        fis = getClass().getResourceAsStream("/data/sapdump.log");
        Map<String, Map<String, String>> dumpMap = new HashMap<>();
        Vector<MutableTreeNode> topNodes = new Vector<>();
        instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);

        assertTrue(instance instanceof SunJDKParser);

        while (instance.hasMoreDumps()) {
            topNodes.add(instance.parseNext());
        }

        // check if two dump were found.
        assertEquals(2, topNodes.size());
    } finally {
        IOUtils.closeQuietly(instance);
        IOUtils.closeQuietly(fis);
    }
}

From source file:com.pironet.tda.SunJDKParserTest.java

public void testRemoteVisualVMDumps() throws IOException {
    System.out.println("VisualVMDumpLoad");
    InputStream fis = null;//from  ww w.  j a  va2s.  co  m
    DumpParser instance = null;

    try {
        fis = getClass().getResourceAsStream("/data/visualvmremote.log");
        Map<String, Map<String, String>> dumpMap = new HashMap<>();
        Vector<MutableTreeNode> topNodes = new Vector<>();
        instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);

        assertTrue(instance instanceof SunJDKParser);

        while (instance.hasMoreDumps()) {
            topNodes.add(instance.parseNext());
        }

        // check if two dump were found.
        assertEquals(1, topNodes.size());
    } finally {
        IOUtils.closeQuietly(instance);
        IOUtils.closeQuietly(fis);
    }
}

From source file:com.pironet.tda.SunJDKParserTest.java

public void testURLThreadNameDumps() throws IOException {
    System.out.println("URLThreadNameDumpLoad");
    InputStream fis = null;/*  w w  w. j  av  a  2s.  c  o m*/
    DumpParser instance = null;

    try {
        fis = getClass().getResourceAsStream("/data/urlthread.log");
        Map<String, Map<String, String>> dumpMap = new HashMap<>();
        Vector<MutableTreeNode> topNodes = new Vector<>();
        instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);

        assertTrue(instance instanceof SunJDKParser);

        while (instance.hasMoreDumps()) {
            topNodes.add(instance.parseNext());
        }

        // check if two dump were found.
        assertEquals(1, topNodes.size());
    } finally {
        IOUtils.closeQuietly(instance);
        IOUtils.closeQuietly(fis);
    }
}

From source file:FileTree2.java

public boolean expand(DefaultMutableTreeNode parent) {
    DefaultMutableTreeNode flag = (DefaultMutableTreeNode) parent.getFirstChild();
    if (flag == null) // No flag
        return false;
    Object obj = flag.getUserObject();
    if (!(obj instanceof Boolean))
        return false; // Already expanded

    parent.removeAllChildren(); // Remove Flag

    File[] files = listFiles();//from w w  w  .  ja  v  a  2s .c  o  m
    if (files == null)
        return true;

    Vector v = new Vector();

    for (int k = 0; k < files.length; k++) {
        File f = files[k];
        if (!(f.isDirectory()))
            continue;

        FileNode newNode = new FileNode(f);

        boolean isAdded = false;
        for (int i = 0; i < v.size(); i++) {
            FileNode nd = (FileNode) v.elementAt(i);
            if (newNode.compareTo(nd) < 0) {
                v.insertElementAt(newNode, i);
                isAdded = true;
                break;
            }
        }
        if (!isAdded)
            v.addElement(newNode);
    }

    for (int i = 0; i < v.size(); i++) {
        FileNode nd = (FileNode) v.elementAt(i);
        IconData idata = new IconData(FileTree2.ICON_FOLDER, FileTree2.ICON_EXPANDEDFOLDER, nd);
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(idata);
        parent.add(node);

        if (nd.hasSubDirs())
            node.add(new DefaultMutableTreeNode(new Boolean(true)));
    }

    return true;
}

From source file:com.pironet.tda.SunJDKParserTest.java

/**
 * Test of hasMoreDumps method, of class com.pironet.tda.SunJDKParser.
 */// w  w w. j  a  v  a  2 s .  co m
public void testDumpLoad() throws IOException {
    System.out.println("dumpLoad");
    InputStream fis = null;
    DumpParser instance = null;

    try {
        fis = getClass().getResourceAsStream("/data/test.log");
        Map<String, Map<String, String>> dumpMap = new HashMap<>();
        Vector<MutableTreeNode> topNodes = new Vector<>();
        instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);

        assertTrue(instance instanceof SunJDKParser);

        while (instance.hasMoreDumps()) {
            topNodes.add(instance.parseNext());
        }

        // check if three dumps are in it.
        assertEquals(3, topNodes.size());
    } finally {
        IOUtils.closeQuietly(instance);
        IOUtils.closeQuietly(fis);
    }
}

From source file:Sampler.java

private void createUI() {
    setFont(new Font("Serif", Font.PLAIN, 12));
    setLayout(new BorderLayout());
    // Set our location to the left of the image frame.
    setSize(200, 350);//from w w w .  ja v  a  2  s .  c  o  m
    Point pt = mImageFrame.getLocation();
    setLocation(pt.x - getSize().width, pt.y);

    final Checkbox accumulateCheckbox = new Checkbox("Accumulate", false);
    final Label statusLabel = new Label("");

    // Make a sorted list of the operators.
    Enumeration e = mOps.keys();
    Vector names = new Vector();
    while (e.hasMoreElements())
        names.addElement(e.nextElement());
    Collections.sort(names);
    final java.awt.List list = new java.awt.List();
    for (int i = 0; i < names.size(); i++)
        list.add((String) names.elementAt(i));
    add(list, BorderLayout.CENTER);

    // When an item is selected, do the corresponding transformation.
    list.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            if (ie.getStateChange() != ItemEvent.SELECTED)
                return;
            String key = list.getSelectedItem();
            BufferedImageOp op = (BufferedImageOp) mOps.get(key);
            BufferedImage source = mSplitImageComponent.getSecondImage();
            boolean accumulate = accumulateCheckbox.getState();
            if (source == null || accumulate == false)
                source = mSplitImageComponent.getImage();
            String previous = mImageFrame.getTitle() + " + ";
            if (accumulate == false)
                previous = "";
            mImageFrame.setTitle(previous + key);
            statusLabel.setText("Performing " + key + "...");
            list.setEnabled(false);
            accumulateCheckbox.setEnabled(false);
            BufferedImage destination = op.filter(source, null);
            mSplitImageComponent.setSecondImage(destination);
            mSplitImageComponent.setSize(mSplitImageComponent.getPreferredSize());
            mImageFrame.setSize(mImageFrame.getPreferredSize());
            list.setEnabled(true);
            accumulateCheckbox.setEnabled(true);
            statusLabel.setText("Performing " + key + "...done.");
        }
    });

    Button loadButton = new Button("Load...");
    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            FileDialog fd = new FileDialog(Sampler.this);
            fd.show();
            if (fd.getFile() == null)
                return;
            String path = fd.getDirectory() + fd.getFile();
            mSplitImageComponent.setImage(path);
            mSplitImageComponent.setSecondImage(null);
            //            Utilities.sizeContainerToComponent(mImageFrame,
            //               mSplitImageComponent);
            mImageFrame.validate();
            mImageFrame.repaint();
        }
    });

    Panel bottom = new Panel(new GridLayout(2, 1));
    Panel topBottom = new Panel();
    topBottom.add(accumulateCheckbox);
    topBottom.add(loadButton);
    bottom.add(topBottom);
    bottom.add(statusLabel);
    add(bottom, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            mImageFrame.dispose();
            dispose();
            System.exit(0);
        }
    });
}