/**
  * Factory method to create an unmodifiable sorted map.
  *
  * @param map  the map to decorate, must not be null
  * @throws IllegalArgumentException if map is null
  */
 public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map)
 {
     if (map is Unmodifiable)
     {
         return(map);
     }
     return(new UnmodifiableSortedMap(map));
 }
 /**
  * Constructor.
  * @param bidi  the parent bidi map
  * @param sm  the subMap sorted map
  */
 protected internal ViewMap(DualTreeBidiMap bidi, java.util.SortedMap <Object, Object> sm) :
     // the implementation is not great here...
     // use the maps[0] as the filtered map, but maps[1] as the full map
     // this forces containsValue and clear to be overridden
     base((java.util.SortedMap <Object, Object>)bidi.createBidiMap(sm, bidi.maps[1], bidi.inverseBidiMapJ))
 {
     this.bidi = (DualTreeBidiMap)map;
 }
Пример #3
0
 /**
  * Factory method to create a typed sorted map.
  * <p>
  * If there are any elements already in the map being decorated, they
  * are validated.
  *
  * @param map  the map to decorate, must not be null
  * @param keyType  the type to allow as keys, must not be null
  * @param valueType  the type to allow as values, must not be null
  * @throws IllegalArgumentException if list or type is null
  * @throws IllegalArgumentException if the list contains invalid elements
  */
 public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map, java.lang.Class keyType, java.lang.Class valueType)
 {
     return(new PredicatedSortedMap(
                map,
                InstanceofPredicate.getInstance(keyType),
                InstanceofPredicate.getInstance(valueType)
                ));
 }
        /**
         * Factory method to create a transforming sorted map that will transform
         * existing contents of the specified map.
         * <p>
         * If there are any elements already in the map being decorated, they
         * will be transformed by this method.
         * Constrast this with {@link #decorate}.
         *
         * @param map  the map to decorate, must not be null
         * @param keyTransformer  the transformer to use for key conversion, null means no transformation
         * @param valueTransformer  the transformer to use for value conversion, null means no transformation
         * @throws IllegalArgumentException if map is null
         * @since Commons Collections 3.2
         */
        public static java.util.SortedMap <Object, Object> decorateTransform(java.util.SortedMap <Object, Object> map, Transformer keyTransformer, Transformer valueTransformer)
        {
            TransformedSortedMap decorated = new TransformedSortedMap(map, keyTransformer, valueTransformer);

            if (map.size() > 0)
            {
                java.util.Map <Object, Object> transformed = decorated.transformMap(map);
                decorated.clear();
                decorated.getMap().putAll(transformed);  // avoids double transformation
            }
            return(decorated);
        }
 public virtual Object previousKey(Object key)
 {
     if (isEmpty())
     {
         return(null);
     }
     if (maps[0] is OrderedMap)
     {
         return(((OrderedMap)maps[0]).previousKey(key));
     }
     java.util.SortedMap <Object, Object> sm = (java.util.SortedMap <Object, Object>)maps[0];
     java.util.SortedMap <Object, Object> hm = sm.headMap(key);
     if (hm.isEmpty())
     {
         return(null);
     }
     return(hm.lastKey());
 }
 public virtual Object nextKey(Object key)
 {
     if (isEmpty())
     {
         return(null);
     }
     if (maps[0] is OrderedMap)
     {
         return(((OrderedMap)maps[0]).nextKey(key));
     }
     java.util.SortedMap <Object, Object> sm = (java.util.SortedMap <Object, Object>)maps[0];
     java.util.Iterator <Object>          it = sm.tailMap(key).keySet().iterator();
     it.next();
     if (it.hasNext())
     {
         return(it.next());
     }
     return(null);
 }
 /**
  * Construct a new map with the same mappings as the specified map,
  * sorted according to the same ordering
  *
  * @param map  the map whose mappings are to be copied
  */
 public FastTreeMap(java.util.SortedMap <Object, Object> map)
     : base()
 {
     this.map = new java.util.TreeMap <Object, Object>(map);
 }
Пример #8
0
 /**
  * Factory method to create a predicated (validating) sorted map.
  * <p>
  * If there are any elements already in the list being decorated, they
  * are validated.
  *
  * @param map  the map to decorate, must not be null
  * @param keyPredicate  the predicate to validate the keys, null means no check
  * @param valuePredicate  the predicate to validate to values, null means no check
  * @throws IllegalArgumentException if the map is null
  */
 public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map, Predicate keyPredicate, Predicate valuePredicate)
 {
     return(new PredicatedSortedMap(map, keyPredicate, valuePredicate));
 }
Пример #9
0
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         *
         * @param map  the map to decorate, must not be null
         * @param keyPredicate  the predicate to validate the keys, null means no check
         * @param valuePredicate  the predicate to validate to values, null means no check
         * @throws IllegalArgumentException if the map is null
         */
        protected internal PredicatedSortedMap(java.util.SortedMap <Object, Object> map, Predicate keyPredicate, Predicate valuePredicate)
            : base(map, keyPredicate, valuePredicate)
        {
        }
Пример #10
0
 public java.util.SortedMap <Object, Object> headMap(Object toKey)
 {
     java.util.SortedMap <Object, Object> map = getSortedMap().headMap(toKey);
     return(new PredicatedSortedMap(map, keyPredicate, valuePredicate));
 }
Пример #11
0
 public java.util.SortedMap <Object, Object> tailMap(Object fromKey)
 {
     java.util.SortedMap <Object, Object> map = getSortedMap().tailMap(fromKey);
     return(new PredicatedSortedMap(map, keyPredicate, valuePredicate));
 }
