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:net.sourceforge.jaulp.io.annotations.ImportResourcesUtils.java

/**
 * Gets a map with ImportResource objects and the corresponding to the found class from the
 * given package Name. The search is made recursive. The key from an entry of the map is the
 * class where the ImportResource objects found and the value is an Array of the ImportResource
 * objects that contains in the class./*from  w ww.  ja  v a2 s .c o  m*/
 * 
 * @param packageName
 *            the package name
 * @return the import resources
 * @throws ClassNotFoundException
 *             the class not found exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public static Map<Class<?>, ImportResource[]> getImportResources(String packageName)
        throws ClassNotFoundException, IOException {
    final Map<Class<?>, ImportResource[]> resourcesMap = new LinkedHashMap<>();

    final Class<ImportResources> importResourcesClass = ImportResources.class;
    final Class<ImportResource> importResourceClass = ImportResource.class;
    final Set<Class<?>> importResourcesClasses = AnnotationUtils.getAllAnnotatedClasses(packageName,
            importResourcesClass);
    final Set<Class<?>> importResourceClasses = AnnotationUtils.getAllAnnotatedClasses(packageName,
            importResourceClass);
    importResourcesClasses.addAll(importResourceClasses);
    for (Class<?> annotatedClass : importResourcesClasses) {
        final ImportResources importResources = annotatedClass.getAnnotation(ImportResources.class);
        ImportResource[] importResourcesArray = null;
        ImportResource[] importResourceArray = null;
        if (importResources != null) {
            importResourcesArray = importResources.resources();
        }

        final ImportResource importResource = annotatedClass.getAnnotation(ImportResource.class);
        if (importResource != null) {
            importResourceArray = new ImportResource[1];
            importResourceArray[0] = importResource;
        }
        ImportResource[] array = (ImportResource[]) ArrayUtils.addAll(importResourceArray,
                importResourcesArray);
        Arrays.sort(array, new ImportResourceComparator());
        resourcesMap.put(annotatedClass, array);

    }
    return resourcesMap;
}

From source file:com.tulskiy.musique.plugins.hotkeys.HotkeyConfiguration.java

public static Map<KeyStroke, HotKeyEvent> getHotkeys(Logger logger) {
    Configuration config = Application.getInstance().getConfiguration();
    List<String> hotkeysRaw = (List<String>) config.getList(getHotkeyKey());
    Map<KeyStroke, HotKeyEvent> hotkeys = new LinkedHashMap<KeyStroke, HotKeyEvent>();
    if (!CollectionUtils.isEmpty(hotkeysRaw)) {
        for (String hotkeyRaw : hotkeysRaw) {
            try {
                String[] tokens = hotkeyRaw.split(": ");

                HotKeyEvent event = HotKeyEvent.valueOf(tokens[0]);
                KeyStroke keyStroke = KeyStroke.getKeyStroke(tokens[1]);

                hotkeys.put(keyStroke, event);
            } catch (IllegalArgumentException e) {
                logger.warning("Could not parse hotkey for string: " + hotkeyRaw);
            }/* ww w.ja  v a 2  s .  co  m*/
        }
    }

    return hotkeys;
}

From source file:com.hp.autonomy.iod.client.api.search.FieldNamesTest.java

@Before
public void initialize() {
    final Map<String, Integer> fieldValue0 = new LinkedHashMap<>();
    fieldValue0.put("1", 1);
    fieldValue0.put("2", 2);

    final Map<String, Integer> fieldValue1 = new LinkedHashMap<>();
    fieldValue1.put("3", 3);
    fieldValue1.put("4", 4);
    fieldValue1.put("5", 5);

    fieldNames = new FieldNames.Builder().addParametricValue("zero", fieldValue0)
            .addParametricValue("one", fieldValue1).build();
}

From source file:com.mirth.connect.server.migration.Migrate2_2_0.java

@Override
public Map<String, Object> getConfigurationPropertiesToAdd() {
    Map<String, Object> propertiesToAdd = new LinkedHashMap<String, Object>();
    propertiesToAdd.put("password.retrylimit", 0);
    propertiesToAdd.put("password.lockoutperiod", 0);
    propertiesToAdd.put("password.expiration", 0);
    propertiesToAdd.put("password.graceperiod", 0);
    propertiesToAdd.put("password.reuseperiod", 0);
    propertiesToAdd.put("password.reuselimit", 0);
    return propertiesToAdd;
}

