1 16 package org.apache.commons.collections.map; 17 18 import java.util.Comparator ; 19 import java.util.SortedMap ; 20 21 import org.apache.commons.collections.Predicate; 22 23 42 public class PredicatedSortedMap 43 extends PredicatedMap 44 implements SortedMap { 45 46 47 private static final long serialVersionUID = 3359846175935304332L; 48 49 60 public static SortedMap decorate(SortedMap map, Predicate keyPredicate, Predicate valuePredicate) { 61 return new PredicatedSortedMap(map, keyPredicate, valuePredicate); 62 } 63 64 73 protected PredicatedSortedMap(SortedMap map, Predicate keyPredicate, Predicate valuePredicate) { 74 super(map, keyPredicate, valuePredicate); 75 } 76 77 83 protected SortedMap getSortedMap() { 84 return (SortedMap ) map; 85 } 86 87 public Object firstKey() { 89 return getSortedMap().firstKey(); 90 } 91 92 public Object lastKey() { 93 return getSortedMap().lastKey(); 94 } 95 96 public Comparator comparator() { 97 return getSortedMap().comparator(); 98 } 99 100 public SortedMap subMap(Object fromKey, Object toKey) { 101 SortedMap map = getSortedMap().subMap(fromKey, toKey); 102 return new PredicatedSortedMap(map, keyPredicate, valuePredicate); 103 } 104 105 public SortedMap headMap(Object toKey) { 106 SortedMap map = getSortedMap().headMap(toKey); 107 return new PredicatedSortedMap(map, keyPredicate, valuePredicate); 108 } 109 110 public SortedMap tailMap(Object fromKey) { 111 SortedMap map = getSortedMap().tailMap(fromKey); 112 return new PredicatedSortedMap(map, keyPredicate, valuePredicate); 113 } 114 115 } 116 | Popular Tags |