Example usage for java.util Collections addAll

List of usage examples for java.util Collections addAll

Introduction

In this page you can find the example usage for java.util Collections addAll.

Prototype

@SafeVarargs
public static <T> boolean addAll(Collection<? super T> c, T... elements) 

Source Link

Document

Adds all of the specified elements to the specified collection.

Usage

From source file:com.liferay.ide.server.core.portal.PortalServerBehavior.java

@Override
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy launch, IProgressMonitor monitor)
        throws CoreException {

    String existingProgArgs = launch.getAttribute(ATTR_PROGRAM_ARGUMENTS, (String) null);

    launch.setAttribute(ATTR_PROGRAM_ARGUMENTS,
            _mergeArguments(existingProgArgs, _getRuntimeStartProgArgs(), null));

    String existingVMArgs = launch.getAttribute(ATTR_VM_ARGUMENTS, (String) null);

    String[] configVMArgs = _getRuntimeStartVMArguments();

    launch.setAttribute(ATTR_VM_ARGUMENTS, _mergeArguments(existingVMArgs, configVMArgs, null));

    PortalRuntime portalRuntime = _getPortalRuntime();

    IVMInstall vmInstall = portalRuntime.getVMInstall();

    if (vmInstall != null) {
        IPath jreContainerPath = JavaRuntime.newJREContainerPath(vmInstall);

        launch.setAttribute(ATTR_JRE_CONTAINER_PATH, jreContainerPath.toPortableString());
    }/*  www .  j ava  2  s.  c om*/

    IRuntimeClasspathEntry[] orgClasspath = JavaRuntime.computeUnresolvedRuntimeClasspath(launch);

    int orgClasspathSize = orgClasspath.length;

    List<IRuntimeClasspathEntry> oldCp = new ArrayList<>(orgClasspathSize);

    Collections.addAll(oldCp, orgClasspath);

    List<IRuntimeClasspathEntry> runCpEntries = portalRuntime.getRuntimeClasspathEntries();

    for (IRuntimeClasspathEntry cpEntry : runCpEntries) {
        _mergeClasspath(oldCp, cpEntry);
    }

    if (vmInstall != null) {
        try {
            IVMInstallType vmInstallType = vmInstall.getVMInstallType();

            String typeId = vmInstallType.getId();

            IPath typeIdPath = new Path(JavaRuntime.JRE_CONTAINER).append(typeId);

            IRuntimeClasspathEntry newJRECp = JavaRuntime.newRuntimeContainerClasspathEntry(
                    typeIdPath.append(vmInstall.getName()), IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);

            _replaceJREConatiner(oldCp, newJRECp);
        } catch (Exception e) {

            // ignore

        }

        File vmInstallLocation = vmInstall.getInstallLocation();

        IPath jrePath = new Path(vmInstallLocation.getAbsolutePath());

        if (jrePath != null) {
            IPath toolsPath = jrePath.append("lib/tools.jar");

            if (FileUtil.exists(toolsPath)) {
                IRuntimeClasspathEntry toolsJar = JavaRuntime.newArchiveRuntimeClasspathEntry(toolsPath);

                // Search for index to any existing tools.jar entry

                int toolsIndex;

                for (toolsIndex = 0; toolsIndex < oldCp.size(); toolsIndex++) {
                    IRuntimeClasspathEntry entry = oldCp.get(toolsIndex);

                    IPath entryPath = entry.getPath();

                    String entryPathLastSegment = entryPath.lastSegment();

                    if ((entry.getType() == IRuntimeClasspathEntry.ARCHIVE)
                            && entryPathLastSegment.equals("tools.jar")) {

                        break;
                    }
                }

                // If existing tools.jar found, replace in case it's different. Otherwise add.

                if (toolsIndex < oldCp.size()) {
                    oldCp.set(toolsIndex, toolsJar);
                } else {
                    _mergeClasspath(oldCp, toolsJar);
                }
            }
        }
    }

    List<String> cp = new ArrayList<>();

    for (IRuntimeClasspathEntry entry : oldCp) {
        try {
            IClasspathEntry classpathEntry = entry.getClasspathEntry();

            if (classpathEntry.getEntryKind() != IClasspathEntry.CPE_CONTAINER) {
                entry = new LiferayRuntimeClasspathEntry(classpathEntry);
            }

            cp.add(entry.getMemento());
        } catch (Exception e) {
            LiferayServerCore.logError("Could not resolve cp entry " + entry, e);
        }
    }

    launch.setAttribute(ATTR_CLASSPATH, cp);
    launch.setAttribute(ATTR_DEFAULT_CLASSPATH, Boolean.FALSE);
}

From source file:com.samples.platform.core.security.UserProvider.java

/**
 * Read the user definitions out of the properties and put the into the map
 * {@link UserProvider#userMap}./* w w w . j  a va  2  s . c  o m*/
 */
