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:com.github.maven_nar.cpptasks.compiler.AbstractCompiler.java

protected boolean resolveInclude(final String includeName, final File[] includePath, final Vector onThisPath) {
    for (final File element : includePath) {
        final File includeFile = new File(element, includeName);
        if (includeFile.exists()) {
            onThisPath.addElement(includeFile);
            return true;
        }//  w  ww  . j  av a 2  s  .c o m
    }
    return false;
}

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

/**
 * Set the value of a header field. <b>This will replace any current
 * value for this header, regardless of how many times it occurs</b>.
 * //  w w  w  .ja  v a2s.c o m
 * @param headerName header name
 * @param value header value
 */
public void setHeaderField(String headerName, String value) {
    if (value == null) {
        throw new IllegalArgumentException("Null value");
    }
    Vector v = new Vector();
    fields.put(headerName.toLowerCase(), new Field(headerName, v));
    if (!fieldNames.contains(headerName)) {
        fieldNames.addElement(headerName);
    }
    v.addElement(value);
}

From source file:net.wastl.webmail.xml.XMLUserModel.java

public synchronized void clearWork() {
    NodeList nl = usermodel.getElementsByTagName("WORK");
    if (nl.getLength() > 0) {
        Element work = (Element) nl.item(0);
        NodeList nl2 = work.getChildNodes();
        Vector<Node> v = new Vector<Node>();
        for (int i = 0; i < nl2.getLength(); i++) {
            v.addElement(nl2.item(i));
        }/*  w  w w  .j a va 2  s .c om*/
        Enumeration<Node> enumVar = v.elements();
        while (enumVar.hasMoreElements()) {
            work.removeChild(enumVar.nextElement());
        }
        invalidateCache();
    }
}

From source file:gov.nih.nci.firebird.service.signing.DigitalSigningHelper.java

@SuppressWarnings({ "PMD.LooseCoupling", "PMD.UseArrayListInsteadOfVector", "PMD.ReplaceVectorWithList" })
// Vector required by bouncycastle X509 implementation
private Vector<DERObjectIdentifier> getAttributeOrder() {
    Vector<DERObjectIdentifier> order = new Vector<DERObjectIdentifier>();
    order.addElement(X509Principal.C);
    order.addElement(X509Principal.ST);
    order.addElement(X509Principal.L);
    order.addElement(X509Principal.O);
    order.addElement(X509Principal.OU);
    order.addElement(X509Principal.CN);
    order.addElement(X509Principal.EmailAddress);
    return order;
}

From source file:com.iucosoft.eavertizare.gui.models.ClientiTableModel.java

