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.Transformer; 22 23 38 public class TransformedSortedMap 39 extends TransformedMap 40 implements SortedMap { 41 42 43 private static final long serialVersionUID = -8751771676410385778L; 44 45 56 public static SortedMap decorate(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) { 57 return new TransformedSortedMap(map, keyTransformer, valueTransformer); 58 } 59 60 72 protected TransformedSortedMap(SortedMap map, Transformer keyTransformer, Transformer valueTransformer) { 73 super(map, keyTransformer, valueTransformer); 74 } 75 76 82 protected SortedMap getSortedMap() { 83 return (SortedMap ) map; 84 } 85 86 public Object firstKey() { 88 return getSortedMap().firstKey(); 89 } 90 91 public Object lastKey() { 92 return getSortedMap().lastKey(); 93 } 94 95 public Comparator comparator() { 96 return getSortedMap().comparator(); 97 } 98 99 public SortedMap subMap(Object fromKey, Object toKey) { 100 SortedMap map = getSortedMap().subMap(fromKey, toKey); 101 return new TransformedSortedMap(map, keyTransformer, valueTransformer); 102 } 103 104 public SortedMap headMap(Object toKey) { 105 SortedMap map = getSortedMap().headMap(toKey); 106 return new TransformedSortedMap(map, keyTransformer, valueTransformer); 107 } 108 109 public SortedMap tailMap(Object fromKey) { 110 SortedMap map = getSortedMap().tailMap(fromKey); 111 return new TransformedSortedMap(map, keyTransformer, valueTransformer); 112 } 113 114 } 115 | Popular Tags |