1 19 20 package org.netbeans.editor.ext.html; 21 22 import java.io.PrintStream ; 23 import org.netbeans.editor.TokenContext; 24 import org.netbeans.editor.TokenContextPath; 25 26 30 public class SyntaxUtils { 31 32 33 public static void dumpTokenContextPath(TokenContextPath tcp, PrintStream out) { 34 TokenContext[] tcs = tcp.getContexts(); 35 for(int i = 0; i < tcs.length; i++ ) { 36 String tcClassName = tcs[i].getClass().getName(); 37 tcClassName = tcClassName.substring(tcClassName.lastIndexOf(".") + 1); 38 out.print(tcClassName + ( (i < (tcs.length - 1)) ? ", " : "")); 39 } 40 } 41 42 43 public static String normalize(String s, String [][] translationTable) { 44 StringBuffer normalized = new StringBuffer (); 45 for(int i = 0; i < s.length(); i++) { 46 String ch = s.substring(i,i+1); 47 for(int j = 0; j < normalizeTable.length; j++) { 48 if(ch.equals(normalizeTable[j][0])) ch = normalizeTable[j][1]; 49 } 50 normalized.append(ch); 51 } 52 return normalized.toString(); 53 } 54 55 57 public static String normalize(String s) { 58 return normalize(s, normalizeTable); 59 } 60 61 public static final String [][] normalizeTable = {{"\n", "<NL>"}, 62 {"\t", "<TAB>"}}; 63 64 } 65 | Popular Tags |