Author: mareshkau
Date: 2009-02-09 09:56:01 -0500 (Mon, 09 Feb 2009)
New Revision: 13545
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-883
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2009-02-09
13:14:06 UTC (rev 13544)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2009-02-09
14:56:01 UTC (rev 13545)
@@ -16,122 +16,122 @@
import org.mozilla.interfaces.nsIDOMKeyEvent;
public class TextUtil {
- private final static String SOURCE_BREAK = "\r\n";
- private final static String VISUAL_BREAK = "\n";
+ private final static String SOURCE_BREAK = "\r\n"; //$NON-NLS-1$
+ private final static String VISUAL_BREAK = "\n"; //$NON-NLS-1$
private final static char SOURCE_SPACE = ' ';
private final static char VISUAL_SPACE = 160;
private final static int CHR_ESC_START = '&';
private final static int CHR_ESC_STOP = ';';
- private final static String SPCHARS = "\f\n\r\t\u0020\u2028\u2029";
- private final static Map textSet = new HashMap();
+ private final static String SPCHARS = "\f\n\r\t\u0020\u2028\u2029";
//$NON-NLS-1$
+ private final static Map<Character,String> textSet = new
HashMap<Character,String>();
static{
- textSet.put(new Character('"'), """);
- textSet.put(new Character('&'),"&");
- textSet.put(new Character('<'),"<");
- textSet.put(new Character('>'),">");
+ textSet.put(new Character('"'), """); //$NON-NLS-1$
+ textSet.put(new Character('&'),"&"); //$NON-NLS-1$
+ textSet.put(new Character('<'),"<"); //$NON-NLS-1$
+ textSet.put(new Character('>'),">"); //$NON-NLS-1$
// textSet.put(new Character(' ')," ");
- textSet.put(new Character('\u00A1'),"¡");
- textSet.put(new Character('\u00A2'),"¢");
- textSet.put(new Character('\u00A3'),"£");
- textSet.put(new Character('\u00A4'),"¤");
- textSet.put(new Character('\u00A5'),"¥");
- textSet.put(new Character('\u00A6'),"¦");
- textSet.put(new Character('\u00A7'),"§");
- textSet.put(new Character('\u00A8'),"¨");
- textSet.put(new Character('\u00A9'),"©");
- textSet.put(new Character('\u00AA'),"ª");
- textSet.put(new Character('\u00AB'),"«");
- textSet.put(new Character('\u00AC'),"¬");
+ textSet.put(new Character('\u00A1'),"¡"); //$NON-NLS-1$
+ textSet.put(new Character('\u00A2'),"¢"); //$NON-NLS-1$
+ textSet.put(new Character('\u00A3'),"£"); //$NON-NLS-1$
+ textSet.put(new Character('\u00A4'),"¤"); //$NON-NLS-1$
+ textSet.put(new Character('\u00A5'),"¥"); //$NON-NLS-1$
+ textSet.put(new Character('\u00A6'),"¦"); //$NON-NLS-1$
+ textSet.put(new Character('\u00A7'),"§"); //$NON-NLS-1$
+ textSet.put(new Character('\u00A8'),"¨"); //$NON-NLS-1$
+ textSet.put(new Character('\u00A9'),"©"); //$NON-NLS-1$
+ textSet.put(new Character('\u00AA'),"ª"); //$NON-NLS-1$
+ textSet.put(new Character('\u00AB'),"«"); //$NON-NLS-1$
+ textSet.put(new Character('\u00AC'),"¬"); //$NON-NLS-1$
//textSet.put(new Character('\u00AD'),"­");
- textSet.put(new Character('\u00AE'),"®");
- textSet.put(new Character('\u00AF'),"¯");
- textSet.put(new Character('\u00B0'),"°");
- textSet.put(new Character('\u00B1'),"±");
- textSet.put(new Character('\u00B2'),"²");
- textSet.put(new Character('\u00B3'),"³");
- textSet.put(new Character('\u00B4'),"´");
- textSet.put(new Character('\u00B5'),"µ");
- textSet.put(new Character('\u00B6'),"¶");
- textSet.put(new Character('\u00B7'),"·");
- textSet.put(new Character('\u00B8'),"¸");
- textSet.put(new Character('\u00B9'),"¹");
- textSet.put(new Character('\u00BA'),"º");
- textSet.put(new Character('\u00BB'),"»");
- textSet.put(new Character('\u00BC'),"¼");
- textSet.put(new Character('\u00BD'),"½");
- textSet.put(new Character('\u00BE'),"¾");
- textSet.put(new Character('\u00BF'),"¿");
- textSet.put(new Character('\u00C0'),"À");
- textSet.put(new Character('\u00E0'),"à");
- textSet.put(new Character('\u00C1'),"Á");
- textSet.put(new Character('\u00E1'),"á");
- textSet.put(new Character('\u00C2'),"Â");
- textSet.put(new Character('\u00E2'),"â");
- textSet.put(new Character('\u00C3'),"Ã");
- textSet.put(new Character('\u00E3'),"ã");
- textSet.put(new Character('\u00C4'),"Ä");
- textSet.put(new Character('\u00E4'),"ä");
- textSet.put(new Character('\u00C5'),"Å");
- textSet.put(new Character('\u00E5'),"å");
- textSet.put(new Character('\u00C6'),"Æ");
- textSet.put(new Character('\u00E6'),"æ");
- textSet.put(new Character('\u00C7'),"Ç");
- textSet.put(new Character('\u00E7'),"ç");
- textSet.put(new Character('\u00C8'),"È");
- textSet.put(new Character('\u00E8'),"è");
- textSet.put(new Character('\u00C9'),"É");
- textSet.put(new Character('\u00E9'),"é");
- textSet.put(new Character('\u00CA'),"Ê");
- textSet.put(new Character('\u00EA'),"ê");
- textSet.put(new Character('\u00CB'),"Ë");
- textSet.put(new Character('\u00EB'),"ë");
- textSet.put(new Character('\u00CC'),"Ì");
- textSet.put(new Character('\u00EC'),"ì");
- textSet.put(new Character('\u00CD'),"Í");
- textSet.put(new Character('\u00ED'),"í");
- textSet.put(new Character('\u00CE'),"Î");
- textSet.put(new Character('\u00EE'),"î");
- textSet.put(new Character('\u00CF'),"Ï");
- textSet.put(new Character('\u00EF'),"ï");
- textSet.put(new Character('\u00D0'),"Ð");
- textSet.put(new Character('\u00F0'),"ð");
- textSet.put(new Character('\u00D1'),"Ñ");
- textSet.put(new Character('\u00F1'),"ñ");
- textSet.put(new Character('\u00D2'),"Ò");
- textSet.put(new Character('\u00F2'),"ò");
- textSet.put(new Character('\u00D3'),"Ó");
- textSet.put(new Character('\u00F3'),"ó");
- textSet.put(new Character('\u00D4'),"Ô");
- textSet.put(new Character('\u00F4'),"ô");
- textSet.put(new Character('\u00D5'),"Õ");
- textSet.put(new Character('\u00F5'),"õ");
- textSet.put(new Character('\u00D6'),"Ö");
- textSet.put(new Character('\u00F6'),"ö");
- textSet.put(new Character('\u00D7'),"×");
- textSet.put(new Character('\u00F7'),"÷");
- textSet.put(new Character('\u00D8'),"Ø");
- textSet.put(new Character('\u00F8'),"ø");
- textSet.put(new Character('\u00D9'),"Ù");
- textSet.put(new Character('\u00F9'),"ù");
- textSet.put(new Character('\u00DA'),"Ú");
- textSet.put(new Character('\u00FA'),"ú");
- textSet.put(new Character('\u00DB'),"Û");
- textSet.put(new Character('\u00FB'),"û");
- textSet.put(new Character('\u00DC'),"Ü");
- textSet.put(new Character('\u00FC'),"ü");
- textSet.put(new Character('\u00DD'),"Ý");
- textSet.put(new Character('\u00FD'),"ý");
- textSet.put(new Character('\u00DE'),"Þ");
- textSet.put(new Character('\u00FE'),"þ");
- textSet.put(new Character('\u00DF'),"ß");
- textSet.put(new Character('\u00FF'),"ÿ");
- textSet.put(new Character('\u2013'),"–");
- textSet.put(new Character('\u2014'),"—");
- textSet.put(new Character('\u2018'),"‘");
- textSet.put(new Character('\u2019'),"’");
- textSet.put(new Character('\u201C'),"“");
- textSet.put(new Character('\u201D'),"”");
- textSet.put(new Character('\u20AC'),"€");
+ textSet.put(new Character('\u00AE'),"®"); //$NON-NLS-1$
+ textSet.put(new Character('\u00AF'),"¯"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B0'),"°"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B1'),"±"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B2'),"²"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B3'),"³"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B4'),"´"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B5'),"µ"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B6'),"¶"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B7'),"·"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B8'),"¸"); //$NON-NLS-1$
+ textSet.put(new Character('\u00B9'),"¹"); //$NON-NLS-1$
+ textSet.put(new Character('\u00BA'),"º"); //$NON-NLS-1$
+ textSet.put(new Character('\u00BB'),"»"); //$NON-NLS-1$
+ textSet.put(new Character('\u00BC'),"¼"); //$NON-NLS-1$
+ textSet.put(new Character('\u00BD'),"½"); //$NON-NLS-1$
+ textSet.put(new Character('\u00BE'),"¾"); //$NON-NLS-1$
+ textSet.put(new Character('\u00BF'),"¿"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C0'),"À"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E0'),"à"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C1'),"Á"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E1'),"á"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C2'),"Â"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E2'),"â"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C3'),"Ã"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E3'),"ã"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C4'),"Ä"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E4'),"ä"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C5'),"Å"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E5'),"å"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C6'),"Æ"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E6'),"æ"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C7'),"Ç"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E7'),"ç"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C8'),"È"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E8'),"è"); //$NON-NLS-1$
+ textSet.put(new Character('\u00C9'),"É"); //$NON-NLS-1$
+ textSet.put(new Character('\u00E9'),"é"); //$NON-NLS-1$
+ textSet.put(new Character('\u00CA'),"Ê"); //$NON-NLS-1$
+ textSet.put(new Character('\u00EA'),"ê"); //$NON-NLS-1$
+ textSet.put(new Character('\u00CB'),"Ë"); //$NON-NLS-1$
+ textSet.put(new Character('\u00EB'),"ë"); //$NON-NLS-1$
+ textSet.put(new Character('\u00CC'),"Ì"); //$NON-NLS-1$
+ textSet.put(new Character('\u00EC'),"ì"); //$NON-NLS-1$
+ textSet.put(new Character('\u00CD'),"Í"); //$NON-NLS-1$
+ textSet.put(new Character('\u00ED'),"í"); //$NON-NLS-1$
+ textSet.put(new Character('\u00CE'),"Î"); //$NON-NLS-1$
+ textSet.put(new Character('\u00EE'),"î"); //$NON-NLS-1$
+ textSet.put(new Character('\u00CF'),"Ï"); //$NON-NLS-1$
+ textSet.put(new Character('\u00EF'),"ï"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D0'),"Ð"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F0'),"ð"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D1'),"Ñ"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F1'),"ñ"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D2'),"Ò"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F2'),"ò"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D3'),"Ó"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F3'),"ó"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D4'),"Ô"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F4'),"ô"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D5'),"Õ"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F5'),"õ"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D6'),"Ö"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F6'),"ö"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D7'),"×"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F7'),"÷"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D8'),"Ø"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F8'),"ø"); //$NON-NLS-1$
+ textSet.put(new Character('\u00D9'),"Ù"); //$NON-NLS-1$
+ textSet.put(new Character('\u00F9'),"ù"); //$NON-NLS-1$
+ textSet.put(new Character('\u00DA'),"Ú"); //$NON-NLS-1$
+ textSet.put(new Character('\u00FA'),"ú"); //$NON-NLS-1$
+ textSet.put(new Character('\u00DB'),"Û"); //$NON-NLS-1$
+ textSet.put(new Character('\u00FB'),"û"); //$NON-NLS-1$
+ textSet.put(new Character('\u00DC'),"Ü"); //$NON-NLS-1$
+ textSet.put(new Character('\u00FC'),"ü"); //$NON-NLS-1$
+ textSet.put(new Character('\u00DD'),"Ý"); //$NON-NLS-1$
+ textSet.put(new Character('\u00FD'),"ý"); //$NON-NLS-1$
+ textSet.put(new Character('\u00DE'),"Þ"); //$NON-NLS-1$
+ textSet.put(new Character('\u00FE'),"þ"); //$NON-NLS-1$
+ textSet.put(new Character('\u00DF'),"ß"); //$NON-NLS-1$
+ textSet.put(new Character('\u00FF'),"ÿ"); //$NON-NLS-1$
+ textSet.put(new Character('\u2013'),"–"); //$NON-NLS-1$
+ textSet.put(new Character('\u2014'),"—"); //$NON-NLS-1$
+ textSet.put(new Character('\u2018'),"‘"); //$NON-NLS-1$
+ textSet.put(new Character('\u2019'),"’"); //$NON-NLS-1$
+ textSet.put(new Character('\u201C'),"“"); //$NON-NLS-1$
+ textSet.put(new Character('\u201D'),"”"); //$NON-NLS-1$
+ textSet.put(new Character('\u20AC'),"€"); //$NON-NLS-1$
}
public static boolean containsKey(char key){
@@ -185,7 +185,7 @@
String value = (String)textSet.get(ch);
char sourceChar = sourceText.charAt(sourceIndex);
if(value != null){
- if(sourceChar != ch.charValue() || (ch.charValue() == '&' &&
sourceText.indexOf("&",sourceIndex) >= 0)){
+ if(sourceChar != ch.charValue() || (ch.charValue() == '&' &&
sourceText.indexOf("&",sourceIndex) >= 0)){ //$NON-NLS-1$
if(visualIndex == visualPosition) return true;
sourceIndex += value.length()-1;
}
@@ -301,8 +301,8 @@
int start1 = s1.length()-delta;
if(position < sourceText.length()){
while(position > sourcePosition){
- int ampersandPosition = s1.lastIndexOf("&");
- int semicolonPosition = s1.lastIndexOf(";");
+ int ampersandPosition = s1.lastIndexOf("&"); //$NON-NLS-1$
+ int semicolonPosition = s1.lastIndexOf(";"); //$NON-NLS-1$
if(ampersandPosition > 0 && semicolonPosition > 0 &&
ampersandPosition < semicolonPosition && (semicolonPosition+1) >
sourcePosition){
String value = s1.substring(ampersandPosition, semicolonPosition+1);
if(textSet.containsValue(value))
@@ -325,7 +325,7 @@
String[] strings = (String[]) textSet.values().toArray(new String[]{});
for(int i=0;i<strings.length;i++){
- s1 = s1.replaceAll(strings[i]," ");
+ s1 = s1.replaceAll(strings[i]," "); //$NON-NLS-1$
}
s1 = visualText(s1);
return sourcePosition-(startLength - s1.length())-(start1-start2);