Example usage for java.util ArrayList addAll

List of usage examples for java.util ArrayList addAll

Introduction

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

Prototype

public boolean addAll(Collection<? extends E> c) 

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.

Usage

From source file:com.glluch.ecf2xmlmaven.Competence.java

public ArrayList<String> getTermsWithoutCounts() {
    ArrayList<String> oterms = new ArrayList<>();
    oterms.addAll(terms.keySet());
    return oterms;
}

From source file:de.uni_koeln.spinfo.maalr.mongo.SpringBackend.java

private void validateUserModification(LemmaVersion current, LemmaVersion version) throws MaalrException {
    LemmaDescription description = Configuration.getInstance().getLemmaDescription();
    // Server-Side validation of a user modification: Check that only fields which are allowed
    // to modify are sent
    ArrayList<String> fields = new ArrayList<String>(
            description.getFields(UseCase.FIELDS_FOR_SIMPLE_EDITOR, true));
    fields.addAll(description.getFields(UseCase.FIELDS_FOR_SIMPLE_EDITOR, false));
    // Add email and comment as default values
    fields.add(LemmaVersion.EMAIL);/*  w w w.j a  va  2  s.co  m*/
    fields.add(LemmaVersion.COMMENT);
    version.getEntryValues().keySet().retainAll(fields);
    if (current != null) {
        // Add values of non-user-fields to the suggestion
        Map<String, String> allowed = new HashMap<String, String>(version.getEntryValues());
        version.getEntryValues().putAll(current.getEntryValues());
        // Overwrite user-fields with suggested entries
        version.getEntryValues().putAll(allowed);
    }
    // Check the length of each field: Normal entries must be less than 200 characters,
    // a comment must be less than 500 chars.
    for (String key : fields) {
        String value = version.getEntryValue(key);
        if (value != null) {
            if (LemmaVersion.COMMENT.equals(key)) {
                if (value.length() > 500) {
                    //   throw new MaalrException("Please limit your comment to 500 characters.");
                    //   workaround for i18n
                    throw new MaalrException("dialog.failure.comment");
                }
            } else {
                if (value.length() > 200) {
                    //   throw new MaalrException("A field cannot contain more than 200 characters.");
                    //workaround for i18n
                    throw new MaalrException("dialog.failure.lemma");
                }
            }
        }
    }
}

From source file:com.mycompany.searchengineaggregator.SearchEngineAggregator.java

public String compileResults(ArrayList<JSONObject> result1, ArrayList<JSONObject> result2,
        ArrayList<JSONObject> result3) {

    StringBuilder finalResult = new StringBuilder();
    ArrayList<JSONObject> combinedResults = new ArrayList<>(result1.size() + result2.size() + result3.size());

    combinedResults.addAll(result1);
    combinedResults.addAll(result2);//from   w  ww .  j a v  a 2s .com
    combinedResults.addAll(result3);

    //Sorts combined list so that all results appear in order of "hit"
    //E.g. Google's first result, Yahoo's first result, Bing's first result, etc.
    Collections.sort(combinedResults, new Comparator<JSONObject>() {

        @Override
        public int compare(JSONObject obj1, JSONObject obj2) {
            try {
                if (obj1.getInt("result number") < obj2.getInt("result number")) {
                    return -1;
                } else if (obj1.getInt("result number") == obj2.getInt("result number")) {
                    return 0;
                } else {
                    return 1;
                }
            } catch (JSONException ex) {
                Logger.getLogger(SearchEngineAggregator.class.getName()).log(Level.SEVERE, null, ex);
            }

            return -1;
        }
    });

    finalResult.append("\n[");

    //Appends all results from each search engine to the final result string
    for (JSONObject s : combinedResults) {
        finalResult.append(s.toString());
        finalResult.append(",");
    }

    //Replace last comma with ']'
    finalResult.replace(finalResult.length() - 1, finalResult.length(), "]");

    return finalResult.toString();
}

From source file:es.pode.modificador.presentacion.configurar.modificacion.ConfigurarModificacionControllerImpl.java

