tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1360814 - in /tomcat/trunk/java/javax/servlet: ./ http/ jsp/el/ jsp/tagext/
Date Thu, 12 Jul 2012 17:04:03 GMT
Author: markt
Date: Thu Jul 12 17:04:02 2012
New Revision: 1360814

URL: http://svn.apache.org/viewvc?rev=1360814&view=rev
Log:
Code clean-up for javax.servlet
 - Add final prompted by UCDetector
 - Java 7 use of <>

Modified:
    tomcat/trunk/java/javax/servlet/ServletSecurityElement.java
    tomcat/trunk/java/javax/servlet/http/Cookie.java
    tomcat/trunk/java/javax/servlet/http/HttpServlet.java
    tomcat/trunk/java/javax/servlet/http/HttpSessionContext.java
    tomcat/trunk/java/javax/servlet/http/HttpUtils.java
    tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
    tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
    tomcat/trunk/java/javax/servlet/jsp/tagext/TagAdapter.java
    tomcat/trunk/java/javax/servlet/jsp/tagext/TagData.java
    tomcat/trunk/java/javax/servlet/jsp/tagext/TagInfo.java
    tomcat/trunk/java/javax/servlet/jsp/tagext/TagLibraryInfo.java
    tomcat/trunk/java/javax/servlet/jsp/tagext/TagSupport.java

