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:mypackage.State_Stream.java

private void toggleUnsavedAndSaved(final int index) {
    // L?MoH??^?[
    if (!Network.isCoverageSufficient()) {
        // ANeBreBCWP?[^?[??
        _screen.deleteActivityIndicator();

        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                Dialog.alert(// w ww.  ja  v  a  2s .  c  o  m
                        "A communication error has occurred. Please make sure your device is connected to Internet.");
            }
        });
        return;
    } //if()

    new Thread() {
        public void run() {
            boolean desired_savedtag_status = false;
            boolean current_savedtag_status = false;

            try {
                // ANeBreBCWP?[^?[\
                _screen.showActivityIndicator();

                // Gg?[Save?I?
                if (isSavedEntry(index)) {
                    desired_savedtag_status = false;
                    current_savedtag_status = true;
                } else {
                    desired_savedtag_status = true;
                    current_savedtag_status = false;
                }

                // saved?Abvf?[g
                Entry _entry = (Entry) entries.elementAt(index);
                if (desired_savedtag_status) {
                    _entry.makeAsSaved();
                } else {
                    _entry.makeAsUnsaved();
                }

                // \?X?V
                _screen.updateSavedAndUpdatedField(index);

                // Gg?[XN?[\???A?X?V?B
                if (_entryScreen != null && _entryScreen.isVisible()) {
                    _entryScreen.updateSavedAndUpdatedField(index);
                }

                //
                String tagId = "user/" + _feedlyclient.getID() + "/tag/global.saved";

                // savedGg?[ID
                String entryId = _entry.getId();

                // Feedly API@?B
                if (current_savedtag_status) {
                    Vector entryIds = new Vector();
                    entryIds.addElement(entryId);
                    _feedlyapi.untagMultipleEntries(tagId, entryIds);
                } else {
                    _feedlyapi.tagEntry(tagId, entryId);
                }

            } catch (final Exception e) {

                // ssaved??B
                Entry _entry = (Entry) entries.elementAt(index);
                if (desired_savedtag_status) {
                    _entry.makeAsSaved();
                } else {
                    _entry.makeAsUnsaved();
                }

                // \?B
                _screen.updateSavedAndUpdatedField(index);

                // Gg?[XN?[\???A?B
                if (_entryScreen != null && _entryScreen.isVisible()) {
                    _entryScreen.updateSavedAndUpdatedField(index);
                }

                // G?[?MO
                updateStatus("toggleUnsavedAndSaved() " + e.toString());

                // s_CA?O\
                UiApplication.getUiApplication().invokeLater(new Runnable() {
                    public void run() {
                        Dialog.alert("An unexpected error occurred while tagging entry.");
                    }
                });

            } finally {
                // ANeBreBCWP?[^?[??
                _screen.deleteActivityIndicator();
            }
        } //run()
    }.start(); //Thread()
}

From source file:gate.annotation.AnnotationSetImpl.java

@Override
public synchronized void addGateListener(GateListener l) {
    @SuppressWarnings("unchecked")
    Vector<GateListener> v = gateListeners == null ? new Vector<GateListener>(2)
            : (Vector<GateListener>) gateListeners.clone();
    if (!v.contains(l)) {
        v.addElement(l);
        gateListeners = v;/*  w ww. j  av  a2  s  .  c  om*/
    }
}

From source file:org.apache.axis.message.SOAPHeader.java

/**
 * Return an Enumeration of headers which match the given namespace
 * and localPart.  Depending on the value of the accessAllHeaders
 * parameter, we will attempt to filter on the current engine's list
 * of actors.//from w  w  w .ja  v  a2s  .  c  o m
 * 
 * !!! NOTE THAT RIGHT NOW WE ALWAYS ASSUME WE'RE THE "ULTIMATE
 * DESTINATION" (i.e. we match on null actor).  IF WE WANT TO FULLY SUPPORT
 * INTERMEDIARIES WE'LL NEED TO FIX THIS.
 */
Enumeration getHeadersByName(String namespace, String localPart, boolean accessAllHeaders) {
    ArrayList actors = null;
    boolean firstTime = false;

    /** This might be optimizable by creating a custom Enumeration
     * which moves through the headers list (parsing on demand, again),
     * returning only the next one each time.... this is Q&D for now.
     */
    Vector v = new Vector();
    List headers = getChildren();
    if (headers == null) {
        return v.elements();
    }
    Iterator e = headers.iterator();
    SOAPHeaderElement header;
    String nextActor = getEnvelope().getSOAPConstants().getNextRoleURI();

    while (e.hasNext()) {
        header = (SOAPHeaderElement) e.next();
        if (header.getNamespaceURI().equals(namespace) && header.getName().equals(localPart)) {

            if (!accessAllHeaders) {
                if (firstTime) {
                    // Do one-time setup
                    MessageContext mc = MessageContext.getCurrentContext();
                    if (mc != null && mc.getAxisEngine() != null) {
                        actors = mc.getAxisEngine().getActorURIs();
                    }
                    firstTime = false;
                }

                String actor = header.getActor();
                if ((actor != null) && !nextActor.equals(actor)
                        && (actors == null || !actors.contains(actor))) {
                    continue;
                }
            }

            v.addElement(header);
        }
    }

    return v.elements();
}

