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.addthis.bundle.core.kvp.KVBundle.java

public KVBundle(KVBundleFormat format) {
    this(format, new LinkedHashMap<String, ValueObject>());
}

From source file:org.uaa.security.core.LoginSuccessHandler.java

public void handle(UsernamePasswordToken token, HttpServletRequest request, HttpServletResponse response) {
    // set cookie
    Map<String, Object> session = new LinkedHashMap<String, Object>();
    session.put("uid", token.getUid());
    session.put("username", token.getUsername());
    session.put("password", token.getPassword());
    session.put("roles", token.getRoles());
    session.put("isAuthenticated", token.isAuthenticated());

    try {//  w w  w .j a  v  a2  s  . co m
        String sessionId = Crypto.encrypt(JsonFactory.toJson(session));
        log.debug(sessionId);
        Cookie cookie = new Cookie(ConfigUtil.getValue("SESSION_ID"), sessionId);
        cookie.setMaxAge(7 * 24 * 3600);
        response.addCookie(cookie);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.SimpleParameterSensitivity.java

/**
 * Default constructor, creating an empty LinkedHashMap for the sensitivity.
 */
public SimpleParameterSensitivity() {
    _sensitivity = new LinkedHashMap<>();
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent.java

@Override
public Map<String, String> getOptions(EditConfigurationVTwo editConfig, String fieldName,
        WebappDaoFactory wDaoFact) throws Exception {

    HashMap<String, String> optionsMap = new LinkedHashMap<String, String>();
    // first test to see whether there's a default "leave blank" value specified with the literal options        
    if (!StringUtils.isEmpty(defaultOptionLabel)) {
        optionsMap.put(LEFT_BLANK, defaultOptionLabel);
    }/*  w w  w  .ja v  a  2s  .  c  om*/

    optionsMap.put(classUri, "Other");

    VClassDao vclassDao = wDaoFact.getVClassDao();
    List<String> subClassList = vclassDao.getAllSubClassURIs(classUri);
    if (subClassList != null && subClassList.size() > 0) {
        for (String subClassUri : subClassList) {
            VClass subClass = vclassDao.getVClassByURI(subClassUri);
            if (subClass != null && !OWL.Nothing.getURI().equals(subClassUri)) {
                optionsMap.put(subClassUri, subClass.getName().trim());
            }
        }
    }
    return optionsMap;
}

From source file:de.alpharogroup.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 w  w  . jav  a  2 s  .  co  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(final 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 (final 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;
        }
        final ImportResource[] array = (ImportResource[]) ArrayUtils.addAll(importResourceArray,
                importResourcesArray);
        Arrays.sort(array, new ImportResourceComparator());
        resourcesMap.put(annotatedClass, array);

    }
    return resourcesMap;
}

From source file:ch.cyberduck.core.Cache.java

public Cache(int size) {
    if (size == Integer.MAX_VALUE) {
        // Unlimited
        impl = Collections.synchronizedMap(new LinkedHashMap<T, AttributedList<T>>());
        reverse = Collections.synchronizedMap(new LinkedHashMap<CacheReference, T>());
    } else if (size == 0) {
        impl = Collections.emptyMap();
        reverse = Collections.emptyMap();
    } else {//ww w .  jav a2s .  co  m
        // Will inflate to the given size
        impl = Collections.synchronizedMap(new LRUMap<T, AttributedList<T>>(size));
        reverse = Collections.synchronizedMap(new LinkedHashMap<CacheReference, T>());
    }
}

From source file:com.tussle.postprocess.PostprocessSystem.java

public PostprocessSystem(int p) {
    super(p);/* ww w.  j av  a2s . c  o m*/
    componentListMap = LazyMap.lazyMap(new LinkedHashMap<Class<Component>, Map<Entity, PostprocessStep>>(),
            () -> LazyMap.lazyMap(new LinkedHashMap<>(), FactoryUtils.constantFactory(((Component c) -> {
            }))));
}

From source file:net.jmhertlein.mcanalytics.api.request.PastOnlinePlayerCountRequest.java

@Override
public LinkedHashMap<LocalDateTime, Integer> processResponse(JSONObject response) {
    JSONObject counts = response.getJSONObject("counts");
    LinkedHashMap<LocalDateTime, Integer> ret = new LinkedHashMap<>();

    for (String s : counts.keySet()) {
        ret.put(LocalDateTime.parse(s), counts.getInt(s));
    }/*from w w  w  .ja va 2 s . com*/

    return ret;
}

From source file:com.jaeksoft.searchlib.scheduler.TaskProperties.java

public TaskProperties(Config config, TaskAbstract task, TaskPropertyDef[] propertyDefs) {
    map = new LinkedHashMap<TaskPropertyDef, TaskProperty>();
    if (propertyDefs == null)
        return;/*from w  ww  .  j a v a2 s . c  o m*/
    cache = new TaskProperty[propertyDefs.length];
    int i = 0;
    for (TaskPropertyDef propertyDef : propertyDefs) {
        TaskProperty taskProperty = new TaskProperty(config, task, propertyDef);
        map.put(propertyDef, taskProperty);
        cache[i++] = taskProperty;
    }
}

From source file:controllers.CNBCProxy.java

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

    if (StringUtils.isEmpty(query)) {

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

        });
    }

    String target = "all";
    String categories = "exclude";
    String partnerId = "2000";
    // ?target=all&categories=exclude&partnerId=2000&keywords=apple
    F.Promise<WSResponse> wsResponsePromise = WS.url("http://search.cnbc.com/main.do")
            .setQueryParameter("target", target).setQueryParameter("categories", categories)
            .setQueryParameter("partnerId", partnerId).setQueryParameter("keywords", 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 {
                // Parse html document
                org.jsoup.nodes.Document doc = Jsoup.parse(body);
                Elements items = doc.select("div:not(.clr).padL.padR"); // Choose elements that contain classes "padL" and "padR", but not "clr"

                // Iterate through results
                for (Element item : items) {

                    Map<String, String> keyValue = new LinkedHashMap<String, String>();

                    // Add the keys and values
                    keyValue.put("title", item.select("a").text());
                    keyValue.put("content", item.select("span.cnbc_bio_content").text());
                    keyValue.put("date", CalculateDateFormat(Long
                            .parseLong(item.getElementsByTag("script").html().replaceAll("[^0-9]", ""), 10))); // Edit the date format
                    keyValue.put("url", item.select("a").attr("href"));

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

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