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:org.apache.slide.store.ExtendedStore.java

protected Vector fillLocksCache(Uri uri) throws ServiceAccessException {
    Vector locksVector = (Vector) locksCache.get(uri.toString());
    if (locksVector != null) {
        return locksVector;
    } else {/*from  ww  w  .j a v a 2 s  .co  m*/
        locksVector = new Vector();
        Enumeration lockList = super.enumerateLocks(uri);
        while (lockList.hasMoreElements()) {
            NodeLock tempLock = (NodeLock) lockList.nextElement();
            tempLock.validate(uri.toString());
            locksVector.addElement(tempLock);
        }
        locksCache.put(uri.toString(), locksVector);
        return locksVector;
    }
}

From source file:com.netscape.cms.logging.LogFile.java

public Vector<String> getDefaultParams() {
    Vector<String> v = new Vector<String>();

    v.addElement(PROP_TYPE + "=");
    v.addElement(PROP_ON + "=");
    v.addElement(PROP_LEVEL + "=");
    v.addElement(PROP_FILE_NAME + "=");
    v.addElement(PROP_BUFFER_SIZE + "=");
    v.addElement(PROP_FLUSH_INTERVAL + "=");

    // needs to find a way to determine what type you want. if this
    // is not for the signed audit type, then we should not show the
    // following parameters.
    //if( mType.equals( ILogger.PROP_SIGNED_AUDIT ) ) {
    v.addElement(PROP_SIGNED_AUDIT_LOG_SIGNING + "=");
    v.addElement(PROP_SIGNED_AUDIT_CERT_NICKNAME + "=");
    v.addElement(PROP_SIGNED_AUDIT_MANDATORY_EVENTS + "=");
    v.addElement(PROP_SIGNED_AUDIT_SELECTED_EVENTS + "=");
    v.addElement(PROP_SIGNED_AUDIT_UNSELECTED_EVENTS + "=");
    //}//from   w  w  w.j  av  a2s .c  om

    return v;
}

From source file:mypackage.State_Stream.java

private void getMoreEntries() {
    // ANeBreBCWP?[^?[\
    _screen.showActivityIndicator();/*from   ww w .  j a v  a2s.  com*/

    // Gg?[??^?[
    if (!isAvailableMoreEntries()) {
        // ANeBreBCWP?[^?[??
        _screen.deleteActivityIndicator();

        // s_CA?O\
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                Dialog.alert("No more entries found.");
            }
        });
        return;
    }

    // L?MoH??^?[
    if (!Network.isCoverageSufficient()) {
        // ANeBreBCWP?[^?[??
        _screen.deleteActivityIndicator();

        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                Dialog.alert(
                        "A communication error has occurred. Please make sure your device is connected to Internet.");
            }
        });
        return;
    } //if()

    // Gg?[
    try {
        // Gg?[?
        int start_index = entries.size();

        // Gg?[
        JSONObject stream_jsonO = getStream(continuation);

        // Xg?[continuation
        continuation = getContinuationId(stream_jsonO);

        // Xg?[ACe
        JSONArray extent_stream = stream_jsonO.getJSONArray("items");

        // Gg?[?B
        Vector extent_entries = new Vector();
        for (int i = 0; i < extent_stream.length(); i++) {
            Entry _entry = new Entry(extent_stream.getJSONObject(i), _feedlyapi);
            extent_entries.addElement(_entry);
            entries.addElement(_entry);
        }

        // ?VGg?[e?[u?B
        addRowToRichList(extent_entries, start_index);

    } catch (final Exception e) {

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

        // s_CA?O\
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {

                Dialog.alert("An unexpected error occurred while getting more entries.");
            }
        });
    } finally {
        // ANeBreBCWP?[^?[??
        _screen.deleteActivityIndicator();
    }
}

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

protected Vector fillPermissionsCache(Uri uri) throws ServiceAccessException {
    Vector permissions = (Vector) permissionsCache.get(uri.toString());
    if (permissions != null) {
        return permissions;
    } else {/* ww w  .  j  a va  2 s  .  c  o m*/
        permissions = new Vector();
        Enumeration permissionsList = super.enumeratePermissions(uri);
        while (permissionsList.hasMoreElements()) {
            NodePermission tempPermission = (NodePermission) permissionsList.nextElement();
            tempPermission.validate(uri.toString());
            permissions.addElement(tempPermission);
        }
        permissionsCache.put(uri.toString(), permissions);
        return permissions;
    }
}