public void findClient(Frame frame, String nume) {
    clearModel();/*from   w w  w  . j  a v a2  s .  c o m*/
    Client client;
    List<Client> listaClienti = null;
    List<Firma> listaFirme = firmaDao.findAll();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy");
    int nr = 1;
    Vector rowData = null;
    for (Firma firma : listaFirme) {
        client = clientsDao.findClient(firma, nume);
        if (client != null) {
            rowData = new Vector();
            rowData.addElement(nr++);
            rowData.addElement(client.getNume());
            rowData.addElement(client.getPrenume());
            rowData.addElement(client.getNrTelefon());
            rowData.addElement(client.getEmail());
            rowData.addElement(sdf.format(client.getDateExpirare()));
            rowData.addElement(client.getFirma().getNumeFirma());
            rowData.addElement(client.isTrimis());

            super.addRow(rowData);
        }
    }
    if (rowData == null) {
        refreshModel();
        JOptionPane.showMessageDialog(frame, "Nu exista client cu asa nume = " + nume, "Error",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:com.iucosoft.eavertizare.gui.models.ClientiTableModel.java

public void findClient(Frame frame, String nume, String prenume) {
    clearModel();/*from w  w  w .  j a v a 2 s.c o m*/
    Client client;
    List<Client> listaClienti = null;
    List<Firma> listaFirme = firmaDao.findAll();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy");
    int nr = 1;
    Vector rowData = null;
    for (Firma firma : listaFirme) {
        client = clientsDao.findClient(firma, nume, prenume);
        if (client != null) {
            rowData = new Vector();
            rowData.addElement(nr++);
            rowData.addElement(client.getNume());
            rowData.addElement(client.getPrenume());
            rowData.addElement(client.getNrTelefon());
            rowData.addElement(client.getEmail());
            rowData.addElement(sdf.format(client.getDateExpirare()));
            rowData.addElement(client.getFirma().getNumeFirma());
            rowData.addElement(client.isTrimis());
            super.addRow(rowData);
        }
    }
    if (rowData == null) {
        refreshModel();
        JOptionPane.showMessageDialog(frame,
                "Nu exista client cu asa nume = " + nume + " si prenume = " + prenume, "Error",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:org.ecoinformatics.emltest.SaxValidateTest.java

/**
 * Get the list of files in a directory.
 *
 * @param directory the directory to list
 * @return a vector of File objects in the directory
 *///from  w  w  w.j  a va2 s. c o  m
private Vector getXmlFiles(File directory) {
    String[] files = directory.list();
    Vector fileList = new Vector();

    for (int i = 0; i < files.length; i++) {
        String filename = files[i];
        File currentFile = new File(directory, filename);
        if (currentFile.isFile() && filename.endsWith(".xml")) {
            fileList.addElement(currentFile);
        }
    }
    return fileList;
}

From source file:net.wastl.webmail.xml.XMLMessagePart.java

public Enumeration<XMLMessagePart> getParts() {
    // Sucking NodeList needs a Vector to store Elements that will be removed!
    Vector<XMLMessagePart> v = new Vector<XMLMessagePart>();
    NodeList parts = part.getChildNodes();
    for (int j = 0; j < parts.getLength(); j++) {
        Element elem = (Element) parts.item(j);
        if (elem.getTagName().equals("PART"))
            v.addElement(new XMLMessagePart(elem));
    }/*w w  w.  j  a va2  s .c om*/
    return v.elements();
}

From source file:org.apache.struts2.jasper.compiler.JspUtil.java

/**
 * Checks if all mandatory attributes are present and if all attributes
 * present have valid names.  Checks attributes specified as XML-style
 * attributes as well as attributes specified using the jsp:attribute
 * standard action.//from w  w  w. j av a  2  s . c  o m
 *
 * @param typeOfTag       type of tag
 * @param n               node
 * @param validAttributes valid attributes
 * @param err             error dispatcher
 * @throws JasperException in case of Jasper errors
 */
public static void checkAttributes(String typeOfTag, Node n, ValidAttribute[] validAttributes,
        ErrorDispatcher err) throws JasperException {
    Attributes attrs = n.getAttributes();
    Mark start = n.getStart();
    boolean valid = true;

    // AttributesImpl.removeAttribute is broken, so we do this...
    int tempLength = (attrs == null) ? 0 : attrs.getLength();
    Vector temp = new Vector(tempLength, 1);
    for (int i = 0; i < tempLength; i++) {
        String qName = attrs.getQName(i);
        if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:")))
            temp.addElement(qName);
    }

    // Add names of attributes specified using jsp:attribute
    Node.Nodes tagBody = n.getBody();
    if (tagBody != null) {
        int numSubElements = tagBody.size();
        for (int i = 0; i < numSubElements; i++) {
            Node node = tagBody.getNode(i);
            if (node instanceof Node.NamedAttribute) {
                String attrName = node.getAttributeValue("name");
                temp.addElement(attrName);
                // Check if this value appear in the attribute of the node
                if (n.getAttributeValue(attrName) != null) {
                    err.jspError(n, "jsp.error.duplicate.name.jspattribute", attrName);
                }
            } else {
                // Nothing can come before jsp:attribute, and only
                // jsp:body can come after it.
                break;
            }
        }
    }

    /*
     * First check to see if all the mandatory attributes are present.
     * If so only then proceed to see if the other attributes are valid
     * for the particular tag.
     */
    String missingAttribute = null;

    for (ValidAttribute validAttribute : validAttributes) {
        int attrPos;
        if (validAttribute.mandatory) {
            attrPos = temp.indexOf(validAttribute.name);
            if (attrPos != -1) {
                temp.remove(attrPos);
                valid = true;
            } else {
                valid = false;
                missingAttribute = validAttribute.name;
                break;
            }
        }
    }

    // If mandatory attribute is missing then the exception is thrown
    if (!valid)
        err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag, missingAttribute);

    // Check to see if there are any more attributes for the specified tag.
    int attrLeftLength = temp.size();
    if (attrLeftLength == 0)
        return;

    // Now check to see if the rest of the attributes are valid too.
    String attribute = null;

    for (int j = 0; j < attrLeftLength; j++) {
        valid = false;
        attribute = (String) temp.elementAt(j);
        for (ValidAttribute validAttribute : validAttributes) {
            if (attribute.equals(validAttribute.name)) {
                valid = true;
                break;
            }
        }
        if (!valid)
            err.jspError(start, "jsp.error.invalid.attribute", typeOfTag, attribute);
    }
    // XXX *could* move EL-syntax validation here... (sb)
}

From source file:com.substanceofcode.twitter.model.Status.java

/**
 * Creates a new instance of StatusEntry
 *
 * @param screenName/*from  w  w  w  .j a v  a  2  s  . c  om*/
 * @param statusText
 * @param date
 */
public Status(String screen_name, JSONObject user, JSONObject status) {
    if (status != null) {
        try {
            id = status.getLong("id");
        } catch (JSONException e) {
        }
        try {
            statusText = StringUtil.decodeEntities(status.getString("text"));
        } catch (JSONException e) {
        }
        try {
            date = DateUtil.parseDate(status.getString("created_at"));
        } catch (JSONException e) {
        }
        try {
            String s = status.getString("source");
            if (s != null) {
                source = StringUtil.removeHtml(StringUtil.decodeEntities(s));
            }
        } catch (JSONException e) {
        }
        try {
            favorited = status.getBoolean("favorited");
        } catch (JSONException e) {
        }
        try {
            following = status.getBoolean("following");
        } catch (JSONException e) {
        }
        if (user == null) {
            try {
                user = status.getJSONObject("user");
            } catch (JSONException je) {
            }
        }
    }
    if (screen_name == null) {
        try {
            String sn = user.getString("screen_name");
            if (sn != null) {
                screenName = StringUtil.decodeEntities(sn);
            }
        } catch (JSONException e) {
        }
    } else {
        screenName = screen_name;
    }
    if (user != null) {
        try {
            long userid = user.getLong("id");
            usersDb.put(new Long(userid), user);
            user_id = userid;
        } catch (Exception e) {
        }
    }
    Enumeration mediaUrl = findMedia(status);
    if (mediaUrl != null) {
        Vector v = new Vector();
        while (mediaUrl.hasMoreElements()) {
            v.addElement(mediaUrl.nextElement());
        }
        this.media_url = v;
    } else {
        media_url = null;
    }
}