Author: markt Date: Wed Oct 19 15:11:15 2011 New Revision: 1186260 URL: http://svn.apache.org/viewvc?rev=1186260&view=rev Log: Code clean-up. No functional change.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Oct 19 15:11:15 2011 @@ -1 +1 @@ -/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153 +/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153,1186254 Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java?rev=1186260&r1=1186259&r2=1186260&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/JspCompilationContext.java Wed Oct 19 15:11:15 2011 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,7 +50,7 @@ import org.apache.juli.logging.LogFactor * the instance variables are set at different points. * * Most of the path-related stuff is here - mangling names, versions, dirs, - * loading resources and dealing with uris. + * loading resources and dealing with uris. * * @author Anil K. Vijendran * @author Harish Prabandham @@ -126,7 +126,7 @@ public class JspCompilationContext { } public JspCompilationContext(String tagfile, - TagInfo tagInfo, + TagInfo tagInfo, Options options, ServletContext context, JspServletWrapper jsw, @@ -139,20 +139,21 @@ public class JspCompilationContext { } /* ==================== Methods to override ==================== */ - + /** ---------- Class path and loader ---------- */ /** - * The classpath that is passed off to the Java compiler. + * The classpath that is passed off to the Java compiler. */ public String getClassPath() { - if( classPath != null ) + if( classPath != null ) { return classPath; + } return rctxt.getClassPath(); } /** - * The classpath that is passed off to the Java compiler. + * The classpath that is passed off to the Java compiler. */ public void setClassPath(String classPath) { this.classPath = classPath; @@ -163,8 +164,9 @@ public class JspCompilationContext { * this JSP? */ public ClassLoader getClassLoader() { - if( loader != null ) + if( loader != null ) { return loader; + } return rctxt.getParentClassLoader(); } @@ -183,7 +185,7 @@ public class JspCompilationContext { } /** ---------- Input/Output ---------- */ - + /** * The output directory to generate code into. The output directory * is make up of the scratch directory, which is provide in Options, @@ -200,7 +202,7 @@ public class JspCompilationContext { /** * Create a "Compiler" object based on some init param data. This * is not done yet. Right now we're just hardcoding the actual - * compilers that are created. + * compilers that are created. */ public Compiler createCompiler() { if (jspCompiler != null ) { @@ -230,7 +232,7 @@ public class JspCompilationContext { } protected Compiler createCompiler(String className) { - Compiler compiler = null; + Compiler compiler = null; try { compiler = (Compiler) Class.forName(className).newInstance(); } catch (InstantiationException e) { @@ -248,14 +250,14 @@ public class JspCompilationContext { } return compiler; } - + public Compiler getCompiler() { return jspCompiler; } /** ---------- Access resources in the webapp ---------- */ - /** + /** * Get the full value of a URI relative to this compilations context * uses current file as the base. */ @@ -272,7 +274,7 @@ public class JspCompilationContext { /** * Gets a resource as a stream, relative to the meanings of this * context's implementation. - * @return a null if the resource cannot be found or represented + * @return a null if the resource cannot be found or represented * as an InputStream. */ public java.io.InputStream getResourceAsStream(String res) { @@ -311,7 +313,7 @@ public class JspCompilationContext { return context.getResourcePaths(canonicalURI(path)); } - /** + /** * Gets the actual path of a URI relative to the context of * the compilation. */ @@ -328,7 +330,7 @@ public class JspCompilationContext { * packaged. * * The map is populated when parsing the tag-file elements of the TLDs - * of any imported taglibs. + * of any imported taglibs. */ public JarResource getTagFileJarResource(String tagFile) { return this.tagFileJarUrls.get(tagFile); @@ -352,7 +354,7 @@ public class JspCompilationContext { /** * Just the class name (does not include package name) of the - * generated class. + * generated class. */ public String getServletClassName() { @@ -376,10 +378,10 @@ public class JspCompilationContext { public void setServletClassName(String className) { this.className = className; } - + /** * Path of the JSP URI. Note that this is not a file name. This is - * the context rooted URI of the JSP file. + * the context rooted URI of the JSP file. */ public String getJspFile() { return jspUri; @@ -521,7 +523,7 @@ public class JspCompilationContext { } return derivedPackageName; } - + /** * The package name into which the servlet class is generated. */ @@ -531,7 +533,7 @@ public class JspCompilationContext { /** * Full path name of the Java file into which the servlet is being - * generated. + * generated. */ public String getServletJavaFileName() { if (servletJavaFileName == null) { @@ -541,7 +543,7 @@ public class JspCompilationContext { } /** - * Get hold of the Options object for this context. + * Get hold of the Options object for this context. */ public Options getOptions() { return options; @@ -594,7 +596,7 @@ public class JspCompilationContext { /** * Gets the 'location' of the TLD associated with the given taglib 'uri'. - * + * * @return An array of two Strings: The first element denotes the real * path to the TLD. If the path to the TLD points to a jar file, then the * second element denotes the name of the TLD entry in the jar file. @@ -602,7 +604,7 @@ public class JspCompilationContext { * 'exposed' in the web application. */ public TldLocation getTldLocation(String uri) throws JasperException { - TldLocation location = + TldLocation location = getOptions().getTldLocationsCache().getLocation(uri); return location; } @@ -614,7 +616,7 @@ public class JspCompilationContext { return getOptions().getKeepGenerated(); } - // ==================== Removal ==================== + // ==================== Removal ==================== public void incrementRemoved() { if (removed == 0 && rctxt != null) { @@ -631,7 +633,7 @@ public class JspCompilationContext { } // ==================== Compile and reload ==================== - + public void compile() throws JasperException, FileNotFoundException { createCompiler(); if (jspCompiler.isOutDated()) { @@ -668,7 +670,7 @@ public class JspCompilationContext { public Class<?> load() throws JasperException { try { getJspLoader(); - + String name = getFQCN(); servletClass = jspLoader.loadClass(name); } catch (ClassNotFoundException cex) { @@ -692,7 +694,7 @@ public class JspCompilationContext { return name; } - // ==================== protected methods ==================== + // ==================== protected methods ==================== static Object outputDirLock = new Object(); @@ -705,7 +707,7 @@ public class JspCompilationContext { createOutputDir(); } } - + protected boolean makeOutputDir() { synchronized(outputDirLock) { File outDirFile = new File(outputDir); @@ -727,7 +729,7 @@ public class JspCompilationContext { try { File base = options.getScratchDir(); baseUrl = base.toURI().toURL(); - outputDir = base.getAbsolutePath() + File.separator + path + + outputDir = base.getAbsolutePath() + File.separator + path + File.separator; if (!makeOutputDir()) { throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder")); @@ -736,13 +738,15 @@ public class JspCompilationContext { throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder"), e); } } - + protected static final boolean isPathSeparator(char c) { return (c == '/' || c == '\\'); } protected static final String canonicalURI(String s) { - if (s == null) return null; + if (s == null) { + return null; + } StringBuilder result = new StringBuilder(); final int len = s.length(); int pos = 0; @@ -761,7 +765,9 @@ public class JspCompilationContext { /* * a single dot at the end of the path - we are done. */ - if (pos+2 >= len) break; + if (pos+2 >= len) { + break; + } switch (s.charAt(pos+2)) { /* @@ -782,13 +788,14 @@ public class JspCompilationContext { if (pos+3 < len && isPathSeparator(s.charAt(pos+3))) { pos += 3; int separatorPos = result.length()-1; - while (separatorPos >= 0 && + while (separatorPos >= 0 && ! isPathSeparator(result .charAt(separatorPos))) { --separatorPos; } - if (separatorPos >= 0) - result.setLength(separatorPos); + if (separatorPos >= 0) { + result.setLength(separatorPos); + } continue; } } Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java?rev=1186260&r1=1186259&r2=1186260&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java Wed Oct 19 15:11:15 2011 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,7 @@ import org.xml.sax.Attributes; /** * This class has all the utility method(s). Ideally should move all the bean * containers here. - * + * * @author Mandar Raje. * @author Rajiv Mordani. * @author Danno Ferrin @@ -80,7 +80,7 @@ public class JspUtil { /** * Checks to see if the given scope is valid. - * + * * @param scope * The scope to be checked * @param n @@ -88,7 +88,7 @@ public class JspUtil { * checked * @param err * error dispatcher - * + * * @throws JasperException * if scope is not null and different from "page", * "request", "session", and @@ -121,8 +121,9 @@ public class JspUtil { for (int i = 0; i < tempLength; i++) { @SuppressWarnings("null") // If attrs==null, tempLength == 0 String qName = attrs.getQName(i); - if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:"))) + if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:"))) { temp.addElement(qName); + } } // Add names of attributes specified using jsp:attribute @@ -171,14 +172,16 @@ public class JspUtil { } // If mandatory attribute is missing then the exception is thrown - if (!valid) + if (!valid) { err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag, missingAttribute); + } // Check to see if there are any more attributes for the specified tag. int attrLeftLength = temp.size(); - if (attrLeftLength == 0) + if (attrLeftLength == 0) { return; + } // Now check to see if the rest of the attributes are valid too. String attribute = null; @@ -192,9 +195,10 @@ public class JspUtil { break; } } - if (!valid) + if (!valid) { err.jspError(start, "jsp.error.invalid.attribute", typeOfTag, attribute); + } } // XXX *could* move EL-syntax validation here... (sb) } @@ -203,8 +207,9 @@ public class JspUtil { * Escape the 5 entities defined by XML. */ public static String escapeXml(String s) { - if (s == null) + if (s == null) { return null; + } StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); @@ -270,7 +275,7 @@ public class JspUtil { * Convert a String value to 'boolean'. Besides the standard conversions * done by Boolean.valueOf(s).booleanValue(), the value "yes" (ignore case) * is also converted to 'true'. If 's' is null, then 'false' is returned. - * + * * @param s * the string to be converted * @return the boolean value associated with the string s @@ -290,7 +295,7 @@ public class JspUtil { /** * Returns the <tt>Class</tt> object associated with the class or * interface with the given string name. - * + * * <p> * The <tt>Class</tt> object is determined by passing the given string * name to the <tt>Class.forName()</tt> method, unless the given string @@ -306,38 +311,42 @@ public class JspUtil { if (i0 > 0) { // This is an array. Count the dimensions for (int i = 0; i < type.length(); i++) { - if (type.charAt(i) == '[') + if (type.charAt(i) == '[') { dims++; + } } type = type.substring(0, i0); } - if ("boolean".equals(type)) + if ("boolean".equals(type)) { c = boolean.class; - else if ("char".equals(type)) + } else if ("char".equals(type)) { c = char.class; - else if ("byte".equals(type)) + } else if ("byte".equals(type)) { c = byte.class; - else if ("short".equals(type)) + } else if ("short".equals(type)) { c = short.class; - else if ("int".equals(type)) + } else if ("int".equals(type)) { c = int.class; - else if ("long".equals(type)) + } else if ("long".equals(type)) { c = long.class; - else if ("float".equals(type)) + } else if ("float".equals(type)) { c = float.class; - else if ("double".equals(type)) + } else if ("double".equals(type)) { c = double.class; - else if ("void".equals(type)) + } else if ("void".equals(type)) { c = void.class; - else if (type.indexOf('[') < 0) + } else if (type.indexOf('[') < 0) { c = loader.loadClass(type); + } - if (dims == 0) + if (dims == 0) { return c; + } - if (dims == 1) + if (dims == 1) { return java.lang.reflect.Array.newInstance(c, 1).getClass(); + } // Array of more than i dimension return java.lang.reflect.Array.newInstance(c, new int[dims]).getClass(); @@ -345,7 +354,7 @@ public class JspUtil { /** * Produces a String representing a call to the EL interpreter. - * + * * @param expression * a String containing zero or more "${}" expressions * @param expectedType @@ -362,10 +371,11 @@ public class JspUtil { * Determine which context object to use. */ String jspCtxt = null; - if (isTagFile) + if (isTagFile) { jspCtxt = "this.getJspContext()"; - else + } else { jspCtxt = "_jspx_page_context"; + } /* * Determine whether to use the expected type's textual name or, if it's @@ -446,10 +456,11 @@ public class JspUtil { return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToBoolean(" + s + ")"; } else { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return "false"; - else + } else { return Boolean.valueOf(s).toString(); + } } } @@ -473,10 +484,11 @@ public class JspUtil { return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToByte(" + s + ")"; } else { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return "(byte) 0"; - else + } else { return "((byte)" + Byte.valueOf(s).toString() + ")"; + } } } @@ -530,10 +542,11 @@ public class JspUtil { return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToDouble(" + s + ")"; } else { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return "(double) 0"; - else + } else { return Double.valueOf(s).toString(); + } } } @@ -557,10 +570,11 @@ public class JspUtil { return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToFloat(" + s + ")"; } else { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return "(float) 0"; - else + } else { return Float.valueOf(s).toString() + "f"; + } } } @@ -583,10 +597,11 @@ public class JspUtil { return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToInt(" + s + ")"; } else { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return "0"; - else + } else { return Integer.valueOf(s).toString(); + } } } @@ -610,10 +625,11 @@ public class JspUtil { return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToShort(" + s + ")"; } else { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return "(short) 0"; - else + } else { return "((short) " + Short.valueOf(s).toString() + ")"; + } } } @@ -637,10 +653,11 @@ public class JspUtil { return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToLong(" + s + ")"; } else { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return "(long) 0"; - else + } else { return Long.valueOf(s).toString() + "l"; + } } } @@ -685,12 +702,12 @@ public class JspUtil { /** * Gets the fully-qualified class name of the tag handler corresponding to * the given tag file path. - * + * * @param path * Tag file path * @param err * Error dispatcher - * + * * @return Fully-qualified class name of the tag handler corresponding to * the given tag file path */ @@ -747,10 +764,10 @@ public class JspUtil { /** * Converts the given path to a Java package or fully-qualified class name - * + * * @param path * Path to convert - * + * * @return Java package corresponding to the given path */ public static final String makeJavaPackage(String path) { @@ -767,7 +784,7 @@ public class JspUtil { /** * Splits a string into it's components. - * + * * @param path * String to split * @param pat @@ -798,10 +815,10 @@ public class JspUtil { /** * Converts the given identifier to a legal Java identifier - * + * * @param identifier * Identifier to convert - * + * * @return Legal Java identifier corresponding to the given identifier */ public static final String makeJavaIdentifier(String identifier) { @@ -810,11 +827,11 @@ public class JspUtil { /** * Converts the given identifier to a legal Java identifier - * to be used for JSP Tag file attribute names. - * + * to be used for JSP Tag file attribute names. + * * @param identifier * Identifier to convert - * + * * @return Legal Java identifier corresponding to the given identifier */ public static final String makeJavaIdentifierForAttribute(String identifier) { @@ -823,10 +840,10 @@ public class JspUtil { /** * Converts the given identifier to a legal Java identifier. - * + * * @param identifier * Identifier to convert - * + * * @return Legal Java identifier corresponding to the given identifier */ private static final String makeJavaIdentifier(String identifier, @@ -891,7 +908,7 @@ public class JspUtil { if (key == null || key.length() == 0) { return false; } - + if (isJavaKeyword(key)) { return false; } @@ -907,7 +924,7 @@ public class JspUtil { return false; } } - + return true; } @@ -940,7 +957,7 @@ public class JspUtil { * Handles taking input from TLDs 'java.lang.Object' -> * 'java.lang.Object.class' 'int' -> 'int.class' 'void' -> 'Void.TYPE' * 'int[]' -> 'int[].class' - * + * * @param type */ public static String toJavaSourceTypeFromTld(String type) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org