org.fopps.model
Class AbstractItem

java.lang.Object
  |
  +--org.fopps.model.AbstractItem
Direct Known Subclasses:
Artefact, ProjectItem, Relation, TreeItem

public class AbstractItem
extends java.lang.Object

AbstractItem is the base class for most classes in the model. It provides a name attribute, a description field and provides methods to issue changes. It also holds relations to other AbstractItem (e. g. dependencies or constraints).

See Also:
*, ModelListener, Relation

Field Summary
static ModelEvent ADDED_EVENT
          Emitted, if an item was added
static ModelEvent CHANGE_EVENT
          Emitted, if a change occurred
protected  java.lang.String name
           
static ModelEvent REMOVED_EVENT
          Emitted, if an item was removed
 
Constructor Summary
AbstractItem(java.lang.String name)
          Creates a new abstact item
 
Method Summary
 void addIncoming(Relation pIncoming)
          Adds one element to association Incoming
 void addListener(ModelListener pListener)
          Adds a listener
 void addOutgoing(Relation pOutgoing)
          Adds one element to association Outgoing
 int commitGhostRelations()
          Change all existing ghost relations to 'real' relations
static boolean containsType(java.lang.Class c, java.util.Collection list)
          Checks if element of given type is in the list
protected  AbstractItem copyAttributes(AbstractItem pItem)
          Copy all attributes into a given instance
 void delete()
          Deletes the current instance.
static java.util.Collection filterElements(java.lang.Class c, java.util.Collection list)
          Filters elements out of a collection.
 void fireItemAdded()
          Notifies all listeners, if event blocking is disabled
 void fireItemChanged()
          Notifies all listeners, if event blocking is disabled
 void fireItemRemoved()
          Notifies all listeners, if event blocking is disabled
 java.util.Collection getConstraints()
          Returns a list containing all (outgoing) constraints.
 java.lang.String getDescription()
          Returns the description of the project
 java.util.List getIncoming()
          Getter Association Incoming
 java.util.Collection getIncomingConstraints()
           
 java.util.List getListeners()
          Returns all listeners
 java.lang.String getName()
          Returns the name of the item
 java.util.List getOutgoing()
          Getter Association Outgoing
 java.util.Collection getOutgoingConstraints()
           
 Relation getRelationTo(AbstractItem pItem)
          Returns the relation to a specified item, if exist.
 boolean hasConstraints()
          Returns true, if item contains constraints
 boolean isBlockEvents()
          Return the current status of event blocking
 boolean isConnectedWith(AbstractItem pItem)
          Checks if a relation to a specified item already exists.
 void notifyListeners(ModelEvent pEvent)
          Notify all listeners of the item
 void removeAllConstraints()
          Removes all (incoming and outgoing) constraints
 void removeAllIncoming()
          Removes all elements from association Incoming
 void removeAllListener()
          Removes all listeners
 void removeAllOutgoing()
          Removes all elements from association Outgoing
 void removeAllRelations()
          Removes all relations (incoming and outcoming)
 int removeGhostRelations()
          Change all existing ghost relations to 'real' relations
 void removeIncoming(Relation pIncoming)
          Removes one element to association Incoming
 void removeListener(ModelListener pListener)
          Removes a listener
 void removeOutgoing(Relation pOutgoing)
          Removes one element to association Outgoing
 boolean removeRelationTo(AbstractItem pItem)
          Removes all connections to given item.
 void setBlockEvents(boolean blockEvents)
          Blocks next project event.
 void setDescription(java.lang.String pDescription)
          Sets a new project description.
 void setIncoming(java.util.List pIncoming)
          Setter Association Outgoing
 void setName(java.lang.String pName)
          Sets a new name.
 void setOutgoing(java.util.List pOutgoing)
          Setter Association Outgoing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHANGE_EVENT

public static final ModelEvent CHANGE_EVENT
Emitted, if a change occurred

See Also:
ModelEvent

ADDED_EVENT

public static final ModelEvent ADDED_EVENT
Emitted, if an item was added

See Also:
ModelEvent

REMOVED_EVENT

public static final ModelEvent REMOVED_EVENT
Emitted, if an item was removed

See Also:
ModelEvent

name

protected java.lang.String name
Constructor Detail

AbstractItem

public AbstractItem(java.lang.String name)
Creates a new abstact item

Parameters:
name - Name of the item
Method Detail

getName

public java.lang.String getName()
Returns the name of the item

Returns:
item name

setName

public void setName(java.lang.String pName)
Sets a new name. If the name differs from the old name, a change event is issued


getDescription

public java.lang.String getDescription()
Returns the description of the project

Returns:
Description of the project

setDescription

public void setDescription(java.lang.String pDescription)
Sets a new project description. If the current value is the same as the given parameter, no change event will be emitted.

