Example usage for java.util Vector copyInto

List of usage examples for java.util Vector copyInto

Introduction

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

Prototype

public synchronized void copyInto(Object[] anArray) 

Source Link

Document

Copies the components of this vector into the specified array.

Usage

From source file:com.yahoo.messenger.data.json.ClientCapabilityList.java

public void unserializeJSON(JSONArray a) throws JSONException {

    Vector v = new Vector();

    //  Mandatory fields

    for (int i = 0; i < a.length(); i++) {

        JSONObject o = a.getJSONObject(i);
        ClientCapability c = new ClientCapability();
        c.unserializeJSON(o.getJSONObject("clientCapability"));
        v.addElement(c);//w ww . j av a 2s .  c  o m
    }

    clientCapabilities = new ClientCapability[v.size()];
    v.copyInto(clientCapabilities);

}

From source file:org.apache.catalina.cluster.tcp.ReplicationTransmitter.java

public IDataSender[] getSenders() {
    java.util.Iterator i = map.entrySet().iterator();
    java.util.Vector v = new java.util.Vector();
    while (i.hasNext()) {
        IDataSender sender = (IDataSender) ((java.util.Map.Entry) i.next()).getValue();
        if (sender != null)
            v.addElement(sender);/*from  w  w w.ja  v a  2 s .c  o m*/
    }
    IDataSender[] result = new IDataSender[v.size()];
    v.copyInto(result);
    return result;
}

From source file:ArrayDictionary.java

/**
 * Create an ArrayDictionary, contructing the arrays of keys and
 * values from the two given vectors./*from  w  w w .  j  a  va2s  .  c o  m*/
 * The two vectors should have the same size.
 * @param keys the vector of keys
 * @param values the vector of values
 * @param incr the increment for growing the arrays
 */
public ArrayDictionary(Vector keys, Vector values, int incr) {
    this.incr = incr;
    nelems = keys.size();
    this.keys = new Object[nelems];
    this.values = new Object[nelems];
    keys.copyInto(this.keys);
    values.copyInto(this.values);
}

From source file:org.soaplab.services.AnalysisInventoryProvider.java

/**************************************************************************
 * A protected constructor, used by sub-classes and by the instance()
 * method./*from  w  ww .ja va2  s  .c o m*/
 **************************************************************************/
protected AnalysisInventoryProvider() {

    // loads all classes providing lists of analysis
    Enumeration<AnalysisInventory> spe = GenUtils.spiProviders(AnalysisInventory.class);
    Vector<AnalysisInventory> v = new Vector<AnalysisInventory>();
    while (spe.hasMoreElements()) {
        v.addElement(spe.nextElement());
    }

    // if no classes loaded, make an instance of a default class
    if (v.size() == 0) {
        v.addElement(new DefaultAnalysisInventory());
    }

    int size = v.size();
    listProviders = new AnalysisInventory[size];
    v.copyInto(listProviders);
    if (size == 0) {
        log.error("No analysis list providers was found. A configuration error?");
    } else {
        log.info(size + " analysis list providers found");
    }
}

From source file:com.yahoo.messenger.data.notification.json.ResponseList.java

public void unserializeJSON(JSONArray a) throws JSONException {

    Vector v = new Vector();

    //  Mandatory fields

    for (int i = 0; i < a.length(); i++) {

        JSONObject o = a.getJSONObject(i);

        if (o.has("message")) {
            Message c = new Message();
            c.unserializeJSON(o.getJSONObject("message"));
            v.addElement(c);// w  ww .  ja  v  a2 s.  c o  m
        }
        if (o.has("buddyInfo")) {
            BuddyInfo c = new BuddyInfo();
            c.unserializeJSON(o.getJSONObject("buddyInfo"));
            v.addElement(c);
        }
    }

    responses = new Response[v.size()];
    v.copyInto(responses);

}

From source file:net.wastl.webmail.server.WebMailServer.java

public Provider[] getStoreProviders() {
    Vector<Provider> v = new Vector<Provider>();
    for (int i = 0; i < store_providers.length; i++) {
        if (storage.getConfig("ENABLE " + store_providers[i].getProtocol().toUpperCase()).equals("YES")) {
            v.addElement(store_providers[i]);
        }/*from   ww  w  .  ja v  a  2  s.  c  o  m*/
    }
    Provider[] retval = new Provider[v.size()];
    v.copyInto(retval);
    return retval;
}

