Example usage for java.util LinkedList add

List of usage examples for java.util LinkedList add

Introduction

In this page you can find the example usage for java.util LinkedList add.

Prototype

public boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this list.

Usage

From source file:de.quadrillenschule.azocamsyncd.astromode.SmartPhoneWrapper.java

public static LinkedList<PhotoSerie> getJobs() throws JSONException, IOException {

    lastStatus = SmartPhoneStatus.TRYING;
    JSONArray ja = new JSONArray(getFromSmartPhone(WebService.WebCommands.list, true));
    LinkedList<PhotoSerie> retval = new LinkedList<PhotoSerie>();
    for (int i = 0; i < ja.length(); i++) {
        PhotoSerie tps = new PhotoSerie();
        try {/* w  w  w  .  j  a va  2  s  .  c om*/
            tps.fromJSONObject(ja.getJSONObject(i));
        } catch (JSONException ex) {
            Logger.getLogger(SmartPhoneWrapper.class.getName()).log(Level.SEVERE, null, ex);
        }
        retval.add(tps);
    }
    lastStatus = SmartPhoneStatus.CONNECTED;
    return retval;

}

From source file:gr.abiss.calipso.jpasearch.specifications.GenericSpecifications.java

protected static void addPredicate(final Class clazz, Root<Persistable> root, CriteriaBuilder cb,
        LinkedList<Predicate> predicates, String[] propertyValues, String propertyName) {
    // dot notation only supports toOne.toOne.id
    if (propertyName.contains(".")) {
        // LOGGER.info("addPredicate, property name is a path: " +
        // propertyName);
        predicates
                .add(anyToOneToOnePredicateFactory.getPredicate(root, cb, propertyName, null, propertyValues));
    } else {// normal single step predicate
        Field field = GenericSpecifications.getField(clazz, propertyName);
        if (field != null) {
            // LOGGER.info("addPredicate, property: " + propertyName);
            Class fieldType = field.getType();
            IPredicateFactory predicateFactory = getPredicateFactoryForClass(field);
            // LOGGER.info("addPredicate, predicateFactory: " +
            // predicateFactory);
            if (predicateFactory != null) {
                predicates/*from w  ww.  ja  va2s .  c  o m*/
                        .add(predicateFactory.getPredicate(root, cb, propertyName, fieldType, propertyValues));
            }
        }
    }
}

From source file:eu.stratosphere.pact.test.util.TestBase.java

/**
 * Helper method to ease the pain to construct valid JUnit test parameter
 * lists//from w  w  w  .  j  av a 2s .  c  o  m
 * 
 * @param tConfigs
 *            list of PACT test configurations
 * @return list of JUnit test configurations
 * @throws IOException
 * @throws FileNotFoundException
 */
protected static Collection<Object[]> toParameterList(Class<? extends TestBase> parent,
        List<Configuration> testConfigs) throws FileNotFoundException, IOException {
    String testClassName = parent.getName();

    File configDir = new File(Constants.TEST_CONFIGS);

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

    if (configDir.isDirectory()) {
        for (File configFile : configDir.listFiles()) {
            Properties p = new Properties();
            p.load(new FileInputStream(configFile));

            for (String key : p.stringPropertyNames()) {
                if (key.endsWith(testClassName)) {
                    for (String config : p.getProperty(key).split(",")) {
                        clusterConfigs.add(config);
                    }
                }
            }
        }
    }

    if (clusterConfigs.isEmpty()) {
        LOG.warn("No test config defined for test-class '" + testClassName + "'. Using default config: '"
                + Constants.DEFAULT_TEST_CONFIG + "'.");
        clusterConfigs.add(Constants.DEFAULT_TEST_CONFIG);
    }

    LinkedList<Object[]> configs = new LinkedList<Object[]>();
    for (String clusterConfig : clusterConfigs) {
        for (Configuration testConfig : testConfigs) {
            Object[] c = { clusterConfig, testConfig };
            configs.add(c);
        }
    }

    return configs;
}

From source file:gr.abiss.calipso.jpasearch.specifications.GenericSpecifications.java

