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.opengamma.analytics.financial.provider.curve.CurveBuildingBlockBundle.java

/**
 * Constructor.
 * An empty map is created.
 */
public CurveBuildingBlockBundle() {
    _bundle = new LinkedHashMap<>();
}

From source file:controllers.TAXIProxy.java

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

    if (StringUtils.isEmpty(query)) {

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

        });
    }

    final String baseUrl = "http://designtaxi.com/";

    F.Promise<WSResponse> wsResponsePromise = WS.url(baseUrl + "news-search.php")
            .setQueryParameter("news_keyword", 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.news-cover");

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

                    keyValue.put("image", baseUrl + item.select("img").attr("src"));
                    keyValue.put("title", item.select("a.addthis_button_expanded").attr("addthis:title"));

                    // Connect to each and every article to get date and first sentence as content
                    try {
                        org.jsoup.nodes.Document articleDoc = Jsoup
                                .connect(item.select("a.addthis_button_expanded").attr("addthis:url"))
                                .userAgent("Mozilla").get();

                        // If connection successful(STATUS 200), the add content and date keys to map
                        keyValue.put("content", articleDoc.select("div#news-content").text().substring(0,
                                articleDoc.select("div#news-content").text().indexOf(".") + 1) + ".");
                        keyValue.put("date", articleDoc.select("span.date").text());

                    } catch (IOException e) {
                        System.out.println(e);
                    }

                    keyValue.put("url", item.select("a.addthis_button_expanded").attr("addthis:url"));

                    results.add(keyValue);
                }

            } catch (DOMException e) {
                e.printStackTrace();
            }

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

From source file:asu.edu.msse.gpeddabu.moviedescriptions.MovieLibrary.java

MovieLibrary(String jsonString) {
    if (movieMap == null) {
        movieMap = new LinkedHashMap<>();
        JSONObject jsonObj;/*from  w  w  w . java  2  s. c om*/
        LinkedHashMap<String, JSONObject> movieDescr;
        try {
            jsonObj = new JSONObject(jsonString);
            Iterator<String> iter = jsonObj.keys();
            while (iter.hasNext()) {
                String name = iter.next();
                JSONObject movie = (JSONObject) jsonObj.get(name);
                if (movieMap.containsKey(movie.get("Genre").toString())) {
                    movieDescr = movieMap.get(movie.get("Genre").toString());
                    movieDescr.put(name, movie);
                } else {
                    movieDescr = new LinkedHashMap<String, JSONObject>();
                    movieDescr.put(name, movie);
                    movieMap.put(movie.get("Genre").toString(), movieDescr);
                }

            }
        } catch (Exception e) {
            android.util.Log.e(e.toString(), "Error in converting JSON String to JSON Object");
        }
    }
}

From source file:com.github.ferstl.depgraph.graph.dot.DotAttributeBuilder.java

public DotAttributeBuilder() {
    this.attributes = new LinkedHashMap<>();
}

From source file:com.yahoo.elide.utils.coerce.converters.FromMapConverterTest.java

@Test
public void testMapToClass() throws Exception {

    //Input Map/* www.  java  2 s.co m*/
    Map<String, Object> nestedMap = new LinkedHashMap<>();
    nestedMap.put("field1", "value3");
    nestedMap.put("field2", "value4");

    Map<String, Object> testMap = new LinkedHashMap<>();
    testMap.put("field1", "value1");
    testMap.put("field2", "value2");
    testMap.put("nestedField", nestedMap);

    //ExpectedObject
    TestClass nestedClass = new TestClass("value3", "value4", null);
    TestClass testClass = new TestClass("value1", "value2", nestedClass);

    assertEquals(converter.convert(TestClass.class, testMap), testClass,
            "Map converter correctly converted Map to TestClass");
}

From source file:jp.primecloud.auto.sdk.client.component.StartComponent.java