From source file:org.apache.slide.store.ExtendedStore.java

public void renewLock(Uri uri, NodeLock lock) throws ServiceAccessException, LockTokenNotFoundException {
    super.renewLock(uri, lock);
    if (lockStore.cacheResults()) {
        enlist(this);
        try {// w  w  w .j a  v a2 s . c o m
            Object value = locksCache.get(uri.toString());
            Vector locksVector = null;
            if (value != null) {
                locksVector = new Vector((Vector) value);
                boolean wasPresent = locksVector.removeElement(lock);
                if (!wasPresent) {
                    throw new LockTokenNotFoundException(lock);
                }
                locksVector.addElement(lock.cloneObject());
                locksCache.put(uri.toString(), locksVector);
            }
        } finally {
            delist(this);
        }
    }
}

From source file:org.apache.flex.forks.velocity.runtime.configuration.Configuration.java

/**
 * Add a property to the configuration. If it already
 * exists then the value stated here will be added
 * to the configuration entry. For example, if
 *
 * resource.loader = file/*w w w.  j a v  a2 s . co m*/
 *
 * is already present in the configuration and you
 *
 * addProperty("resource.loader", "classpath")
 *
 * Then you will end up with a Vector like the
 * following:
 *
 * ["file", "classpath"]
 *
 * @param String key
 * @param String value
 */
//public void setProperty(String key, Object token)
public void addProperty(String key, Object token) {

    // $$$ GMJ : remove after 1.1 release
    // for deprecation help
    deprecationCrutch.addProperty(key, token);

    Object o = this.get(key);

    /*
     *  $$$ GMJ
     *  FIXME : post 1.0 release, we need to not assume
     *  that a scalar is a String - it can be an Object
     *  so we should make a little vector-like class
     *  say, Foo that wraps (not extends Vector),
     *  so we can do things like
     *  if ( !( o instanceof Foo) )
     *  so we know it's our 'vector' container
     *
     *  This applies throughout
     */

    if (o instanceof String) {
        Vector v = new Vector(2);
        v.addElement(o);
        v.addElement(token);
        put(key, v);
    } else if (o instanceof Vector) {
        ((Vector) o).addElement(token);
    } else {
        /*
         * This is the first time that we have seen
         * request to place an object in the 
         * configuration with the key 'key'. So
         * we just want to place it directly into
         * the configuration ... but we are going to
         * make a special exception for String objects
         * that contain "," characters. We will take
         * CSV lists and turn the list into a vector of
         * Strings before placing it in the configuration.
         * This is a concession for Properties and the
         * like that cannot parse multiple same key
         * values.
         */
        if (token instanceof String && ((String) token).indexOf(PropertiesTokenizer.DELIMITER) > 0) {
            PropertiesTokenizer tokenizer = new PropertiesTokenizer((String) token);

            while (tokenizer.hasMoreTokens()) {
                String value = tokenizer.nextToken();

                /*
                 * we know this is a string, so make sure it
                 * just goes in rather than risking vectorization
                 * if it contains an escaped comma
                 */
                addStringProperty(key, value);
            }
        } else {
            /*
             * We want to keep track of the order the keys
             * are parsed, or dynamically entered into
             * the configuration. So when we see a key
             * for the first time we will place it in
             * an ArrayList so that if a client class needs
             * to perform operations with configuration
             * in a definite order it will be possible.
             */

            /*
             * safety check
             */

            if (!containsKey(key)) {
                keysAsListed.add(key);
            }

            /*
             * and the value
             */
            put(key, token);
        }
    }
}

From source file:org.apache.flex.forks.velocity.runtime.configuration.Configuration.java

/**
 * Get an array of strings associated with the given configuration
 * key./*from  ww w  .  jav  a 2  s  . co m*/
 *
 * @param key The configuration key.
 * @return The associated string array if key is found.
 * @exception ClassCastException is thrown if the key maps to an
 * object that is not a String/Vector.
 */
