myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: refactored
Date Sun, 21 Apr 2019 10:03:00 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 94c2f3a  refactored
94c2f3a is described below

commit 94c2f3a6244f78e4081bc8cd1e7442f7dda0b33a
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Sun Apr 21 12:02:55 2019 +0200

    refactored
---
 .../myfaces/application/NavigationHandlerImpl.java |  22 +++--
 .../myfaces/application/NavigationUtils.java       |   2 +-
 .../myfaces/application/ResourceHandlerImpl.java   | 101 +++++++--------------
 .../apache/myfaces/el/ValueReferenceResolver.java  |   2 +-
 .../org/apache/myfaces/util/UrlPatternMatcher.java |  19 ++--
 5 files changed, 58 insertions(+), 88 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
b/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
index 926dc59..f600aee 100755
--- a/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
@@ -468,7 +468,6 @@ public class NavigationHandlerImpl extends ConfigurableNavigationHandler
         if (navigationCase == null)
         {
             // Wildcard match?
-            //List<String> sortedWildcardKeys = getSortedWildcardKeys();
             List<_WildcardPattern> wildcardPatterns = getSortedWildcardPatterns();
             
             for (int i = 0; i < wildcardPatterns.size(); i++)
@@ -1164,7 +1163,7 @@ public class NavigationHandlerImpl extends ConfigurableNavigationHandler
             }
             
             // Finally, create the NavigationCase.
-            result = new NavigationCase (viewId, fromAction, outcome, null, implicitViewId,
params, isRedirect,
+            result = new NavigationCase(viewId, fromAction, outcome, null, implicitViewId,
params, isRedirect,
                     includeViewParams);
         }
 
@@ -1220,8 +1219,8 @@ public class NavigationHandlerImpl extends ConfigurableNavigationHandler
             {
                 if (cazeOutcome != null)
                 {
-                    if ((actionRef != null) && (outcome != null) && cazeActionRef.equals
(actionRef) &&
-                            cazeOutcome.equals (outcome))
+                    if (actionRef != null && outcome != null
+                            && cazeActionRef.equals(actionRef) && cazeOutcome.equals(outcome))
                     {
                         // First case: match if <from-action> matches action and <from-outcome>
matches outcome.
                         // Caveat: evaluate <if> if available.
@@ -1398,8 +1397,7 @@ public class NavigationHandlerImpl extends ConfigurableNavigationHandler
         Map<String, Set<NavigationCase>> rules = flow.getNavigationCases();
         int rulesSize = rules.size();
 
-        Map<String, Set<NavigationCase>> cases = new HashMap<String, Set<NavigationCase>>(
-                HashMapUtils.calcCapacity(rulesSize));
+        Map<String, Set<NavigationCase>> cases = new HashMap<>(HashMapUtils.calcCapacity(rulesSize));
 
         List<_WildcardPattern> wildcardPatterns = new ArrayList<_WildcardPattern>();
 
@@ -1433,7 +1431,7 @@ public class NavigationHandlerImpl extends ConfigurableNavigationHandler
             }
         }
 
-        Collections.sort(wildcardPatterns, new KeyComparator());
+        Collections.sort(wildcardPatterns, KeyComparator.INSTANCE);
 
         _flowNavigationStructureMap.put(
             flow.getId(), 
@@ -1481,7 +1479,7 @@ public class NavigationHandlerImpl extends ConfigurableNavigationHandler
                 }
             }
 
