Example usage for java.util Vector addElement

List of usage examples for java.util Vector addElement

Introduction

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

Prototype

public synchronized void addElement(E obj) 

Source Link

Document

Adds the specified component to the end of this vector, increasing its size by one.

Usage

From source file:org.apache.webdav.lib.WebdavState.java

/**
 * Get locks//  ww  w  .  j  a v a  2s. c om
 *
 * @param uri Uri
 * @return Enumeration of lock tokens
 * @deprecated
 */
public Enumeration getLocks(String uri) {

    Vector result = new Vector();
    String lockToken = getLock(uri);
    if (lockToken != null)
        result.addElement(lockToken);
    return result.elements();

}

From source file:aplicacion.herramientas.conexion.ftp.test.JakartaFtpWrapper.java

/** Get the list of subdirectories in the current directory as a Vector of Strings 
  * (excludes files) *//*from  w w  w . j  av a2s .c o m*/
public Vector listSubdirNames() throws IOException, FTPConnectionClosedException {
    FTPFile[] files = listFiles();
    Vector v = new Vector();
    for (int i = 0; i < files.length; i++) {
        if (files[i].isDirectory())
            v.addElement(files[i].getName());
    }
    return v;
}

From source file:aplicacion.herramientas.conexion.ftp.test.JakartaFtpWrapper.java

/** Get the list of files in the current directory as a Vector of Strings 
  * (excludes subdirectories) *///from   w  ww .  j a va 2 s .  c  om
public Vector listFileNames() throws IOException, FTPConnectionClosedException {
    FTPFile[] files = listFiles();
    Vector v = new Vector();
    for (int i = 0; i < files.length; i++) {
        if (!files[i].isDirectory())
            v.addElement(files[i].getName());
    }
    return v;
}

From source file:com.maverick.http.HttpHeader.java

/**
 * Add a header field. <b>If headers with the same name already exist
 * they will not be replaced</b>. 
 * //from  w ww  . j  a  v a2  s .  c  om
 * @param headerName header name
 * @param value value
 */
public void addHeaderField(String headerName, String value) {
    if (value == null) {
        throw new IllegalArgumentException("Null value");
    }

    if (!fields.containsKey(headerName.toLowerCase())) {
        fields.put(headerName.toLowerCase(), new Field(headerName, new Vector()));
        fieldNames.addElement(headerName);
    }

    Vector v = ((Field) fields.get(headerName.toLowerCase())).headerValues;
    v.addElement(value);
}

From source file:org.apache.tomcat.util.IntrospectionUtils.java

public static String[] findBooleanSetters(Class c) {
    Method m[] = findMethods(c);/*from ww  w  .  jav a  2  s .com*/
    if (m == null)
        return null;
    Vector v = new Vector();
    for (int i = 0; i < m.length; i++) {
        if (m[i].getName().startsWith("set") && m[i].getParameterTypes().length == 1
                && "boolean".equalsIgnoreCase(m[i].getParameterTypes()[0].getName())) {
            String arg = m[i].getName().substring(3);
            v.addElement(unCapitalize(arg));
        }
    }
    String s[] = new String[v.size()];
    for (int i = 0; i < s.length; i++) {
        s[i] = (String) v.elementAt(i);
    }
    return s;
}

From source file:com.cohort.util.String2LogFactory.java

/**
 * Return an array containing the names of all currently defined
 * configuration attributes.  If there are no such attributes, a zero
 * length array is returned.//from w  ww  . j  av  a  2 s  . c om
 */
public String[] getAttributeNames() {
    synchronized (attributes) {
        Vector names = new Vector();
        Enumeration keys = attributes.keys();
        while (keys.hasMoreElements()) {
            names.addElement((String) keys.nextElement());
        }
        String results[] = new String[names.size()];
        for (int i = 0; i < results.length; i++) {
            results[i] = (String) names.elementAt(i);
        }
        return (results);
    }
}

From source file:com.duroty.application.home.actions.GetFeedAction.java

protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionMessages errors = new ActionMessages();

    //String name = request.getParameter("name");
    int channel = 0;
    String name = request.getParameter("name");

    try {// w w w .  java  2 s  .c  om
        channel = Integer.valueOf(request.getParameter("channel"));
    } catch (Exception ex) {
    }

    try {
        if (!StringUtils.isBlank(name)) {
            Home homeInstance = getHomeInstance(request);
            Vector aux = new Vector();
            FeedObj obj = homeInstance.getFeed(channel, name);
            if (obj != null) {
                aux.addElement(obj.getValue());
            }
            request.setAttribute(FEEDS, aux);
        }
    } catch (Exception ex) {
        String errorMessage = ExceptionUtilities.parseMessage(ex);

        if (errorMessage == null) {
            errorMessage = "NullPointerException";
        }

        errors.add("general", new ActionMessage(ExceptionCode.ERROR_MESSAGES_PREFIX + "general", errorMessage));
        request.setAttribute("exception", errorMessage);
        doTrace(request, DLog.ERROR, getClass(), errorMessage);
    } finally {
    }

    if (errors.isEmpty()) {
        doTrace(request, DLog.INFO, getClass(), "OK");

        return mapping.findForward(Constants.ACTION_SUCCESS_FORWARD);
    } else {
        saveErrors(request, errors);

        return mapping.findForward(Constants.ACTION_FAIL_FORWARD);
    }
}

From source file:events.FocusEventDemo.java