From source file:cm.aptoide.pt.ManageRepos.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {

    EnumOptionsMenu option = EnumOptionsMenu.reverseOrdinal(item.getItemId());

    CharSequence[] reposArray = new CharSequence[repos.getList().size() - reposInserting.size()];
    int j = 0;//from ww  w.  j  ava2 s.  co m
    for (int i = 0; i < repos.getList().size(); i++) {
        if (!reposInserting.containsKey(repos.getList().get(i).get(Constants.KEY_REPO_HASHID))) {
            reposArray[j] = (String) repos.getList().get(i).get(Constants.KEY_REPO_URI);
            j++;
        }
    }

    switch (option) {
    case ADD_REPO:
        validateRepo(null, false);
        break;

    case REMOVE_REPO:
        if (reposArray.length == 0) {
            return true;
        }
        final Vector<Integer> remList = new Vector<Integer>();

        AlertDialog.Builder builder = new AlertDialog.Builder(theme);
        builder.setTitle(getString(R.string.remove_repo_choose));
        builder.setIcon(R.drawable.ic_menu_close_clear_cancel);
        builder.setMultiChoiceItems(reposArray, null, new DialogInterface.OnMultiChoiceClickListener() {
            public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) {
                if (isChecked) {
                    remList.addElement(
                            (Integer) (repos.getList().get(whichButton).get(Constants.KEY_REPO_HASHID)));
                } else {
                    remList.removeElement(
                            (Integer) (repos.getList().get(whichButton).get(Constants.KEY_REPO_HASHID)));
                }
            }
        });
        builder.setPositiveButton(getString(R.string.remove), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                for (Integer repoHashid : remList) {
                    removeDisplayRepo(repoHashid);
                }
                alert.dismiss();
                refreshReposList();
            }
        });
        builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                alert.dismiss();
                return;
            }
        });
        alert = builder.create();
        alert.show();
        break;

    case EDIT_REPO:
        if (reposArray.length == 0) {
            return true;
        }
        AlertDialog.Builder builder2 = new AlertDialog.Builder(theme);
        builder2.setTitle(getString(R.string.edit_repo_choose));
        builder2.setIcon(R.drawable.ic_menu_edit);
        builder2.setSingleChoiceItems(reposArray, -1, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                updt_repo = (String) (repos.getList().get(whichButton).get(Constants.KEY_REPO_URI));
            }
        });
        builder2.setPositiveButton(getString(R.string.edit), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                alert2.dismiss();
                validateRepo(updt_repo, true);
                return;
            }
        });
        builder2.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                alert2.dismiss();
                return;
            }
        });
        alert2 = builder2.create();
        alert2.show();
        break;
    }
    return super.onMenuItemSelected(featureId, item);
}

From source file:com.sittinglittleduck.DirBuster.Manager.java