public void createUsers() {
    this.logger.trace("+createUsers");
    /* Create an _sorted_ map containing all user definition properties. */
    TreeMap<String, String> userDefinitionProperties = new TreeMap<String, String>();
    for (Map.Entry<String, String> entry : this.properties.getProperties().entrySet()) {
        if (entry.getKey() != null && entry.getKey().startsWith(BUS_PROPERTY_NAME_START)) {
            userDefinitionProperties.put(entry.getKey(), entry.getValue());
        }
    }

    /* Create a map of UserDefinitions parsed out of the properties. */
    HashMap<String, UserDefinition> parsedUserDefinitions = new HashMap<String, UserProvider.UserDefinition>();
    UserDefinition userDefinition = null;
    String userKey = null;
    for (Map.Entry<String, String> userDefinitionProperty : userDefinitionProperties.entrySet()) {
        /* Get the user key out of the property name. */
        userKey = extractUser(userDefinitionProperty.getKey());
        if (userDefinition == null || !userDefinition.getKey().equals(userKey)) {
            /* New user key extracted out of the property name. */
            if (userDefinition != null) {
                /* Previous UserDefinition finished. Put it into the map. */
                parsedUserDefinitions.put(userDefinition.getName(), userDefinition);
            }
            /* Create the actual UserDefinition with the user key. */
            userDefinition = new UserDefinition(userKey);
        }
        /* Setup the content of the property into the UserDefinition. */
        if (userDefinitionProperty.getKey().endsWith("userName")) {
            userDefinition.setName(userDefinitionProperty.getValue());
        } else if (userDefinitionProperty.getKey().endsWith("password")) {
            userDefinition.setPassword(userDefinitionProperty.getValue());
        } else if (userDefinitionProperty.getKey().contains(".role.")) {
            if (userDefinitionProperty.getValue() != null
                    && !userDefinitionProperty.getValue().equals(ROLE_ANONYMOUS)) {
                userDefinition.addRolename(userDefinitionProperty.getValue());
            }
        }
    }
    /* Put the last UserDefinition to the map of parsedUserDefinitions. */
    if (userDefinition != null && userDefinition.getName() != null) {
        parsedUserDefinitions.put(userDefinition.getName(), userDefinition);
    }

    /*
     * Update the userMap. If the userName of the userMap is not part of the
     * parsedUserDefinitions any more, the user is removed out of the
     * userMap.
     */
    List<String> keyList = new ArrayList<String>(this.userMap.size());
    Collections.addAll(keyList, this.userMap.keySet().toArray(new String[this.userMap.keySet().size()]));
    for (String userName : keyList) {
        userDefinition = parsedUserDefinitions.get(userName);
        if (!parsedUserDefinitions.containsKey(userName)) {
            this.userMap.remove(userName);
        }
    }
    /*
     * All UserDefinitions out of the parsedUserDefinitions are mapped to a
     * User and put into the userMap.
     */
    for (UserDefinition ud : parsedUserDefinitions.values()) {
        this.userMap.put(ud.getName(), this.getUser(ud));
    }
    this.logger.trace("-createUsers");
}

From source file:jahirfiquitiva.iconshowcase.utilities.ZooperIconFontsHelper.java

private void preChecks() {
    this.mIconsets = new ArrayList<>();
    this.mMissing = new ArrayList<>();
    this.mFixed = new ArrayList<>();
    this.mFixIndex = 0;
    this.mCancelIndex = 0;
    try {//ww w .j a v  a  2s .  c  om
        File d = new File(USERunderscoreICONSETSunderscorePATH);
        if (!d.exists())
            throw new FileNotFoundException();
        Collections.addAll(this.mIconsets, d.list());
    } catch (FileNotFoundException exception) {
        if (this.mCallback != null)
            this.mCallback.OnError(exception);
    }
}

From source file:android.databinding.compilationTest.BaseCompilationTest.java

protected CompilationResult runGradle(String... params) throws IOException, InterruptedException {
    setExecutable();//w  ww  . java 2 s . c o m
    File pathToExecutable = new File(testFolder, "gradlew");
    List<String> args = new ArrayList<>();
    args.add(pathToExecutable.getAbsolutePath());
    args.add("-P" + PRINT_ENCODED_ERRORS_PROPERTY + "=true");
    args.add("--project-cache-dir");
    args.add(new File("../.caches/", name.getMethodName()).getAbsolutePath());
    Collections.addAll(args, params);
    ProcessBuilder builder = new ProcessBuilder(args);
    builder.environment().putAll(System.getenv());
    String javaHome = System.getProperty("java.home");
    if (StringUtils.isNotBlank(javaHome)) {
        builder.environment().put("JAVA_HOME", javaHome);
    }
    builder.directory(testFolder);
    Process process = builder.start();
    String output = IOUtils.toString(process.getInputStream());
    String error = IOUtils.toString(process.getErrorStream());
    int result = process.waitFor();
    return new CompilationResult(result, output, error);
}