@Deprecated
protected static Predicate getPredicate(final Class clazz, final Restriction searchTerms,
        Root<Persistable> root, CriteriaBuilder cb) {
    LinkedList<Predicate> predicates = new LinkedList<Predicate>();
    Predicate predicate;/*w w w .ja  va  2  s  .c o  m*/
    // process child restrictions
    if (!CollectionUtils.isEmpty(searchTerms.getRestrictions())) {
        for (Restriction restriction : searchTerms.getRestrictions()) {
            predicates.add(getPredicate(clazz, restriction, root, cb));
        }
    }
    // process main restriction
    if (StringUtils.isNotBlank(searchTerms.getField())) {
        String propertyName = searchTerms.getField();
        addPredicate(clazz, root, cb, predicates,
                searchTerms.getValues().toArray(new String[searchTerms.getValues().size()]), propertyName);
    }
    if (searchTerms.getJunction().equals(Restriction.Junction.OR)) {
        predicate = cb.or(predicates.toArray(new Predicate[predicates.size()]));
    } else {
        predicate = cb.and(predicates.toArray(new Predicate[predicates.size()]));
    }
    return predicate;
}

From source file:eu.stratosphere.pact.test.pactPrograms.TPCHQuery9ITCase.java

@Parameters
public static Collection<Object[]> getConfigurations() {

    LinkedList<Configuration> tConfigs = new LinkedList<Configuration>();

    Configuration config = new Configuration();

    config.setInteger("TPCHQuery9ITCase#NoSubtasks", 4);
    tConfigs.add(config);

    return toParameterList(tConfigs);
}

From source file:com.ikanow.aleph2.search_service.elasticsearch.utils.ElasticsearchHiveUtils.java

/** Basic validation of the data warehouse schema
 * @param schema/*from   www  .  ja  v a2  s . c o  m*/
 * @param bucket
 * @param security_service
 * @return
 */
public static List<String> validateSchema(final DataSchemaBean.DataWarehouseSchemaBean schema,
        final DataBucketBean bucket, Optional<Client> maybe_client, ElasticsearchIndexServiceConfigBean config,
        final ISecurityService security_service) {
    final LinkedList<String> mutable_errs = new LinkedList<>();

    if (Optional.ofNullable(schema.enabled()).orElse(true)) {

        if (null == schema.main_table()) {
            mutable_errs.add(ErrorUtils.get(ERROR_INVALID_MAIN_TABLE, bucket.full_name()));
        } else {
            // Currently: auto schema not supported
            if (Optional.ofNullable(schema.main_table().table_format()).orElse(Collections.emptyMap())
                    .isEmpty()) {
                mutable_errs.add(ErrorUtils.get(ERROR_AUTO_SCHEMA_NOT_YET_SUPPORTED, bucket.full_name(),
                        MAIN_TABLE_NAME));
            } else { // check the schema is well formed
                final Validation<String, String> schema_str = generateFullHiveSchema(Optional.empty(), bucket,
                        schema, maybe_client, config);
                schema_str.validation(
                        fail -> mutable_errs.add(
                                ErrorUtils.get(ERROR_SCHEMA_ERROR, bucket.full_name(), MAIN_TABLE_NAME, fail)),
                        success -> true);
            }

            // Currently: sql query not supported
            if (Optional.ofNullable(schema.main_table().sql_query()).isPresent()) {
                mutable_errs.add(ErrorUtils.get(ERROR_SQL_QUERY_NOT_YET_SUPPORTED, bucket.full_name()));
            }

            // Can't specify view name for main table
            if (Optional.ofNullable(schema.main_table().view_name()).isPresent()) {
                mutable_errs
                        .add(ErrorUtils.get(ERROR_INVALID_MAIN_TABLE_FIELD, bucket.full_name(), "view_name"));
            }
        }
        // Currently: no views allowed

        if (!Optionals.ofNullable(schema.views()).isEmpty()) {
            mutable_errs.add(ErrorUtils.get(ERROR_NO_VIEWS_ALLOWED_YET, bucket.full_name()));
        }

        //TODO (ALEPH-17): need permission to specify table name (wait for security service API to calm down)
    }
    return mutable_errs;
}

From source file:com.qingstor.sdk.utils.QSJSONUtil.java