public String[] getStringArray(String key) {
    Object value = get(key);

    // What's your vector, Victor?
    Vector vector;
    if (value instanceof String) {
        vector = new Vector(1);
        vector.addElement(value);
    } else if (value instanceof Vector) {
        vector = (Vector) value;
    } else if (value == null) {
        if (defaults != null) {
            return defaults.getStringArray(key);
        } else {
            return new String[0];
        }
    } else {
        throw new ClassCastException('\'' + key + "' doesn't map to a String/Vector object");
    }

    String[] tokens = new String[vector.size()];
    for (int i = 0; i < tokens.length; i++) {
        tokens[i] = (String) vector.elementAt(i);
    }

    return tokens;
}

From source file:gate.annotation.AnnotationSetImpl.java

@Override
public synchronized void addAnnotationSetListener(AnnotationSetListener l) {
    @SuppressWarnings("unchecked")
    Vector<AnnotationSetListener> v = annotationSetListeners == null ? new Vector<AnnotationSetListener>(2)
            : (Vector<AnnotationSetListener>) annotationSetListeners.clone();
    if (!v.contains(l)) {
        v.addElement(l);
        annotationSetListeners = v;/*from   w w  w  .  j  av  a 2 s.com*/
    }
}

From source file:eionet.acl.PersistenceDB.java

private String[][] executeStringQuery(String sql) throws SQLException {
    Vector<String[]> rvec = new Vector<String[]>(); // Return value as Vector
    String[][] rval = {}; // Return value
    Connection con = null;//from  ww  w  .  j  av a  2 s .  c  o  m
    Statement stmt = null;
    ResultSet rset = null;

    // Process the result set
    con = getConnection();

    try {
        stmt = con.createStatement();
        rset = stmt.executeQuery(sql);
        ResultSetMetaData md = rset.getMetaData();

        //number of columns in the result set
        int colCnt = md.getColumnCount();

        while (rset.next()) {
            String[] row = new String[colCnt]; // Row of the result set

            // Retrieve the columns of the result set
            for (int i = 0; i < colCnt; ++i) {
                row[i] = rset.getString(i + 1);
            }
            rvec.addElement(row);
        }
    } catch (SQLException e) {
        e.printStackTrace(System.out);
        throw new SQLException("Error occurred when processing result set: " + sql);
    } finally {

        close(con, stmt, null);
    }

    // Build return value
    if (rvec.size() > 0) {
        rval = new String[rvec.size()][];

        for (int i = 0; i < rvec.size(); ++i)
            rval[i] = (String[]) rvec.elementAt(i);
    }

    // Success
    return rval;
}

From source file:com.duroty.application.files.manager.FilesManager.java

/**
 * DOCUMENT ME!//  w  w  w . j  a  v a  2  s  . c  o  m
 *
 * @param hsession DOCUMENT ME!
 * @param repositoryName DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws MailException DOCUMENT ME!
 */
public Vector getLabels(Session hsession, String repositoryName) throws FilesException {
    Vector labels = new Vector();

    try {
        Criteria criteria = hsession.createCriteria(Label.class);
        criteria.add(Restrictions.eq("users", getUser(hsession, repositoryName)));
        criteria.addOrder(Order.asc("labName"));

        ScrollableResults scroll = criteria.scroll();

        while (scroll.next()) {
            Label label = (Label) scroll.get(0);

            LabelObj obj = new LabelObj(label.getLabIdint(), label.getLabName());

            labels.addElement(obj);
        }

        return labels;
    } catch (Exception e) {
        throw new FilesException(e);
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}

From source file:EditorPaneExample16.java

public URL[] findLinks(Document doc, String protocol) {
    Vector links = new Vector();
    Vector urlNames = new Vector();
    URL baseURL = (URL) doc.getProperty(Document.StreamDescriptionProperty);

    if (doc instanceof HTMLDocument) {
        Element elem = doc.getDefaultRootElement();
        ElementIterator iterator = new ElementIterator(elem);

        while ((elem = iterator.next()) != null) {
            AttributeSet attrs = elem.getAttributes();
            Object link = attrs.getAttribute(HTML.Tag.A);
            if (link instanceof AttributeSet) {
                Object linkAttr = ((AttributeSet) link).getAttribute(HTML.Attribute.HREF);
                if (linkAttr instanceof String) {
                    try {
                        URL linkURL = new URL(baseURL, (String) linkAttr);
                        if (protocol == null || protocol.equalsIgnoreCase(linkURL.getProtocol())) {
                            String linkURLName = linkURL.toString();
                            if (urlNames.contains(linkURLName) == false) {
                                urlNames.addElement(linkURLName);
                                links.addElement(linkURL);
                            }//from   w w w  .  jav a 2  s  . co m
                        }
                    } catch (MalformedURLException e) {
                        // Ignore invalid links
                    }
                }
            }
        }
    }

    URL[] urls = new URL[links.size()];
    links.copyInto(urls);
    links.removeAllElements();
    urlNames.removeAllElements();

    return urls;
}