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.duroty.application.mail.manager.PreferencesManager.java

/**
 * DOCUMENT ME!/*from   w ww . j a  v a 2  s  .com*/
 *
 * @param hsession DOCUMENT ME!
 * @param token DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws ManagerException DOCUMENT ME!
 */
public Vector suggestContacts(Session hsession, String repositoryName, String token) throws Exception {
    Vector contacts = new Vector();

    try {
        Criteria crit = hsession.createCriteria(ContactList.class);
        crit.add(Restrictions.ilike("coliName", token, MatchMode.ANYWHERE));
        crit.add(Restrictions.eq("users", getUser(hsession, repositoryName)));
        crit.addOrder(Order.asc("coliName"));

        ScrollableResults scroll = crit.scroll();

        while (scroll.next()) {
            ContactList contactList = (ContactList) scroll.get(0);

            ContactObj obj = new ContactObj();
            obj.setIdint(contactList.getColiIdint());
            obj.setName(contactList.getColiName());
            obj.setEmail("GROUP");

            contacts.addElement(obj);
        }

        crit = hsession.createCriteria(Contact.class);
        crit.add(Restrictions.or(Restrictions.ilike("conName", token, MatchMode.ANYWHERE),
                Restrictions.ilike("conEmail", token, MatchMode.ANYWHERE)));
        crit.add(Restrictions.isNotNull("conSentDate"));
        crit.add(Restrictions.isNotNull("conReceivedDate"));
        crit.add(Restrictions.eq("users", getUser(hsession, repositoryName)));

        crit.add(Restrictions.eq("users", getUser(hsession, repositoryName)));
        crit.addOrder(Order.desc("conCount"));

        scroll = crit.scroll();

        while (scroll.next()) {
            Contact contact = (Contact) scroll.get(0);

            ContactObj obj = new ContactObj();
            obj.setIdint(contact.getConIdint());
            obj.setName(contact.getConName());
            obj.setEmail(contact.getConEmail());

            contacts.addElement(obj);
        }

        return contacts;
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}

From source file:de.juwimm.cms.remote.ClientServiceSpringImpl.java

private void getAllViewComponentsChildren4Status(ViewComponentHbm view, Vector<ViewComponentValue> vec,
        int status, Integer unitId) throws Exception {
    if (view.getStatus() == status && !view.isRoot()) {
        ViewComponentValue viewDao = view.getDeployDao();
        viewDao.setPath2Unit(this.getParents4View(view));
        vec.addElement(viewDao);
    }//from   w  w w  .  jav a2s  .com
    Iterator it = view.getChildren().iterator();
    while (it.hasNext()) {
        ViewComponentHbm vcl = (ViewComponentHbm) it.next();
        if (vcl.getAssignedUnit() == null || vcl.getAssignedUnit().getUnitId().equals(unitId)) {
            this.getAllViewComponentsChildren4Status(vcl, vec, status, unitId);
        }
    }
}

From source file:com.splicemachine.db.impl.sql.compile.TableElementList.java

/**
 * Validate this TableElementList.  This includes checking for
 * duplicate columns names, and checking that user types really exist.
 *
 * @param ddlStmt   DDLStatementNode which contains this list
 * @param dd      DataDictionary to use// w w w  . j  ava2s .c om
 * @param td      TableDescriptor for table, if existing table.
 *
 * @exception StandardException      Thrown on error
 */
void validate(DDLStatementNode ddlStmt, DataDictionary dd, TableDescriptor td) throws StandardException {
    this.td = td;
    int numAutoCols = 0;

    int size = size();
    Hashtable columnHT = new Hashtable(size + 2, (float) .999);
    Hashtable constraintHT = new Hashtable(size + 2, (float) .999);
    //all the primary key/unique key constraints for this table
    Vector constraintsVector = new Vector();

    //special case for alter table (td is not null in case of alter table)
    if (td != null) {
        //In case of alter table, get the already existing primary key and unique
        //key constraints for this table. And then we will compare them with  new
        //primary key/unique key constraint column lists.
        ConstraintDescriptorList cdl = dd.getConstraintDescriptors(td);
        ConstraintDescriptor cd;

        if (cdl != null) //table does have some pre-existing constraints defined on it
        {
            for (int i = 0; i < cdl.size(); i++) {
                cd = cdl.elementAt(i);
                //if the constraint type is not primary key or unique key, ignore it.
                if (cd.getConstraintType() == DataDictionary.PRIMARYKEY_CONSTRAINT
                        || cd.getConstraintType() == DataDictionary.UNIQUE_CONSTRAINT)
                    constraintsVector.addElement(cd);
            }
        }
    }

    int tableType = TableDescriptor.BASE_TABLE_TYPE;
    if (ddlStmt instanceof CreateTableNode)
        tableType = ((CreateTableNode) ddlStmt).tableType;

    for (int index = 0; index < size; index++) {
        TableElementNode tableElement = (TableElementNode) elementAt(index);

        if (tableElement instanceof ColumnDefinitionNode) {
            ColumnDefinitionNode cdn = (ColumnDefinitionNode) elementAt(index);
            if (tableType == TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE
                    && (cdn.getType().getTypeId().isLongConcatableTypeId()
                            || cdn.getType().getTypeId().isUserDefinedTypeId())) {
                throw StandardException.newException(SQLState.LANG_LONG_DATA_TYPE_NOT_ALLOWED,
                        cdn.getColumnName());
            }
            checkForDuplicateColumns(ddlStmt, columnHT, cdn.getColumnName());
            cdn.checkUserType(td);
            cdn.bindAndValidateDefault(dd, td);

            cdn.validateAutoincrement(dd, td, tableType);

            if (tableElement instanceof ModifyColumnNode) {
                ModifyColumnNode mcdn = (ModifyColumnNode) cdn;
                mcdn.checkExistingConstraints(td);
                mcdn.useExistingCollation(td);

            } else if (cdn.isAutoincrementColumn()) {
                numAutoCols++;
            }
        } else if (tableElement.getElementType() == TableElementNode.AT_DROP_COLUMN) {
            String colName = tableElement.getName();
            if (td.getColumnDescriptor(colName) == null) {
                throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOUND_IN_TABLE, colName,
                        td.getQualifiedName());
            }
            break;
        }

        /* The rest of this method deals with validating constraints */
        if (!(tableElement.hasConstraint())) {
            continue;
        }

        ConstraintDefinitionNode cdn = (ConstraintDefinitionNode) tableElement;

        cdn.bind(ddlStmt, dd);

        //if constraint is primary key or unique key, add it to the vector
        if (cdn.getConstraintType() == DataDictionary.PRIMARYKEY_CONSTRAINT
                || cdn.getConstraintType() == DataDictionary.UNIQUE_CONSTRAINT) {
            /* In case of create table, the vector can have only ConstraintDefinitionNode
            * elements. In case of alter table, it can have both ConstraintDefinitionNode
            * (for new constraints) and ConstraintDescriptor(for pre-existing constraints).
            */

            Object destConstraint;
            String destName = null;
            String[] destColumnNames = null;

            for (int i = 0; i < constraintsVector.size(); i++) {

                destConstraint = constraintsVector.elementAt(i);
                if (destConstraint instanceof ConstraintDefinitionNode) {
                    ConstraintDefinitionNode destCDN = (ConstraintDefinitionNode) destConstraint;
                    destName = destCDN.getConstraintMoniker();
                    destColumnNames = destCDN.getColumnList().getColumnNames();
                } else if (destConstraint instanceof ConstraintDescriptor) {
                    //will come here only for pre-existing constraints in case of alter table
                    ConstraintDescriptor destCD = (ConstraintDescriptor) destConstraint;
                    destName = destCD.getConstraintName();
                    destColumnNames = destCD.getColumnDescriptors().getColumnNames();
                }
                //check if there are multiple constraints with same set of columns
                if (columnsMatch(cdn.getColumnList().getColumnNames(), destColumnNames))
                    throw StandardException.newException(SQLState.LANG_MULTIPLE_CONSTRAINTS_WITH_SAME_COLUMNS,
                            cdn.getConstraintMoniker(), destName);
            }
            constraintsVector.addElement(cdn);
        }

        /* Make sure that there are no duplicate constraint names in the list */
        checkForDuplicateConstraintNames(ddlStmt, constraintHT, cdn.getConstraintMoniker());

        /* Make sure that the constraint we are trying to drop exists */
        if (cdn.getConstraintType() == DataDictionary.DROP_CONSTRAINT) {
            /*
            ** If no schema descriptor, then must be an invalid
            ** schema name.
            */

            String dropConstraintName = cdn.getConstraintMoniker();

            if (dropConstraintName != null) {

                String dropSchemaName = cdn.getDropSchemaName();

                SchemaDescriptor sd = dropSchemaName == null ? td.getSchemaDescriptor()
                        : getSchemaDescriptor(dropSchemaName);

                ConstraintDescriptor cd = dd.getConstraintDescriptorByName(td, sd, dropConstraintName, false);
                if (cd == null) {
                    throw StandardException.newException(SQLState.LANG_DROP_NON_EXISTENT_CONSTRAINT,
                            (sd.getSchemaName() + "." + dropConstraintName), td.getQualifiedName());
                }
                /* Statement is dependendent on the ConstraintDescriptor */
                getCompilerContext().createDependency(cd);
            }
        }

        // validation of primary key nullability moved to validatePrimaryKeyNullability().
        if (cdn.hasPrimaryKeyConstraint()) {
            // for PRIMARY KEY, check that columns are unique
            verifyUniqueColumnList(ddlStmt, cdn);
        } else if (cdn.hasUniqueKeyConstraint()) {
            // for UNIQUE, check that columns are unique
            verifyUniqueColumnList(ddlStmt, cdn);
        } else if (cdn.hasForeignKeyConstraint()) {
            // for FOREIGN KEY, check that columns are unique
            verifyUniqueColumnList(ddlStmt, cdn);
        }
    }

    /* Can have only one autoincrement column in DB2 mode */
    if (numAutoCols > 1)
        throw StandardException.newException(SQLState.LANG_MULTIPLE_AUTOINCREMENT_COLUMNS);

}

