Example usage for java.util LinkedHashMap LinkedHashMap

List of usage examples for java.util LinkedHashMap LinkedHashMap

Introduction

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

Prototype

public LinkedHashMap() 

Source Link

Document

Constructs an empty insertion-ordered LinkedHashMap instance with the default initial capacity (16) and load factor (0.75).

Usage

From source file:com.mapr.data.sputnik.JsonGenerator.java

public Map<String, Object> testMapGenerator(String config) throws IOException {
    Map<String, Object> props = JSONConfigReader
            .readConfig(this.getClass().getClassLoader().getResourceAsStream(config), Map.class);
    Map<String, Object> wrapper = new LinkedHashMap<>();
    wrapper.put(null, props);// ww  w.  j  a v  a2  s  . c  o  m
    RandomJsonGenerator generator = new RandomJsonGenerator(wrapper);
    Map<String, Object> map = generator.generateJsonMap();
    return map;
}

From source file:com.opengamma.analytics.financial.curve.building.CurveBuildingBlockBundle.java

/**
 * Constructor./*from w ww .j  ava  2  s  . co  m*/
 * An empty map is created.
 */
public CurveBuildingBlockBundle() {
    _bundle = new LinkedHashMap<String, Pair<CurveBuildingBlock, DoubleMatrix2D>>();
}

From source file:controllers.KWProxy.java

public static F.Promise<Result> index(String query) {

    if (StringUtils.isEmpty(query)) {

        F.Promise.promise(new F.Function0<Object>() {
            @Override//from w ww.  j  av  a  2s .  com
            public Object apply() throws Throwable {
                return ok(Json.toJson("Query parameter (q) not provided "));
            }

        });
    }

    F.Promise<WSResponse> wsResponsePromise = WS.url("http://knowledge.wharton.upenn.edu/")
            .setQueryParameter("s", query).get();

    return wsResponsePromise.map(new F.Function<WSResponse, Result>() {
        @Override
        public Result apply(WSResponse wsResponse) throws Throwable {

            String body = wsResponse.getBody();

            List<Map<String, String>> results = new ArrayList<Map<String, String>>();

            try {

                // Insert into map
                org.jsoup.nodes.Document doc = Jsoup.parse(body);
                Elements items = doc.select("div.article.type-article.status-publish"); // All articles belong to this classes

                for (Element item : items) {
                    Map<String, String> keyValue = new LinkedHashMap<String, String>();

                    // Check if specific article belongs to "has-post-thumbnail" class (therefore it contains an image)
                    if (item.hasClass("has-post-thumbnail")) {
                        // Add image key and value to map
                        keyValue.put("image", item.select("img").attr("src"));
                    }

                    // Add the rest of keys and values
                    keyValue.put("title", item.select("h2").select("a").text());
                    keyValue.put("content", item.select("div.attribute.categorythumbs").first().text());
                    keyValue.put("date", item.select("ul.datestamp").select("li").first().text());
                    keyValue.put("url", item.select("h2").select("a").attr("href"));

                    results.add(keyValue);
                }
            } catch (DOMException e) {
                e.printStackTrace();
            }

            return ok(Json.toJson(results));
        }
    });
}

From source file:bz.tsung.jsonapi4j.models.JsonApiDocument.java

public JsonApiDocument() {
    links = new LinkedHashMap<String, String>();
    included = new ArrayList<Resource>();
    includedRecs = new LinkedHashSet<Resource>();
    data = null;/*from w w  w. j  a  v  a  2s . c om*/
}

From source file:org.kitodo.data.index.elasticsearch.type.HistoryType.java

