Example usage for org.apache.commons.collections OrderedMap firstKey

List of usage examples for org.apache.commons.collections OrderedMap firstKey

Introduction

In this page you can find the example usage for org.apache.commons.collections OrderedMap firstKey.

Prototype

public Object firstKey();

Source Link

Document

Gets the first key currently in this map.

Usage

From source file:edu.harvard.iq.dvn.core.web.StudyListing.java

public static String addToStudyListingMap(StudyListing sl, Map sessionMap) {
    Long slCount = (Long) sessionMap.get("studyListingsCount");
    OrderedMap slMap = (OrderedMap) sessionMap.get("studyListings");
    String sessionId = ((HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false))
            .getId();//  w w  w. j  a v a  2 s  .  c  o m

    if (slCount == null) {
        slCount = new Long(0);

    } else {
        slCount = slCount + 1;
    }

    if (slMap == null) {
        slMap = new LinkedMap();
        sessionMap.put("studyListings", slMap);
    }

    sessionMap.put("studyListingsCount", slCount);
    String newIndex = slCount + "_" + sessionId;
    slMap.put(newIndex, sl);

    if (slMap.size() > 5) {
        slMap.remove(slMap.firstKey());
    }

    return newIndex;
}