Author: aheritier
Date: Fri Jul 21 14:51:10 2006
New Revision: 424464

URL: http://svn.apache.org/viewvc?rev=424464&view=rev
Log:
Avoid using negation in if/else 

Modified:
    
maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/ArtifactDownloader.java
    
maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/BootstrapPomParser.java
    maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/Dependency.java
    maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java
    
maven/maven-1/core/trunk/src/java/org/apache/maven/jelly/JellyBuildListener.java
    
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java
    
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginCacheManager.java
    maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java
    
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginScriptParser.java
    maven/maven-1/core/trunk/src/java/org/apache/maven/util/MavenTool.java

Modified: 
maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/ArtifactDownloader.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/ArtifactDownloader.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- 
maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/ArtifactDownloader.java 
(original)
+++ 
maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/ArtifactDownloader.java 
Fri Jul 21 14:51:10 2006
@@ -155,7 +155,12 @@
             // used here. Those are the "" parameters you see below.
             String url = remoteRepo + "/" + file;
 
-            if ( !url.startsWith( "file" ) )
+            if ( url.startsWith( "file" ) )
+            {
+                // THe JDK URL for file: should have one or no / instead of // 
for some reason
+                url = replace( url, "file://", "file:" );
+            }
+            else
             {
                 url = replace( url, "//", "/" );
                 if ( url.startsWith( "https" ) )
@@ -166,11 +171,6 @@
                 {
                     url = replace( url, "http:/", "http://"; );
                 }
-            }
-            else
-            {
-                // THe JDK URL for file: should have one or no / instead of // 
for some reason
-                url = replace( url, "file://", "file:" );
             }
 
             // Attempt to retrieve the artifact and set the checksum if 
retrieval

Modified: 
maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/BootstrapPomParser.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/BootstrapPomParser.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- 
maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/BootstrapPomParser.java 
(original)
+++ 
maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/BootstrapPomParser.java 
Fri Jul 21 14:51:10 2006
@@ -33,16 +33,20 @@
  * A class to parse the POM.
  */
 public class BootstrapPomParser