From source file:com.github.maven_nar.cpptasks.CCTask.java

protected TargetInfo getLinkTarget(final LinkerConfiguration linkerConfig, final Vector<File> objectFiles,
        final Vector<File> sysObjectFiles, final Map<String, TargetInfo> compileTargets,
        final VersionInfo versionInfo) {
    ///*from  w ww. ja v  a  2  s . c  o m*/
    // walk the compile phase targets and
    // add those sources that have already been
    // assigned to the linker or
    // our output files the linker knows how to consume
    // files the linker knows how to consume
    //
    for (final TargetInfo compileTarget : compileTargets.values()) {
        //
        // output of compile tasks
        //
        final int bid = linkerConfig.bid(compileTarget.getOutput().toString());
        if (bid > 0) {
            objectFiles.addElement(compileTarget.getOutput());
        }
    }
    final File[] objectFileArray = new File[objectFiles.size()];
    objectFiles.copyInto(objectFileArray);
    final File[] sysObjectFileArray = new File[sysObjectFiles.size()];
    sysObjectFiles.copyInto(sysObjectFileArray);
    final String baseName = this._outfile.getName();
    final String[] fullNames = linkerConfig.getOutputFileNames(baseName, versionInfo);
    final File outputFile = new File(this._outfile.getParent(), fullNames[0]);
    return new TargetInfo(linkerConfig, objectFileArray, sysObjectFileArray, outputFile,
            linkerConfig.getRebuild());
}