public synchronized void foundDir(URL url, int statusCode, String Responce, String BaseCase, String RawResponce,
        BaseCase baseCaseObj) {//  ww  w  .j ava2s.  com
    try {

        boolean isStartPoint;

        if (Config.caseInsensativeMode) {
            isStartPoint = url.getPath().equalsIgnoreCase(startPoint);

            /*
             * loop through all the items in the queue
             */

            /*
             * convert to array
             */
            boolean foundDir = false;
            DirToCheck[] dirArray = (DirToCheck[]) dirQueue.toArray();

            for (int a = 0; a < dirArray.length; a++) {
                /*
                 * perform case in seneative check
                 */
                if (url.getPath().equalsIgnoreCase(dirArray[a].getName())) {
                    foundDir = true;
                    break;
                }
            }

            /*
             * if the dir is not already there.
             */
            if (!foundDir) {

                // hack to prevent getting an instance of the main extToUse and its contents!

                Vector tempExtToUse = new Vector(10, 10);
                // tempExtToUse = extToUse.clone();

                for (int a = 0; a < extToUse.size(); a++) {
                    ExtToCheck oldExtToCheck = (ExtToCheck) extToUse.elementAt(a);
                    ExtToCheck tempExtToCheck = new ExtToCheck(oldExtToCheck.getName(),
                            oldExtToCheck.toCheck());
                    tempExtToUse.addElement(tempExtToCheck);
                }

                boolean addToDirQueue = true;

                if (onlyUnderStartPoint) {
                    addToDirQueue = url.getPath().toLowerCase(Locale.ENGLISH)
                            .startsWith(startPoint.toLowerCase(Locale.ENGLISH));
                }

                if (addToDirQueue) {
                    dirQueue.put(new DirToCheck(url.getPath(), tempExtToUse));
                }
                totalDirsFound++;
            }

        }
        /*
         * normal case sensative search
         */
        else {
            isStartPoint = url.getPath().equals(startPoint);
            // check it is not already in the queue
            if (!dirQueue.contains(new DirToCheck(url.getPath(), extToUse)) && !isStartPoint && isRecursive()) {
                // Vector tempext = (Vector) extToUse.clone();

                // hack to prevent getting an instance of the main extToUse and its contents!

                Vector tempExtToUse = new Vector(10, 10);
                // tempExtToUse = extToUse.clone();

                for (int a = 0; a < extToUse.size(); a++) {
                    ExtToCheck oldExtToCheck = (ExtToCheck) extToUse.elementAt(a);
                    ExtToCheck tempExtToCheck = new ExtToCheck(oldExtToCheck.getName(),
                            oldExtToCheck.toCheck());
                    tempExtToUse.addElement(tempExtToCheck);
                }

                boolean addToDirQueue = true;

                if (onlyUnderStartPoint) {
                    addToDirQueue = url.getPath().startsWith(startPoint);
                }

                if (addToDirQueue) {
                    dirQueue.put(new DirToCheck(url.getPath(), tempExtToUse));
                }
                totalDirsFound++;
            }
        }

        System.out.println("Dir found: " + url.getFile() + " - " + statusCode);
        // add to list of items that have already processed
        addParsedLink(url.getPath());

        headlessResult.addElement(new HeadlessResult(url.getFile(), statusCode, HeadlessResult.DIR));
    } catch (InterruptedException e) {
        // e.printStackTrace();
        return;
    }
}

From source file:com.netscape.cms.logging.LogFile.java

public Vector<String> getInstanceParams() {
    Vector<String> v = new Vector<String>();

    try {//from   w  w  w  . j a va  2 s  .  co  m

        if (mType == null) {
            v.addElement(PROP_TYPE + "=");
        } else {
            v.addElement(PROP_TYPE + "=" + mConfig.getString(PROP_TYPE));
        }
        v.addElement(PROP_ON + "=" + String.valueOf(mOn));
        if (mLevel == 0)
            v.addElement(PROP_LEVEL + "=" + ILogger.LL_DEBUG_STRING);
        else if (mLevel == 1)
            v.addElement(PROP_LEVEL + "=" + ILogger.LL_INFO_STRING);
        else if (mLevel == 2)
            v.addElement(PROP_LEVEL + "=" + ILogger.LL_WARN_STRING);
        else if (mLevel == 3)
            v.addElement(PROP_LEVEL + "=" + ILogger.LL_FAILURE_STRING);
        else if (mLevel == 4)
            v.addElement(PROP_LEVEL + "=" + ILogger.LL_MISCONF_STRING);
        else if (mLevel == 5)
            v.addElement(PROP_LEVEL + "=" + ILogger.LL_CATASTRPHE_STRING);
        else if (mLevel == 6)
            v.addElement(PROP_LEVEL + "=" + ILogger.LL_SECURITY_STRING);

        if (mFileName == null) {
            v.addElement(PROP_FILE_NAME + "=");
        } else {
            v.addElement(PROP_FILE_NAME + "=" + mFileName);
        }
        v.addElement(PROP_BUFFER_SIZE + "=" + mBufferSize);
        v.addElement(PROP_FLUSH_INTERVAL + "=" + mFlushInterval / 1000);

        if ((mType != null) && mType.equals(ILogger.PROP_SIGNED_AUDIT)) {
            v.addElement(PROP_SIGNED_AUDIT_LOG_SIGNING + "=" + String.valueOf(mLogSigning));

            if (mSAuditCertNickName == null) {
                v.addElement(PROP_SIGNED_AUDIT_CERT_NICKNAME + "=");
            } else {
                v.addElement(PROP_SIGNED_AUDIT_CERT_NICKNAME + "=" + mSAuditCertNickName);
            }

            v.addElement(PROP_SIGNED_AUDIT_MANDATORY_EVENTS + "=" + StringUtils.join(mandatoryEvents, ","));
            v.addElement(PROP_SIGNED_AUDIT_SELECTED_EVENTS + "=" + StringUtils.join(selectedEvents, ","));
            v.addElement(PROP_SIGNED_AUDIT_UNSELECTED_EVENTS + "=" + StringUtils.join(unselectedEvents, ","));
        }
    } catch (Exception e) {
    }
    return v;
}

