Dresden OCL Toolkit

tudresden.ocl.lib
Class OclBag

java.lang.Object
  extended bytudresden.ocl.lib.OclCollection
      extended bytudresden.ocl.lib.OclUnsortedCollection
          extended bytudresden.ocl.lib.OclBag
All Implemented Interfaces:
Cloneable, OclRoot, OclSizable

public class OclBag
extends OclUnsortedCollection

A OclBag is a unordered collection that may contain duplicates. See documentation of OclCollection for further information.

Author:
Frank Finger
See Also:
OclCollection

Field Summary
 
Fields inherited from class tudresden.ocl.lib.OclCollection
collection, STRICT_VALUE_TYPES
 
Constructor Summary
OclBag(int dummy, String reason)
          constructor for undefined OclBag
OclBag(List list)
          package-visible constructor for OclBag; the ordering of the argument list is not reflected by OclBag
 
Method Summary
 OclCollection collect(OclIterator iter, OclRootEvaluatable eval)
           
 OclCollection excluding(OclRoot obj)
          STRICT_VALUE_TYPES determines whether the changes of the returned collection affect this collection, and if the returned is actually different from this collection.
protected  HashMap getCountMap()
           
static OclBag getEmptyOclBag()
          static factory method that returns an OclBag that contains no elements
 OclCollection including(OclRoot obj)
          STRICT_VALUE_TYPES determines whether the changes of the returned collection affect this collection, and if the returned is actually different from this collection.
 OclUnsortedCollection intersection(OclBag bag)
          The OCL types Bag and Set have this operation defined.
 OclSet intersection(OclSet set)
          The OCL types Bag and Set have this operation defined.
 OclBoolean isEqualTo(Object o)
          two OclBags are equal if they contain the same elements the same number of times
 OclCollection select(OclIterator iter, OclBooleanEvaluatable eval)
           
 String toString()
           
 OclBag union(OclBag bag)
          The union of two OclBags is again an OclBag.
 OclCollection union(OclCollection col)
          This method tries to call the appropriate method of the same name (for OclSet or OclBag parameters) or, if there is no such method, handles this error by returning an undefined value.
 OclBag union(OclSet set)
          The union of an OclBag and an OclSet is an OclBag.
 
Methods inherited from class tudresden.ocl.lib.OclUnsortedCollection
getFeature
 
Methods inherited from class tudresden.ocl.lib.OclCollection
asBag, asSequence, asSet, becomeUndefined, collectToList, count, equals, excludes, exists, forAll, getFeatureAsCollection, getIterator, getUndefinedReason, includes, includesAll, isEmpty, isNotEqualTo, isUndefined, isUnique, iterate, notEmpty, reject, selectToList, setToInclude, setToRange, size, sortedBy, sum
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OclBag

public OclBag(List list)
package-visible constructor for OclBag; the ordering of the argument list is not reflected by OclBag


OclBag

public OclBag(int dummy,
              String reason)
constructor for undefined OclBag

Method Detail

getEmptyOclBag

public static OclBag getEmptyOclBag()
static factory method that returns an OclBag that contains no elements


isEqualTo

public OclBoolean isEqualTo(Object o)
two OclBags are equal if they contain the same elements the same number of times

Specified by:
isEqualTo in interface OclRoot
Specified by:
isEqualTo in class OclCollection

select

public OclCollection select(OclIterator iter,
                            OclBooleanEvaluatable eval)
Specified by:
select in class OclCollection
Returns:
an instance of OclBag
See Also:
OclCollection.select(OclIterator iter, OclBooleanEvaluatable eval), OclCollection.selectToList(OclIterator iter, OclBooleanEvaluatable eval)

collect

public OclCollection collect(OclIterator iter,
                             OclRootEvaluatable eval)
Specified by:
collect in class OclCollection
Returns:
an instance of OclBag
See Also:
OclCollection.collect(OclIterator iter, OclRootEvaluatable eval), OclCollection.collectToList(OclIterator iter, OclRootEvaluatable eval)

union

public OclCollection union(OclCollection col)
This method tries to call the appropriate method of the same name (for OclSet or OclBag parameters) or, if there is no such method, handles this error by returning an undefined value.

Specified by:
union in class OclCollection
Returns:
a collection containing all elements found in this collection or the collection given as parameter; for details see implementations in subclasses
See Also:
OclCollection.union(OclCollection col), union(OclBag col), union(OclSet col)

union

public OclBag union(OclSet set)
The union of an OclBag and an OclSet is an OclBag. This method calls OclSet.union(OclBag).

See Also:
OclSet.union(OclBag bag)

union

public OclBag union(OclBag bag)
The union of two OclBags is again an OclBag.


intersection

public OclSet intersection(OclSet set)
Description copied from class: OclUnsortedCollection
The OCL types Bag and Set have this operation defined.

Specified by:
intersection in class OclUnsortedCollection
Returns:
an OclSet containing all elements found in both this bag (regardless of their number) and the set given as argument

intersection

public OclUnsortedCollection intersection(OclBag bag)
Description copied from class: OclUnsortedCollection
The OCL types Bag and Set have this operation defined.

Specified by:
intersection in class OclUnsortedCollection
Returns:
an OclBag that contains all elements found in both this OclBag and the OclBag given as argument; the number of times the element is contained in the result OclBag is the minimum of the numbers it is found in the two source OclBags

including

public OclCollection including(OclRoot obj)
STRICT_VALUE_TYPES determines whether the changes of the returned collection affect this collection, and if the returned is actually different from this collection.

Specified by:
including in class OclCollection
Returns:
an OclBag containing all elements of this bag, plus the argument
See Also:
OclCollection.STRICT_VALUE_TYPES

excluding

public OclCollection excluding(OclRoot obj)
STRICT_VALUE_TYPES determines whether the changes of the returned collection affect this collection, and if the returned is actually different from this collection. If this OclBag is not backed by a java.util.ArrayList, a new OclBag is created even if STRICT_VALUE_TYPES is set to false.

Specified by:
excluding in class OclCollection
Returns:
an OclBag containing all elements of this bag but the argument
See Also:
OclCollection.STRICT_VALUE_TYPES

getCountMap

protected HashMap getCountMap()
Returns:
a HashMap with elements of this collection as keys and an Integer denoting their count as value

toString

public String toString()
Overrides:
toString in class OclCollection

Dresden OCL Toolkit

Submit a bug
Developed at the Dresden University of Technology.
This software is published under the GNU Lesser General Public License.