/**
 * @see es.pode.modificador.presentacion.configurar.modificacion.ConfigurarModificacionController#eliminarCambios(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.configurar.modificacion.EliminarCambiosForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*ww w  . j av a2s .c  o m*/
public final void eliminarCambios(ActionMapping mapping,
        es.pode.modificador.presentacion.configurar.modificacion.EliminarCambiosForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    int[] posiciones = (int[]) request.getSession().getAttribute("posiciones");
    request.getSession().removeAttribute("posiciones");
    if (posiciones != null) {
        if (logger.isDebugEnabled())
            logger.debug("Se han seleccionado " + posiciones.length + " cambios para eliminar");
        ArrayList cambios = new ArrayList();
        cambios.addAll(Arrays.asList(
                this.getConfigurarModificacionSession(request).getConfiguracion().getCambios().getCambios()));
        ArrayList paraBorrar = new ArrayList();
        for (int i = 0; i < posiciones.length; i++) {
            paraBorrar.add((Change) cambios.get(posiciones[i]));
        }
        for (int i = 0; i < paraBorrar.size(); i++) {
            cambios.remove(paraBorrar.get(i));
        }
        if (logger.isDebugEnabled())
            logger.debug("Actualizando el objeto de sesion");
        this.getConfigurarModificacionSession(request).getConfiguracion().getCambios()
                .setCambios((Change[]) cambios.toArray(new Change[cambios.size()]));
    } else {
        logger.error("No habia ningun cambio para eliminar");
    }
}

From source file:com.idega.bedework.presentation.BedeworkCalendarViewer.java

@Override
public void main(IWContext iwc) {
    ArrayList<String> list = new ArrayList<String>();

    Collection<String> names = getBedeworkEventsService()
            .getNamesOfEvents(getBedeworkEventsService().getEvents(iwc.getCurrentUser()));

    if (!ListUtil.isEmpty(names)) {
        list.addAll(names);
    }/*from   w  w  w.  ja  v a 2 s  . com*/

    setEvents(list);
    //      CalendarPropertiesBean cpb = new CalendarPropertiesBean();
    //            
    //      cpb.setShowAddress(Boolean.TRUE);
    //      cpb.setShowDescription(Boolean.TRUE);
    //      cpb.setShowEmails(Boolean.TRUE);
    //      cpb.setShowEntriesAsList(Boolean.TRUE);
    //      cpb.setShowExtraInfo(Boolean.TRUE);
    //      cpb.setShowLabels(Boolean.TRUE);
    //      cpb.setShowTime(Boolean.TRUE);
    //      
    //      setCalendarProperties(cpb);
    super.main(iwc);
}

From source file:com.tesora.dve.sql.parser.InvokeParser.java

private static ParseResult parameterizeAndParse(SchemaContext pc, ParserOptions options, byte[] line,
        Charset cs) throws ParserException {
    String singleByteEncoded = PECharsetUtils.getString(line, PECharsetUtils.latin1, false);

    logParse(pc, singleByteEncoded, null);

    ListOfPairs<Statement, List<Object>> parameterized = buildParameterizedCommands(singleByteEncoded, cs, pc);
    ArrayList<Statement> out = new ArrayList<Statement>();
    for (Pair<Statement, List<Object>> p : parameterized) {
        DMLStatement dmls = (DMLStatement) p.getFirst();
        String msql = dmls.getSQL(pc, false, true);
        List<Object> params = p.getSecond();
        byte[] modstmt = msql.getBytes(PECharsetUtils.latin1);
        String orig = PECharsetUtils.getString(modstmt, cs, true);
        if (orig == null)
            throw new ParserException(Pass.FIRST,
                    "Unable to parameterize SQL statement to handle characters invalid for character set "
                            + cs.name());
        orig = StringUtils.strip(orig, new String(Character.toString(Character.MIN_VALUE)));
        out.addAll(parse(buildInputState(orig, pc), DEFAULT_PARSER_RULE, options, pc, params,
                TranslatorInitCallback.INSTANCE).getStatements());
    }//from   w  w w. ja v a 2  s.c  om
    return new ParseResult(out, null);
}

