Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 79328 invoked from network); 21 Nov 2006 19:22:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Nov 2006 19:22:33 -0000 Received: (qmail 45295 invoked by uid 500); 21 Nov 2006 19:22:42 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 45245 invoked by uid 500); 21 Nov 2006 19:22:41 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 45234 invoked by uid 500); 21 Nov 2006 19:22:41 -0000 Received: (qmail 45230 invoked by uid 99); 21 Nov 2006 19:22:41 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Nov 2006 11:22:41 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Nov 2006 11:22:30 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id C8DD71A9846; Tue, 21 Nov 2006 11:21:56 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r477837 - /ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java Date: Tue, 21 Nov 2006 19:21:56 -0000 To: ant-cvs@apache.org From: mbenson@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061121192156.C8DD71A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mbenson Date: Tue Nov 21 11:21:56 2006 New Revision: 477837 URL: http://svn.apache.org/viewvc?view=rev&rev=477837 Log: move a public method above private and protected; lazily create the child-holding Vector. Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java?view=diff&rev=477837&r1=477836&r2=477837 ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java Tue Nov 21 11:21:56 2006 @@ -19,10 +19,12 @@ package org.apache.tools.ant.types.resources; import java.io.File; +import java.util.List; import java.util.Stack; import java.util.Vector; import java.util.Iterator; import java.util.Collection; +import java.util.Collections; import java.util.AbstractCollection; import java.util.NoSuchElementException; @@ -65,7 +67,7 @@ MyCollection() { size = 0; - for (Iterator rci = rc.iterator(); rci.hasNext();) { + for (Iterator rci = getNested().iterator(); rci.hasNext();) { size += ((ResourceCollection) rci.next()).size(); } } @@ -76,7 +78,7 @@ return new MyIterator(); } private class MyIterator implements Iterator { - private Iterator rci = rc.iterator(); + private Iterator rci = getNested().iterator(); private Iterator ri = null; public boolean hasNext() { @@ -99,8 +101,8 @@ } } - private Vector rc = new Vector(); - private Collection coll = null; + private Vector rc; + private Collection coll; /** * Add a ResourceCollection. @@ -113,6 +115,9 @@ if (c == null) { return; } + if (rc == null) { + rc = new Vector(); + } rc.add(c); FailFast.invalidate(this); coll = null; @@ -153,7 +158,7 @@ } validate(); - for (Iterator i = rc.iterator(); i.hasNext();) { + for (Iterator i = getNested().iterator(); i.hasNext();) { if ((!((ResourceCollection) i.next()).isFilesystemOnly())) { return false; } @@ -162,6 +167,27 @@ } /** + * Format this BaseResourceCollectionContainer as a String. + * @return a descriptive String. + */ + public synchronized String toString() { + if (isReference()) { + return getCheckedRef().toString(); + } + if (coll == null || coll.isEmpty()) { + return ""; + } + StringBuffer sb = new StringBuffer(); + for (Iterator i = coll.iterator(); i.hasNext();) { + if (sb.length() > 0) { + sb.append(File.pathSeparatorChar); + } + sb.append(i.next()); + } + return sb.toString(); + } + + /** * Overrides the version of DataType to recurse on all DataType * child elements that may have been added. * @param stk the stack of data types to use (recursively). @@ -176,7 +202,7 @@ if (isReference()) { super.dieOnCircularReference(stk, p); } else { - for (Iterator i = rc.iterator(); i.hasNext();) { + for (Iterator i = getNested().iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof DataType) { invokeCircularReferenceCheck((DataType) o, stk, p); @@ -200,25 +226,7 @@ coll = (coll == null) ? new MyCollection() : coll; } - /** - * Format this BaseResourceCollectionContainer as a String. - * @return a descriptive String. - */ - public synchronized String toString() { - if (isReference()) { - return getCheckedRef().toString(); - } - if (coll == null || coll.isEmpty()) { - return ""; - } - StringBuffer sb = new StringBuffer(); - for (Iterator i = coll.iterator(); i.hasNext();) { - if (sb.length() > 0) { - sb.append(File.pathSeparatorChar); - } - sb.append(i.next()); - } - return sb.toString(); + private synchronized List getNested() { + return rc == null ? Collections.EMPTY_LIST : rc; } - } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org