Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 33574 invoked from network); 27 Dec 2006 23:49:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Dec 2006 23:49:34 -0000 Received: (qmail 89518 invoked by uid 500); 27 Dec 2006 23:49:40 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 89476 invoked by uid 500); 27 Dec 2006 23:49:40 -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 89465 invoked by uid 500); 27 Dec 2006 23:49:40 -0000 Received: (qmail 89462 invoked by uid 99); 27 Dec 2006 23:49:40 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Dec 2006 15:49:40 -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; Wed, 27 Dec 2006 15:49:32 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id C06AD1A981A; Wed, 27 Dec 2006 15:48:39 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r490604 - /ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java Date: Wed, 27 Dec 2006 23:48:39 -0000 To: ant-cvs@apache.org From: peterreilly@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061227234839.C06AD1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: peterreilly Date: Wed Dec 27 15:48:39 2006 New Revision: 490604 URL: http://svn.apache.org/viewvc?view=rev&rev=490604 Log: checkstyle: make method a little smaller Modified: ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java?view=diff&rev=490604&r1=490603&r2=490604 ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java Wed Dec 27 15:48:39 2006 @@ -853,18 +853,7 @@ AntTypeDefinition def = getDefinition(componentName); if (def == null) { //not a known type - boolean isAntlib = componentName.indexOf(MagicNames.ANTLIB_PREFIX) == 0; - out.println("Cause: The name is undefined."); - out.println("Action: Check the spelling."); - out.println("Action: Check that any custom tasks/types have been declared."); - out.println("Action: Check that any /" - + " declarations have taken place."); - if (isAntlib) { - out.println(); - out.println("This appears to be an antlib declaration. "); - out.println("Action: Check that the implementing library exists in one of:"); - out.println(dirListing); - } + printUnknownDefinition(out, componentName, dirListing); definitions = true; } else { //we are defined, so it is an instantiation problem @@ -878,35 +867,14 @@ try { clazz = def.innerGetTypeClass(); } catch (ClassNotFoundException e) { - out.println("Cause: the class " + classname + " was not found."); jars = true; - if (optional) { - out.println(" This looks like one of Ant's optional components."); - out.println("Action: Check that the appropriate optional JAR exists in"); - out.println(dirListing); - } else { - out.println("Action: Check that the component has been correctly declared"); - out.println(" and that the implementing JAR is in one of:"); - out.println(dirListing); + if (!optional) { definitions = true; } + printClassNotFound(out, classname, optional, dirListing); } catch (NoClassDefFoundError ncdfe) { jars = true; - out.println("Cause: Could not load a dependent class " - + ncdfe.getMessage()); - if (optional) { - out.println(" It is not enough to have Ant's optional JARs"); - out.println(" you need the JAR files that the" - + " optional tasks depend upon."); - out.println(" Ant's optional task dependencies are" - + " listed in the manual."); - } else { - out.println(" This class may be in a separate JAR" - + " that is not installed."); - } - out.println("Action: Determine what extra JAR files are" - + " needed, and place them in one of:"); - out.println(dirListing); + printNotLoadDependentClass(out, optional, ncdfe, dirListing); } //here we successfully loaded the class or failed. if (clazz != null) { @@ -973,6 +941,66 @@ out.flush(); out.close(); return errorText.toString(); + } + + /** + * Print unknown definition. + */ + private void printUnknownDefinition( + PrintWriter out, String componentName, String dirListing) { + boolean isAntlib = componentName.indexOf(MagicNames.ANTLIB_PREFIX) == 0; + out.println("Cause: The name is undefined."); + out.println("Action: Check the spelling."); + out.println("Action: Check that any custom tasks/types have been declared."); + out.println("Action: Check that any /" + + " declarations have taken place."); + if (isAntlib) { + out.println(); + out.println("This appears to be an antlib declaration. "); + out.println("Action: Check that the implementing library exists in one of:"); + out.println(dirListing); + } + } + + /** + * Print class not found. + */ + private void printClassNotFound( + PrintWriter out, String classname, boolean optional, + String dirListing) { + out.println("Cause: the class " + classname + " was not found."); + if (optional) { + out.println(" This looks like one of Ant's optional components."); + out.println("Action: Check that the appropriate optional JAR exists in"); + out.println(dirListing); + } else { + out.println("Action: Check that the component has been correctly declared"); + out.println(" and that the implementing JAR is in one of:"); + out.println(dirListing); + } + } + + /** + * Print could not load dependent class. + */ + private void printNotLoadDependentClass( + PrintWriter out, boolean optional, NoClassDefFoundError ncdfe, + String dirListing) { + out.println("Cause: Could not load a dependent class " + + ncdfe.getMessage()); + if (optional) { + out.println(" It is not enough to have Ant's optional JARs"); + out.println(" you need the JAR files that the" + + " optional tasks depend upon."); + out.println(" Ant's optional task dependencies are" + + " listed in the manual."); + } else { + out.println(" This class may be in a separate JAR" + + " that is not installed."); + } + out.println("Action: Determine what extra JAR files are" + + " needed, and place them in one of:"); + out.println(dirListing); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org