public static List sortJSONArray(JSONArray array) {
    LinkedList llist = new LinkedList();
    try {//from   w ww  . j  a  va2 s  . co  m
        for (int i = 0, c = array.length(); i < c; i++) {
            llist.add(array.getString(i));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    Collections.sort((List<String>) llist, new Comparator<String>() {
        @Override
        public int compare(String s1, String s2) {
            return s2.compareToIgnoreCase(s1);
        }
    });
    return llist;
}

From source file:eu.stratosphere.pact.test.contracts.UnionITCase.java

@Parameters
public static Collection<Object[]> getConfigurations() throws FileNotFoundException, IOException {
    LinkedList<Configuration> testConfigs = new LinkedList<Configuration>();

    //second input empty
    Configuration config = new Configuration();
    config.setInteger("UnionTest#NoSubtasks", 4);
    config.setString("UnionTest#ExpectedResult", MAP_RESULT);
    config.setString("UnionTest#Input1Path", inputFilePathPostfix);
    config.setString("UnionTest#Input2Path", emptyInputFilePathPostfix);
    testConfigs.add(config);

    //first input empty
    config = new Configuration();
    config.setInteger("UnionTest#NoSubtasks", 4);
    config.setString("UnionTest#ExpectedResult", MAP_RESULT);
    config.setString("UnionTest#Input1Path", emptyInputFilePathPostfix);
    config.setString("UnionTest#Input2Path", inputFilePathPostfix);
    testConfigs.add(config);//from  w  w  w  .  j  a v  a  2  s. c  o m

    //both inputs full
    config = new Configuration();
    config.setInteger("UnionTest#NoSubtasks", 4);
    config.setString("UnionTest#ExpectedResult", MAP_RESULT_TWICE);
    config.setString("UnionTest#Input1Path", inputFilePathPostfix);
    config.setString("UnionTest#Input2Path", inputFilePathPostfix);
    testConfigs.add(config);

    //both inputs empty
    config = new Configuration();
    config.setInteger("UnionTest#NoSubtasks", 4);
    config.setString("UnionTest#ExpectedResult", EMPTY_MAP_RESULT);
    config.setString("UnionTest#Input1Path", emptyInputFilePathPostfix);
    config.setString("UnionTest#Input2Path", emptyInputFilePathPostfix);
    testConfigs.add(config);

    return toParameterList(UnionITCase.class, testConfigs);
}

From source file:eu.stratosphere.test.operators.UnionSinkITCase.java

@Parameters
public static Collection<Object[]> getConfigurations() throws FileNotFoundException, IOException {
    LinkedList<Configuration> testConfigs = new LinkedList<Configuration>();

    //second input empty
    Configuration config = new Configuration();
    config.setInteger("UnionTest#NoSubtasks", 4);
    config.setString("UnionTest#ExpectedResult", MAP_RESULT);
    config.setString("UnionTest#Input1Path", inputFilePathPostfix);
    config.setString("UnionTest#Input2Path", emptyInputFilePathPostfix);
    testConfigs.add(config);

    //first input empty
    config = new Configuration();
    config.setInteger("UnionTest#NoSubtasks", 4);
    config.setString("UnionTest#ExpectedResult", MAP_RESULT);
    config.setString("UnionTest#Input1Path", emptyInputFilePathPostfix);
    config.setString("UnionTest#Input2Path", inputFilePathPostfix);
    testConfigs.add(config);//from   w  ww. ja v a2  s. c  o  m

    //both inputs full
    config = new Configuration();
    config.setInteger("UnionTest#NoSubtasks", 4);
    config.setString("UnionTest#ExpectedResult", MAP_RESULT_TWICE);
    config.setString("UnionTest#Input1Path", inputFilePathPostfix);
    config.setString("UnionTest#Input2Path", inputFilePathPostfix);
    testConfigs.add(config);

    //both inputs empty
    config = new Configuration();
    config.setInteger("UnionTest#NoSubtasks", 4);
    config.setString("UnionTest#ExpectedResult", EMPTY_MAP_RESULT);
    config.setString("UnionTest#Input1Path", emptyInputFilePathPostfix);
    config.setString("UnionTest#Input2Path", emptyInputFilePathPostfix);
    testConfigs.add(config);

    return toParameterList(UnionSinkITCase.class, testConfigs);
}

From source file:com.hp.alm.ali.idea.model.HorizonStrategy.java

private static List<String> teamFields() {
    LinkedList<String> fields = new LinkedList<String>();
    fields.add("name");
    fields.add("description");
    fields.add("release-id");
    return fields;
}