You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/11/13 00:01:39 UTC

svn commit: r1541300 - in /myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago: ajax/AjaxUtils.java application/ActionListenerImpl.java application/LabelValueExpressionFacesMessage.java

Author: lofwyr
Date: Tue Nov 12 23:01:39 2013
New Revision: 1541300

URL: http://svn.apache.org/r1541300
Log:
code style: setting final, when possible

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/AjaxUtils.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/ActionListenerImpl.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/LabelValueExpressionFacesMessage.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/AjaxUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/AjaxUtils.java?rev=1541300&r1=1541299&r2=1541300&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/AjaxUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/ajax/AjaxUtils.java Tue Nov 12 23:01:39 2013
@@ -40,49 +40,49 @@ import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
 
-public class AjaxUtils {
+public final class AjaxUtils {
 
   private static final Logger LOG = LoggerFactory.getLogger(AjaxUtils.class);
 
   private AjaxUtils() {
   }
 
-  public static boolean isAjaxRequest(FacesContext facesContext) {
-    Map parameterMap = facesContext.getExternalContext().getRequestParameterMap();
-    String ajaxComponentIds = (String) parameterMap.get(AjaxInternalUtils.TOBAGO_PARTIAL_IDS);
+  public static boolean isAjaxRequest(final FacesContext facesContext) {
+    final Map parameterMap = facesContext.getExternalContext().getRequestParameterMap();
+    final String ajaxComponentIds = (String) parameterMap.get(AjaxInternalUtils.TOBAGO_PARTIAL_IDS);
     return ajaxComponentIds != null;
   }
 
-  public static void removeAjaxComponent(FacesContext facesContext, String clientId) {
-    Map<String, UIComponent> ajaxComponents = AjaxInternalUtils.getAjaxComponents(facesContext);
+  public static void removeAjaxComponent(final FacesContext facesContext, final String clientId) {
+    final Map<String, UIComponent> ajaxComponents = AjaxInternalUtils.getAjaxComponents(facesContext);
     if (ajaxComponents != null) {
       ajaxComponents.remove(clientId);
     }
   }
 
-  public static void addAjaxComponent(FacesContext facesContext, String clientId) {
+  public static void addAjaxComponent(final FacesContext facesContext, final String clientId) {
     addAjaxComponent(facesContext, facesContext.getViewRoot().findComponent(clientId));
   }
 
-  public static void addAjaxComponent(FacesContext facesContext, UIComponent component) {
+  public static void addAjaxComponent(final FacesContext facesContext, final UIComponent component) {
     if (component == null) {
       LOG.warn("Ignore AjaxComponent: null");
       return;
     }
-    Map<String, UIComponent> ajaxComponents = AjaxInternalUtils.getAjaxComponents(facesContext);
+    final Map<String, UIComponent> ajaxComponents = AjaxInternalUtils.getAjaxComponents(facesContext);
     if (ajaxComponents != null) {
       ajaxComponents.put(component.getClientId(facesContext), component);
     }
   }
 
-  public static Set<String> getRequestPartialIds(FacesContext facesContext) {
-    Map parameterMap = facesContext.getExternalContext().getRequestParameterMap();
-    String ajaxComponentIds = (String) parameterMap.get(AjaxInternalUtils.TOBAGO_PARTIAL_IDS);
+  public static Set<String> getRequestPartialIds(final FacesContext facesContext) {
+    final Map parameterMap = facesContext.getExternalContext().getRequestParameterMap();
+    final String ajaxComponentIds = (String) parameterMap.get(AjaxInternalUtils.TOBAGO_PARTIAL_IDS);
     if (ajaxComponentIds != null) {
-      StringTokenizer tokenizer = new StringTokenizer(ajaxComponentIds, ",");
-      Set<String> ajaxComponents = new HashSet<String>(tokenizer.countTokens());
+      final StringTokenizer tokenizer = new StringTokenizer(ajaxComponentIds, ",");
+      final Set<String> ajaxComponents = new HashSet<String>(tokenizer.countTokens());
       while (tokenizer.hasMoreTokens()) {
-        String ajaxId = tokenizer.nextToken();
+        final String ajaxId = tokenizer.nextToken();
         ajaxComponents.add(ajaxId);
       }
       return ajaxComponents;
@@ -93,12 +93,12 @@ public class AjaxUtils {
   /**
    * @return true if a UIMessage component has added to renderedPartially
    */
-  public static boolean addUIMessagesToRenderedPartially(FacesContext context) {
+  public static boolean addUIMessagesToRenderedPartially(final FacesContext context) {
     if (!isAjaxRequest(context)) {
       return false;
     }
-    List<String> list = AjaxInternalUtils.getMessagesComponentIds(context);
-    Iterator clientIds = context.getClientIdsWithMessages();
+    final List<String> list = AjaxInternalUtils.getMessagesComponentIds(context);
+    final Iterator clientIds = context.getClientIdsWithMessages();
     boolean added = false;
 
     if (clientIds.hasNext()) { // messages in the partial part
@@ -119,14 +119,14 @@ public class AjaxUtils {
   /**
    * @deprecated since 2.0.0. Is no longer needed
    */
-  public static boolean redirect(FacesContext facesContext, String url) throws IOException {
+  public static boolean redirect(final FacesContext facesContext, final String url) throws IOException {
     if (!isAjaxRequest(facesContext)) {
       return false;
     }
-    HttpServletResponse httpServletResponse
+    final HttpServletResponse httpServletResponse
           = (HttpServletResponse) facesContext.getExternalContext().getResponse();
-    Writer writer = httpServletResponse.getWriter();
-    String contentType = "application/json; charset=UTF-8";
+    final Writer writer = httpServletResponse.getWriter();
+    final String contentType = "application/json; charset=UTF-8";
     ResponseUtils.ensureContentTypeHeader(facesContext, contentType);
     ResponseUtils.ensureNoCacheHeader(facesContext);
     redirectInternal(writer, url);
@@ -138,7 +138,7 @@ public class AjaxUtils {
   /**
    * @deprecated since 2.0.0. Is no longer needed
    */
-  private static void redirectInternal(Writer writer, String url) throws IOException {
+  private static void redirectInternal(final Writer writer, final String url) throws IOException {
     writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
     writer.write("{\n  \"tobagoAjaxResponse\": true,\n");
     writer.write("  \"responseCode\": 302,\n");
@@ -151,7 +151,7 @@ public class AjaxUtils {
   /**
    * @deprecated since 2.0.0. Is no longer needed
    */
-  public static void redirect(HttpServletResponse response, String url) throws IOException {
+  public static void redirect(final HttpServletResponse response, final String url) throws IOException {
     PrintWriter writer = response.getWriter();
     String contentType = "application/json; charset=UTF-8";
     ResponseUtils.ensureContentTypeHeader(response, contentType);

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/ActionListenerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/ActionListenerImpl.java?rev=1541300&r1=1541299&r2=1541300&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/ActionListenerImpl.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/ActionListenerImpl.java Tue Nov 12 23:01:39 2013
@@ -42,11 +42,11 @@ public class ActionListenerImpl implemen
 
   private String errorOutcome = "error";
 
-  public ActionListenerImpl(ActionListener base) {
+  public ActionListenerImpl(final ActionListener base) {
     this.base = base;
   }
 
-  public void processAction(ActionEvent event) throws AbortProcessingException {
+  public void processAction(final ActionEvent event) throws AbortProcessingException {
     try {
       base.processAction(event);
     } catch (Throwable e) {
@@ -60,19 +60,19 @@ public class ActionListenerImpl implemen
         }
       }
       LOG.error("Processing failed. Forwarding to error page. errorOutcome=" + errorOutcome, e.getCause());
-      FacesContext facesContext = FacesContext.getCurrentInstance();
+      final FacesContext facesContext = FacesContext.getCurrentInstance();
       if (e.getCause() != null) {
          FacesMessage facesMessage = new FacesMessage(e.getCause().toString());
          facesContext.addMessage(null, facesMessage);
       }
-      UIComponent source = event.getComponent();
-      ActionSource2 actionSource = (ActionSource2) source;
-      Application application = facesContext.getApplication();
-      MethodExpression expression = actionSource.getActionExpression();
+      final UIComponent source = event.getComponent();
+      final ActionSource2 actionSource = (ActionSource2) source;
+      final Application application = facesContext.getApplication();
+      final MethodExpression expression = actionSource.getActionExpression();
       // Retrieve the NavigationHandler instance..
-      NavigationHandler navHandler = application.getNavigationHandler();
+      final NavigationHandler navHandler = application.getNavigationHandler();
       // Invoke nav handling..
-      String navBinding = (null != expression) ? expression.getExpressionString() : null;
+      final String navBinding = (null != expression) ? expression.getExpressionString() : null;
       navHandler.handleNavigation(facesContext, navBinding, errorOutcome);
       // Trigger a switch to Render Response if needed
       facesContext.renderResponse();
@@ -83,7 +83,7 @@ public class ActionListenerImpl implemen
     return errorOutcome;
   }
 
-  public void setErrorOutcome(String errorOutcome) {
+  public void setErrorOutcome(final String errorOutcome) {
     this.errorOutcome = errorOutcome;
   }
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/LabelValueExpressionFacesMessage.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/LabelValueExpressionFacesMessage.java?rev=1541300&r1=1541299&r2=1541300&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/LabelValueExpressionFacesMessage.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/application/LabelValueExpressionFacesMessage.java Tue Nov 12 23:01:39 2013
@@ -28,30 +28,31 @@ public class LabelValueExpressionFacesMe
     super();
   }
 
-  public LabelValueExpressionFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
+  public LabelValueExpressionFacesMessage(
+      final FacesMessage.Severity severity, final String summary, final String detail) {
     super(severity, summary, detail);
   }
 
-  public LabelValueExpressionFacesMessage(String summary, String detail) {
+  public LabelValueExpressionFacesMessage(final String summary, final String detail) {
     super(summary, detail);
   }
 
-  public LabelValueExpressionFacesMessage(String summary) {
+  public LabelValueExpressionFacesMessage(final String summary) {
     super(summary);
   }
 
   @Override
   public String getDetail() {
-    FacesContext facesContext = FacesContext.getCurrentInstance();
-    ValueExpression value = facesContext.getApplication().getExpressionFactory().
+    final FacesContext facesContext = FacesContext.getCurrentInstance();
+    final ValueExpression value = facesContext.getApplication().getExpressionFactory().
         createValueExpression(facesContext.getELContext(), super.getDetail(), String.class);
     return (String) value.getValue(facesContext.getELContext());
   }
 
   @Override
   public String getSummary() {
-    FacesContext facesContext = FacesContext.getCurrentInstance();
-    ValueExpression value = facesContext.getApplication().getExpressionFactory().
+    final FacesContext facesContext = FacesContext.getCurrentInstance();
+    final ValueExpression value = facesContext.getApplication().getExpressionFactory().
         createValueExpression(facesContext.getELContext(), super.getSummary(), String.class);
     return (String) value.getValue(facesContext.getELContext());
   }