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.cloudera.recordservice.tests.MiniClusterController.java

/**
 * Every node in the local minicluster runs in its own process. This method
 * returns a hashset of all the process ids of running nodes in the mini
 * cluster.//from  w  ww .  j  a  v a  2  s . com
 */
public HashSet<Integer> getRunningMiniNodePids() {
    HashSet<Integer> pidSet = new HashSet<Integer>();
    Collections.addAll(pidSet, ArrayUtils.toObject(GetRunningMiniNodePids()));
    return pidSet;
}

From source file:com.marklogic.contentpump.RDFWritable.java

@Override
public Content getContent(Configuration conf, ContentCreateOptions options, String uri) {
    String[] collections = conf.getStrings(MarkLogicConstants.OUTPUT_COLLECTION);
    String outputGraph = conf.get(MarkLogicConstants.OUTPUT_GRAPH);
    String outputOverrideGraph = conf.get(MarkLogicConstants.OUTPUT_OVERRIDE_GRAPH);

    if (collections != null) {
        List<String> optionList = new ArrayList<String>();
        if (graphUri == null) { //no graph specified in quad
            if (outputGraph != null)//output_graph is set
                optionList.add(outputGraph.trim());
            else if (outputOverrideGraph != null) {
                optionList.add(outputOverrideGraph.trim());
            }//w w w  .  j  av a 2 s. c o  m
        } else {
            if (outputOverrideGraph != null)
                optionList.add(outputOverrideGraph);
            else
                optionList.add(graphUri);//use quad's graph
        }
        //collections are always added
        Collections.addAll(optionList, collections);
        collections = optionList.toArray(new String[0]);
        for (int i = 0; i < collections.length; i++) {
            collections[i] = collections[i].trim();
        }
        options.setCollections(collections);
    } else {
        if (graphUri == null) {
            if (outputOverrideGraph != null) {
                graphUri = outputOverrideGraph;
            } else if (outputGraph != null) {
                graphUri = outputGraph;
            } else {
                graphUri = "http://marklogic.com/semantics#default-graph";
            }
        }
        String[] col = new String[1];
        col[0] = graphUri;
        options.setCollections(col);
    }

    options.setGraph(graphUri);
    //permissions
    if (permissions != null)
        options.setPermissions(permissions);

    Content content = null;
    if (value instanceof Text) {
        content = ContentFactory.newContent(uri, ((Text) value).toString(), options);
    } else if (value instanceof MarkLogicNode) {
        content = ContentFactory.newContent(uri, ((MarkLogicNode) value).get(), options);
    } else if (value instanceof BytesWritable) {
        content = ContentFactory.newContent(uri, ((BytesWritable) value).getBytes(), 0,
                ((BytesWritable) value).getLength(), options);
    }
    return content;
}

From source file:energy.usef.core.data.participant.Participant.java

/**
 * Add participant roles to the {@link Participant}.
 *
 * @param participantRoles/*www  . j a  va 2s.c  o  m*/
 */
public void addParticipantRoles(ParticipantRole... participantRoles) {
    if (participantRoles == null || participantRoles.length == 0) {
        return;
    }
    if (this.roles == null) {
        this.roles = new ArrayList<>();
    }
    Collections.addAll(this.roles, participantRoles);
}

From source file:com.developmentsprint.spring.breaker.annotations.AnnotationCircuitBreakerAttributeSource.java

/**
 * Create a custom AnnotationTransactionAttributeSource.
 * /*from  w w w . j  a v  a2 s.c o m*/
 * @param annotationParsers
 *            the TransactionAnnotationParsers to use
 */
public AnnotationCircuitBreakerAttributeSource(CircuitBreakerAnnotationParser... annotationParsers) {
    this.publicMethodsOnly = true;
    Assert.notEmpty(annotationParsers, "At least one CircuitBreakerAnnotationParser needs to be specified");
    Set<CircuitBreakerAnnotationParser> parsers = new LinkedHashSet<CircuitBreakerAnnotationParser>(
            annotationParsers.length);
    Collections.addAll(parsers, annotationParsers);
    this.annotationParsers = parsers;
}

From source file:eu.impact_project.resultsrepository.DavHandler.java

