1 21 package proguard.util; 22 23 import proguard.classfile.ClassConstants; 24 25 37 public class ClassNameMatcher extends BasicMatcher 38 { 39 private static final char[] CLASS_NAME_CHARACTERS = new char[] 40 { 41 ClassConstants.SPECIAL_CLASS_CHARACTER 42 }; 43 44 private static final char[] EXTENDED_CLASS_NAME_CHARACTERS = new char[] 45 { 46 ClassConstants.INTERNAL_PACKAGE_SEPARATOR 47 }; 48 49 private static final char[] SPECIAL_PRIMITIVE_CHARACTERS = new char[] 50 { 51 ClassConstants.INTERNAL_TYPE_BOOLEAN, 52 ClassConstants.INTERNAL_TYPE_BYTE, 53 ClassConstants.INTERNAL_TYPE_CHAR, 54 ClassConstants.INTERNAL_TYPE_SHORT, 55 ClassConstants.INTERNAL_TYPE_INT, 56 ClassConstants.INTERNAL_TYPE_FLOAT, 57 ClassConstants.INTERNAL_TYPE_LONG, 58 ClassConstants.INTERNAL_TYPE_DOUBLE 59 }; 60 61 62 67 public ClassNameMatcher(String regularExpression) 68 { 69 super(regularExpression, 70 CLASS_NAME_CHARACTERS, 71 EXTENDED_CLASS_NAME_CHARACTERS, 72 SPECIAL_PRIMITIVE_CHARACTERS); 73 } 74 75 76 79 public static void main(String [] args) 80 { 81 try 82 { 83 System.out.println("Regular expression ["+args[0]+"]"); 84 ClassNameMatcher matcher = new ClassNameMatcher(args[0]); 85 for (int index = 1; index < args.length; index++) 86 { 87 String string = args[index]; 88 System.out.print("String ["+string+"]"); 89 System.out.println(" -> match = "+matcher.matches(args[index])); 90 } 91 } 92 catch (Exception ex) 93 { 94 ex.printStackTrace(); 95 } 96 } 97 } 98 | Popular Tags |