From source file:ca.uhn.fhir.validation.FhirValidator.java

/**
 * Add a new validator module to this validator. You may register as many modules as you like at any time.
 * //from   w  w  w .j  a  va  2  s .c  om
 * @param theValidator
 *           The validator module. Must not be null.
 */
public synchronized void registerValidatorModule(IValidatorModule theValidator) {
    Validate.notNull(theValidator, "theValidator must not be null");
    ArrayList<IValidatorModule> newValidators = new ArrayList<IValidatorModule>(myValidators.size() + 1);
    newValidators.addAll(myValidators);
    newValidators.add(theValidator);

    myValidators = newValidators;
}

From source file:ca.uhn.fhir.validation.FhirValidator.java

/**
 * Removes a validator module from this validator. You may register as many modules as you like, and remove them at any time.
 * //from   w w  w .  j  av a  2 s.c  om
 * @param theValidator
 *           The validator module. Must not be null.
 */
public synchronized void unregisterValidatorModule(IValidatorModule theValidator) {
    Validate.notNull(theValidator, "theValidator must not be null");
    ArrayList<IValidatorModule> newValidators = new ArrayList<IValidatorModule>(myValidators.size() + 1);
    newValidators.addAll(myValidators);
    newValidators.remove(theValidator);

    myValidators = newValidators;
}

From source file:licenseUtil.LicensingList.java

public void writeToSpreadsheet(String spreadsheetFN) throws IOException {
    logger.info("write spreadsheet to \"" + spreadsheetFN + "\"");
    FileWriter fileWriter = null;
    CSVPrinter csvFilePrinter = null;/*w  ww  . j a  va2  s  .  co m*/

    //Create the CSVFormat object with "\n" as a record delimiter
    CSVFormat csvFileFormat = CSVFormat.DEFAULT.withDelimiter(columnDelimiter);

    try {
        //initialize FileWriter object
        fileWriter = new FileWriter(spreadsheetFN);

        //initialize CSVPrinter object
        csvFilePrinter = new CSVPrinter(fileWriter, csvFileFormat);

        ArrayList<String> headers = new ArrayList<>();
        headers.addAll(LicensingObject.ColumnHeader.HEADER_VALUES);
        headers.addAll(getNonFixedHeaders());
        //Create CSV file header
        csvFilePrinter.printRecord(headers);
        for (LicensingObject licensingObject : this) {
            csvFilePrinter.printRecord(licensingObject.getRecord(headers));
        }
        logger.info("CSV file was created successfully");

    } catch (Exception e) {
        logger.error("Error in CsvFileWriter");
        e.printStackTrace();
    } finally {
        try {
            fileWriter.flush();
            fileWriter.close();
            csvFilePrinter.close();
        } catch (IOException e) {
            logger.error("Error while flushing/closing fileWriter/csvPrinter !!!");
            e.printStackTrace();
        }
    }
}

From source file:ch.unibas.fittingwizard.infrastructure.base.PythonScriptRunner.java

private void setCommand(File scriptName, List<String> args, File outputFile) {
    if (scriptName != null && !scriptName.exists()) {
        throw new ScriptExecutionException("Could not find Python script " + scriptName);
    }/*from  www  . j a va2  s.  c  om*/

    ArrayList<String> list = new ArrayList<>();
    list.add(ExecutableName);
    if (scriptName != null) {
        list.add(FilenameUtils.normalize(scriptName.getAbsolutePath()));
    }
    if (!args.isEmpty()) {
        list.addAll(args);
    }

    pb.command(list);
    if (logger.isDebugEnabled()) {
        logger.debug("ProcessBuilder.command = " + StringUtils.join(pb.command(), " "));
    }

    if (outputFile != null) {
        logger.debug("redirectOutput an redirectError set to "
                + FilenameUtils.normalize(outputFile.getAbsolutePath()));
        pb.redirectOutput(outputFile);
        pb.redirectError(outputFile);
    } else {
        logger.debug("redirectOutput set to inheritIO");
        pb.inheritIO();
    }
}