From source file:com.vsquaresystem.safedeals.rawmarketprice.RawMarketPriceService.java

public Vector read() throws IOException {

    File excelFile = attachmentUtils
            .getDirectoryByAttachmentType(AttachmentUtils.AttachmentType.RAW_MARKET_PRICE);
    File[] listofFiles = excelFile.listFiles();
    String fileName = excelFile + "/" + listofFiles[0].getName();

    Vector cellVectorHolder = new Vector();
    int type;//from www  . ja  v a  2 s . c o  m
    try {
        FileInputStream myInput = new FileInputStream(fileName);

        XSSFWorkbook myWorkBook = new XSSFWorkbook(myInput);
        XSSFSheet mySheet = myWorkBook.getSheetAt(0);
        Iterator rowIter = mySheet.rowIterator();
        while (rowIter.hasNext()) {
            XSSFRow myRow = (XSSFRow) rowIter.next();
            Iterator cellIter = myRow.cellIterator();

            List list = new ArrayList();
            while (cellIter.hasNext()) {
                XSSFCell myCell = (XSSFCell) cellIter.next();
                if (myCell != null) {
                    switch (myCell.getCellType()) {
                    case Cell.CELL_TYPE_BOOLEAN:
                        System.out.println(new DataFormatter().formatCellValue(myCell));
                        list.add(new DataFormatter().formatCellValue(myCell));
                        break;
                    case Cell.CELL_TYPE_NUMERIC:
                        System.out.println(new DataFormatter().formatCellValue(myCell));
                        list.add(new DataFormatter().formatCellValue(myCell));
                        break;
                    case Cell.CELL_TYPE_STRING:
                        System.out.println(new DataFormatter().formatCellValue(myCell));
                        list.add(new DataFormatter().formatCellValue(myCell));
                        break;
                    case Cell.CELL_TYPE_BLANK:
                        break;
                    case Cell.CELL_TYPE_ERROR:
                        System.out.println(new DataFormatter().formatCellValue(myCell));
                        list.add(new DataFormatter().formatCellValue(myCell));
                        break;

                    case Cell.CELL_TYPE_FORMULA:
                        break;
                    }
                }

            }

            cellVectorHolder.addElement(list);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return cellVectorHolder;

}

From source file:com.duroty.application.mail.manager.PreferencesManager.java

/**
 * DOCUMENT ME!/*from   www  .  ja  v a 2s . com*/
 *
 * @param hsession DOCUMENT ME!
 * @param username DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws MailException DOCUMENT ME!
 */
public Vector getIdentities(Session hsession, String username) throws MailException {
    Vector identities = new Vector();

    try {
        Criteria crit = hsession.createCriteria(Identity.class);
        crit.add(Restrictions.eq("users", getUser(hsession, username)));
        crit.add(Restrictions.eq("ideActive", new Boolean(true)));
        crit.addOrder(Order.asc("ideEmail"));

        ScrollableResults scroll = crit.scroll();

        while (scroll.next()) {
            Identity identity = (Identity) scroll.get(0);
            IdentityObj obj = new IdentityObj();
            obj.setIdint(identity.getIdeIdint());
            obj.setEmail(identity.getIdeEmail());
            obj.setImportant(identity.isIdeDefault());
            obj.setName(identity.getIdeName());
            obj.setReplyTo(identity.getIdeReplyTo());

            identities.addElement(obj);
        }

        return identities;
    } catch (Exception ex) {
        return null;
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}

From source file:net.anidb.udp.UdpFileFactory.java

/**
 * <p>Returns the files with the given anime Id, group Id and episode
 * number.</p>/*from w w  w . ja v a2 s .c om*/
 * <p>Only the fields specified by the two masks will be filled.</p>
 * @param animeId The anime Id.
 * @param groupId The group Id.
 * @param episodeNumber The episode number.
 * @param fileMask The file mask.
 * @param animeFileMask The anime file mask.
 * @return The files.
 * @throws IllegalArgumentException If the file mask is <code>null</code>.
 * @throws IllegalArgumentException If the anime file mask is
 * <code>null</code>.
 * @throws UdpConnectionException If a connection problem occured.
 * @throws AniDbException If a problem with AniDB occured.
 * @see UdpReturnCodes#NO_SUCH_FILE
 */
public List<File> getFiles(final long animeId, final long groupId, final long episodeNumber,
        final FileMask fileMask, final AnimeFileMask animeFileMask)
        throws UdpConnectionException, AniDbException {

    UdpRequest request;
    UdpResponse response;
    Vector<File> files;

    if (fileMask == null) {
        throw new IllegalArgumentException("Argument fileMask is null.");
    }
    if (animeFileMask == null) {
        throw new IllegalArgumentException("Argument animeFileMask is null.");
    }
    if (!this.conn.isOpen()) {
        throw new UdpConnectionException("Connection is already closed.");
    }
    if (!this.conn.isLoggedIn()) {
        throw new UdpConnectionException("Client is not logged in.");
    }
    request = new UdpRequest("FILE");
    request.addParameter("aid", animeId);
    request.addParameter("gid", groupId);
    request.addParameter("epno", episodeNumber);
    request.addParameter("fmask", fileMask.getHexMask());
    request.addParameter("amask", animeFileMask.getHexMask());
    response = this.conn.communicate(request);
    if ((response.getReturnCode() != UdpReturnCodes.FILE)
            && (response.getReturnCode() != UdpReturnCodes.MULTIPLE_FILES_FOUND)) {
        throw new AniDbException(response.getReturnCode(), response.getReturnString(),
                response.getMessageString());
    }
    if (response.getEntryCount() < 1) {
        throw new UdpConnectionException("Received invalid response to the command FILE: "
                + "The response has less than 1 entry: " + response.toString());
    } else if (response.getEntryCount() > 1) {
        LOG.warn("Response to the command FILE has more than 1 " + "entry: " + response.toString());
    }
    if (response.getReturnCode() == UdpReturnCodes.FILE) {
        files = new Vector<File>();
        files.addElement(this.getFile(response, fileMask, animeFileMask));
        return files;
    }
    return this.getFiles(response, fileMask, animeFileMask);
}

From source file:org.apache.catalina.loader.WebappClassLoader.java

/**
 * Return an enumeration of <code>URLs</code> representing all of the
 * resources with the given name.  If no resources with this name are
 * found, return an empty enumeration./* ww  w.  jav  a  2  s  .  co m*/
 *
 * @param name Name of the resources to be found
 *
 * @exception IOException if an input/output error occurs
 */
public Enumeration findResources(String name) throws IOException {

    if (log.isDebugEnabled())
        log.debug("    findResources(" + name + ")");

    Vector result = new Vector();

    int jarFilesLength = jarFiles.length;
    int repositoriesLength = repositories.length;

    int i;

    // Looking at the repositories
    for (i = 0; i < repositoriesLength; i++) {
        try {
            String fullPath = repositories[i] + name;
            resources.lookup(fullPath);
            // Note : Not getting an exception here means the resource was
            // found
            try {
                result.addElement(getURI(new File(files[i], name)));
            } catch (MalformedURLException e) {
                // Ignore
            }
        } catch (NamingException e) {
        }
    }

    // Looking at the JAR files
    synchronized (jarFiles) {
        openJARs();
        for (i = 0; i < jarFilesLength; i++) {
            JarEntry jarEntry = jarFiles[i].getJarEntry(name);
            if (jarEntry != null) {
                try {
                    String jarFakeUrl = getURI(jarRealFiles[i]).toString();
                    jarFakeUrl = "jar:" + jarFakeUrl + "!/" + name;
                    result.addElement(new URL(jarFakeUrl));
                } catch (MalformedURLException e) {
                    // Ignore
                }
            }
        }
    }

    // Adding the results of a call to the superclass
    if (hasExternalRepositories) {

        Enumeration otherResourcePaths = super.findResources(name);

        while (otherResourcePaths.hasMoreElements()) {
            result.addElement(otherResourcePaths.nextElement());
        }

    }

    return result.elements();

}

From source file:com.netscape.cmsutil.crypto.CryptoUtil.java

/**
 * Retrieves all user certificates from all tokens.
 *///from   ww w. j  a  v a  2  s .  com
public static X509CertImpl[] getAllUserCerts() throws NotInitializedException, TokenException {
    Vector<X509CertImpl> certs = new Vector<X509CertImpl>();
    CryptoManager cm = CryptoManager.getInstance();
    @SuppressWarnings("unchecked")
    Enumeration<CryptoToken> enums = cm.getAllTokens();

    while (enums.hasMoreElements()) {
        CryptoToken token = enums.nextElement();

        CryptoStore store = token.getCryptoStore();
        org.mozilla.jss.crypto.X509Certificate list[] = store.getCertificates();

        for (int i = 0; i < list.length; i++) {
            try {
                @SuppressWarnings("unused")
                PrivateKey key = cm.findPrivKeyByCert(list[i]); // check for errors
                X509CertImpl impl = null;

                try {
                    impl = new X509CertImpl(list[i].getEncoded());
                } catch (CertificateException e) {
                    continue;
                }
                certs.addElement(impl);
            } catch (TokenException e) {
                continue;
            } catch (ObjectNotFoundException e) {
                continue;
            }
        }
    }
    if (certs.size() == 0) {
        return null;
    } else {
        X509CertImpl c[] = new X509CertImpl[certs.size()];

        certs.copyInto(c);
        return c;
    }
}

From source file:com.duroty.application.mail.manager.MailManager.java

/**
 * DOCUMENT ME!/*from w w w . j  a va  2s .co  m*/
 *
 * @param hsession DOCUMENT ME!
 * @param repositoryName DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws MailException DOCUMENT ME!
 */
public Vector getLabels(Session hsession, String repositoryName) throws MailException {
    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 MailException(e);
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}