1 19 20 21 package org.netbeans.modules.java.ui.wizard; 22 23 import java.util.ResourceBundle ; 24 import java.util.StringTokenizer ; 25 26 import org.openide.src.*; 27 import org.openide.loaders.TemplateWizard; 28 import org.openide.util.Utilities; 29 30 public class Util { 31 static String getString(String key) { 32 return org.openide.util.NbBundle.getMessage(Util.class, key); 33 } 34 35 40 static boolean isValidPackageName(String str) { 41 if (str.length() > 0 && str.charAt(0) == '.') return false; 42 StringTokenizer tukac = new StringTokenizer (str, "."); while (tukac.hasMoreTokens()) { 44 String token = tukac.nextToken(); 45 if ("".equals(token)) 46 return false; 47 if (!Utilities.isJavaIdentifier(token)) 48 return false; 49 } 50 return true; 51 } 52 53 static boolean isValidTypeIdentifier(String ident) { 54 if (ident == null || "".equals(ident)) 55 return false; 56 try { 57 Type t = Type.parse(ident); 58 return t.isClass(); 59 } catch (IllegalArgumentException e) { 60 return false; 61 } 62 } 63 64 static boolean implementsInterface(ClassElement clazz, Identifier id) { 65 Identifier[] implemented = clazz.getInterfaces(); 66 for (int i = 0; i < implemented.length; i++) { 67 if (implemented[i].equals(id)) { 68 return true; 69 } 70 } 71 return false; 72 } 73 74 static TemplateWizard.Iterator packageIt; 75 76 public static TemplateWizard.Iterator createPackageIterator() { 77 if (packageIt == null) 78 packageIt = JavaPackageIterator.create(); 79 return packageIt; 80 } 81 } 82 | Popular Tags |