public void addComponentsToPane(final Container pane) {
    GridBagLayout gridbag = new GridBagLayout();
    pane.setLayout(gridbag);//from   w  w  w  .  j a  v a  2s  . com

    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0; //Make column as wide as possible.
    JTextField textField = new JTextField("A TextField");
    textField.setMargin(new Insets(0, 2, 0, 2));
    textField.addFocusListener(this);
    gridbag.setConstraints(textField, c);
    add(textField);

    c.weightx = 0.1; //Widen every other column a bit, when possible.
    c.fill = GridBagConstraints.NONE;
    JLabel label = new JLabel("A Label");
    label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    label.addFocusListener(this);
    gridbag.setConstraints(label, c);
    add(label);

    String comboPrefix = "ComboBox Item #";
    final int numItems = 15;
    Vector<String> vector = new Vector<String>(numItems);
    for (int i = 0; i < numItems; i++) {
        vector.addElement(comboPrefix + i);
    }
    JComboBox comboBox = new JComboBox(vector);
    comboBox.addFocusListener(this);
    gridbag.setConstraints(comboBox, c);
    add(comboBox);

    c.gridwidth = GridBagConstraints.REMAINDER;
    JButton button = new JButton("A Button");
    button.addFocusListener(this);
    gridbag.setConstraints(button, c);
    add(button);

    c.weightx = 0.0;
    c.weighty = 0.1;
    c.fill = GridBagConstraints.BOTH;
    String listPrefix = "List Item #";
    Vector<String> listVector = new Vector<String>(numItems);
    for (int i = 0; i < numItems; i++) {
        listVector.addElement(listPrefix + i);
    }
    JList list = new JList(listVector);
    list.setSelectedIndex(1); //It's easier to see the focus change
    //if an item is selected.
    list.addFocusListener(this);
    JScrollPane listScrollPane = new JScrollPane(list);

    gridbag.setConstraints(listScrollPane, c);
    add(listScrollPane);

    c.weighty = 1.0; //Make this row as tall as possible.
    c.gridheight = GridBagConstraints.REMAINDER;
    //Set up the area that reports focus-gained and focus-lost events.
    display = new JTextArea();
    display.setEditable(false);
    //The setRequestFocusEnabled method prevents a
    //component from being clickable, but it can still
    //get the focus through the keyboard - this ensures
    //user accessibility.
    display.setRequestFocusEnabled(false);
    display.addFocusListener(this);
    JScrollPane displayScrollPane = new JScrollPane(display);

    gridbag.setConstraints(displayScrollPane, c);
    add(displayScrollPane);
    setPreferredSize(new Dimension(450, 450));
    ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:FocusEventDemo.java

public FocusEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0; //Make column as wide as possible.
    JTextField textField = new JTextField("A TextField");
    textField.setMargin(new Insets(0, 2, 0, 2));
    textField.addFocusListener(this);
    gridbag.setConstraints(textField, c);
    add(textField);/*  ww  w. j ava 2s  . c om*/

    c.weightx = 0.1; //Widen every other column a bit, when possible.
    c.fill = GridBagConstraints.NONE;
    JLabel label = new JLabel("A Label");
    label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    label.addFocusListener(this);
    gridbag.setConstraints(label, c);
    add(label);

    String comboPrefix = "ComboBox Item #";
    final int numItems = 15;
    Vector vector = new Vector(numItems);
    for (int i = 0; i < numItems; i++) {
        vector.addElement(comboPrefix + i);
    }
    JComboBox comboBox = new JComboBox(vector);
    comboBox.addFocusListener(this);
    gridbag.setConstraints(comboBox, c);
    add(comboBox);

    c.gridwidth = GridBagConstraints.REMAINDER;
    JButton button = new JButton("A Button");
    button.addFocusListener(this);
    gridbag.setConstraints(button, c);
    add(button);

    c.weightx = 0.0;
    c.weighty = 0.1;
    c.fill = GridBagConstraints.BOTH;
    String listPrefix = "List Item #";
    Vector listVector = new Vector(numItems);
    for (int i = 0; i < numItems; i++) {
        listVector.addElement(listPrefix + i);
    }
    JList list = new JList(listVector);
    list.setSelectedIndex(1); //It's easier to see the focus change
    //if an item is selected.
    list.addFocusListener(this);
    JScrollPane listScrollPane = new JScrollPane(list);
    //We want to prevent the list's scroll bars
    //from getting the focus - even with the keyboard.
    //Note that in general we prefer setRequestFocusable
    //over setFocusable for reasons of accessibility,
    //but this is to work around bug #4866958.
    listScrollPane.getVerticalScrollBar().setFocusable(false);
    listScrollPane.getHorizontalScrollBar().setFocusable(false);
    gridbag.setConstraints(listScrollPane, c);
    add(listScrollPane);

    c.weighty = 1.0; //Make this row as tall as possible.
    c.gridheight = GridBagConstraints.REMAINDER;
    //Set up the area that reports focus-gained and focus-lost events.
    display = new JTextArea();
    display.setEditable(false);
    //The method setRequestFocusEnabled prevents a
    //component from being clickable, but it can still
    //get the focus through the keyboard - this ensures
    //user accessibility.
    display.setRequestFocusEnabled(false);
    display.addFocusListener(this);
    JScrollPane displayScrollPane = new JScrollPane(display);

    //Work around for bug #4866958.
    displayScrollPane.getHorizontalScrollBar().setFocusable(false);
    displayScrollPane.getVerticalScrollBar().setFocusable(false);
    gridbag.setConstraints(displayScrollPane, c);
    add(displayScrollPane);

    setPreferredSize(new Dimension(450, 450));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:AppletJDBCDrop.java

private void loadTables() {
    Vector v = new Vector();
    try {/*  ww  w .  jav  a 2 s. com*/
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("SHOW TABLES");

        while (rs.next()) {
            v.addElement(rs.getString(1));
        }
        rs.close();
    } catch (SQLException e) {
    }
    v.addElement("acc_acc");
    v.addElement("acc_add");
    v.addElement("junk");
    tableList.setListData(v);
}