Example usage for java.util Vector size

List of usage examples for java.util Vector size

Introduction

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

Prototype

public synchronized int size() 

Source Link

Document

Returns the number of components in this vector.

Usage

From source file:de.nmichael.efa.Daten.java

public static void printEfaInfos(boolean efaInfos, boolean pluginInfos, boolean javaInfos, boolean hostInfos,
        boolean jarInfos) {
    Vector infos = getEfaInfos(efaInfos, pluginInfos, javaInfos, hostInfos, jarInfos);
    for (int i = 0; infos != null && i < infos.size(); i++) {
        Logger.log(Logger.INFO, Logger.MSG_INFO_CONFIGURATION, (String) infos.get(i));
    }//from  www .  j  a  v a2  s  .co m
}

From source file:charts.Chart.java

public static int FindPathwayPosition(Vector pathways, String pathway) {
    if (!pathways.contains(pathway)) {
        return (-1);//nao contem
    }/*from ww w.  j a v  a2  s  .  c  o m*/
    for (int p = 0; p < pathways.size(); p++) {
        if (((String) pathways.get(p)).equalsIgnoreCase(pathway)) {
            return (p);
        }
    }
    return (-1);
}

From source file:eionet.gdem.utils.InputFile.java

/**
 * Get Host credentials from database. There could be restriction for accessing files in different servers. Username and
 * password are saved in the T_HOST table for these cases.
 *
 * @param host URL.//from w  ww. j  ava2s . c  om
 */
private void getHostCredentials(String host) {
    try {

        Vector v = hostDao.getHosts(host);

        if (v == null) {
            return;
        }
        if (v.size() > 0) {
            Hashtable h = (Hashtable) v.get(0);
            String user = (String) h.get("user_name");
            String pwd = (String) h.get("pwd");
            this.ticket = Utils.getEncodedAuthentication(user, pwd);

        }

    } catch (Exception e) {
        LOGGER.error("Error getting host data from the DB " + e.toString());
        LOGGER.error("Conversion proceeded");
    }
}

From source file:it.eng.spagobi.tools.downloadFiles.service.DownloadZipAction.java

