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:org.carewebframework.ui.spring.FrameworkAppContext.java

/**
 * Constructor for creating an application context. Disallows bean overrides by default.
 * /* w  w w .  java 2s . c  om*/
 * @param desktop The desktop associated with this application context. Will be null for the
 *            root application context.
 * @param testConfig If true, use test profiles.
 * @param locations Optional list of configuration file locations. If not specified, defaults to
 *            the default configuration locations ({@link #getDefaultConfigLocations}).
 */
public FrameworkAppContext(Desktop desktop, boolean testConfig, String... locations) {
    super();
    setAllowBeanDefinitionOverriding(false);
    this.desktop = desktop;
    ConfigurableEnvironment env = getEnvironment();
    Set<String> aps = new LinkedHashSet<String>();
    Collections.addAll(aps, env.getActiveProfiles());

    if (desktop != null) {
        desktop.setAttribute(APP_CONTEXT_ATTRIB, this);
        final Session session = desktop.getSession();
        final ServletContext sc = session.getWebApp().getServletContext();
        final WebApplicationContext rootContext = WebApplicationContextUtils
                .getRequiredWebApplicationContext(sc);
        setDisplayName("Child XmlWebApplicationContext " + desktop);
        setParent(rootContext);
        setServletContext(sc);
        this.ctxListener = new ContextClosedListener();
        getParent().getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class)
                .addApplicationListener(this.ctxListener);
        // Set up profiles (remove root profiles merged from parent)
        aps.removeAll(Arrays.asList(Constants.PROFILES_ROOT));
        Collections.addAll(aps, testConfig ? Constants.PROFILES_DESKTOP_TEST : Constants.PROFILES_DESKTOP_PROD);
    } else {
        AppContextFinder.rootContext = this;
        Collections.addAll(aps, testConfig ? Constants.PROFILES_ROOT_TEST : Constants.PROFILES_ROOT_PROD);
        env.getPropertySources().addLast(new LabelPropertySource(this));
        env.getPropertySources().addLast(new DomainPropertySource(this));
    }

    env.setActiveProfiles(aps.toArray(new String[aps.size()]));
    setConfigLocations(locations == null || locations.length == 0 ? null : locations);
}

From source file:jease.cms.service.Contents.java

/**
 * Returns all descendants for given nodes.
 *//*from  ww w. ja  v  a 2s .  c om*/
public static Content[] getDescendants(Content[] nodes) {
    List<Content> contents = new ArrayList<>();
    if (nodes != null) {
        for (Content node : nodes) {
            Collections.addAll(contents, node.getDescendants(Content.class));
        }
    }
    return contents.toArray(new Content[contents.size()]);
}

From source file:com.google.gdt.eclipse.designer.util.DefaultModuleDescription.java

public List<String> getLocations() throws Exception {
    if (m_locations == null) {
        IProject project = getProject();
        IJavaProject javaProject = getJavaProject();
        m_locations = Lists.newArrayList();
        // add source locations
        {//from ww w  .j  a va2  s.  com
            List<String> sourceLocations = Lists.newArrayList();
            ProjectClassLoader.addSourceLocations(Sets.<IProject>newHashSet(), sourceLocations, project);
            m_locations.addAll(sourceLocations);
        }
        // add binary locations
        {
            String[] classpath = ProjectClassLoader.getClasspath(javaProject);
            Collections.addAll(m_locations, classpath);
        }
        // keep output locations, because there may be Generator implementations
    }
    return m_locations;
}

From source file:de.tor.tribes.util.GlobalOptions.java

/**
 * Get the list of available skins// w ww .  j  a  v  a 2  s .  c om
 */
public static String[] getAvailableSkins() {
    List<String> skins = new LinkedList<>();
    skins.add(Skin.MINIMAP_SKIN_ID);
    Collections.addAll(skins, new File("graphics/skins").list());
    Collections.sort(skins);
    return skins.toArray(new String[] {});
}

From source file:gaffer.graph.hook.OperationAuthoriser.java

/**
 * Add operation authorisations for a given operation class.
 * This can be called multiple times for the same operation class and the
 * authorisations will be appended./*from  w  w  w  .  j a  va 2s.c om*/
 *
 * @param opClass the operation class
 * @param auths   the authorisations
 */
public void addOpAuths(final Class<? extends Operation> opClass, final String... auths) {
    Set<String> opAuths = opAuthsMap.get(opClass);
    if (null == opAuths) {
        opAuths = new HashSet<>();
        opAuthsMap.put(opClass, opAuths);
    }
    Collections.addAll(opAuths, auths);
    Collections.addAll(allOpAuths, auths);
}

From source file:ec.com.ebos.web.master.jsf.bean.TechnicalInfo.java

private void proccessNewsComponents(final String newComp, final String updatedComp) {
    try {/*w ww  .  j a v a  2  s. co m*/
        String[] newCompArray = newComp.split(";");
        Collections.addAll(newComponents, newCompArray);

        String[] updatedCompArray = updatedComp.split(";");
        Collections.addAll(updatedComponents, updatedCompArray);
    } catch (Exception ex) {
        this.newComponents = new ArrayList<String>();
        this.updatedComponents = new ArrayList<String>();
    }
}

From source file:de.tor.tribes.util.bb.DefStatsFormatter.java

@Override
public String[] getTemplateVariables() {
    List<String> vars = new LinkedList<>();
    Collections.addAll(vars, VARIABLES);
    Collections.addAll(vars, STAT_SPECIFIC_VARIABLES);
    return vars.toArray(new String[vars.size()]);
}

From source file:net.sf.logsaw.dialect.websphere.WebsphereDialect.java

@Override
public void parse(ILogResource log, InputStream input, ILogEntryCollector collector) throws CoreException {
    Assert.isNotNull(log, "log"); //$NON-NLS-1$
    Assert.isNotNull(input, "input"); //$NON-NLS-1$
    Assert.isNotNull(collector, "collector"); //$NON-NLS-1$
    Assert.isTrue(isConfigured(), "Dialect should be configured by now"); //$NON-NLS-1$
    try {/*  w  w w.  j a  v  a  2 s  .  co m*/
        LogEntry currentEntry = null;
        IHasEncoding enc = (IHasEncoding) log.getAdapter(IHasEncoding.class);
        IHasLocale loc = (IHasLocale) log.getAdapter(IHasLocale.class);
        // WebSphere Dialect doesn't need to care about the timezone, because it is encoded in the log messages
        DateFormat df = getDateFormat(loc.getLocale());
        LineIterator iter = IOUtils.lineIterator(input, enc.getEncoding());
        int lineNo = 0;
        try {
            while (iter.hasNext()) {
                // Error handling
                lineNo++;
                List<IStatus> statuses = null;
                boolean fatal = false; // determines whether to interrupt parsing

                String line = iter.nextLine();
                Matcher m = getInternalPattern().matcher(line);
                if (m.find()) {
                    // The next line matches, so flush the previous entry and continue
                    if (currentEntry != null) {
                        collector.collect(currentEntry);
                        currentEntry = null;
                    }
                    currentEntry = new LogEntry();
                    for (int i = 0; i < m.groupCount(); i++) {
                        try {
                            extractField(currentEntry, i + 1, m.group(i + 1), df);
                        } catch (CoreException e) {
                            // Mark for interruption
                            fatal = fatal || e.getStatus().matches(IStatus.ERROR);

                            // Messages will be displayed later
                            if (statuses == null) {
                                statuses = new ArrayList<IStatus>();
                            }
                            if (e.getStatus().isMultiStatus()) {
                                Collections.addAll(statuses, e.getStatus().getChildren());
                            } else {
                                statuses.add(e.getStatus());
                            }
                        }
                    }

                    // We encountered errors or warnings
                    if (statuses != null && !statuses.isEmpty()) {
                        currentEntry = null; // Stop propagation
                        IStatus status = new MultiStatus(WebsphereDialectPlugin.PLUGIN_ID, 0,
                                statuses.toArray(new IStatus[statuses.size()]),
                                NLS.bind(Messages.WebsphereDialect_error_failedToParseLine, lineNo), null);
                        if (fatal) {
                            // Interrupt parsing in case of error
                            throw new CoreException(status);
                        } else {
                            collector.addMessage(status);
                        }
                    }
                } else if (currentEntry != null) {
                    // Append to message
                    String msg = currentEntry.get(getFieldProvider().getMessageField());
                    StringWriter strWriter = new StringWriter();
                    PrintWriter printWriter = new PrintWriter(strWriter);
                    printWriter.print(msg);
                    printWriter.println();
                    printWriter.print(line);
                    currentEntry.put(getFieldProvider().getMessageField(), strWriter.toString());
                }

                if (collector.isCanceled()) {
                    // Cancel parsing
                    break;
                }
            }

            if (currentEntry != null) {
                // Collect left over entry
                collector.collect(currentEntry);
            }
        } finally {
            LineIterator.closeQuietly(iter);
        }
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, WebsphereDialectPlugin.PLUGIN_ID,
                NLS.bind(Messages.WebsphereDialect_error_failedToParseFile,
                        new Object[] { log.getName(), e.getLocalizedMessage() }),
                e));
    }
}

From source file:edu.kit.dama.staging.adapters.DefaultDownloadInformationServiceAdapter.java

@Override
public List<DownloadInformation> getDownloadsForStaging(IAuthorizationContext pContext)
        throws ServiceAdapterException {
    LOGGER.debug("Getting all downloads ready for staging");
    List<DownloadInformation> result = new LinkedList<>();
    List<DownloadInformation> queryResult = DownloadInformationServiceLocal.getSingleton()
            .getDownloadInformationByStatus(DOWNLOAD_STATUS.SCHEDULED.getId(), 0, Integer.MAX_VALUE, pContext);
    if (queryResult != null && !queryResult.isEmpty()) {
        LOGGER.debug("Query for stageable downloads returned '{}' results", queryResult.size());
        Collections.addAll(result, queryResult.toArray(new DownloadInformation[queryResult.size()]));
    } else {/*from w  ww .j  av  a  2s .  c  o m*/
        LOGGER.info("Query to DownloadInformationService returned no result");
    }
    return result;
}