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.CurveBuildingBlock.java

/**
 * Constructor.
 */
public CurveBuildingBlock() {
    _unit = new LinkedHashMap<>();
}

From source file:controllers.WDCDProxy.java

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

    if (StringUtils.isEmpty(query)) {

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

        });
    }

    F.Promise<WSResponse> wsResponsePromise = WS.url("http://www.whatdesigncando.com/")
            .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.item");

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

                    String imageUrl = item.select("a").attr("style");

                    keyValue.put("image", imageUrl.substring(imageUrl.indexOf("'") + 1,
                            imageUrl.indexOf("'", imageUrl.indexOf("'") + 1)));
                    keyValue.put("title", item.select("h3").text());

                    // Get date and the first sentence as "content" from each article separately (or the "sub-title" tag)
                    org.jsoup.nodes.Document articleDoc = Jsoup.connect(item.select("a").attr("href")).get();

                    String datePublished = articleDoc.select("div#maincontent p.metainfo").text().substring(0,
                            articleDoc.select("div#maincontent p.metainfo").text().indexOf("Published"));
                    String firstSentence;

                    if (articleDoc.select("div#maincontent p.sub-title").text().length() == 0) {
                        firstSentence = articleDoc.select("div#maincontent p:not(.metainfo)").text().substring(
                                0,
                                articleDoc.select("div#maincontent p:not(.metainfo)").text().indexOf(".") + 1);
                        firstSentence = firstSentence + ".";
                    } else {
                        firstSentence = articleDoc.select("div#maincontent p.sub-title").text();
                        firstSentence = firstSentence + "..";
                    }

                    keyValue.put("content", firstSentence);
                    keyValue.put("date", datePublished);
                    keyValue.put("url", item.select("a").attr("href"));

                    results.add(keyValue);
                }

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

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

From source file:controllers.NWProxy.java

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

    if (StringUtils.isEmpty(query)) {

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

        });
    }

    final String officialUrl = "http://www.newsweek.com";

    F.Promise<WSResponse> wsResponsePromise = WS.url(officialUrl + "/search/site/" + 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("li.search-result"); // All articles belong to this class

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

                    keyValue.put("image", item.select("img").attr("src"));
                    keyValue.put("title", item.select("h2").select("a").text());
                    keyValue.put("content", item.select("div.article-summary").first().text());

                    // Get date from each article separately
                    org.jsoup.nodes.Document articleDoc = RedirectionHandler(
                            officialUrl + item.select("a").attr("href"));

                    keyValue.put("date", articleDoc.select("span.timedate").text());
                    keyValue.put("url", officialUrl + item.select("a").attr("href"));

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

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

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

@SuppressWarnings("unchecked")
@Override/*from w ww .j  a v a 2s. c  om*/
public HttpEntity createDocument(UserGroup userGroup) {

    LinkedHashMap<String, String> orderedUserGroupMap = new LinkedHashMap<>();
    orderedUserGroupMap.put("title", userGroup.getTitle());
    orderedUserGroupMap.put("permission", userGroup.getPermission().toString());

    JSONArray users = new JSONArray();
    List<User> userGroupUsers = userGroup.getUsers();
    for (User user : userGroupUsers) {
        JSONObject userObject = new JSONObject();
        userObject.put("id", user.getId().toString());
        users.add(userObject);
    }

    JSONObject userGroupObject = new JSONObject(orderedUserGroupMap);
    userGroupObject.put("users", users);

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

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

@SuppressWarnings("unchecked")
@Override//from w  w  w  . jav a2  s  . c  o  m
public HttpEntity createDocument(Template template) {

    LinkedHashMap<String, String> orderedTemplateMap = new LinkedHashMap<>();
    String process = template.getProcess() != null ? template.getProcess().getId().toString() : "null";
    orderedTemplateMap.put("process", process);

    JSONObject processObject = new JSONObject(orderedTemplateMap);

    JSONArray properties = new JSONArray();
    List<TemplateProperty> templateProperties = template.getProperties();
    for (TemplateProperty property : templateProperties) {
        JSONObject propertyObject = new JSONObject();
        propertyObject.put("title", property.getTitle());
        propertyObject.put("value", property.getValue());
        properties.add(propertyObject);
    }
    processObject.put("properties", properties);

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

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

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

    LinkedHashMap<String, String> orderedWorkpieceMap = new LinkedHashMap<>();
    String process = workpiece.getProcess() != null ? workpiece.getProcess().getId().toString() : "null";
    orderedWorkpieceMap.put("process", process);

    JSONObject processObject = new JSONObject(orderedWorkpieceMap);

    JSONArray properties = new JSONArray();
    List<WorkpieceProperty> workpieceProperties = workpiece.getProperties();
    for (WorkpieceProperty property : workpieceProperties) {
        JSONObject propertyObject = new JSONObject();
        propertyObject.put("title", property.getTitle());
        propertyObject.put("value", property.getValue());
        properties.add(propertyObject);
    }
    processObject.put("properties", properties);

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

From source file:com.github.ferstl.depgraph.dot.AttributeBuilder.java

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

From source file:net.sf.zekr.engine.theme.Theme.java

/**
 * Save a ThemeData configuration file.//from   w w  w .  j a  va2  s  .  com
 * 
 * @param td theme data object to be stored to the disk
 * @throws IOException
 */
public static void save(ThemeData td) throws IOException {
    OutputStreamWriter osw = new OutputStreamWriter(
            new FileOutputStream(Naming.getThemePropsDir() + "/" + td.fileName));
    LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
    map.put("name", td.name);
    map.put("author", td.author);
    map.put("version", td.version);
    map.putAll(td.props);
    ConfigUtils.write(new MapConfiguration(map), osw);
    // ConfigurationUtils.dump(new MapConfiguration(map), new PrintWriter(osw));
    IOUtils.closeQuietly(osw);
}

From source file:de.yaio.commons.config.Configuration.java

protected Configuration() {
    args = new LinkedHashMap<>();
    options = new LinkedHashMap<>();
    properties = new LinkedHashMap<>();
}

From source file:com.github.jcustenborder.kafka.connect.salesforce.TestData.java

License:asdf

public static Map<String, String> settings() {
    Map<String, String> settings = new LinkedHashMap<>();
    settings.put(SalesforceSourceConnectorConfig.CONSUMER_KEY_CONF, "sdfasdfasd");
    settings.put(SalesforceSourceConnectorConfig.CONSUMER_SECRET_CONF, "sdfasdfasd");
    settings.put(SalesforceSourceConnectorConfig.PASSWORD_CONF, "sdfasdfasd");
    settings.put(SalesforceSourceConnectorConfig.PASSWORD_TOKEN_CONF, "sdfasdfasd");
    settings.put(SalesforceSourceConnectorConfig.SALESFORCE_OBJECT_CONF, "Lead");
    settings.put(SalesforceSourceConnectorConfig.USERNAME_CONF, "Lead");
    settings.put(SalesforceSourceConnectorConfig.KAFKA_TOPIC_CONF, "salesforce.${__ObjectType}");
    settings.put(SalesforceSourceConnectorConfig.SALESFORCE_PUSH_TOPIC_NAME_CONF, "Testing");
    return settings;
}