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.Factory; 22 import org.apache.commons.collections.Transformer; 23 24 54 public class LazySortedMap 55 extends LazyMap 56 implements SortedMap { 57 58 59 private static final long serialVersionUID = 2715322183617658933L; 60 61 68 public static SortedMap decorate(SortedMap map, Factory factory) { 69 return new LazySortedMap(map, factory); 70 } 71 72 79 public static SortedMap decorate(SortedMap map, Transformer factory) { 80 return new LazySortedMap(map, factory); 81 } 82 83 91 protected LazySortedMap(SortedMap map, Factory factory) { 92 super(map, factory); 93 } 94 95 102 protected LazySortedMap(SortedMap map, Transformer factory) { 103 super(map, factory); 104 } 105 106 112 protected SortedMap getSortedMap() { 113 return (SortedMap ) map; 114 } 115 116 public Object firstKey() { 118 return getSortedMap().firstKey(); 119 } 120 121 public Object lastKey() { 122 return getSortedMap().lastKey(); 123 } 124 125 public Comparator comparator() { 126 return getSortedMap().comparator(); 127 } 128 129 public SortedMap subMap(Object fromKey, Object toKey) { 130 SortedMap map = getSortedMap().subMap(fromKey, toKey); 131 return new LazySortedMap(map, factory); 132 } 133 134 public SortedMap headMap(Object toKey) { 135 SortedMap map = getSortedMap().headMap(toKey); 136 return new LazySortedMap(map, factory); 137 } 138 139 public SortedMap tailMap(Object fromKey) { 140 SortedMap map = getSortedMap().tailMap(fromKey); 141 return new LazySortedMap(map, factory); 142 } 143 144 } 145 | Popular Tags |