1 18 19 package org.apache.tools.ant.taskdefs.optional.jsp; 20 21 import java.io.File ; 22 23 28 public class Jasper41Mangler implements JspMangler { 29 30 31 37 public String mapJspToJavaName(File jspFile) { 38 String jspUri = jspFile.getAbsolutePath(); 39 int start = jspUri.lastIndexOf(File.separatorChar) + 1; 40 int end = jspUri.length(); 41 StringBuffer modifiedClassName; 42 modifiedClassName = new StringBuffer (jspUri.length() - start); 43 if (!Character.isJavaIdentifierStart(jspUri.charAt(start)) 44 || jspUri.charAt(start) == '_') { 45 modifiedClassName.append('_'); 48 } 49 for (int i = start; i < end; i++) { 50 char ch = jspUri.charAt(i); 51 if (Character.isJavaIdentifierPart(ch)) { 52 modifiedClassName.append(ch); 53 } else if (ch == '.') { 54 modifiedClassName.append('_'); 55 } else { 56 modifiedClassName.append(mangleChar(ch)); 57 } 58 } 59 return modifiedClassName.toString(); 60 } 61 62 65 private static String mangleChar(char ch) { 66 67 String s = Integer.toHexString(ch); 68 int nzeros = 5 - s.length(); 69 char[] result = new char[6]; 70 result[0] = '_'; 71 for (int i = 1; i <= nzeros; i++) { 72 result[i] = '0'; 73 } 74 for (int i = nzeros + 1, j = 0; i < 6; i++, j++) { 75 result[i] = s.charAt(j); 76 } 77 return new String (result); 78 } 79 80 81 88 public String mapPath(String path) { 89 return null; 90 } 91 92 } 93 | Popular Tags |