Example usage for java.util Vector clone

List of usage examples for java.util Vector clone

Introduction

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

Prototype

public synchronized Object clone() 

Source Link

Document

Returns a clone of this vector.

Usage

From source file:org.ecoinformatics.seek.sms.AnnotationEngine.java

/**
 * helper function to find all class names
 * //w  w  w .  jav a 2  s .com
 *@param classname
 *            Description of the Parameter
 *@param approx
 *            Description of the Parameter
 *@return The matchingClassNames value
 */
private Vector<OntClass> getMatchingClassNames(String classname, boolean approx) {
    Vector<OntClass> initResult = new Vector<OntClass>();
    // get all classes in ontology
    Iterator iter = ontModelOntology().listClasses();
    while (iter.hasNext()) {
        // find classes that have a similar name
        OntClass cls = (OntClass) iter.next();
        if (approx && approxMatch(cls.getLocalName(), classname)) {
            initResult.add(cls);
        } else if (!approx && classname.equals(cls.getLocalName())) {
            initResult.add(cls);
        }
    }
    Vector<OntClass> result = (Vector) initResult.clone();
    iter = initResult.iterator();
    while (iter.hasNext()) {
        // find all subclasses of direct classes
        OntClass cls = (OntClass) iter.next();
        Iterator clsIter = cls.listSubClasses(false);
        // direct = false
        while (clsIter.hasNext()) {
            OntClass subCls = (OntClass) clsIter.next();
            if (!result.contains(subCls)) {
                result.add(subCls);
            }
        }
    }
    return result;
}

From source file:org.esupportail.portal.ws.groups.PortalGroups.java

/**
 * Recupere recursivement les groupes contenant un groupe donne, jusque la racine
 * @param igm un groupe sous la forme IGroupMember
 * @param allGroups vecteur contenant la liste de tous les groupes de l'utilisateur donne. Il peut etre agrandi au cours de la recursivite au cas ou un groupe est rattache a plusieurs groupes en meme temps
 * @param v le vecteur a remplir a chaque etape de la recursivite
 * @throws GroupsException/*from  w ww  . jav  a  2s .  c  om*/
 */
private void getRecurContainingGroups(IGroupMember igm, Vector allGroups, Vector v) throws GroupsException {

    // recupere les groupes contenant le groupe passe en parametre
    Iterator iter = igm.getContainingGroups();

    // pour savoir combien on a d'elements, on recopie cette iteration dans un vecteur
    Vector containingGroups = new Vector();
    while (iter.hasNext()) {
        containingGroups.addElement(iter.next());
    }

    // pour chacun, on l'ajoute dans la liste
    for (int i = 0; i < containingGroups.size(); i++) {

        // on recupere le groupe courant dans l'iteration      
        IEntityGroup egi = (IEntityGroup) containingGroups.elementAt(i);

        // clone du vecteur passe en parametre, ou le vecteur lui meme
        Vector v2 = null;
        if (i == containingGroups.size() - 1) {
            v2 = v;
        } else {
            v2 = (Vector) v.clone();
            //System.out.println(v2+" clone de "+v);
        }

        // on ajoute la clef de ce groupe
        v2.add(0, egi.getKey());
        //System.out.println("Add "+egi.getName());

        // appel a la recursivite
        getRecurContainingGroups(egi, allGroups, v2);

        // on ajoute cette hierarchie a tous les groupes
        if (i < containingGroups.size() - 1) {
            allGroups.addElement(v2);
            //System.out.println("AddAll "+v2);
        }
    }

}

From source file:org.executequery.gui.browser.ColumnData.java

@SuppressWarnings("unchecked")
public void setValues(ColumnData cd) {
    tableName = cd.getTableName();/*  ww  w  .j  a va 2 s  .c o  m*/
    columnName = cd.getColumnName();
    columnType = cd.getColumnType();
    keyType = cd.getKeyType();
    primaryKey = cd.isPrimaryKey();
    foreignKey = cd.isForeignKey();
    columnSize = cd.getColumnSize();
    columnRequired = cd.getColumnRequired();
    sqlType = cd.getSQLType();

    Vector<ColumnConstraint> constraints = cd.getColumnConstraintsVector();
    if (constraints != null) {
        columnConstraints = (Vector<ColumnConstraint>) constraints.clone();
    }
}

