⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections.bag

Class TransformedSortedBag

java.lang.Object
|
+--org.apache.commons.collections.collection.AbstractCollectionDecorator
   |
   +--org.apache.commons.collections.collection.TransformedCollection
      |
      +--org.apache.commons.collections.bag.TransformedBag
         |
         +--org.apache.commons.collections.bag.TransformedSortedBag

All Implemented Interfaces:
Collection, Bag, SortedBag


public class TransformedSortedBag
extends TransformedBag
implements SortedBag

Decorates another SortedBag to transform objects that are added.

The add methods are affected by this class. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.

Since:
Commons Collections 3.0
Author:
Stephen Colebourne

Constructor Summary

TransformedSortedBag(SortedBag bag, Transformer transformer)

Constructor that wraps (not copies).

Method Summary

Comparator

comparator()

static SortedBag

decorate(SortedBag bag, Transformer transformer)

Factory method to create a transforming sorted bag.

Object

first()

SortedBag

getSortedBag()

Gets the decorated bag.

Object

last()

Constructor Details

TransformedSortedBag

protected TransformedSortedBag(SortedBag bag, Transformer transformer)

Constructor that wraps (not copies).

If there are any elements already in the bag being decorated, they are NOT transformed.

Parameters:
bag - the bag to decorate, must not be null
transformer - the transformer to use for conversion, must not be null
Throws:
- if bag or transformer is null

Method Details

comparator

public Comparator comparator()


decorate

public static SortedBag decorate(SortedBag bag, Transformer transformer)

Factory method to create a transforming sorted bag.

If there are any elements already in the bag being decorated, they are NOT transformed.

Parameters:
bag - the bag to decorate, must not be null
transformer - the transformer to use for conversion, must not be null
Throws:
- if bag or transformer is null

first

public Object first()


getSortedBag

protected SortedBag getSortedBag()

Gets the decorated bag.

Returns:
the decorated bag

last

public Object last()