org.zkoss.util
Class FilterMap

java.lang.Object
  extended by java.util.AbstractMap
      extended by org.zkoss.util.FilterMap
All Implemented Interfaces:
Map

public class FilterMap
extends AbstractMap

A map that allows the value to be evaluated before returning (so called filtering). For example, if you allow the value to have EL expressions and want to evaluate it before returning, then you could implemnent FilterMap.Filter to evaluate the value when the value is retrieved. Then, encapsulate the original map with this class. For example,


 return new FilterMap(map,
     new FilterMap.Filter() {
         public Object filter(Object key, Object value) {
             //evaluate the value and return the result
         }
     });

Notice that this map is readonly, and it is thread-safe if the give map and the fitler are both thread safe.

Since:
5.0.7
Author:
tomyeh

Nested Class Summary
static interface FilterMap.Filter
          Filters the given value (to evaluate when the value is retrieved).
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry, AbstractMap.SimpleImmutableEntry
 
Constructor Summary
FilterMap(Map map, FilterMap.Filter filter)
           
 
Method Summary
 boolean containsKey(Object key)
           
 Set entrySet()
           
 boolean equals(Object o)
           
 Object get(Object key)
           
 Map getOrigin()
          Returns the original map being filtered.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilterMap

public FilterMap(Map map,
                 FilterMap.Filter filter)
Method Detail

getOrigin

public Map getOrigin()
Returns the original map being filtered. That is, the map passed to the constructor.


get

public Object get(Object key)
Specified by:
get in interface Map
Overrides:
get in class AbstractMap

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map
Overrides:
containsKey in class AbstractMap

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
Specified by:
entrySet in class AbstractMap

toString

public String toString()
Overrides:
toString in class AbstractMap

hashCode

public int hashCode()
Specified by:
hashCode in interface Map
Overrides:
hashCode in class AbstractMap

equals

public boolean equals(Object o)
Specified by:
equals in interface Map
Overrides:
equals in class AbstractMap


Copyright © 2012. All Rights Reserved.