Modified: tomcat/trunk/java/javax/servlet/ServletSecurityElement.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/ServletSecurityElement.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/ServletSecurityElement.java (original)
+++ tomcat/trunk/java/javax/servlet/ServletSecurityElement.java Thu Jul 12 17:04:02 2012
@@ -34,7 +34,7 @@ import javax.servlet.annotation.ServletS
 public class ServletSecurityElement extends HttpConstraintElement {
 
     private final Map<String,HttpMethodConstraintElement> methodConstraints =
-        new HashMap<String,HttpMethodConstraintElement>();
+        new HashMap<>();
 
     /**
      * Use default HttpConstraint.
@@ -90,8 +90,7 @@ public class ServletSecurityElement exte
                 annotation.value().transportGuarantee(),
                 annotation.value().rolesAllowed()));
 
-        List<HttpMethodConstraintElement> l =
-            new ArrayList<HttpMethodConstraintElement>();
+        List<HttpMethodConstraintElement> l = new ArrayList<>();
         HttpMethodConstraint[] constraints = annotation.httpMethodConstraints();
         if (constraints != null) {
             for (int i = 0; i < constraints.length; i++) {
@@ -108,14 +107,13 @@ public class ServletSecurityElement exte
     }
 
     public Collection<HttpMethodConstraintElement> getHttpMethodConstraints() {
-        Collection<HttpMethodConstraintElement> result =
-                new HashSet<HttpMethodConstraintElement>();
+        Collection<HttpMethodConstraintElement> result = new HashSet<>();
         result.addAll(methodConstraints.values());
         return result;
     }
 
     public Collection<String> getMethodNames() {
-        Collection<String> result = new HashSet<String>();
+        Collection<String> result = new HashSet<>();
         result.addAll(methodConstraints.keySet());
         return result;
     }

Modified: tomcat/trunk/java/javax/servlet/http/Cookie.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/Cookie.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/Cookie.java (original)
+++ tomcat/trunk/java/javax/servlet/http/Cookie.java Thu Jul 12 17:04:02 2012
@@ -59,13 +59,14 @@ public class Cookie implements Cloneable
     private static final long serialVersionUID = 1L;
 
     private static final String LSTRING_FILE = "javax.servlet.http.LocalStrings";
-    private static ResourceBundle lStrings = ResourceBundle.getBundle(LSTRING_FILE);
+    private static final ResourceBundle lStrings =
+            ResourceBundle.getBundle(LSTRING_FILE);
 
     //
     // The value of the cookie itself.
     //
 
-    private String name; // NAME= ... "$Name" style is reserved
+    private final String name; // NAME= ... "$Name" style is reserved
     private String value; // value of NAME
 
     //

Modified: tomcat/trunk/java/javax/servlet/http/HttpServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/HttpServlet.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/HttpServlet.java (original)
+++ tomcat/trunk/java/javax/servlet/http/HttpServlet.java Thu Jul 12 17:04:02 2012
@@ -90,7 +90,7 @@ public abstract class HttpServlet extend
 
     private static final String LSTRING_FILE =
         "javax.servlet.http.LocalStrings";
-    private static ResourceBundle lStrings =
+    private static final ResourceBundle lStrings =
         ResourceBundle.getBundle(LSTRING_FILE);
 
 
@@ -732,9 +732,9 @@ public abstract class HttpServlet extend
  */
 // file private
 class NoBodyResponse extends HttpServletResponseWrapper {
-    private NoBodyOutputStream                noBody;
-    private PrintWriter                        writer;
-    private boolean                        didSetContentLength;
+    private final NoBodyOutputStream noBody;
+    private PrintWriter writer;
+    private boolean didSetContentLength;
 
     // file private
     NoBodyResponse(HttpServletResponse r) {
@@ -821,10 +821,10 @@ class NoBodyOutputStream extends Servlet
 
     private static final String LSTRING_FILE =
         "javax.servlet.http.LocalStrings";
-    private static ResourceBundle lStrings =
+    private static final ResourceBundle lStrings =
         ResourceBundle.getBundle(LSTRING_FILE);
 
-    private int                contentLength = 0;
+    private int contentLength = 0;
 
     // file private
     NoBodyOutputStream() {

Modified: tomcat/trunk/java/javax/servlet/http/HttpSessionContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/HttpSessionContext.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/HttpSessionContext.java (original)
+++ tomcat/trunk/java/javax/servlet/http/HttpSessionContext.java Thu Jul 12 17:04:02 2012
@@ -38,7 +38,6 @@ public interface HttpSessionContext {
      *             must return null and will be removed in a future version of
      *             this API.
      */
-    @SuppressWarnings("dep-ann")
     // Spec API does not use @Deprecated
     public HttpSession getSession(String sessionId);
 
@@ -47,7 +46,6 @@ public interface HttpSessionContext {
      *             must return an empty <code>Enumeration</code> and will be
      *             removed in a future version of this API.
      */
-    @SuppressWarnings("dep-ann")
     // Spec API does not use @Deprecated
     public Enumeration<String> getIds();
 }

Modified: tomcat/trunk/java/javax/servlet/http/HttpUtils.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/HttpUtils.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/HttpUtils.java (original)
+++ tomcat/trunk/java/javax/servlet/http/HttpUtils.java Thu Jul 12 17:04:02 2012
@@ -35,7 +35,7 @@ public class HttpUtils {
 
     private static final String LSTRING_FILE =
         "javax.servlet.http.LocalStrings";
-    private static ResourceBundle lStrings =
+    private static final ResourceBundle lStrings =
         ResourceBundle.getBundle(LSTRING_FILE);
 
 
@@ -86,7 +86,7 @@ public class HttpUtils {
         if (s == null) {
             throw new IllegalArgumentException();
         }
-        Hashtable<String,String[]> ht = new Hashtable<String,String[]>();
+        Hashtable<String,String[]> ht = new Hashtable<>();
         StringBuilder sb = new StringBuilder();
         StringTokenizer st = new StringTokenizer(s, "&");
         while (st.hasMoreTokens()) {
@@ -161,7 +161,7 @@ public class HttpUtils {
 
         // cheap hack to return an empty hash
         if (len <=0)
-            return new Hashtable<String,String[]>();
+            return new Hashtable<>();
 
         if (in == null) {
             throw new IllegalArgumentException();

Modified: tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java Thu Jul 12 17:04:02
2012
@@ -174,8 +174,7 @@ public class ImplicitObjectELResolver ex
 
     @Override
     public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object
base) {
-        List<FeatureDescriptor> feats = new ArrayList<FeatureDescriptor>(
-                SCOPE_NAMES.length);
+        List<FeatureDescriptor> feats = new ArrayList<>(SCOPE_NAMES.length);
         FeatureDescriptor feat;
         for (int i = 0; i < SCOPE_NAMES.length; i++) {
             feat = new FeatureDescriptor();
@@ -272,7 +271,7 @@ public class ImplicitObjectELResolver ex
                         Cookie[] c = ((HttpServletRequest) page.getRequest())
                                 .getCookies();
                         if (c != null) {
-                            Vector<String> v = new Vector<String>();
+                            Vector<String> v = new Vector<>();
                             for (int i = 0; i < c.length; i++) {
                                 v.add(c[i].getName());
                             }
@@ -334,7 +333,7 @@ public class ImplicitObjectELResolver ex
                             ((HttpServletRequest) page.getRequest())
                                     .getHeaders(name);
                         if (e != null) {
-                            List<String> list = new ArrayList<String>();
+                            List<String> list = new ArrayList<>();
                             while (e.hasMoreElements()) {
                                 list.add(e.nextElement());
                             }
@@ -517,7 +516,7 @@ public class ImplicitObjectELResolver ex
         @Override
         public final Set<Map.Entry<String,V>> entrySet() {
             Enumeration<String> e = getAttributeNames();
-            Set<Map.Entry<String, V>> set = new HashSet<Map.Entry<String,
V>>();
+            Set<Map.Entry<String, V>> set = new HashSet<>();
             if (e != null) {
                 while (e.hasMoreElements()) {
                     set.add(new ScopeEntry(e.nextElement()));

Modified: tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java Thu Jul 12 17:04:02
2012
@@ -119,7 +119,7 @@ public class ScopedAttributeELResolver e
             Object base) {
 
         PageContext ctxt = (PageContext) context.getContext(JspContext.class);
-        List<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>();
+        List<FeatureDescriptor> list = new ArrayList<>();
         Enumeration<String> e;
         Object value;
         String name;

Modified: tomcat/trunk/java/javax/servlet/jsp/tagext/TagAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/tagext/TagAdapter.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/tagext/TagAdapter.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/tagext/TagAdapter.java Thu Jul 12 17:04:02 2012
@@ -34,7 +34,7 @@ import javax.servlet.jsp.PageContext;
  */
 public class TagAdapter implements Tag {
     /** The simple tag that's being adapted. */
-    private SimpleTag simpleTagAdaptee;
+    private final SimpleTag simpleTagAdaptee;
 
     /** The parent, of this tag, converted (if necessary) to be of type Tag. */
     private Tag parent;

Modified: tomcat/trunk/java/javax/servlet/jsp/tagext/TagData.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/tagext/TagData.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/tagext/TagData.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/tagext/TagData.java Thu Jul 12 17:04:02 2012
@@ -56,9 +56,9 @@ public class TagData implements Cloneabl
      */
     public TagData(Object[] atts[]) {
         if (atts == null) {
-            attributes = new Hashtable<String, Object>();
+            attributes = new Hashtable<>();
         } else {
-            attributes = new Hashtable<String, Object>(atts.length);
+            attributes = new Hashtable<>(atts.length);
         }
 
         if (atts != null) {

Modified: tomcat/trunk/java/javax/servlet/jsp/tagext/TagInfo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/tagext/TagInfo.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/tagext/TagInfo.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/tagext/TagInfo.java Thu Jul 12 17:04:02 2012
@@ -90,6 +90,13 @@ public class TagInfo {
         this.tagExtraInfo  = tagExtraInfo;
         this.attributeInfo = attributeInfo;
 
+        // Use defaults for unspecified values
+        this.displayName = null;
+        this.largeIcon = null;
+        this.smallIcon = null;
+        this.tagVariableInfo = null;
+        this.dynamicAttributes = false;
+
         if (tagExtraInfo != null)
             tagExtraInfo.setTagInfo(this);
     }
@@ -141,6 +148,9 @@ public class TagInfo {
         this.largeIcon = largeIcon;
         this.tagVariableInfo = tvi;
 
+        // Use defaults for unspecified values
+        this.dynamicAttributes = false;
+
         if (tagExtraInfo != null)
             tagExtraInfo.setTagInfo(this);
     }
@@ -424,24 +434,24 @@ public class TagInfo {
     /*
      * private fields for 1.1 info
      */
-    private String             tagName; // the name of the tag
-    private String             tagClassName;
-    private String             bodyContent;
-    private String             infoString;
-    private TagLibraryInfo     tagLibrary;
-    private TagExtraInfo       tagExtraInfo; // instance of TagExtraInfo
-    private TagAttributeInfo[] attributeInfo;
+    private final String             tagName; // the name of the tag
+    private final String             tagClassName;
+    private final String             bodyContent;
+    private final String             infoString;
+    private TagLibraryInfo           tagLibrary;
+    private TagExtraInfo             tagExtraInfo; // instance of TagExtraInfo
+    private final TagAttributeInfo[] attributeInfo;
 
     /*
      * private fields for 1.2 info
      */
-    private String             displayName;
-    private String             smallIcon;
-    private String             largeIcon;
-    private TagVariableInfo[]  tagVariableInfo;
+    private final String             displayName;
+    private final String             smallIcon;
+    private final String             largeIcon;
+    private final TagVariableInfo[]  tagVariableInfo;
 
     /*
      * Additional private fields for 2.0 info
      */
-    private boolean dynamicAttributes;
+    private final boolean dynamicAttributes;
 }

Modified: tomcat/trunk/java/javax/servlet/jsp/tagext/TagLibraryInfo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/tagext/TagLibraryInfo.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/tagext/TagLibraryInfo.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/tagext/TagLibraryInfo.java Thu Jul 12 17:04:02 2012
@@ -230,13 +230,13 @@ public abstract class TagLibraryInfo {
     /**
      * The prefix assigned to this taglib from the taglib directive.
      */
-    protected String prefix;
+    protected final String prefix;
 
     /**
      * The value of the uri attribute from the taglib directive for this
      * library.
      */
-    protected String uri;
+    protected final String uri;
 
     /**
      * An array describing the tags that are defined in this tag library.

Modified: tomcat/trunk/java/javax/servlet/jsp/tagext/TagSupport.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/tagext/TagSupport.java?rev=1360814&r1=1360813&r2=1360814&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/tagext/TagSupport.java (original)
+++ tomcat/trunk/java/javax/servlet/jsp/tagext/TagSupport.java Thu Jul 12 17:04:02 2012
@@ -230,7 +230,7 @@ public class TagSupport implements Itera
      */
     public void setValue(String k, Object o) {
         if (values == null) {
-            values = new Hashtable<String, Object>();
+            values = new Hashtable<>();
         }
         values.put(k, o);
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message