1 19 20 21 package org.netbeans.modules.i18n.regexp; 22 23 import java.util.Map ; 24 25 31 public final class Translator { 32 33 46 public static String translateRegexp(String regexp) 47 throws IllegalArgumentException , ParseException { 48 TreeNodeRoot tree = Parser.parse(regexp); 49 return Generator.generateRegexp(tree); 50 } 51 52 70 public static String translateRegexp(String regexp, 71 Map tokenReplacements) 72 throws IllegalArgumentException , ParseException { 73 74 if ((tokenReplacements == null) || (tokenReplacements.isEmpty())) { 75 return translateRegexp(regexp); 76 } 77 78 String [] tokenNames = new String [tokenReplacements.size()]; 79 try { 80 tokenReplacements.keySet().toArray(tokenNames); 81 } catch (ArrayStoreException ex) { 82 throw new ClassCastException (); 83 } 84 TreeNodeRoot tree = Parser.parse(regexp, tokenNames); 85 return Generator.generateRegexp(tree, tokenReplacements); 86 } 87 88 } 89 | Popular Tags |