com.telelogic.rhapsody.core
Interface IRPCollection


public interface IRPCollection

The IRPCollection interface contains methods used to store and manipulate collections of various types of elements that you may have in your Rational Rhapsody model. Collections of this type are used by methods that return multiple model elements and by certain methods that take a collection of model elements as an argument.


Method Summary
 void addGraphicalItem(IRPGraphElement newVal)
          Adds a graphical element to a collection.
 void addItem(IRPModelElement newVal)
          Adds a model element to a collection.
 void empty()
          Used to empty out a collection.
 int getCount()
          Returns the number of items in a collection.
 java.lang.Object getItem(int index)
          Retrieves an item from a collection, using the index specified.
 void remove(int index)
          Removes an element from a collection.
 void setInteger(int index, int val)
          Used to place an integer in a specific place in a collection.
 void setModelElement(int index, IRPModelElement val)
          Places an item in a specific place in a collection.
 void setSize(int size)
          Sets the size of a collection.
 void setString(int index, java.lang.String val)
          Used to place a String in a specific place in a collection.
 java.util.List toList()
          Returns a java.util.List populated with the elements in the collection.
 

Method Detail

getCount

int getCount()
Returns the number of items in a collection.

Returns:
the number of items in the collection

getItem

java.lang.Object getItem(int index)
Retrieves an item from a collection, using the index specified. Note that when using the getItem method, the index parameter is based on an index value of 1 for the first element (not 0).

Parameters:
index - the index of the item to be retrieved (index of first element is 1, not 0)
Returns:
the item with the index specified
Throws:
RhapsodyRuntimeException

addItem

void addItem(IRPModelElement newVal)
Adds a model element to a collection. This method adds items, one at a time, to the end of a collection. When adding multiple items, it may be more efficient to call setSize to set the new size of the collection and then call setModelElement to place elements in specific locations in the collection.

Parameters:
newVal - the model element to add to the collection
Throws:
RhapsodyRuntimeException

addGraphicalItem

void addGraphicalItem(IRPGraphElement newVal)
Adds a graphical element to a collection.

Parameters:
newVal - the graphical element to add to the collection
Throws:
RhapsodyRuntimeException

toList

java.util.List toList()
Returns a java.util.List populated with the elements in the collection.

Returns:
java.util.List populated with the elements in the collection
Throws:
RhapsodyRuntimeException

setSize

void setSize(int size)
Sets the size of a collection.

Parameters:
size - the new size that should be used for the collection
Throws:
RhapsodyRuntimeException

remove

void remove(int index)
Removes an element from a collection.

Parameters:
index - the index of the element that should be removed from the collection
Throws:
RhapsodyRuntimeException

setString

void setString(int index,
               java.lang.String val)
Used to place a String in a specific place in a collection. Note that when using setString, the index parameter is based on an index value of 1 for the first element (not 0). The following code illustrates the use of this method with the populateDiagram method, which takes a number of arguments, one of which is a collection of Strings.
 
 //The populateDiagram method takes 3 parameters, the first two being collections: a collection of model elements and a collection of strings
 IRPDiagram classDiagramToCreate = vehiclePackage.addObjectModelDiagram("Classes in Vehicles package");
 IRPCollection classesToAddToDiagram = vehiclePackage.getClasses();
 IRPCollection typesOfRelationsToShow = app.createNewCollection();
 typesOfRelationsToShow.setSize(2);
 typesOfRelationsToShow.setString(1, "Inheritance");
 typesOfRelationsToShow.setString(2, "Dependency");
 classDiagramToCreate.populateDiagram(classesToAddToDiagram, typesOfRelationsToShow, "fromto");
 

Parameters:
index - the index representing the place in the collection where the String should be placed (index of first element is 1, not 0)
val - the String to place in the collection
Throws:
RhapsodyRuntimeException

setModelElement

void setModelElement(int index,
                     IRPModelElement val)
Places an item in a specific place in a collection. Note that when using setModelElement, the index parameter is based on an index value of 1 for the first element (not 0).

Parameters:
index - the index representing the place in the collection where the item should be placed (index of first element is 1, not 0)
val - the item to place in the collection
Throws:
RhapsodyRuntimeException

empty

void empty()
Used to empty out a collection.

Throws:
RhapsodyRuntimeException

setInteger

void setInteger(int index,
                int val)
Used to place an integer in a specific place in a collection. Note that when using setInteger, the index parameter is based on an index value of 1 for the first element (not 0).

Parameters:
index - the index representing the place in the collection where the integer should be placed (index of first element is 1, not 0)
val - the integer to place in the collection