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

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

Introduction

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

Prototype

V remove(Object key);

Source Link

Document

Removes the mapping for a key from this map if it is present (optional operation).

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  ww.  j a  va  2s.  co  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;
}