From source file:AppletFinder.java

public String[] findApplets(URL u) {
    BufferedReader inrdr = null;/*from   w  w  w  . j  a  v  a  2  s  . c om*/
    Vector v = new Vector();
    char thisChar = 0;

    try {
        inrdr = new BufferedReader(new InputStreamReader(u.openStream()));
        int i;
        while ((i = inrdr.read()) != -1) {
            thisChar = (char) i;
            if (thisChar == '<') {
                String tag = readTag(inrdr);
                // System.out.println("TAG: " + tag);
                if (tag.toUpperCase().startsWith("<APPLET"))
                    v.addElement(tag);
            }
        }
        inrdr.close();
    } catch (IOException e) {
        System.err.println("Error reading from main URL: " + e);
    }
    String applets[] = new String[v.size()];
    v.copyInto(applets);
    return applets;
}

From source file:com.jada.admin.contactus.ContactUsMaintAction.java

public void initSearchInfo(ContactUsMaintActionForm form, String siteId) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Query query = em//w  w  w. j  av  a  2 s  .  c  o m
            .createQuery("from country in class Country where country.siteId = :siteId order by countryName");
    query.setParameter("siteId", siteId);
    Iterator<?> iterator = query.getResultList().iterator();
    Vector<LabelValueBean> vector = new Vector<LabelValueBean>();
    while (iterator.hasNext()) {
        Country country = (Country) iterator.next();
        LabelValueBean bean = new LabelValueBean(country.getCountryName(), country.getCountryCode());
        vector.add(bean);
    }
    LabelValueBean countries[] = new LabelValueBean[vector.size()];
    vector.copyInto(countries);
    form.setCountries(countries);

    String sql = "";
    sql = "from      State state " + "left   join fetch state.country country "
            + "where   country.siteId = :siteId " + "order   by country.countryId, state.stateName";
    query = em.createQuery(sql);
    query.setParameter("siteId", siteId);
    iterator = query.getResultList().iterator();
    vector = new Vector<LabelValueBean>();
    vector.add(new LabelValueBean("", ""));
    while (iterator.hasNext()) {
        State state = (State) iterator.next();
        LabelValueBean bean = new LabelValueBean(state.getStateName(), state.getStateCode());
        vector.add(bean);
    }
    LabelValueBean states[] = new LabelValueBean[vector.size()];
    vector.copyInto(states);
    form.setStates(states);
}

From source file:com.xpn.xwiki.plugin.svg.SVGPlugin.java

protected String[] expandSources(Vector sources) {
    Vector expandedSources = new Vector();
    Iterator iter = sources.iterator();
    while (iter.hasNext()) {
        String v = (String) iter.next();
        File f = new File(v);
        if (f.exists() && f.isDirectory()) {
            File[] fl = f.listFiles(new SVGConverter.SVGFileFilter());
            for (File element : fl) {
                expandedSources.addElement(element.getPath());
            }//  w w  w . j av a 2  s .co  m
        } else {
            expandedSources.addElement(v);
        }
    }

    String[] s = new String[expandedSources.size()];
    expandedSources.copyInto(s);
    return s;
}

From source file:com.panet.imeta.job.entries.sftp.SFTPClient.java

public String[] dir() throws KettleJobException {
    String[] fileList = null;/*from   w w w  .ja v a  2 s . c  om*/

    try {
        java.util.Vector<?> v = c.ls(".");
        java.util.Vector<String> o = new java.util.Vector<String>();
        if (v != null) {
            for (int i = 0; i < v.size(); i++) {
                Object obj = v.elementAt(i);
                if (obj != null && obj instanceof com.jcraft.jsch.ChannelSftp.LsEntry) {
                    LsEntry lse = (com.jcraft.jsch.ChannelSftp.LsEntry) obj;
                    if (!lse.getAttrs().isDir())
                        o.add(lse.getFilename());
                }
            }
        }
        if (o.size() > 0) {
            fileList = new String[o.size()];
            o.copyInto(fileList);
        }
    } catch (SftpException e) {
        throw new KettleJobException(e);
    }

    return fileList;
}