-            Collections.sort(wildcardPatterns, new KeyComparator());
+            Collections.sort(wildcardPatterns, KeyComparator.INSTANCE);
 
             synchronized (cases)
             {
@@ -1499,6 +1497,12 @@ public class NavigationHandlerImpl extends ConfigurableNavigationHandler
 
     private static final class KeyComparator implements Comparator<_WildcardPattern>
     {
+        private static final KeyComparator INSTANCE = new KeyComparator();
+        
+        private KeyComparator()
+        {
+        }
+
         @Override
         public int compare(_WildcardPattern s1, _WildcardPattern s2)
         {
@@ -1513,7 +1517,7 @@ public class NavigationHandlerImpl extends ConfigurableNavigationHandler
         
         for(org.apache.myfaces.config.element.NavigationCase configCase : configCases)
         {   
-            if(configCase.getRedirect() != null)
+            if (configCase.getRedirect() != null)
             {
                 String includeViewParamsAttribute = configCase.getRedirect().getIncludeViewParams();
                 boolean includeViewParams = false; // default value is false
diff --git a/impl/src/main/java/org/apache/myfaces/application/NavigationUtils.java b/impl/src/main/java/org/apache/myfaces/application/NavigationUtils.java
index 3053a01..3c6106d 100644
--- a/impl/src/main/java/org/apache/myfaces/application/NavigationUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/application/NavigationUtils.java
@@ -98,7 +98,7 @@ public class NavigationUtils
     
     private static boolean _isExpression(String text)
     {
-        return text.indexOf("#{") != -1;
+        return text.contains("#{");
     }
 
 }
diff --git a/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java b/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
index 79e400e..343bb3e 100644
--- a/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
@@ -79,27 +79,24 @@ public class ResourceHandlerImpl extends ResourceHandler
 {
     private static final String IS_RESOURCE_REQUEST = "org.apache.myfaces.IS_RESOURCE_REQUEST";
 
-    private ResourceHandlerSupport _resourceHandlerSupport;
-
-    private ResourceHandlerCache _resourceHandlerCache;
-
     private static final Logger log = Logger.getLogger(ResourceHandlerImpl.class.getName());
 
     public static final Pattern LIBRARY_VERSION_CHECKER = Pattern.compile("\\p{Digit}+(_\\p{Digit}*)*");
     public static final Pattern RESOURCE_VERSION_CHECKER = Pattern.compile("\\p{Digit}+(_\\p{Digit}*)*\\..*");
   
     
-    private Boolean _allowSlashLibraryName;
-    private int _resourceBufferSize = -1;
-    
-    private String[] _excludedResourceExtensions;
+    public final static String RENDERED_RESOURCES_SET = "org.apache.myfaces.RENDERED_RESOURCES_SET";
+
+    private static final String SHARED_STRING_BUILDER = ResourceHandlerImpl.class.getName()
+ ".SHARED_STRING_BUILDER";
     
     private static final String[] FACELETS_VIEW_MAPPINGS_PARAM = {ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME,
             "facelets.VIEW_MAPPINGS"};
-    private Set<String> _viewSuffixes = null;
     
-    public final static String RENDERED_RESOURCES_SET = "org.apache.myfaces.RENDERED_RESOURCES_SET";
-
-    private static final String SHARED_STRING_BUILDER = ResourceHandlerImpl.class.getName()
+ ".SHARED_STRING_BUILDER";
+    private ResourceHandlerSupport _resourceHandlerSupport;
+    private ResourceHandlerCache _resourceHandlerCache;
+    private Boolean _allowSlashLibraryName;
+    private int _resourceBufferSize = -1;
+    private String[] _excludedResourceExtensions;
+    private Set<String> _viewSuffixes = null;
 
     @Override
     public Resource createResource(String resourceName)
@@ -290,15 +287,12 @@ public class ResourceHandlerImpl extends ResourceHandler
                     String pathToResource = localePrefix + '/'
                             + libraryName + '/' + libraryVersion + '/'
                             + resourceName;
-                    resourceVersion = resourceLoader
-                            .getResourceVersion(pathToResource, contractName);
+                    resourceVersion = resourceLoader.getResourceVersion(pathToResource, contractName);
                 }
                 else
                 {
-                    String pathToResource = localePrefix + '/'
-                            + libraryName + '/' + resourceName;
-                    resourceVersion = resourceLoader
-                            .getResourceVersion(pathToResource, contractName);
+                    String pathToResource = localePrefix + '/' + libraryName + '/' + resourceName;
+                    resourceVersion = resourceLoader.getResourceVersion(pathToResource, contractName);
                 }
 
                 if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
@@ -309,8 +303,7 @@ public class ResourceHandlerImpl extends ResourceHandler
             }
             else
             {
-                resourceVersion = resourceLoader
-                        .getResourceVersion(localePrefix + '/'+ resourceName, contractName);
+                resourceVersion = resourceLoader.getResourceVersion(localePrefix + '/'+ resourceName,
contractName);
                 if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
                 {               
                     resourceId = resourceLoader.createResourceMeta(localePrefix, null, null,
@@ -333,17 +326,13 @@ public class ResourceHandlerImpl extends ResourceHandler
 
                 if (null != libraryVersion)
                 {
-                    String pathToResource = (libraryName + '/' + libraryVersion
-                            + '/' + resourceName);
-                    resourceVersion = resourceLoader
-                            .getResourceVersion(pathToResource, contractName);
+                    String pathToResource = libraryName + '/' + libraryVersion + '/' + resourceName;
+                    resourceVersion = resourceLoader.getResourceVersion(pathToResource, contractName);
                 }
                 else
                 {
-                    String pathToResource = (libraryName + '/'
-                            + resourceName);
-                    resourceVersion = resourceLoader
-                            .getResourceVersion(pathToResource, contractName);
+                    String pathToResource = libraryName + '/' + resourceName;
+                    resourceVersion = resourceLoader.getResourceVersion(pathToResource, contractName);
                 }
 
                 if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
@@ -354,8 +343,7 @@ public class ResourceHandlerImpl extends ResourceHandler
             }
             else
             {
-                resourceVersion = resourceLoader
-                        .getResourceVersion(resourceName, contractName);
+                resourceVersion = resourceLoader.getResourceVersion(resourceName, contractName);
                 
                 if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
                 {               
@@ -399,15 +387,12 @@ public class ResourceHandlerImpl extends ResourceHandler
                     String pathToResource = localePrefix + '/'
                             + libraryName + '/' + libraryVersion + '/'
                             + resourceName;
-                    resourceVersion = resourceLoader
-                            .getResourceVersion(pathToResource);
+                    resourceVersion = resourceLoader.getResourceVersion(pathToResource);
                 }
                 else
                 {
-                    String pathToResource = localePrefix + '/'
-                            + libraryName + '/' + resourceName;
-                    resourceVersion = resourceLoader
-                            .getResourceVersion(pathToResource);
+                    String pathToResource = localePrefix + '/' + libraryName + '/' + resourceName;
+                    resourceVersion = resourceLoader.getResourceVersion(pathToResource);
                 }
 
                 if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
@@ -418,8 +403,7 @@ public class ResourceHandlerImpl extends ResourceHandler
             }
             else
             {
-                resourceVersion = resourceLoader
-                        .getResourceVersion(localePrefix + '/'+ resourceName);
+                resourceVersion = resourceLoader.getResourceVersion(localePrefix + '/'+ resourceName);
                 if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
                 {               
                     resourceId = resourceLoader.createResourceMeta(localePrefix, null, null,
@@ -442,17 +426,13 @@ public class ResourceHandlerImpl extends ResourceHandler
 
                 if (null != libraryVersion)
                 {
-                    String pathToResource = (libraryName + '/' + libraryVersion
-                            + '/' + resourceName);
-                    resourceVersion = resourceLoader
-                            .getResourceVersion(pathToResource);
+                    String pathToResource = libraryName + '/' + libraryVersion + '/' + resourceName;
+                    resourceVersion = resourceLoader.getResourceVersion(pathToResource);
                 }
                 else
                 {
-                    String pathToResource = (libraryName + '/'
-                            + resourceName);
-                    resourceVersion = resourceLoader
-                            .getResourceVersion(pathToResource);
+                    String pathToResource = libraryName + '/' + resourceName;
+                    resourceVersion = resourceLoader.getResourceVersion(pathToResource);
                 }
 
                 if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
@@ -463,8 +443,7 @@ public class ResourceHandlerImpl extends ResourceHandler
             }
             else
             {
-                resourceVersion = resourceLoader
-                        .getResourceVersion(resourceName);
+                resourceVersion = resourceLoader.getResourceVersion(resourceName);
                 
                 if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
                 {               
@@ -554,8 +533,7 @@ public class ResourceHandlerImpl extends ResourceHandler
             return;
         }
 
-        String libraryName = facesContext.getExternalContext()
-                .getRequestParameterMap().get("ln");
+        String libraryName = facesContext.getExternalContext().getRequestParameterMap().get("ln");
 
         if (libraryName != null && !ResourceValidationUtils.isValidLibraryName(
                 libraryName, isAllowSlashesLibraryName()))
@@ -894,18 +872,11 @@ public class ResourceHandlerImpl extends ResourceHandler
         return false;
     }
 
-    /**
-     * @param resourceHandlerSupport
-     *            the resourceHandlerSupport to set
-     */
     public void setResourceHandlerSupport(ResourceHandlerSupport resourceHandlerSupport)
     {
         _resourceHandlerSupport = resourceHandlerSupport;
     }
 
-    /**
-     * @return the resourceHandlerSupport
-     */
     protected ResourceHandlerSupport getResourceHandlerSupport()
     {
         if (_resourceHandlerSupport == null)
@@ -1445,12 +1416,11 @@ public class ResourceHandlerImpl extends ResourceHandler
         resourceMeta = resourceLoader.createResourceMeta(
             localePrefix, libraryName, libraryVersion, resourceName, resourceVersion, contractName);
 
-        if (resourceMeta != null &&
-            !resourceLoader.resourceExists(resourceMeta))
+        if (resourceMeta != null && !resourceLoader.resourceExists(resourceMeta))
         {
             resourceMeta = null;
         }
-        //}
+
         return resourceMeta;
     }
     
@@ -1523,8 +1493,7 @@ public class ResourceHandlerImpl extends ResourceHandler
         //2. Try to localize resource in a non localized path
         if (resourceMeta == null)
         {
-            resourceVersion = resourceLoader
-                    .getResourceVersion(resourceName, contractName);
+            resourceVersion = resourceLoader.getResourceVersion(resourceName, contractName);
             if (!(resourceVersion != null && ResourceLoader.VERSION_INVALID.equals(resourceVersion)))
             {
                 resourceMeta = resourceLoader.createResourceMeta(null, null, null,
@@ -1616,8 +1585,7 @@ public class ResourceHandlerImpl extends ResourceHandler
         if (resourceValue == null)
         {
             // Try to get resource without contract name
-            resourceValue = getResourceLoaderCache().getViewResource(
-                resourceName, contentType, localePrefix);
+            resourceValue = getResourceLoaderCache().getViewResource(resourceName, contentType,
localePrefix);
         }
 
         if(resourceValue != null)
@@ -1637,8 +1605,7 @@ public class ResourceHandlerImpl extends ResourceHandler
                         facesContext, loader, resourceName, localePrefix, contractPreferred);
                     if (resourceMeta != null)
                     {
-                        resource = new ResourceImpl(resourceMeta, loader, 
-                            getResourceHandlerSupport(), contentType);
+                        resource = new ResourceImpl(resourceMeta, loader, getResourceHandlerSupport(),
contentType);
 
                         // cache it
                         getResourceLoaderCache().putViewResource(
@@ -1703,7 +1670,7 @@ public class ResourceHandlerImpl extends ResourceHandler
     }
 
     @Override
-    public Stream<java.lang.String> getViewResources(FacesContext facesContext, 
+    public Stream<String> getViewResources(FacesContext facesContext, 
             String path, int maxDepth, ResourceVisitOption... options)   
     {
         final String localePrefix = getLocalePrefixForLocateResource(facesContext);
diff --git a/impl/src/main/java/org/apache/myfaces/el/ValueReferenceResolver.java b/impl/src/main/java/org/apache/myfaces/el/ValueReferenceResolver.java
index 4a3628b..a9efa4e 100644
--- a/impl/src/main/java/org/apache/myfaces/el/ValueReferenceResolver.java
+++ b/impl/src/main/java/org/apache/myfaces/el/ValueReferenceResolver.java
@@ -41,7 +41,7 @@ public class ValueReferenceResolver
         {
             valueExpression = ((CompositeComponentExpressionHolder) valueReference.getBase())
                                   .getExpression((String) valueReference.getProperty());
-            if(valueExpression == null)
+            if (valueExpression == null)
             {
                 break;
             }
diff --git a/impl/src/main/java/org/apache/myfaces/util/UrlPatternMatcher.java b/impl/src/main/java/org/apache/myfaces/util/UrlPatternMatcher.java
index 6d636ea..350a4f7 100644
--- a/impl/src/main/java/org/apache/myfaces/util/UrlPatternMatcher.java
+++ b/impl/src/main/java/org/apache/myfaces/util/UrlPatternMatcher.java
@@ -34,11 +34,11 @@ public class UrlPatternMatcher
     public static boolean match(String path, String pattern)
     {
         // Normalize the argument strings
-        if ((path == null) || (path.length() == 0))
+        if (LangUtils.isEmpty(path))
         {
             path = "/";
         }
-        if ((pattern == null) || (pattern.length() == 0))
+        if (LangUtils.isEmpty(pattern))
         {
             pattern = "/";
         }
@@ -46,7 +46,7 @@ public class UrlPatternMatcher
         // Check for exact match
         if (path.equals(pattern))
         {
-            return (true);
+            return true;
         }
 
         // Check for path prefix matching
@@ -55,7 +55,7 @@ public class UrlPatternMatcher
             pattern = pattern.substring(0, pattern.length() - 2);
             if (pattern.length() == 0)
             {
-                return (true);  // "/*" is the same as "/"
+                return true;  // "/*" is the same as "/"
             }
             if (path.endsWith("/"))
             {
@@ -65,7 +65,7 @@ public class UrlPatternMatcher
             {
                 if (pattern.equals(path))
                 {
-                    return (true);
+                    return true;
                 }
                 int slash = path.lastIndexOf('/');
                 if (slash <= 0)
@@ -74,7 +74,7 @@ public class UrlPatternMatcher
                 }
                 path = path.substring(0, slash);
             }
-            return (false);
+            return false;
         }
 
         // Check for suffix matching
@@ -82,12 +82,11 @@ public class UrlPatternMatcher
         {
             int slash = path.lastIndexOf('/');
             int period = path.lastIndexOf('.');
-            if ((slash >= 0) && (period > slash) &&
-                path.endsWith(pattern.substring(1)))
+            if (slash >= 0 && period > slash && path.endsWith(pattern.substring(1)))
             {
-                return (true);
+                return true;
             }
-            return (false);
+            return false;
         }
 
         // Check for universal mapping


Mime
View raw message