@SuppressWarnings("unchecked")
@Override//from  w ww  .  j  a v  a 2  s. c  o m
public HttpEntity createDocument(History history) {

    LinkedHashMap<String, String> orderedHistoryMap = new LinkedHashMap<>();
    orderedHistoryMap.put("numericValue", history.getNumericValue().toString());
    orderedHistoryMap.put("stringValue", history.getStringValue());
    orderedHistoryMap.put("type", history.getHistoryType().toString());
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String date = history.getDate() != null ? dateFormat.format(history.getDate()) : null;
    orderedHistoryMap.put("date", date);
    orderedHistoryMap.put("process", history.getProcess().getId().toString());

    JSONObject historyObject = new JSONObject(orderedHistoryMap);

    return new NStringEntity(historyObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:com.ims.service.CustomerService.java

public Map<String, CustomerProductCodeMap> getCustomerProdCodeMap() {
    Map<String, CustomerProductCodeMap> customerProductCodeMapping = new LinkedHashMap<String, CustomerProductCodeMap>();
    List<CustomerProductCodeMap> codeMaps = this.getCustomerProdCodeMapList();
    for (CustomerProductCodeMap codeMap : codeMaps) {
        customerProductCodeMapping.put(codeMap.getCustomerProductCode(), codeMap);
    }//from www  .  j ava2 s. c o m
    return customerProductCodeMapping;
}

From source file:com.glaf.core.util.QueryUtils.java

public static SqlExecutor getMyBatisAndConditionSql(List<QueryCondition> conditions) {
    SqlExecutor se = new SqlExecutor();
    Map<String, Object> params = new LinkedHashMap<String, Object>();
    StringBuffer buffer = new StringBuffer(1000);
    if (conditions != null && !conditions.isEmpty()) {
        int index = 0;
        Iterator<QueryCondition> iter = conditions.iterator();
        while (iter.hasNext()) {
            index++;/*from  w w w  .j a v  a  2 s .c o  m*/
            QueryCondition c = iter.next();
            buffer.append(FileUtils.newline);
            String column = c.getColumn();
            String filter = c.getFilter();
            String alias = c.getAlias();
            params.put("param_" + index, c.getValue());
            String operator = " = ";
            if (StringUtils.isNotEmpty(filter)) {
                if (SearchFilter.GREATER_THAN.equals(filter)) {
                    operator = SearchFilter.GREATER_THAN;
                } else if (SearchFilter.GREATER_THAN_OR_EQUAL.equals(filter)) {
                    operator = SearchFilter.GREATER_THAN_OR_EQUAL;
                } else if (SearchFilter.LESS_THAN.equals(filter)) {
                    operator = SearchFilter.LESS_THAN;
                } else if (SearchFilter.LESS_THAN_OR_EQUAL.equals(filter)) {
                    operator = SearchFilter.LESS_THAN_OR_EQUAL;
                } else if (SearchFilter.LIKE.equals(filter)) {
                    operator = SearchFilter.LIKE;
                } else if (SearchFilter.NOT_LIKE.equals(filter)) {
                    operator = SearchFilter.NOT_LIKE;
                } else if (SearchFilter.EQUALS.equals(filter)) {
                    operator = SearchFilter.EQUALS;
                } else if (SearchFilter.NOT_EQUALS.equals(filter)) {
                    operator = SearchFilter.NOT_EQUALS;
                } else {
                    operator = SearchFilter.EQUALS;
                }
            }
            if (StringUtils.isNotEmpty(alias)) {
                buffer.append(" and ").append(alias).append(".").append(column).append(" ").append(operator)
                        .append(" #{").append("param_" + index).append("} ");
            } else {
                buffer.append(" and ").append(column).append(" ").append(operator).append(" #{")
                        .append("param_" + index).append("} ");
            }
        }
    }

    se.setSql(buffer.toString());
    se.setParameter(params);

    return se;
}

From source file:com.intel.cosbench.driver.util.OperationPicker.java

public OperationPicker() {
    Map<Integer, String> ops = new LinkedHashMap<Integer, String>();
    this.ops = ops;
    this.last = 0;
}

From source file:com.yahoo.elide.jsonapi.models.JsonApiDocument.java

public JsonApiDocument(Data<Resource> data) {
    links = new LinkedHashMap<>();
    included = new ArrayList<>();
    includedRecs = new LinkedHashSet<>();
    this.data = data;
}

From source file:org.kitodo.data.index.elasticsearch.type.BatchType.java

@SuppressWarnings("unchecked")
@Override/*w  ww  .  j a  va2s. c  om*/
public HttpEntity createDocument(Batch batch) {

    LinkedHashMap<String, String> orderedBatchMap = new LinkedHashMap<>();
    orderedBatchMap.put("title", batch.getTitle());
    String type = batch.getType() != null ? batch.getType().toString() : "null";
    orderedBatchMap.put("type", type);

    JSONArray processes = new JSONArray();
    List<Process> batchProcesses = batch.getProcesses();
    for (Process process : batchProcesses) {
        JSONObject processObject = new JSONObject();
        processObject.put("id", process.getId().toString());
        processes.add(processObject);
    }

    JSONObject batchObject = new JSONObject(orderedBatchMap);
    batchObject.put("processes", processes);

    return new NStringEntity(batchObject.toJSONString(), ContentType.APPLICATION_JSON);
}