| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--org.jutil.java.collections.Mapping
A mapping of collections.
 
 Mappings exchange an element for another element, calculated based on the original element. In relational algebra, this is projection.
That mapping is defined in the 
 mapping(Object) method. The mapping of the collection happens through the
 invocation of the 
 applyTo(Collection) method, or the 
 
 applyTo(Collection, Collection) method which maps the first
 collection into the second.
The code it typically used as follows:
 new Mapping() {
   /oo
     o also public behavior
     o
     o post (* postconditions *);
     o/
   public Object mapping(Object element) {
     // mapping code
   }
 }.applyTo(collection);
 
| Field Summary | |
| static java.lang.String | CVS_REVISION | 
| Constructor Summary | |
| Mapping() | |
| Method Summary | |
|  java.util.Collection | applyFromTo(java.util.Collection fromCollection,
            java.util.Collection toCollection)Perform the mapping defined in public Object mapping(Object)on all elements in | 
|  java.util.Collection | applyTo(java.util.Collection collection)Perform the mapping defined in public Object mapping(Object)on | 
| abstract  java.lang.Object | mapping(java.lang.Object element)The mapping to be applied to all elements of a collection. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Methods inherited from interface org.jutil.java.collections.CollectionOperator | 
| isValidElement | 
| Field Detail | 
public static final java.lang.String CVS_REVISION
| Constructor Detail | 
public Mapping()
| Method Detail | 
public abstract java.lang.Object mapping(java.lang.Object element)
element - The object the mapping should replace.
public final java.util.Collection applyTo(java.util.Collection collection)
                                   throws java.util.ConcurrentModificationException
Perform the mapping defined in public Object mapping(Object)
 on 
If the collection is a sorted set, make sure that the new elements are also Comparable, or that the Comparator is changed accordingly.
If the collection is a List, the order of the elements is preserved. The mapped element has the same position as the object it was mapped from.
collection - The collection to perform this mapping on. This can be null, in which case
         nothing happens.
public final java.util.Collection applyFromTo(java.util.Collection fromCollection,
                                              java.util.Collection toCollection)
                                       throws java.util.ConcurrentModificationException
Perform the mapping defined in public Object mapping(Object)
 on all elements in 
If 
If  
fromCollection - The collection which contains to elements to be mapped into the other
         collection. This can be null, in which case nothing happens.toCollection - The collection into which the elements of 
requires ( \forall Object o; fromCollection.contains(o); isValidElement(o));
ensures ( \forall Object o; fromCollection.contains(o); \result .contains(mapping(o)))&&( \forall Object o; toCollection.contains(o); ( \exists Object o2; fromCollection.contains(o2); o.equals(mapping(o2))));
ensures \result  == toCollection;
signals (ConcurrentModificationException) (* The collection was modified while mapping *);
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||