Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 15th, 2011  |  syntax: None  |  size: 0.53 KB  |  views: 42  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. @ConversationScoped
  2. public class ObjectStore implements Serializable
  3. {
  4.         private static final long serialVersionUID = 1L;
  5.  
  6.         private BiMap<String, Object> map = HashBiMap.create();
  7.         private int key;
  8.  
  9.         public Object string2Object(String key)
  10.         {
  11.                 return map.get(key);
  12.         }
  13.  
  14.         public String object2String(Object object)
  15.         {
  16.                 if (map.inverse().containsKey(object))
  17.                 {
  18.                         return map.inverse().get(object);
  19.                 }
  20.                 else
  21.                 {
  22.                         String strKey = String.valueOf(key++);
  23.                         map.put(strKey, object);
  24.                         return strKey;
  25.                 }
  26.         }
  27.  
  28. }
clone this paste RAW Paste Data