From source file:nl.nn.adapterframework.ldap.LdapSender.java

/** 
 * Return a list of all of the subcontexts of the current context, which is relative to parentContext. 
 * @return an array of Strings containing a list of the subcontexts for a current context.
 *///from w  ww  .  ja v a  2s  .  c  o  m
public String[] getSubContextList(DirContext parentContext, String relativeContext,
        ParameterResolutionContext prc) {
    String[] retValue = null;

    try {
        // Create a vector object and add the names of all of the subcontexts
        //  to it
        Vector n = new Vector();
        NamingEnumeration list = parentContext.list(relativeContext);
        if (log.isDebugEnabled())
            log.debug("getSubCOntextList(context) : context = " + relativeContext);
        for (int x = 0; list.hasMore(); x++) {
            NameClassPair nc = (NameClassPair) list.next();
            n.addElement(nc);
        }

        // Create a string array of the same size as the vector object
        String contextList[] = new String[n.size()];
        for (int x = 0; x < n.size(); x++) {
            // Add each name to the array
            contextList[x] = ((NameClassPair) (n.elementAt(x))).getName();
        }
        retValue = contextList;

    } catch (NamingException e) {
        storeLdapException(e, prc);
        log.error("Exception in operation [" + getOperation() + "] ", e);
    }

    return retValue;
}

From source file:com.github.maven_nar.cpptasks.compiler.CommandLineCompiler.java