public void service(SourceBean request, SourceBean response) throws Exception {
    logger.debug("IN");
    freezeHttpResponse();//from   w w w. j  a  v  a 2 s  .co m

    HttpServletRequest httpRequest = getHttpRequest();
    HttpServletResponse httpResponse = getHttpResponse();

    // get Attribute DATE, MINUTE, DIRECTORY
    String directory = (String) request.getAttribute(DIRECTORY);

    String beginDate = (String) request.getAttribute(BEGIN_DATE);
    String beginTime = (String) request.getAttribute(BEGIN_TIME);
    String endDate = (String) request.getAttribute(END_DATE);
    String endTime = (String) request.getAttribute(END_TIME);
    String prefix1 = (request.getAttribute(PREFIX1) != null) ? (String) request.getAttribute(PREFIX1) + "_"
            : "";
    String prefix2 = (request.getAttribute(PREFIX2) != null) ? (String) request.getAttribute(PREFIX2) + "_"
            : "";
    //String prefix1 = (request.getAttribute(PREFIX1) != null)?(String) request.getAttribute(PREFIX1): "";
    //String prefix2 = (request.getAttribute(PREFIX2) != null)?(String) request.getAttribute(PREFIX2): "";

    // build begin Date         

    if (directory == null) {
        logger.error("search directory not specified");
        throw new SpagoBIServiceException(SERVICE_NAME, "Missing directory parameter");
    }

    if (beginDate == null || beginTime == null) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Missing begin date parameter");
    }

    if (endDate == null || endTime == null) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Missing end date parameter");
    }

    try {

        // remove / from days name
        beginDate = beginDate.replaceAll("/", "");
        endDate = endDate.replaceAll("/", "");
        beginTime = beginTime.replaceAll(":", "");
        endTime = endTime.replaceAll(":", "");

        String beginWhole = beginDate + " " + beginTime;
        String endWhole = endDate + " " + endTime;

        java.text.DateFormat myTimeFormat = new java.text.SimpleDateFormat(PARAMETERS_FORMAT);

        Date begin = myTimeFormat.parse(beginWhole);
        Date end = myTimeFormat.parse(endWhole);

        logger.debug("earch file from begin date " + begin.toString() + " to end date " + end.toString());

        directory = directory.replaceAll("\\\\", "/");

        File dir = new File(directory);
        if (!dir.isDirectory()) {
            logger.error("Not a valid directory specified");
            return;
        }

        // get all files that has to be zipped
        Vector filesToZip = searchDateFiles(dir, begin, end, prefix1 + prefix2);
        if (filesToZip.size() == 0) {
            /*throw new Exception ("Warning: Files not found with these parameters: <p><br>" +
                    " <b>Directory:</b> " + dir + "<p>" +
                    " <b>Begin date:</b> " + begin + "<p>" + 
                    " <b>End date:</b> " + end + "<p>" + 
                    " <b>Prefix:</b> " + prefix1 + prefix2 ); */
            throw new Exception("Warning: Missing files in specified interval!");
        }

        Date today = (new Date());
        DateFormat formatter = new SimpleDateFormat("dd-MMM-yy hh:mm:ss");
        //date = (Date)formatter.parse("11-June-07");    
        String randomName = formatter.format(today);
        randomName = randomName.replaceAll(" ", "_");
        randomName = randomName.replaceAll(":", "-");

        String directoryZip = System.getProperty("java.io.tmpdir");
        if (!directoryZip.endsWith(System.getProperty("file.separator"))) {
            directoryZip += System.getProperty("file.separator");
        }
        String fileZip = randomName + ".zip";
        String pathZip = directoryZip + fileZip;
        pathZip = pathZip.replaceAll("\\\\", "/");
        directoryZip = directoryZip.replaceAll("\\\\", "/");

        //         String directoryZip="C:/logs";
        //         String fileZip="prova.zip";
        //         String pathZip=directoryZip+"/"+fileZip;

        createZipFromFiles(filesToZip, pathZip, directory);

        //Vector<File> filesToZip = searchDateFiles(dir, beginDate, endDate)

        manageDownloadZipFile(httpRequest, httpResponse, directoryZip, fileZip);

        //manageDownloadExportFile(httpRequest, httpResponse);
    } catch (Throwable t) {
        logger.error("Error in writing the zip ", t);
        throw new SpagoBIServiceException(SERVICE_NAME, t.getMessage(), t);
        /* this manage defines a file with the error message and returns it.
        try{                     
           File file = new File("exception.txt");
           String text = t.getMessage() + " \n" + (( t.getStackTrace()!=null)?t.getStackTrace():"");
           FileUtils.writeStringToFile(file, text, "UTF-8");
           writeBackToClient(file, null, false, "exception.txt", "text/plain");                        
        }catch(Throwable t2){
           logger.error("Error in defining error file ",t2);
           throw new SpagoBIServiceException(SERVICE_NAME, "Server Error in writing the zip", t2);
        }
         */
    } finally {
        logger.debug("OUT");
    }
}

From source file:com.dimdim.conference.application.portal.PortalServerAdapter.java

public boolean timerCall() {
    Vector v = null;
    synchronized (this) {
        if (this.urlQueue != null && this.urlQueue.size() > 0) {
            v = this.urlQueue;
            this.urlQueue = new Vector();
        }//from w w  w . j a va 2s. com
    }
    if (v != null) {
        int num = v.size();
        for (int i = 0; i < num; i++) {
            String url = (String) v.elementAt(i);
            this.getURL_String(this.httpClient, url);
        }
    }
    return true;
}

From source file:com.symbian.driver.core.controller.tasks.BuildTask.java