-     extends DefaultHandler
+    extends DefaultHandler
 {
     /** the project dependencies */
     private ArrayList dependencies = new ArrayList();
+
     /** current dependency being processed */
     private Dependency currentDependency;
+
     /** factory to create a sax parser */
     private static SAXParserFactory saxFactory;
+
     /** whether we're inside a dependency element during parsing */
     private boolean insideDependency = false;
+
     /** text of the element being processed */
     private StringBuffer bodyText = new StringBuffer();
 
@@ -58,16 +62,16 @@
      * Parse a POM
      * @param project the project file to parse
      */
-    public void parse(File project)
+    public void parse( File project )
     {
         try
         {
             saxFactory = SAXParserFactory.newInstance();
             SAXParser parser = saxFactory.newSAXParser();
-            InputSource is = new InputSource(new FileInputStream(project));
-            parser.parse(is, this);
+            InputSource is = new InputSource( new FileInputStream( project ) );
+            parser.parse( is, this );
         }
-        catch (Exception e)
+        catch ( Exception e )
         {
             e.printStackTrace();
         }
@@ -80,9 +84,9 @@
      * @param rawName element name
      * @param attributes element attributes
      */
-    public void startElement(String uri, String localName, String rawName, 
Attributes attributes)
+    public void startElement( String uri, String localName, String rawName, 
Attributes attributes )
     {
-        if ("dependency".equals( rawName ))
+        if ( "dependency".equals( rawName ) )
         {
             currentDependency = new Dependency();
             insideDependency = true;
@@ -95,9 +99,9 @@
      * @param start the start position of text in the buffer
      * @param length the length of the text in the buffer
      */
-    public void characters(char[] buffer, int start, int length)
+    public void characters( char[] buffer, int start, int length )
     {
-        bodyText.append(buffer, start, length);
+        bodyText.append( buffer, start, length );
     }
 
     /**
@@ -114,36 +118,36 @@
      * @param localName element without namespace
      * @param rawName element name
      */
-    public void endElement(String uri, String localName, String rawName)
+    public void endElement( String uri, String localName, String rawName )
     {
-        if ("dependency".equals( rawName ))
+        if ( "dependency".equals( rawName ) )
         {
-            dependencies.add(currentDependency);
+            dependencies.add( currentDependency );
             insideDependency = false;
         }
-        else if ("id".equals( rawName ) && insideDependency)
+        else if ( "id".equals( rawName ) && insideDependency )
         {
-            currentDependency.setId(getBodyText());
+            currentDependency.setId( getBodyText() );
         }
-        else if ("version".equals( rawName ) && insideDependency)
+        else if ( "version".equals( rawName ) && insideDependency )
         {
-            currentDependency.setVersion(getBodyText());
+            currentDependency.setVersion( getBodyText() );
         }
-        else if ("jar".equals( rawName ) && insideDependency)
+        else if ( "jar".equals( rawName ) && insideDependency )
         {
-            currentDependency.setJar(getBodyText());
+            currentDependency.setJar( getBodyText() );
         }
-        else if ("type".equals( rawName ) && insideDependency)
+        else if ( "type".equals( rawName ) && insideDependency )
         {
-            currentDependency.setType(getBodyText());
+            currentDependency.setType( getBodyText() );
         }
-        else if ("groupId".equals( rawName ) && insideDependency)
+        else if ( "groupId".equals( rawName ) && insideDependency )
         {
-            currentDependency.setGroupId(getBodyText());
+            currentDependency.setGroupId( getBodyText() );
         }
-        else if ("artifactId".equals( rawName ) && insideDependency)
+        else if ( "artifactId".equals( rawName ) && insideDependency )
         {
-            currentDependency.setArtifactId(getBodyText());
+            currentDependency.setArtifactId( getBodyText() );
         }
 
         bodyText = new StringBuffer();
@@ -154,9 +158,9 @@
      *
      * @param spe The parse exception that caused the callback to be invoked.
      */
-    public void warning(SAXParseException spe)
+    public void warning( SAXParseException spe )
     {
-        printParseError("Warning", spe);
+        printParseError( "Warning", spe );
     }
 
     /**
@@ -164,9 +168,9 @@
      *
      * @param spe The parse exception that caused the callback to be invoked.
      */
-    public void error(SAXParseException spe)
+    public void error( SAXParseException spe )
     {
-        printParseError("Error", spe);
+        printParseError( "Error", spe );
     }
 
     /**
@@ -174,9 +178,9 @@
      *
      * @param spe The parse exception that caused the callback to be invoked.
      */
-    public void fatalError(SAXParseException spe)
+    public void fatalError( SAXParseException spe )
     {
-        printParseError("Fatal Error", spe);
+        printParseError( "Fatal Error", spe );
     }
 
     /**
@@ -184,10 +188,9 @@
      * @param type the type of error
      * @param spe The parse exception that caused the callback to be invoked.
      */
-    private final void printParseError(String type, SAXParseException spe)
+    private final void printParseError( String type, SAXParseException spe )
     {
-        System.err.println(type + " [line " + spe.getLineNumber()
-            + ", row " + spe.getColumnNumber() + "]: "
-            + spe.getMessage());
+        System.err.println( type + " [line " + spe.getLineNumber() + ", row " 
+ spe.getColumnNumber() + "]: "
+            + spe.getMessage() );
     }
 }

Modified: 
maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/Dependency.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/Dependency.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/Dependency.java 
(original)
+++ maven/maven-1/core/trunk/src/bootstrap/org/apache/maven/Dependency.java Fri 
Jul 21 14:51:10 2006
@@ -66,8 +66,7 @@
      */
     public String getId()
     {
-        if (    isValid( getGroupId() )
-             && isValid( getArtifactId() ) )
+        if ( isValid( getGroupId() ) && isValid( getArtifactId() ) )
         {
             // We have something like:
             //
@@ -150,7 +149,7 @@
     {
         // If the jar name has been explicty set then use that. This
         // is when the <jar/> element is explicity used in the POM.
-        if ( jar != null)
+        if ( jar != null )
         {
             return jar;
         }
@@ -235,7 +234,6 @@
         return url;
     }
 
-
     /**
      * Set the type of the dependency.
      *
@@ -263,8 +261,7 @@
      */
     public String toString()
     {
-        return "Dep[ id:" + getId() + " pid:" + getId()
-            + " ver:" + getVersion() + " ar:" + getArtifact() + " jar:"
+        return "Dep[ id:" + getId() + " pid:" + getId() + " ver:" + 
getVersion() + " ar:" + getArtifact() + " jar:"
             + getJar() + " ]";
     }
 
@@ -278,8 +275,7 @@
      */
     protected boolean isValid( String value )
     {
-        if (    value != null
-             && !"".equals( value.trim() ) )
+        if ( value != null && !"".equals( value.trim() ) )
         {
             return true;
         }

Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java 
(original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java Fri Jul 
21 14:51:10 2006
@@ -850,13 +850,13 @@
         throws IOException
     {
         File f = new File( dir );
-        if ( !( f.isAbsolute() ) )
+        if ( ( f.isAbsolute() ) )
         {
-            return new File( basedir, dir ).getCanonicalPath();
+            return f.getCanonicalPath();
         }
         else
         {
-            return f.getCanonicalPath();
+            return new File( basedir, dir ).getCanonicalPath();
         }
     }
 

Modified: 
maven/maven-1/core/trunk/src/java/org/apache/maven/jelly/JellyBuildListener.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/jelly/JellyBuildListener.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- 
maven/maven-1/core/trunk/src/java/org/apache/maven/jelly/JellyBuildListener.java
 (original)
+++ 
maven/maven-1/core/trunk/src/java/org/apache/maven/jelly/JellyBuildListener.java
 Fri Jul 21 14:51:10 2006
@@ -105,19 +105,19 @@
 
             switch ( event.getPriority() )
             {
-                case ( Project.MSG_ERR    ):
+                case ( Project.MSG_ERR     ):
                     out.write( "[ERROR] " );
                     break;
-                case ( Project.MSG_WARN    ):
+                case ( Project.MSG_WARN     ):
                     // out.write( "[WARN] ");
                     break;
-                case ( Project.MSG_INFO    ):
+                case ( Project.MSG_INFO     ):
                     // normal, do nothing.
                     break;
-                case ( Project.MSG_VERBOSE    ):
+                case ( Project.MSG_VERBOSE     ):
                     out.write( "[VERBOSE] " );
                     break;
-                case ( Project.MSG_DEBUG    ):
+                case ( Project.MSG_DEBUG     ):
                     out.write( "[DEBUG] " );
                     break;
             }

Modified: 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java
 (original)
+++ 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/GoalToJellyScriptHousingMapper.java
 Fri Jul 21 14:51:10 2006
@@ -502,7 +502,7 @@
         for ( Iterator i = dynaTagPluginMap.keySet().iterator(); i.hasNext(); )
         {
             String uri = (String) i.next();
-            if ( dynaTagPluginMap.get(uri).equals( housing ) )
+            if ( dynaTagPluginMap.get( uri ).equals( housing ) )
             {
                 i.remove();
             }

Modified: 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginCacheManager.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginCacheManager.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginCacheManager.java
 (original)
+++ 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginCacheManager.java
 Fri Jul 21 14:51:10 2006
@@ -450,17 +450,17 @@
                 while ( tok.hasMoreTokens() )
                 {
                     String name = tok.nextToken();
-                    if ( !name.equals( pluginName ) )
+                    if ( name.equals( pluginName ) )
+                    {
+                        changed = true;
+                    }
+                    else
                     {
                         if ( newCallback.length() > 0 )
                         {
                             newCallback.append( "," );
                         }
                         newCallback.append( name );
-                    }
-                    else
-                    {
-                        changed = true;
                     }
                 }
                 if ( changed )

Modified: 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java 
(original)
+++ 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginManager.java 
Fri Jul 21 14:51:10 2006
@@ -1049,7 +1049,12 @@
         if ( housing != null )
         {
             Project project = housing.getProject();
-            if ( !baseContext.equals( project.getContext().getParent() ) )
+            if ( baseContext.equals( project.getContext().getParent() ) )
+            {
+                log.debug( "Plugin context for " + id + " already initialised 
for this base context" );
+                return project.getContext();
+            }
+            else
             {
                 log.debug( "Plugin context for " + id
                     + " not initialised for this base context: initialising 
inside getPluginContext" );
@@ -1061,11 +1066,6 @@
                 {
                     throw new MavenException( "Error initialising plugin 
context", e );
                 }
-            }
-            else
-            {
-                log.debug( "Plugin context for " + id + " already initialised 
for this base context" );
-                return project.getContext();
             }
         }
         throw new UnknownPluginException( id );

Modified: 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginScriptParser.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginScriptParser.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginScriptParser.java
 (original)
+++ 
maven/maven-1/core/trunk/src/java/org/apache/maven/plugin/PluginScriptParser.java
 Fri Jul 21 14:51:10 2006
@@ -225,7 +225,8 @@
      */
     private final void printParseError( String type, SAXParseException spe )
     {
-        log.error( type + " [line " + spe.getLineNumber() + ", row " + 
spe.getColumnNumber() + "]: "
-            + spe.getMessage() );
+        log
+            .error( type + " [line " + spe.getLineNumber() + ", row " + 
spe.getColumnNumber() + "]: "
+                + spe.getMessage() );
     }
 }

Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/util/MavenTool.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/util/MavenTool.java?rev=424464&r1=424463&r2=424464&view=diff
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/util/MavenTool.java 
(original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/util/MavenTool.java Fri 
Jul 21 14:51:10 2006
@@ -166,13 +166,13 @@
             list = (List) counted.get( key );
             Integer count = new Integer( list.size() );
             Set items = null;
-            if ( !map.containsKey( count ) )
+            if ( map.containsKey( count ) )
             {
-                items = new TreeSet();
+                items = (Set) map.get( count );
             }
             else
             {
-                items = (Set) map.get( count );
+                items = new TreeSet();
             }
             items.add( key );
             map.put( count, items );


Reply via email to