From source file:com.francetelecom.clara.cloud.presentation.tools.PopulateDatasService.java

public void populateSingleApp(String appName, String nbOfReleases, String nbOfEnvironments, boolean mock)
        throws MalformedURLException, BusinessException {
    SampleAppFactory appFactory = getAppFactory(appName);
    String version;//from   w  ww .j  a  v  a2  s.  co  m

    // Create application
    Application app = createApp(appName, appFactory);

    for (int i = 1; i <= Integer.parseInt(nbOfReleases); i++) {
        version = "G00R0" + i;

        // create release
        ApplicationRelease release = createRelease(app, appFactory, version);

        // Populate logical model.
        populateLogicalDeployment(appFactory, release);

        for (int j = 1; j <= Integer.parseInt(nbOfEnvironments); j++) {

            List<EnvironmentDto.EnvironmentTypeEnum> envTypeList = new ArrayList<EnvironmentDto.EnvironmentTypeEnum>();

            Collections.addAll(envTypeList, EnvironmentDto.EnvironmentTypeEnum.values());

            Random random = new Random();

            EnvironmentDto.EnvironmentTypeEnum envType;

            // if mock mode activate we can select a random type of
            // environment
            if (mock)
                envType = envTypeList.get(random.nextInt(envTypeList.size()));
            // if mock mode deactivate we can only create development
            // environment
            else
                envType = EnvironmentDto.EnvironmentTypeEnum.DEVELOPMENT;

            manageEnvironment.isEnvironmentLabelUniqueForRelease(
                    WicketSession.get().getPaasUser().getSsoId().getValue(), "my env " + j, release.getUID());

            manageEnvironment.createEnvironment(release.getUID(), envType,
                    WicketSession.get().getPaasUser().getSsoId().getValue(), "my env " + j);
        }
    }
}

From source file:net.sf.jabref.openoffice.AutoDetectPaths.java

/**
 * Search for Program files directory.//from   ww w. j a  v  a2 s .  com
 * @return the File pointing to the Program files directory, or null if not found.
 *   Since we are not including a library for Windows integration, this method can't
 *   find the Program files dir in localized Windows installations.
 */
private static List<File> findProgramFilesDir() {
    List<String> sourceList = new ArrayList<>();
    List<File> dirList = new ArrayList<>();

    // 64-bits first
    String progFiles = System.getenv("ProgramFiles");
    if (progFiles != null) {
        sourceList.add(progFiles);
    }

    // Then 32-bits
    progFiles = System.getenv("ProgramFiles(x86)");
    if (progFiles != null) {
        sourceList.add(progFiles);
    }

    for (String rootPath : sourceList) {
        File root = new File(rootPath);
        File[] dirs = root.listFiles(File::isDirectory);
        if (dirs != null) {
            Collections.addAll(dirList, dirs);
        }
    }
    return dirList;
}

From source file:com.joyent.manta.util.MantaUtils.java

/**
 * Converts a naive CSV string to a collection.
 *
 * @param line CSV string//from  w ww.ja va2 s .c  om
 * @return collection containing each value between each comma
 */
public static Collection<String> fromCsv(final String line) {
    Validate.notNull(line, "Line must not be null");

    final List<String> list = new ArrayList<>();

    if (line.contains(",")) {
        String[] parts = line.split(",\\s*");
        Collections.addAll(list, parts);
    } else {
        list.add(line);
    }

    return list;
}

From source file:com.taobao.tdhs.jdbc.sqlparser.ParseSQL.java

public List<String> changeToList(String str) {
    if (StringUtils.isBlank(str)) {
        return null;
    }//from ww  w .  j  a v a  2s.com
    String[] array = str.split(",");
    List<String> list = new LinkedList<String>();
    Collections.addAll(list, array);
    return list;
}

From source file:jetbrains.buildServer.buildTriggers.vcs.git.PluginConfigImpl.java

private Set<Class> fetchProcessClasses() {
    Set<Class> result = new HashSet<Class>();
    result.addAll(asList(Fetcher.class, VcsRoot.class, ProgressMonitor.class, VcsPersonalSupport.class,
            Logger.class, GitVcsRoot.class, JSch.class, Decoder.class, TObjectHashingStrategy.class,
            EncryptUtil.class, DiagnosticUtil.class, FileUtil.class, Element.class, Layout.class,
            VcsException.class, BasicConfigurator.class, HttpClientConnectionFactory.class, HttpClient.class,
            LogFactory.class, HttpEntity.class, CachePaths.class, ServiceMessage.class, org.slf4j.Logger.class,
            org.slf4j.impl.StaticLoggerBinder.class, EWAHCompressedBitmap.class));
    Collections.addAll(result, GitVcsSupport.class.getInterfaces());
    return result;
}

From source file:goja.initialize.ctxbox.ClassSearcher.java

public ClassSearcher inJars(String... jars) {
    if (jars != null) {
        Collections.addAll(includeJars, jars);
    }
    return this;
}