From source file:org.executequery.gui.importexport.AbstractImportExportWorker.java

/**
 * Returns the columns to be exported for the specified table.
 *
 * @param table - the table to be dumped
 *//*from  w w w  . j  av a  2  s. c  om*/
@SuppressWarnings("unchecked")
protected Vector<ColumnData> getColumns(String table) throws SQLException {
    Vector<ColumnData> columns = parent.getSelectedColumns();
    if (columns == null) {
        String schema = parent.getSchemaName();
        MetaDataValues metaData = parent.getMetaDataUtility();
        try {
            columns = metaData.getColumnMetaDataVector(table, schema);
        } catch (DataSourceException e) {
            if (e.getCause() instanceof SQLException) {
                throw (SQLException) (e.getCause());
            }
            throw new SQLException(e.getMessage());
        }
    } else {
        columns = (Vector<ColumnData>) columns.clone();
    }
    return columns;
}

From source file:org.feistymeow.process.Defaults.java

@SuppressWarnings("unchecked")
public ThreadSpawnerAndWatcher(Vector<String> command_line) {
    cmdline = (Vector<String>) command_line.clone();
    procbuild = new ProcessBuilder(cmdline);
}

From source file:org.kchine.rpf.db.ServantProxyPoolSingletonDB.java

public static GenericObjectPool getInstance(String poolName, String driver, final String url, final String user,
        final String password) {
    String key = driver + "%" + poolName + "%" + url + "%" + user + "%" + password;
    if (_pool.get(key) != null)
        return _pool.get(key);
    synchronized (lock) {
        if (_pool.get(key) == null) {
            Connection conn = null;
            try {
                Class.forName(driver);
                final Vector<Object> borrowedObjects = new Vector<Object>();
                DBLayerInterface dbLayer = DBLayer.getLayer(getDBType(url), new ConnectionProvider() {
                    public Connection newConnection() throws SQLException {
                        return DriverManager.getConnection(url, user, password);
                    }/* w  w w  . j a va 2s  .  co m*/
                });
                final GenericObjectPool p = new GenericObjectPool(
                        new ServantProxyFactoryDB(poolName, dbLayer)) {
                    @Override
                    public synchronized Object borrowObject() throws Exception {
                        if (_shuttingDown)
                            throw new NoSuchElementException();
                        Object result = super.borrowObject();
                        borrowedObjects.add(result);
                        return result;
                    }

                    @Override
                    public synchronized void returnObject(Object obj) throws Exception {
                        super.returnObject(obj);
                        borrowedObjects.remove(obj);
                    }
                };

                if (System.getProperty("pools.dbmode.shutdownhook.enabled") != null
                        && System.getProperty("pools.dbmode.shutdownhook.enabled").equalsIgnoreCase("false")) {

                } else {
                    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
                        public void run() {
                            synchronized (p) {

                                final Vector<Object> bo = (Vector<Object>) borrowedObjects.clone();

                                _shuttingDown = true;
                                try {
                                    for (int i = 0; i < bo.size(); ++i)
                                        p.returnObject(bo.elementAt(i));
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }));
                }

                _pool.put(key, p);
                p.setMaxIdle(0);
                p.setTestOnBorrow(true);
                p.setTestOnReturn(true);
            } catch (Exception e) {
                throw new RuntimeException(getStackTraceAsString(e));
            }

        }
        return _pool.get(key);
    }
}

From source file:org.kchine.rpf.db.ServantProxyPoolSingletonDB.java