/**
 * Builds the Symbian code./*from   w w w.j av  a2s. c om*/
 * 
 * @param aGroupDir
 *            The group directory containing the bld.inf file.
 * @param aBuildType
 *            If <code>true</code> then will run "abld test build", else
 *            if <code>false</code> then it will run "abld build".
 * @param aComponent
 *            The mmp target.
 * @return The vector of files to tranfer.
 * @throws IOException
 *             If reading the output of the build commands failed.
 * @throws InterruptedException
 *             If the build commands thread was interupted
 * @throws ParseException
 * @throws TimeLimitExceededException
 */
private Vector<File> doBuild(final File aGroupDir, final boolean aBuildType, final String aComponent)
        throws IOException, ParseException, TimeLimitExceededException {
    int sbsVersion = this.getSBSVersion();
    String lTest = (aBuildType ? com.symbian.driver.core.environment.ILiterals.TEST : "");
    String lBuildCommand = "";
    if (sbsVersion == 1) {
        lBuildCommand = com.symbian.driver.core.environment.ILiterals.ABLD_BAT + lTest
                + com.symbian.driver.core.environment.ILiterals.BUILD + iConfig.getPreference(TDConfig.PLATFORM)
                + " " + iConfig.getPreference(TDConfig.VARIANT) + (aComponent != null ? " " + aComponent : "");
        // excute the build command. 
        ExecuteOnHost lAbld = new ExecuteOnHost(aGroupDir, lBuildCommand);
        if (!PCVisitor.isRBuild()) {
            lAbld.doTask(true, TimeOut.NO_TIMEOUT, true);
            iOuputBuffer.append(lAbld.getOutput());
        } else if (!new File(aGroupDir, com.symbian.driver.core.environment.ILiterals.ABLD_BAT).isFile()) {
            doBeforeBuild(aGroupDir, aBuildType, sbsVersion);
            ExecuteOnHost lExport = new ExecuteOnHost(aGroupDir,
                    com.symbian.driver.core.environment.ILiterals.ABLD_BAT + lTest
                            + com.symbian.driver.core.environment.ILiterals.EXPORT);
            ExecuteOnHost lMakeFile = new ExecuteOnHost(aGroupDir,
                    com.symbian.driver.core.environment.ILiterals.ABLD_BAT + lTest
                            + com.symbian.driver.core.environment.ILiterals.MAKEFILE);
            lExport.doTask(true, TimeOut.NO_TIMEOUT, true);
            lMakeFile.doTask(true, TimeOut.NO_TIMEOUT, true);
            iOuputBuffer.append(lExport.getOutput() + lMakeFile.getOutput());
        }
        Vector<File> lTransferFileVector = findTargets(aGroupDir, lBuildCommand);
        if (PCVisitor.isRBuild() && lTransferFileVector.size() == 0) {
            LOGGER.fine("Could not find any targets. Attempting to rebuild.");
            lAbld.doTask(true, TimeOut.NO_TIMEOUT, true);
            iOuputBuffer.append(lAbld.getOutput());
            lTransferFileVector = findTargets(aGroupDir, lBuildCommand);

        }
        return lTransferFileVector;
    } else {
        // sbs v2
        lBuildCommand = com.symbian.driver.core.environment.ILiterals.SBS_BAT + "-c "
                + iConfig.getPreference(TDConfig.PLATFORM) + "_" + iConfig.getPreference(TDConfig.VARIANT) + "."
                + lTest + (aComponent != null ? " " + "-p " + aComponent + ".mmp" : "");
        // execute the build command. 
        ExecuteOnHost lSbs = new ExecuteOnHost(aGroupDir, lBuildCommand);
        lSbs.doTask(true, TimeOut.NO_TIMEOUT, true);
        iOuputBuffer.append(lSbs.getOutput());
        Vector<File> lTransferFileVector = findTargets(aGroupDir, lBuildCommand);
        return lTransferFileVector;
    }
}

From source file:ca.uqac.info.trace.generation.PQTraceGenerator.java