public void execute(Long componentNo, List<Long> instanceNos) {
    Map<String, String> parameters = new LinkedHashMap<String, String>();
    parameters.put("ComponentNo", componentNo.toString());
    parameters.put("InstanceNos", StringUtils.join(instanceNos, ","));

    requester.execute("/StartComponent", parameters);
}

From source file:eionet.cr.harvest.util.MediaTypeToDcmiTypeConverter.java

/**
 * Loads the mimetypes from the file and puts them into mimeToRdfMap.
 *///from  ww w.j a  v a  2  s.c o m
private static void initialize() {

    mappings = new LinkedHashMap<String, String>();

    InputStream inputStream = null;
    Properties properties = new Properties();
    try {
        inputStream = MediaTypeToDcmiTypeConverter.class.getClassLoader()
                .getResourceAsStream(MAPPINGS_FILENAME);
        properties.loadFromXML(inputStream);
    } catch (IOException e) {
        LOGGER.error("Failed to load XML-formatted properties from " + MAPPINGS_FILENAME, e);
    } finally {
        if (inputStream != null) {
            IOUtils.closeQuietly(inputStream);
        }
    }

    if (!properties.isEmpty()) {

        for (Map.Entry entry : properties.entrySet()) {

            String rdfType = entry.getKey().toString();
            String[] mediaTypes = entry.getValue().toString().split("\\s+");

            if (!StringUtils.isBlank(rdfType) && mediaTypes != null && mediaTypes.length > 0) {

                for (int i = 0; i < mediaTypes.length; i++) {

                    if (!StringUtils.isBlank(mediaTypes[i])) {

                        mappings.put(mediaTypes[i].trim(), rdfType.trim());
                    }
                }
            }
        }
    }
}

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

@SuppressWarnings("unchecked")
@Override//from www .j a v a2  s  .c o  m
public HttpEntity createDocument(User user) {

    LinkedHashMap<String, String> orderedUserMap = new LinkedHashMap<>();
    orderedUserMap.put("name", user.getName());
    orderedUserMap.put("surname", user.getSurname());
    orderedUserMap.put("login", user.getLogin());
    orderedUserMap.put("ldapLogin", user.getLdapLogin());
    orderedUserMap.put("active", String.valueOf(user.isActive()));
    orderedUserMap.put("location", user.getLocation());
    orderedUserMap.put("metadataLanguage", user.getMetadataLanguage());
    String ldapGroup = user.getLdapGroup() != null ? user.getLdapGroup().getId().toString() : "null";
    orderedUserMap.put("ldapGroup", ldapGroup);

    JSONObject userObject = new JSONObject(orderedUserMap);

    JSONArray userGroups = new JSONArray();
    List<UserGroup> userUserGroups = user.getUserGroups();
    for (UserGroup userGroup : userUserGroups) {
        JSONObject userGroupObject = new JSONObject();
        userGroupObject.put("id", userGroup.getId().toString());
        userGroups.add(userGroupObject);
    }
    userObject.put("userGroups", userGroups);

    JSONArray properties = new JSONArray();
    List<UserProperty> userProperties = user.getProperties();
    for (UserProperty property : userProperties) {
        JSONObject propertyObject = new JSONObject();
        propertyObject.put("title", property.getTitle());
        propertyObject.put("value", property.getValue());
        properties.add(propertyObject);
    }
    userObject.put("properties", properties);

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

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

/**
 * Constructor from a map. A new map is created.
 * @param block The curve block. Not null.
 *//* w w  w.j a v  a 2s .c  o m*/
public CurveBuildingBlock(LinkedHashMap<String, Pair<Integer, Integer>> block) {
    ArgumentChecker.notNull(block, "Curve building block");
    _unit = new LinkedHashMap<String, Pair<Integer, Integer>>();
    _unit.putAll(block);
}

From source file:ch.ralscha.extdirectspring.bean.MetaData.java

public MetaData() {
    metaData = new LinkedHashMap<String, Object>();
    metaData.put("root", "records");
    metaData.put("totalProperty", "total");
    metaData.put("successProperty", "success");
}