1 package org.apache.velocity.anakia; 2 3 18 19 27 public class Escape 28 { 29 32 public Escape() 33 { 34 } 36 37 40 public static final String getText(String st) 41 { 42 StringBuffer buff = new StringBuffer (); 43 char[] block = st.toCharArray(); 44 String stEntity = null; 45 int i, last; 46 47 for (i=0, last=0; i < block.length; i++) 48 { 49 switch(block[i]) 50 { 51 case '<' : 52 stEntity = "<"; 53 break; 54 case '>' : 55 stEntity = ">"; 56 break; 57 case '&' : 58 stEntity = "&"; 59 break; 60 case '"' : 61 stEntity = """; 62 break; 63 default : 64 ; 65 } 66 if (stEntity != null) 67 { 68 buff.append(block, last, i - last); 69 buff.append(stEntity); 70 stEntity = null; 71 last = i + 1; 72 } 73 } 74 if(last < block.length) 75 { 76 buff.append(block, last, i - last); 77 } 78 return buff.toString(); 79 } 80 } 81 | Popular Tags |