Parameters:
pDescription - New value for description

copyAttributes

protected AbstractItem copyAttributes(AbstractItem pItem)
Copy all attributes into a given instance


isBlockEvents

public boolean isBlockEvents()
Return the current status of event blocking

Returns:
true, if event blocking is active

setBlockEvents

public void setBlockEvents(boolean blockEvents)
Blocks next project event. This is useful for multiple updates. Please note, that setBlockEvents(true) causes only the next event to be blocked. All following calls of fireItemChanged() will notify its listeners.

Parameters:
blockEvents - Flag, if the next event shold be block

fireItemChanged

public void fireItemChanged()
Notifies all listeners, if event blocking is disabled

See Also:
setBlockEvents(boolean)

fireItemAdded

public void fireItemAdded()
Notifies all listeners, if event blocking is disabled

See Also:
setBlockEvents(boolean)

fireItemRemoved

public void fireItemRemoved()
Notifies all listeners, if event blocking is disabled

See Also:
setBlockEvents(boolean)

getOutgoing

public java.util.List getOutgoing()
Getter Association Outgoing


setOutgoing

public void setOutgoing(java.util.List pOutgoing)
Setter Association Outgoing


addOutgoing

public void addOutgoing(Relation pOutgoing)
Adds one element to association Outgoing

Parameters:
pOutgoing - New element in association

removeOutgoing

public void removeOutgoing(Relation pOutgoing)
Removes one element to association Outgoing

Parameters:
pOutgoing - Element to remove from association

removeAllOutgoing

public void removeAllOutgoing()
Removes all elements from association Outgoing


getIncoming

public java.util.List getIncoming()
Getter Association Incoming


setIncoming

public void setIncoming(java.util.List pIncoming)
Setter Association Outgoing


addIncoming

public void addIncoming(Relation pIncoming)
Adds one element to association Incoming

Parameters:
pIncoming - New element in association

removeIncoming

public void removeIncoming(Relation pIncoming)
Removes one element to association Incoming

Parameters:
pIncoming - Element to remove from association

removeAllIncoming

public void removeAllIncoming()
Removes all elements from association Incoming


isConnectedWith

public boolean isConnectedWith(AbstractItem pItem)
Checks if a relation to a specified item already exists. It doesn't matter, if the relation is in- or outcoming

Parameters:
pItem - Peer of relation
Returns:
true, if relation between this instance and the specified item exists

getRelationTo

public Relation getRelationTo(AbstractItem pItem)
Returns the relation to a specified item, if exist. It doesn't matter, if the relation is in- or outcoming

Parameters:
pItem - Peer of relation
Returns:
Relation between this instance and the specified item or null, if no such relation exists

removeGhostRelations

public int removeGhostRelations()
Change all existing ghost relations to 'real' relations

Returns:
Number of changed relations

removeRelationTo

public boolean removeRelationTo(AbstractItem pItem)
Removes all connections to given item. It doesn't matter, if the relation is incoming or outgoing.

Parameters:
pItem - Connection peer
Returns:
true, if relation was removed or false, if no such relation exists

commitGhostRelations

public int commitGhostRelations()
Change all existing ghost relations to 'real' relations

Returns:
Number of changed relations

removeAllRelations

public void removeAllRelations()
Removes all relations (incoming and outcoming)


addListener

public void addListener(ModelListener pListener)
Adds a listener

Parameters:
pListener - Listener to add

removeListener

public void removeListener(ModelListener pListener)
Removes a listener

Parameters:
pListener - Listener to remove

removeAllListener

public void removeAllListener()
Removes all listeners


notifyListeners

public void notifyListeners(ModelEvent pEvent)
Notify all listeners of the item


delete

public void delete()
Deletes the current instance. All relations are dropped and all lssteners are removed.


hasConstraints

public boolean hasConstraints()
Returns true, if item contains constraints


getIncomingConstraints

public java.util.Collection getIncomingConstraints()

getOutgoingConstraints

public java.util.Collection getOutgoingConstraints()

getConstraints

public java.util.Collection getConstraints()
Returns a list containing all (outgoing) constraints.


removeAllConstraints

public void removeAllConstraints()
Removes all (incoming and outgoing) constraints


containsType

public static boolean containsType(java.lang.Class c,
                                   java.util.Collection list)
Checks if element of given type is in the list


filterElements

public static java.util.Collection filterElements(java.lang.Class c,
                                                  java.util.Collection list)
Filters elements out of a collection. If list is null or list instance cannot be created, an empty list is returned.


getListeners

public java.util.List getListeners()
Returns all listeners



Fopps 0.19 - Copyright © 2002 Oliver Wieland. All Rights Reserved.