public static GenericObjectPool getInstance(String poolName, DBLayerInterface dbLayer) {
    String key = poolName + "%" + dbLayer.toString();

    if (_pool.get(key) != null)
        return _pool.get(key);
    synchronized (lock) {
        if (_pool.get(key) == null) {
            Connection conn = null;
            try {
                final Vector<Object> borrowedObjects = new Vector<Object>();

                final GenericObjectPool p = new GenericObjectPool(
                        new ServantProxyFactoryDB(poolName, dbLayer)) {
                    @Override/*from   w w  w  .ja v a2  s . c o  m*/
                    public synchronized Object borrowObject() throws Exception {
                        if (_shuttingDown)
                            throw new NoSuchElementException();
                        Object result = super.borrowObject();
                        borrowedObjects.add(result);
                        return result;
                    }

                    @Override
                    public synchronized void returnObject(Object obj) throws Exception {
                        super.returnObject(obj);
                        borrowedObjects.remove(obj);
                    }
                };

                if (System.getProperty("pools.dbmode.shutdownhook.enabled") != null
                        && System.getProperty("pools.dbmode.shutdownhook.enabled").equalsIgnoreCase("false")) {

                } else {
                    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
                        public void run() {
                            synchronized (p) {

                                final Vector<Object> bo = (Vector<Object>) borrowedObjects.clone();

                                _shuttingDown = true;
                                try {
                                    for (int i = 0; i < bo.size(); ++i)
                                        p.returnObject(bo.elementAt(i));
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }));
                }

                _pool.put(key, p);
                p.setMaxIdle(0);
                p.setTestOnBorrow(true);
                p.setTestOnReturn(true);
            } catch (Exception e) {
                throw new RuntimeException(getStackTraceAsString(e));
            }

        }
        return _pool.get(key);
    }
}

From source file:org.kepler.ssh.LocalDelete.java

/**
 * Recursively traverse the directories looking for matches on each level to
 * the relevant part of the mask. Matched files will be deleted. Matched
 * directories will be deleted only if 'recursive' is true.
 *//*from   w  w  w  .j a va  2s . com*/
private boolean delete(File node, Vector masks, boolean recursive) {

    if (isDebugging)
        log.debug(">>> " + node.getPath() + " with masks length = " + masks.size() + ": " + masks.toString());

    // the query is for a single file/dir --> it will be deleted now
    if (masks.isEmpty()) {
        return deleteNode(node, recursive, "Delete ");
    }

    // handle the case where path is not a directory but something else
    if (!node.isDirectory()) {
        if (node.isFile()) {
            // single file
            // this file cannot match the rest of the query mask
            return true; // this is not an error, just skip
        } else {
            // wildcardless mask referred to a non-existing file/dir
            log.error("Path " + node.getPath() + " is not a directory!");
            return false;
        }
    }

    // path refers to an existing dir.
    // Let's list its content with the appropriate mask
    String localMask = null;
    Vector restMask = (Vector) masks.clone();
    if (!masks.isEmpty()) {
        localMask = (String) masks.firstElement(); // first element as local
        // mask
        restMask.remove(0); // the rest
    }

    boolean result = true; // will become false if at least one file removal
    // fails

    // handle special masks . and .. separately
    if (localMask.equals(".") || localMask.equals("..")) {

        // we just need to call this method again with the next mask
        File newNode = new File(node, localMask);
        if (isDebugging)
            log.debug("Special case of " + localMask + " --> Call delete() with " + newNode.getPath());
        result = delete(newNode, restMask, recursive);

    } else {
        // meaningful mask... so list the directory and recursively traverse
        // directories
        MyLocalFilter localFilter = new MyLocalFilter(localMask);

        // Get files matching the localMask in the dir 'node'
        File[] files = node.listFiles(localFilter);

        if (isDebugging)
            log.debug("Found " + files.length + " matching files in " + node);

        for (int i = 0; i < files.length; i++) {
            // recursive call with the rest of the masks
            boolean succ = delete(files[i], restMask, recursive);
            if (!succ && isDebugging)
                log.debug("Failed removal of " + files[i].getPath());
            result = result && succ;
        }
    }

    if (isDebugging)
        log.debug("<<< " + node.getPath());
    return result;
}

From source file:org.sakaiproject.announcement.tool.AnnouncementActionState.java

/**
 * Set//from  w ww  .j a va  2 s. c  o  m
 */
public void setDeleteMessages(Vector delete_messages) {
    // if there's a change
    if (delete_messages != null) {
        m_delete_messages = (Vector) delete_messages.clone();
    } else {
        m_delete_messages = null;
    }
    // remember the new

}

From source file:org.sakaiproject.announcement.tool.AnnouncementActionState.java

/**
 * Set//from w  w w.  ja  v  a 2s.  c o  m
 */
public void setSelectedAttachments(Vector selectedAttachments) {
    // if there's a change
    if (selectedAttachments != null) {
        m_selectedAttachments = (Vector) selectedAttachments.clone();
    } else {
        m_selectedAttachments = null;
    }

    // remember the new
}