Return-Path: Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 5654 invoked by uid 500); 22 Sep 2003 00:24:57 -0000 Received: (qmail 5650 invoked from network); 22 Sep 2003 00:24:57 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 22 Sep 2003 00:24:57 -0000 Received: (qmail 79608 invoked by uid 1581); 22 Sep 2003 00:25:12 -0000 Date: 22 Sep 2003 00:25:12 -0000 Message-ID: <20030922002512.79607.qmail@minotaur.apache.org> From: dgraham@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources MessageList.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N dgraham 2003/09/21 17:25:12 Modified: resources/src/java/org/apache/commons/resources/impl BasicMessageList.java resources/src/java/org/apache/commons/resources MessageList.java Log: Added isAccessed() to interface to determine if the MessageList's messages have been retrieved one or more times. Revision Changes Path 1.6 +20 -7 jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/impl/BasicMessageList.java Index: BasicMessageList.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/impl/BasicMessageList.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- BasicMessageList.java 19 Aug 2003 23:34:22 -0000 1.5 +++ BasicMessageList.java 22 Sep 2003 00:25:12 -0000 1.6 @@ -94,10 +94,15 @@ return ((MessageItem) o1).getOrder() - ((MessageItem) o2).getOrder(); } }; + + /** + * Have the messages been retrieved from this object? + */ + private boolean accessed = false; /** * The accumulated set of Message objects (represented - * as an ArrayList) for each property, keyed by property name. + * as a List) for each property, keyed by property name. */ protected HashMap messages = new HashMap(); @@ -213,6 +218,11 @@ public void clear() { messages.clear(); } + + // See interface for JavaDoc + public boolean isAccessed() { + return this.accessed; + } // See interface for JavaDoc public boolean isEmpty() { @@ -221,7 +231,8 @@ // See interface for JavaDoc public Iterator get() { - + this.accessed = true; + if (messages.isEmpty()) { return Collections.EMPTY_LIST.iterator(); } @@ -250,8 +261,10 @@ // See interface for JavaDoc public Iterator get(String property) { - + this.accessed = true; + MessageItem item = (MessageItem) messages.get(property); + return (item == null) ? Collections.EMPTY_LIST.iterator() : item.getList().iterator(); 1.5 +13 -4 jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/MessageList.java Index: MessageList.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/MessageList.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MessageList.java 19 Aug 2003 23:35:00 -0000 1.4 +++ MessageList.java 22 Sep 2003 00:25:12 -0000 1.5 @@ -145,6 +145,15 @@ * Clear all messages recorded by this object. */ public void clear(); + + /** + * Determines if the MessageList's messages have been accessed one or more + * times. Returns true if the get() or + * get(String) methods are called. + * @return true if the messages have been accessed one or more + * times. + */ + public boolean isAccessed(); /** * Return true if there are no messages recorded