jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From juanpa...@apache.org
Subject svn commit: r1553562 - /jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java
Date Thu, 26 Dec 2013 19:44:00 GMT
Author: juanpablo
Date: Thu Dec 26 19:44:00 2013
New Revision: 1553562

URL: http://svn.apache.org/r1553562
Log:
sonar: Dodgy - Redundant nullcheck of value known to be non-null

code formatting

Modified:
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java?rev=1553562&r1=1553561&r2=1553562&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/forms/FormTextarea.java Thu Dec
26 19:44:00 2013
@@ -29,6 +29,7 @@ import org.apache.wiki.api.exceptions.Pl
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.preferences.Preferences;
 
+
 /**
  *  Creates a Form text area element.   You may specify the size of the textarea
  *  by using the {@link #PARAM_COLS} and {@link #PARAM_ROWS} to signify the width
@@ -46,25 +47,20 @@ public class FormTextarea extends FormEl
     /**
      *  {@inheritDoc}
      */
-    public String execute( WikiContext ctx, Map< String, String > params )
-        throws PluginException
-    {
+    public String execute( WikiContext ctx, Map< String, String > params ) throws PluginException
{
         // Don't render if no error and error-only-rendering is on.
         FormInfo info = getFormInfo( ctx );
         Map< String, String > previousValues = null;
         ResourceBundle rb = Preferences.getBundle( ctx, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE
);
 
-        if( info != null )
-        {
-            if( info.hide() )
-            {
+        if( info != null ) {
+            if( info.hide() ) {
                 return "<p>" + rb.getString( "formclose.noneedtoshow" ) + "</p>";
             }
             previousValues = info.getSubmission();
         }
 
-        if( previousValues == null )
-        {
+        if( previousValues == null ) {
             previousValues = new HashMap< String, String >();
         }
 
@@ -73,10 +69,7 @@ public class FormTextarea extends FormEl
         field = buildTextArea( params, previousValues, rb );
 
         // We should look for extra params, e.g. width, ..., here.
-        if( field != null )
-            return field.toString( ctx.getEngine().getContentEncoding() );
-
-        return "";
+        return field.toString( ctx.getEngine().getContentEncoding() );
     }
 
     private textarea buildTextArea( Map< String, String > params, Map< String, String
> previousValues, ResourceBundle rb )
@@ -86,14 +79,14 @@ public class FormTextarea extends FormEl
         String rows = params.get( PARAM_ROWS );
         String cols = params.get( PARAM_COLS );
 
-        if( inputName == null )
-            throw new PluginException( rb.getString( "formtextarea.namemissing" ) );
+        if( inputName == null ) {
+        	throw new PluginException( rb.getString( "formtextarea.namemissing" ) );
+        }
 
         // In order to isolate posted form elements into their own
         // map, prefix the variable name here. It will be stripped
         // when the handler plugin is executed.
-        textarea field = new textarea( HANDLERPARAM_PREFIX + inputName,
-                                       rows, cols);
+        textarea field = new textarea( HANDLERPARAM_PREFIX + inputName, rows, cols);
 
         if( previousValues != null )
         {
@@ -105,9 +98,12 @@ public class FormTextarea extends FormEl
             else
             {
                 oldValue = params.get( PARAM_VALUE );
-                if( oldValue != null ) field.addElement( oldValue );
+                if( oldValue != null ) {
+                	field.addElement( oldValue );
+                }
             }
         }
         return field;
     }
+
 }



Mime
View raw message