/**
 * Instantiates a new dav handler./*from w  ww  . j  a  v a 2 s . co m*/
 * 
 * @param folderHierarchy
 *            The folders are created in the repository.
 * @throws HttpException
 *             if there are problems with the connection.
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public DavHandler(List<String> folderHierarchy) throws HttpException, IOException {
    this.folderHierarchy = new ArrayList<String>(folderHierarchy);

    Properties properties = new Properties();

    InputStream is = null;

    try {
        is = getClass().getResource("/dav.properties").openStream();
        properties.load(is);
    }

    finally {
        is.close();
    }

    String endings = properties.getProperty("fileEndingsToStore");
    String[] endingsArray = endings.split(",");
    Collections.addAll(fileEndings, endingsArray);

    this.davUrl = properties.getProperty("url");

    // remove the slash at the end if any
    if (davUrl.endsWith("/")) {
        davUrl = davUrl.substring(0, davUrl.length() - 1);
    }

    this.davUser = properties.getProperty("user");
    this.davPassword = properties.getProperty("password");

    client = new HttpClient();

    createFolders();
}

From source file:com.marklogic.contentpump.ContentWithFileNameWritable.java

@Override
public Content getContent(Configuration conf, ContentCreateOptions options, String uri) {

    String[] collections = conf.getStrings(MarkLogicConstants.OUTPUT_COLLECTION);

    String collectionUri = null;/*  w w  w.ja v a 2 s .c o m*/
    try {
        URI fileUri = new URI(null, null, null, 0, fileName, null, null);
        collectionUri = fileUri.toString();
    } catch (URISyntaxException e) {
        LOG.error("Error parsing file name as URI " + fileName, e);
    }
    if (collections != null) {
        List<String> optionList = new ArrayList<String>();
        Collections.addAll(optionList, collections);
        if (collectionUri != null) {
            optionList.add(collectionUri);
        }
        collections = optionList.toArray(new String[0]);
        for (int i = 0; i < collections.length; i++) {
            collections[i] = collections[i].trim();
        }
        options.setCollections(collections);
    } else {
        String[] col = new String[1];
        col[0] = collectionUri;
        options.setCollections(col);
    }

    Content content = null;
    if (value instanceof Text) {
        content = ContentFactory.newContent(uri, ((Text) value).toString(), options);
    } else if (value instanceof MarkLogicNode) {
        content = ContentFactory.newContent(uri, ((MarkLogicNode) value).get(), options);
    } else if (value instanceof BytesWritable) {
        content = ContentFactory.newContent(uri, ((BytesWritable) value).getBytes(), 0,
                ((BytesWritable) value).getLength(), options);
    }
    return content;
}

From source file:bear.plugins.sh.CommandLine.java

public CommandLine<T, SCRIPT> addSplit(String s) {
    Collections.addAll(strings, s.split("\\s+"));
    return this;
}

From source file:manage.appli.patri.awb.webapp.TechnicalInfo.java

private void proccessNewsComponents(String newComp, String updatedComp) {
    try {//w  w  w  . jav a2  s  .c o 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:org.openmrs.web.controller.person.RelationshipTypeViewFormController.java

/**
 * The onSubmit function receives the form/command object that was modified by the input form
 * and saves it to the db/*from   w  ww  . j a va 2  s. co  m*/
 *
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    HttpSession httpSession = request.getSession();

    String view = getFormView();
    if (Context.isAuthenticated()) {

        String[] relationshipTypeIds = request.getParameterValues("relationshipTypeIds");
        String[] displayOrders = request.getParameterValues("displayOrders");
        List<String> preferredTypes = new ArrayList<String>();
        String[] preferredTypesArray = request.getParameterValues("preferredTypes");
        if (preferredTypesArray != null) {
            Collections.addAll(preferredTypes, preferredTypesArray);
        }

        PersonService ps = Context.getPersonService();

        for (int i = 0; i < relationshipTypeIds.length; i++) {
            String id = relationshipTypeIds[i];
            String displayOrder = displayOrders[i];
            Boolean preferred = preferredTypes.contains(id);
            RelationshipType type = ps.getRelationshipType(Integer.valueOf(id));
            type.setWeight(Integer.valueOf(displayOrder));
            type.setPreferred(preferred);
            ps.saveRelationshipType(type);
        }

        String success = getMessageSourceAccessor().getMessage("RelationshipType.views.saved");

        view = getSuccessView();
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success);
    }

    return new ModelAndView(new RedirectView(view));
}

From source file:io.hops.hopsworks.common.dao.user.security.audit.AccountAuditFacade.java

@PostConstruct
private void init() {
    whitelistUserLogins = new HashSet<>();
    String whitelist = settings.getWhitelistUsersLogin();
    String[] whitelistTokens = whitelist.split(",");
    Collections.addAll(whitelistUserLogins, whitelistTokens);
}