Пример #12
0
 public override java.util.SortedMap <Object, Object> tailMap(Object fromKey)
 {
     java.util.SortedMap <Object, Object> sm = getSortedBidiMap().tailMap(fromKey);
     return(UnmodifiableSortedMap.decorate(sm));
 }
Пример #13
0
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         *
         * @param map  the map to decorate, must not be null
         * @throws IllegalArgumentException if map is null
         */
        protected FixedSizeSortedMap(java.util.SortedMap <Object, Object> map)
            : base(map)
        {
        }
Пример #14
0
 public java.util.SortedMap <Object, Object> headMap(Object toKey)
 {
     java.util.SortedMap <Object, Object> map = getSortedMap().headMap(toKey);
     return(new LazySortedMap(map, factory));
 }
Пример #15
0
 /**
  * Factory method to create a lazily instantiated sorted map.
  *
  * @param map  the map to decorate, must not be null
  * @param factory  the factory to use, must not be null
  * @throws IllegalArgumentException if map or factory is null
  */
 public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map, Transformer factory)
 {
     return(new LazySortedMap(map, factory));
 }
 public override java.util.SortedMap <Object, Object> subMap(Object fromKey, Object toKey)
 {
     java.util.SortedMap <Object, Object> map = getSortedMap().subMap(fromKey, toKey);
     return(new UnmodifiableSortedMap(map));
 }
 /**
  * Constructor that wraps (not copies).
  *
  * @param map  the map to decorate, must not be null
  * @throws IllegalArgumentException if the collection is null
  */
 public AbstractSortedMapDecorator(java.util.SortedMap <Object, Object> map)
     : base(map)
 {
 }
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         *
         * @param map  the map to decorate, must not be null
         * @throws IllegalArgumentException if map is null
         */
        private UnmodifiableSortedMap(java.util.SortedMap <Object, Object> map)
            : base(map)
        {
        }
 /**
  * Factory method to create a transforming sorted map.
  * <p>
  * If there are any elements already in the map being decorated, they
  * are NOT transformed.
  * Constrast this with {@link #decorateTransform}.
  *
  * @param map  the map to decorate, must not be null
  * @param keyTransformer  the predicate to validate the keys, null means no transformation
  * @param valueTransformer  the predicate to validate to values, null means no transformation
  * @throws IllegalArgumentException if the map is null
  */
 public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map, Transformer keyTransformer, Transformer valueTransformer)
 {
     return(new TransformedSortedMap(map, keyTransformer, valueTransformer));
 }
 public java.util.SortedMap <Object, Object> tailMap(Object fromKey)
 {
     java.util.SortedMap <Object, Object> map = getSortedMap().tailMap(fromKey);
     return(new TransformedSortedMap(map, keyTransformer, valueTransformer));
 }
 public java.util.SortedMap <Object, Object> headMap(Object toKey)
 {
     java.util.SortedMap <Object, Object> map = getSortedMap().headMap(toKey);
     return(new TransformedSortedMap(map, keyTransformer, valueTransformer));
 }
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         * <p>
         * If there are any elements already in the collection being decorated, they
         * are NOT transformed.</p>
         *
         * @param map  the map to decorate, must not be null
         * @param keyTransformer  the predicate to validate the keys, null means no transformation
         * @param valueTransformer  the predicate to validate to values, null means no transformation
         * @throws IllegalArgumentException if the map is null
         */
        protected TransformedSortedMap(java.util.SortedMap <Object, Object> map, Transformer keyTransformer, Transformer valueTransformer)
            : base(map, keyTransformer, valueTransformer)
        {
        }
 public virtual java.util.SortedMap <Object, Object> subMap(Object fromKey, Object toKey)
 {
     java.util.SortedMap <Object, Object> sub = ((java.util.SortedMap <Object, Object>)maps[0]).subMap(fromKey, toKey);
     return(new ViewMap(this, sub));
 }
Пример #24
0
 public override java.util.SortedMap <Object, Object> headMap(Object toKey)
 {
     java.util.SortedMap <Object, Object> map = getSortedMap().headMap(toKey);
     return(new FixedSizeSortedMap(map));
 }
Пример #25
0
 /**
  * Constructor that wraps (not copies).
  *
  * @param map  the map to decorate, must not be null
  * @param factory  the factory to use, must not be null
  * @throws IllegalArgumentException if map or factory is null
  */
 protected LazySortedMap(java.util.SortedMap <Object, Object> map, Transformer factory)
     : base(map, factory)
 {
 }
Пример #26
0
 public override java.util.SortedMap <Object, Object> tailMap(Object fromKey)
 {
     java.util.SortedMap <Object, Object> map = getSortedMap().tailMap(fromKey);
     return(new FixedSizeSortedMap(map));
 }
Пример #27
0
 public java.util.SortedMap <Object, Object> tailMap(Object fromKey)
 {
     java.util.SortedMap <Object, Object> map = getSortedMap().tailMap(fromKey);
     return(new LazySortedMap(map, factory));
 }
Пример #28
0
 /**
  * Factory method to create a fixed size sorted map.
  *
  * @param map  the map to decorate, must not be null
  * @throws IllegalArgumentException if map is null
  */
 public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map)
 {
     return(new FixedSizeSortedMap(map));
 }
Пример #29
0
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         *
         * @param map  the map to decorate, must not be null
         * @param factory  the factory to use, must not be null
         * @throws IllegalArgumentException if map or factory is null
         */
        protected LazySortedMap(java.util.SortedMap <Object, Object> map, Factory factory)
            : base(map, factory)
        {
        }
Пример #30
0
 public override java.util.SortedMap <Object, Object> headMap(Object toKey)
 {
     java.util.SortedMap <Object, Object> sm = getSortedBidiMap().headMap(toKey);
     return(UnmodifiableSortedMap.decorate(sm));
 }