From source file:controllers.BIProxy.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 av  a2  s .c  om
            public Object apply() throws Throwable {
                return ok(Json.toJson("Query parameter (q) not provided "));
            }

        });
    }

    F.Promise<WSResponse> wsResponsePromise = WS.url("http://www.businessinsider.com/s")
            .setQueryParameter("q", 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.search-result");

                // Iterate through results
                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("h3").text());
                    keyValue.put("content", item.select("div.excerpt").first().text());
                    keyValue.put("date", item.select("li.date").text());
                    keyValue.put("url", item.select("a").attr("href"));

                    results.add(keyValue);
                }

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

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

From source file:org.wallride.web.support.RestValidationErrorModel.java

public static RestValidationErrorModel fromBindingResult(BindingResult result,
        MessageSourceAccessor messageSourceAccessor) {
    RestValidationErrorModel restResult = new RestValidationErrorModel();
    restResult.globalErrors = new ArrayList<>();
    for (ObjectError error : result.getGlobalErrors()) {
        restResult.globalErrors.add(/*from   w w w.j  a v a  2s .co m*/
                messageSourceAccessor.getMessage(error.getDefaultMessage(), LocaleContextHolder.getLocale()));
    }
    restResult.fieldErrors = new LinkedHashMap<>();
    for (FieldError error : result.getFieldErrors()) {
        restResult.fieldErrors.put(error.getField(),
                messageSourceAccessor.getMessage(error, LocaleContextHolder.getLocale()));
    }
    return restResult;
}

From source file:com.smartitengineering.dao.impl.hbase.JsonConfigLoaderTest.java

@BeforeClass
public static void setupConfigs() {
    Map<String, FilterConfig> map = new LinkedHashMap<String, FilterConfig>();
    FilterConfigImpl configImpl = new FilterConfigImpl();
    configImpl.setColumnFamilyAsString("test");
    configImpl.setColumnQualifierAsString("id");
    configImpl.setFilterOnIfMissing(true);
    configImpl.setFilterOnLatestVersionOnly(true);
    configImpl.setQualifierARangePrefix(true);
    configImpl.setFilterOnRowId(true);/*from  www .  j  a  v  a2s  .c  o  m*/
    map.put("id", configImpl);
    configImpl = new FilterConfigImpl();
    configImpl.setColumnFamilyAsString("test");
    configImpl.setColumnQualifierAsString("name");
    map.put("name", configImpl);
    CONFIGS.setConfigs(map);
}

From source file:edu.stanford.muse.util.ThunderbirdUtils.java

private static Map<String, String> readUserPrefs(String prefsFile) throws IOException {
    // parse lines like 
    // user_pref("mail.server.server2.directory-rel", "[ProfD]Mail/Local Folders");
    // to create a map of user_pref's
    Map<String, String> map = new LinkedHashMap<String, String>();
    LineNumberReader lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(prefsFile), "UTF-8"));
    while (true) {
        String line = lnr.readLine();
        if (line == null) {
            lnr.close();//ww  w  .  j  a va 2  s.c o m
            break;
        }

        line = line.trim();
        // parse the line. maybe this is better done with regexps
        String startSig = "user_pref(";
        if (line.startsWith(startSig)) {
            line = line.substring(startSig.length());
            int idx = line.indexOf(",");
            if (idx < 0)
                continue; // not expected format, bail out
            String result[] = Util.splitIntoTwo(line, ',');
            String key = result[0].trim(), value = result[1].trim();

            if (!value.endsWith(");"))
                continue; // not expected format, bail out   

            value = value.substring(0, value.length() - ");".length()); // strip out the );
            value = value.trim();

            // now remove quotes if present
            if (key.startsWith("\""))
                key = key.substring(1);
            if (value.startsWith("\""))
                value = value.substring(1);
            if (key.endsWith("\""))
                key = key.substring(0, key.length() - 1);
            if (value.endsWith("\""))
                value = value.substring(0, value.length() - 1);
            map.put(key, value);
        }
    }
    log.info(map.size() + " Thunderbird preferences read from " + prefsFile);
    return map;
}

From source file:controllers.FRBProxy.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  .ja  v  a 2s. c om
            public Object apply() throws Throwable {
                return ok(Json.toJson("Query parameter (q) not provided "));
            }

        });
    }

    F.Promise<WSResponse> wsResponsePromise = WS.url("http://www.forbes.com/search/")
            .setQueryParameter("q", 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.edittools-contentitem"); // All articles belong to this class

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

                    // Check if specific article belongs to gallery class (therefore it contains an image)
                    if (item.hasClass("gallery")) {
                        // 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("p").first().ownText());
                    keyValue.put("date", item.select("time").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:com.qwazr.search.bench.test.TestResults.java

public TestResults() {
    this.statsMap = new LinkedHashMap<>();
}