Author: mvw
Date: 2007-05-22 12:17:42-0700
New Revision: 12632
Modified:
trunk/src_new/org/argouml/cognitive/ToDoList.java
trunk/src_new/org/argouml/cognitive/ToDoListEvent.java
Log:
Clarified code. At least now it is clear what the Vectors contain.
Modified: trunk/src_new/org/argouml/cognitive/ToDoList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/cognitive/ToDoList.java?view=diff&rev=12632&p1=trunk/src_new/org/argouml/cognitive/ToDoList.java&p2=trunk/src_new/org/argouml/cognitive/ToDoList.java&r1=12631&r2=12632
==============================================================================
--- trunk/src_new/org/argouml/cognitive/ToDoList.java (original)
+++ trunk/src_new/org/argouml/cognitive/ToDoList.java 2007-05-22 12:17:42-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -78,7 +78,7 @@
private static final Logger LOG = Logger.getLogger(ToDoList.class);
private static Object recentOffender;
- private static Vector recentOffenderItems;
+ private static Vector<ToDoItem> recentOffenderItems;
////////////////////////////////////////////////////////////////
// instance variables
@@ -86,7 +86,7 @@
/**
* Pending ToDoItems for the designer to consider.
*/
- private Vector items;
+ private Vector<ToDoItem> items;
/**
* These are computed when needed.
@@ -104,7 +104,7 @@
*
* TODO: generalize into a design rationale logging facility.
*/
- private LinkedHashSet resolvedItems;
+ private LinkedHashSet<ResolvedCritic> resolvedItems;
/**
* A Thread that keeps checking if the items on the list are
@@ -143,12 +143,12 @@
*/
public ToDoList() {
- items = new Vector(100);
- resolvedItems = new LinkedHashSet(100);
+ items = new Vector<ToDoItem>(100);
+ resolvedItems = new LinkedHashSet<ResolvedCritic>(100);
listenerList = new EventListenerList();
longestToDoList = 0;
numNotValid = 0;
- recentOffenderItems = new Vector();
+ recentOffenderItems = new Vector<ToDoItem>();
}
/**
@@ -181,7 +181,7 @@
* Periodically check to see if items on the list are still valid.
*/
public void run() {
- Vector removes = new Vector();
+ Vector<ToDoItem> removes = new Vector<ToDoItem>();
while (true) {
// the validity checking thread should wait if disabled.
@@ -212,7 +212,7 @@
* pressing a button via forceValidityCheck().
*/
public void forceValidityCheck() {
- Vector removes = new Vector();
+ Vector<ToDoItem> removes = new Vector<ToDoItem>();
forceValidityCheck(removes);
}
@@ -227,11 +227,11 @@
*
* @param removes the items removed
*/
- protected synchronized void forceValidityCheck(Vector removes) {
+ protected synchronized void forceValidityCheck(Vector<ToDoItem> removes) {
//Enumeration cur = _items.elements();
int size = items.size();
for (int i = 0; i < size; ++i) {
- ToDoItem item = (ToDoItem) items.elementAt(i);
+ ToDoItem item = items.elementAt(i);
boolean valid;
try {
valid = item.stillValid(designer);
@@ -251,7 +251,7 @@
//cur = removes.elements();
size = removes.size();
for (int i = 0; i < size; ++i) {
- ToDoItem item = (ToDoItem) removes.elementAt(i);
+ ToDoItem item = removes.elementAt(i);
removeE(item);
// History.TheHistory.addItemResolution(item, "no longer valid");
//((ToDoItem)item).resolve("no longer valid");
@@ -305,7 +305,7 @@
*/
public void notifyObservers(String action, Object arg) {
setChanged();
- Vector v = new Vector(2);
+ Vector<Object> v = new Vector<Object>(2);
v.addElement(action);
v.addElement(arg);
super.notifyObservers(v);
@@ -333,12 +333,12 @@
/**
* @return the todo items
*/
- public Vector getToDoItems() { return items; }
+ public Vector<ToDoItem> getToDoItems() { return items; }
/**
* @return the resolved items
*/
- public Set getResolvedItems() { return resolvedItems; }
+ public Set<ResolvedCritic> getResolvedItems() { return resolvedItems; }
/**
* @return the set of offenders
@@ -351,7 +351,7 @@
int size = items.size();
all = new ListSet(size * 2);
for (int i = 0; i < size; i++) {
- ToDoItem item = (ToDoItem) items.elementAt(i);
+ ToDoItem item = items.elementAt(i);
all.addAllElements(item.getOffenders());
}
allOffenders = all;
@@ -376,7 +376,7 @@
int size = items.size();
all = new ListSet();
for (int i = 0; i < size; i++) {
- ToDoItem item = (ToDoItem) items.elementAt(i);
+ ToDoItem item = items.elementAt(i);
all.addElement(item.getPoster());
}
allPosters = all;
@@ -416,7 +416,7 @@
new ResolvedCritic((Critic) item.getPoster(),
item.getOffenders(),
false);
- Iterator elems = resolvedItems.iterator();
+ Iterator<ResolvedCritic> elems = resolvedItems.iterator();
//cat.debug("Checking for inhibitors " + rc);
while (elems.hasNext()) {
if (elems.next().equals(rc)) {
@@ -452,9 +452,9 @@
* @param list the todo items to be removed
*/
public void removeAll(ToDoList list) {
- Enumeration cur = list.elements();
+ Enumeration<ToDoItem> cur = list.elements();
while (cur.hasMoreElements()) {
- ToDoItem item = (ToDoItem) cur.nextElement();
+ ToDoItem item = cur.nextElement();
removeE(item);
}
recomputeAllOffenders();
@@ -561,7 +561,7 @@
* @param off the offender
* @return the todo tems for this offender
*/
- public Vector elementsForOffender(Object off) {
+ public Vector<ToDoItem> elementsForOffender(Object off) {
if (off == recentOffender) {
return recentOffenderItems;
}
@@ -569,7 +569,7 @@
recentOffenderItems.removeAllElements();
synchronized (items) {
for (int i = 0; i < items.size(); i++) {
- ToDoItem item = (ToDoItem) items.elementAt(i);
+ ToDoItem item = items.elementAt(i);
if (item.getOffenders().contains(off)) {
recentOffenderItems.addElement(item);
}
@@ -586,7 +586,7 @@
/**
* @return the todo items
*/
- public Enumeration elements() {
+ public Enumeration<ToDoItem> elements() {
return items.elements();
}
@@ -595,7 +595,7 @@
* @return the item at the index
*/
public ToDoItem elementAt(int index) {
- return (ToDoItem) items.elementAt(index);
+ return items.elementAt(index);
}
/**
@@ -667,7 +667,7 @@
if (listeners[i] == ToDoListListener.class) {
// Lazily create the event:
if (e == null) {
- Vector its = new Vector();
+ Vector<ToDoItem> its = new Vector<ToDoItem>();
its.addElement(item);
e = new ToDoListEvent(its);
}
@@ -680,7 +680,7 @@
* @param item the todo item
*/
protected void fireToDoItemAdded(ToDoItem item) {
- Vector v = new Vector();
+ Vector<ToDoItem> v = new Vector<ToDoItem>();
v.addElement(item);
fireToDoItemsAdded(v);
}
@@ -688,7 +688,7 @@
/**
* @param theItems the todo items
*/
- protected void fireToDoItemsAdded(Vector theItems) {
+ protected void fireToDoItemsAdded(Vector<ToDoItem> theItems) {
recentOffender = null;
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
@@ -710,7 +710,7 @@
* @param item the todo item
*/
protected void fireToDoItemRemoved(ToDoItem item) {
- Vector v = new Vector();
+ Vector<ToDoItem> v = new Vector<ToDoItem>();
v.addElement(item);
fireToDoItemsRemoved(v);
}
@@ -718,7 +718,7 @@
/**
* @param theItems the todo items
*/
- protected void fireToDoItemsRemoved(Vector theItems) {
+ protected void fireToDoItemsRemoved(Vector<ToDoItem> theItems) {
recentOffender = null;
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
@@ -745,9 +745,9 @@
public String toString() {
StringBuffer res = new StringBuffer(100);
res.append(getClass().getName()).append(" {\n");
- Enumeration cur = elements();
+ Enumeration<ToDoItem> cur = elements();
while (cur.hasMoreElements()) {
- ToDoItem item = (ToDoItem) cur.nextElement();
+ ToDoItem item = cur.nextElement();
res.append(" ").append(item.toString()).append("\n");
}
res.append(" }");
Modified: trunk/src_new/org/argouml/cognitive/ToDoListEvent.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/cognitive/ToDoListEvent.java?view=diff&rev=12632&p1=trunk/src_new/org/argouml/cognitive/ToDoListEvent.java&p2=trunk/src_new/org/argouml/cognitive/ToDoListEvent.java&r1=12631&r2=12632
==============================================================================
--- trunk/src_new/org/argouml/cognitive/ToDoListEvent.java (original)
+++ trunk/src_new/org/argouml/cognitive/ToDoListEvent.java 2007-05-22 12:17:42-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -33,7 +33,7 @@
*/
public class ToDoListEvent {
- private Vector items;
+ private Vector<ToDoItem> items;
/**
* The constructor.
@@ -43,13 +43,13 @@
/**
* The constructor.
*
- * @param i the todo list events
+ * @param i the Vector of ToDoItems that were changed/added/removed
*/
- public ToDoListEvent(Vector i) { items = i; }
+ public ToDoListEvent(Vector<ToDoItem> i) { items = i; }
/**
* @return the todo list events
*/
- public Vector getToDoItems() { return items; }
+ public Vector<ToDoItem> getToDoItems() { return items; }
} /* end class ToDoListEvent */
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.