1 5 6 package com.hp.hpl.jena.rdf.arp; 7 8 import com.ibm.icu.lang.UCharacter; 9 import com.ibm.icu.text.Normalizer; 10 19 public class CharacterModel { 20 static private final boolean SWITCH_OFF = false; 21 24 static public boolean isNormalFormC(String str) { 25 try { 26 return SWITCH_OFF || Normalizer. isNormalized(str,Normalizer.NFC,0); 27 } 28 catch (ArrayIndexOutOfBoundsException e) { 29 String normalized = Normalizer.compose(str,false); 31 return normalized.equals(str); 32 } 33 } 34 35 41 static public boolean startsWithComposingCharacter(String str) { 42 return SWITCH_OFF ? false : (str.length()==0?false:isComposingChar(str.charAt(0))); 43 } 44 50 static public boolean isFullyNormalizedConstruct(String str) { 51 return SWITCH_OFF || (isNormalFormC(str) && !startsWithComposingCharacter(str)); 52 } 53 59 static public boolean isComposingChar(char x) { 60 if ( SWITCH_OFF ) 61 return false; 62 switch (x) { 63 case 0X09BE: case 0X09D7: case 0X0B3E: case 0X0B56: case 0X0B57: case 0X0BBE: case 0X0BD7: case 0X0CC2: case 0X0CD5: case 0X0CD6: case 0X0D3E: case 0X0D57: case 0X0DCF: case 0X0DDF: case 0X0FB5: case 0X0FB7: case 0X102E: case 0X1161: case 0X1162: case 0X1163: case 0X1164: case 0X1165: case 0X1166: case 0X1167: case 0X1168: case 0X1169: case 0X116A: case 0X116B: case 0X116C: case 0X116D: case 0X116E: case 0X116F: case 0X1170: case 0X1171: case 0X1172: case 0X1173: case 0X1174: case 0X1175: case 0X11A8: case 0X11A9: case 0X11AA: case 0X11AB: case 0X11AC: case 0X11AD: case 0X11AE: case 0X11AF: case 0X11B0: case 0X11B1: case 0X11B2: case 0X11B3: case 0X11B4: case 0X11B5: case 0X11B6: case 0X11B7: case 0X11B8: case 0X11B9: case 0X11BA: case 0X11BB: case 0X11BC: case 0X11BD: case 0X11BE: case 0X11BF: case 0X11C0: case 0X11C1: case 0X11C2: return true; 132 default: 133 return UCharacter.getCombiningClass(x) != 0; 134 } 135 } 136 142 } 143 144 170 | Popular Tags |