@Override
public EventTrace generate() {
    EventTrace trace = new EventTrace();
    // We choose the number of messages to produce
    int n_messages = super.nextInt(m_maxMessages - m_minMessages) + m_minMessages;
    for (int i = 0; i < n_messages; i++) {
        Node n = trace.getNode();
        Vector<String> available_params = new Vector<String>();
        // We produce the list of available parameters for this message
        available_params.add("p");
        available_params.add("q");
        // We choose the number of param-value pairs to generate
        int arity = super.nextInt(m_maxArity - m_minArity) + m_minArity;
        for (int j = 0; j < arity; j++) {
            // We generate as many param-value pairs as required
            int index = super.nextInt(available_params.size());
            int value = super.nextInt(m_domainSize);
            if (m_minArity == 1 && m_maxArity == 1 && m_flatten) {
                // For traces of messages with fixed arity = 1, we
                // simply put the value as the text child of the "Event"
                // element
                n.appendChild(trace.createTextNode(new Integer(value).toString()));
            } else {
                Node el = trace.createElement(available_params.elementAt(index));
                el.appendChild(trace.createTextNode(new Integer(value).toString()));
                n.appendChild(el);/*from   www . ja va  2s  .  c  om*/
            }
        }
        Event e = new Event(n);
        trace.add(e);
    }
    return trace;
}

From source file:multiplayer.pong.client.LobbyFrame.java

private void pendingRequests() {
    Vector<String> req = daoReq.pendingRequests(SocketHandler.username);
    int count = req.size();
    if (count == 0)
        return;//from  w w w  .  ja v a 2 s. c  om
    displayWarning("Vous avez " + count + " demande" + (count != 1 ? "s" : "") + " d'ajout de: "
            + String.join(", ", req) + "\n");
    displayWarning("Utilisez la commande '/accepterAmi [nom]' pour accepter une demande.\n");
}

From source file:com.globalsight.connector.mindtouch.MindTouchCreateJobHandler.java

@ActionHandler(action = "connect", formClass = "")
public void prepareConnect(HttpServletRequest p_request, HttpServletResponse p_response, Object form)
        throws Exception {
    String mtcId = p_request.getParameter("mtcId");
    MindTouchConnector mtc = MindTouchManager.getMindTouchConnectorById(Long.parseLong(mtcId));
    p_request.setAttribute("mindtouchConnector", mtc);

    List<GlobalSightLocale> trgServerLocaleList = new ArrayList<GlobalSightLocale>();
    HashSet<String> trgServerLocales = new HashSet<String>();
    List<MindTouchConnectorTargetServer> targetServers = MindTouchManager
            .getAllTargetServers(Long.parseLong(mtcId));
    for (MindTouchConnectorTargetServer trgServer : targetServers) {
        trgServerLocales.add(trgServer.getTargetLocale().toLowerCase());
    }//from  ww w  .ja  va 2 s.  co m
    Vector allLocales = new Vector();
    try {
        allLocales = ServerProxy.getLocaleManager().getAvailableLocales();
        for (int i = 0; i < allLocales.size(); i++) {
            GlobalSightLocale gsl = (GlobalSightLocale) allLocales.get(i);
            if (trgServerLocales.contains(gsl.toString().toLowerCase())) {
                trgServerLocaleList.add(gsl);
            }
        }
    } catch (Exception e) {
        logger.error(e);
    }
    p_request.setAttribute("allAvailableLocales", allLocales);
    p_request.setAttribute("targetServerLocales", trgServerLocaleList);
}

From source file:captureplugin.drivers.defaultdriver.AdditionalParams.java

private void fillModel(DeviceConfig config) {
    Vector<Object> vec = new Vector<Object>(config.getParamList());
    mListModel = new DefaultListModel();

    for (Object aVec : vec) {
        mListModel.addElement(aVec);/* w w  w  .j a  va2 s. c  om*/
    }

    if (vec.size() == 0) {
        mListModel.addElement(new ParamEntry());
    }

}