@Override
protected CompilerConfiguration createConfiguration(final CCTask task, final LinkType linkType,
        final ProcessorDef[] baseDefs, final CompilerDef specificDef, final TargetDef targetPlatform,
        final VersionInfo versionInfo) {

    this.prefix = specificDef.getCompilerPrefix();
    this.objDir = task.getObjdir();
    final Vector<String> args = new Vector<>();
    final CompilerDef[] defaultProviders = new CompilerDef[baseDefs.length + 1];
    for (int i = 0; i < baseDefs.length; i++) {
        defaultProviders[i + 1] = (CompilerDef) baseDefs[i];
    }//from   w w w.  jav  a2  s.c  o m
    defaultProviders[0] = specificDef;
    final Vector<CommandLineArgument> cmdArgs = new Vector<>();

    //
    // add command line arguments inherited from <cc> element
    // any "extends" and finally the specific CompilerDef
    CommandLineArgument[] commandArgs;
    for (int i = defaultProviders.length - 1; i >= 0; i--) {
        commandArgs = defaultProviders[i].getActiveProcessorArgs();
        for (final CommandLineArgument commandArg : commandArgs) {
            if (commandArg.getLocation() == 0) {
                String arg = commandArg.getValue();
                if (isWindows() && arg.matches(".*[ \"].*")) {
                    // Work around inconsistent quoting by Ant
                    arg = "\"" + arg.replaceAll("[\\\\\"]", "\\\\$0") + "\"";
                }
                args.addElement(arg);
            } else {
                cmdArgs.addElement(commandArg);
            }
        }
    }
    final Vector<ProcessorParam> params = new Vector<>();
    //
    // add command line arguments inherited from <cc> element
    // any "extends" and finally the specific CompilerDef
    ProcessorParam[] paramArray;
    for (int i = defaultProviders.length - 1; i >= 0; i--) {
        paramArray = defaultProviders[i].getActiveProcessorParams();
        Collections.addAll(params, paramArray);
    }
    paramArray = params.toArray(new ProcessorParam[params.size()]);

    if (specificDef.isClearDefaultOptions() == false) {
        final boolean multithreaded = specificDef.getMultithreaded(defaultProviders, 1);
        final boolean debug = specificDef.getDebug(baseDefs, 0);
        final boolean exceptions = specificDef.getExceptions(defaultProviders, 1);
        final Boolean rtti = specificDef.getRtti(defaultProviders, 1);
        final OptimizationEnum optimization = specificDef.getOptimization(defaultProviders, 1);
        this.addImpliedArgs(args, debug, multithreaded, exceptions, linkType, rtti, optimization);
    }

    //
    // add all appropriate defines and undefines
    //
    buildDefineArguments(defaultProviders, args);
    final int warnings = specificDef.getWarnings(defaultProviders, 0);
    addWarningSwitch(args, warnings);
    Enumeration<CommandLineArgument> argEnum = cmdArgs.elements();
    int endCount = 0;
    while (argEnum.hasMoreElements()) {
        final CommandLineArgument arg = argEnum.nextElement();
        switch (arg.getLocation()) {
        case 1:
            args.addElement(arg.getValue());
            break;
        case 2:
            endCount++;
            break;
        }
    }
    final String[] endArgs = new String[endCount];
    argEnum = cmdArgs.elements();
    int index = 0;
    while (argEnum.hasMoreElements()) {
        final CommandLineArgument arg = argEnum.nextElement();
        if (arg.getLocation() == 2) {
            endArgs[index++] = arg.getValue();
        }
    }
    //
    // Want to have distinct set of arguments with relative
    // path names for includes that are used to build
    // the configuration identifier
    //
    final Vector<String> relativeArgs = (Vector) args.clone();
    //
    // add all active include and sysincludes
    //
    final StringBuffer includePathIdentifier = new StringBuffer();
    final File baseDir = specificDef.getProject().getBaseDir();
    String baseDirPath;
    try {
        baseDirPath = baseDir.getCanonicalPath();
    } catch (final IOException ex) {
        baseDirPath = baseDir.toString();
    }
    final Vector<String> includePath = new Vector<>();
    final Vector<String> sysIncludePath = new Vector<>();
    for (int i = defaultProviders.length - 1; i >= 0; i--) {
        String[] incPath = defaultProviders[i].getActiveIncludePaths();
        for (final String element : incPath) {
            includePath.addElement(element);
        }
        incPath = defaultProviders[i].getActiveSysIncludePaths();
        for (final String element : incPath) {
            sysIncludePath.addElement(element);
        }
    }
    final File[] incPath = new File[includePath.size()];
    for (int i = 0; i < includePath.size(); i++) {
        incPath[i] = new File(includePath.elementAt(i));
    }
    final File[] sysIncPath = new File[sysIncludePath.size()];
    for (int i = 0; i < sysIncludePath.size(); i++) {
        sysIncPath[i] = new File(sysIncludePath.elementAt(i));
    }
    addIncludes(baseDirPath, incPath, args, relativeArgs, includePathIdentifier, false);
    addIncludes(baseDirPath, sysIncPath, args, null, null, true);
    final StringBuffer buf = new StringBuffer(getIdentifier());
    for (int i = 0; i < relativeArgs.size(); i++) {
        buf.append(' ');
        buf.append(relativeArgs.elementAt(i));
    }
    for (final String endArg : endArgs) {
        buf.append(' ');
        buf.append(endArg);
    }
    final String configId = buf.toString();
    final String[] argArray = new String[args.size()];
    args.copyInto(argArray);
    final boolean rebuild = specificDef.getRebuild(baseDefs, 0);
    final File[] envIncludePath = getEnvironmentIncludePath();
    final String path = specificDef.getToolPath();

    CommandLineCompiler compiler = this;
    Environment environment = specificDef.getEnv();
    if (environment == null) {
        for (final ProcessorDef baseDef : baseDefs) {
            environment = baseDef.getEnv();
            if (environment != null) {
                compiler = (CommandLineCompiler) compiler.changeEnvironment(baseDef.isNewEnvironment(),
                        environment);
            }
        }
    } else {
        compiler = (CommandLineCompiler) compiler.changeEnvironment(specificDef.isNewEnvironment(),
                environment);
    }
    return new CommandLineCompilerConfiguration(compiler, configId, incPath, sysIncPath, envIncludePath,
            includePathIdentifier.toString(), argArray, paramArray, rebuild, endArgs, path,
            specificDef.getCcache());
}