Character.java 121 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052
  1. /* java.lang.Character -- Wrapper class for char, and Unicode subsets
  2. Copyright (C) 1998, 1999, 2001, 2002, 2005, 2006, 2007
  3. Free Software Foundation, Inc.
  4. This file is part of GNU Classpath.
  5. GNU Classpath is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9. GNU Classpath is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GNU Classpath; see the file COPYING. If not, write to the
  15. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA.
  17. Linking this library statically or dynamically with other modules is
  18. making a combined work based on this library. Thus, the terms and
  19. conditions of the GNU General Public License cover the whole
  20. combination.
  21. As a special exception, the copyright holders of this library give you
  22. permission to link this library with independent modules to produce an
  23. executable, regardless of the license terms of these independent
  24. modules, and to copy and distribute the resulting executable under
  25. terms of your choice, provided that you also meet, for each linked
  26. independent module, the terms and conditions of the license of that
  27. module. An independent module is a module which is not derived from
  28. or based on this library. If you modify this library, you may extend
  29. this exception to your version of the library, but you are not
  30. obligated to do so. If you do not wish to do so, delete this
  31. exception statement from your version. */
  32. /*
  33. * Note: This class must not be merged with Classpath. Gcj uses C-style
  34. * arrays (see include/java-chartables.h) to store the Unicode character
  35. * database, whereas Classpath uses Java objects (char[] extracted from
  36. * String constants) in gnu.java.lang.CharData. Gcj's approach is more
  37. * efficient, because there is no vtable or data relocation to worry about.
  38. * However, despite the difference in the database interface, the two
  39. * versions share identical algorithms.
  40. */
  41. package java.lang;
  42. import java.io.Serializable;
  43. import java.text.Collator;
  44. import java.util.Locale;
  45. /**
  46. * Wrapper class for the primitive char data type. In addition, this class
  47. * allows one to retrieve property information and perform transformations
  48. * on the defined characters in the Unicode Standard, Version 4.0.0.
  49. * java.lang.Character is designed to be very dynamic, and as such, it
  50. * retrieves information on the Unicode character set from a separate
  51. * database, gnu.java.lang.CharData, which can be easily upgraded.
  52. *
  53. * <p>For predicates, boundaries are used to describe
  54. * the set of characters for which the method will return true.
  55. * This syntax uses fairly normal regular expression notation.
  56. * See 5.13 of the Unicode Standard, Version 4.0, for the
  57. * boundary specification.
  58. *
  59. * <p>See <a href="http://www.unicode.org">http://www.unicode.org</a>
  60. * for more information on the Unicode Standard.
  61. *
  62. * @author Tom Tromey (tromey@cygnus.com)
  63. * @author Paul N. Fisher
  64. * @author Jochen Hoenicke
  65. * @author Eric Blake (ebb9@email.byu.edu)
  66. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  67. * @since 1.0
  68. * @status partly updated to 1.5; some things still missing
  69. */
  70. public final class Character implements Serializable, Comparable<Character>
  71. {
  72. /**
  73. * A subset of Unicode blocks.
  74. *
  75. * @author Paul N. Fisher
  76. * @author Eric Blake (ebb9@email.byu.edu)
  77. * @since 1.2
  78. */
  79. public static class Subset
  80. {
  81. /** The name of the subset. */
  82. private final String name;
  83. /**
  84. * Construct a new subset of characters.
  85. *
  86. * @param name the name of the subset
  87. * @throws NullPointerException if name is null
  88. */
  89. protected Subset(String name)
  90. {
  91. // Note that name.toString() is name, unless name was null.
  92. this.name = name.toString();
  93. }
  94. /**
  95. * Compares two Subsets for equality. This is <code>final</code>, and
  96. * restricts the comparison on the <code>==</code> operator, so it returns
  97. * true only for the same object.
  98. *
  99. * @param o the object to compare
  100. * @return true if o is this
  101. */
  102. public final boolean equals(Object o)
  103. {
  104. return o == this;
  105. }
  106. /**
  107. * Makes the original hashCode of Object final, to be consistent with
  108. * equals.
  109. *
  110. * @return the hash code for this object
  111. */
  112. public final int hashCode()
  113. {
  114. return super.hashCode();
  115. }
  116. /**
  117. * Returns the name of the subset.
  118. *
  119. * @return the name
  120. */
  121. public final String toString()
  122. {
  123. return name;
  124. }
  125. } // class Subset
  126. /**
  127. * A family of character subsets in the Unicode specification. A character
  128. * is in at most one of these blocks.
  129. *
  130. * This inner class was generated automatically from
  131. * <code>libjava/gnu/gcj/convert/Blocks-3.txt</code>, by some perl scripts.
  132. * This Unicode definition file can be found on the
  133. * <a href="http://www.unicode.org">http://www.unicode.org</a> website.
  134. * JDK 1.4 uses Unicode version 3.0.0.
  135. *
  136. * @author scripts/unicode-blocks.pl (written by Eric Blake)
  137. * @since 1.2
  138. */
  139. public static final class UnicodeBlock extends Subset
  140. {
  141. /** The start of the subset. */
  142. private final int start;
  143. /** The end of the subset. */
  144. private final int end;
  145. /** The canonical name of the block according to the Unicode standard. */
  146. private final String canonicalName;
  147. /** Enumeration for the <code>forName()</code> method */
  148. private enum NameType { CANONICAL, NO_SPACES, CONSTANT; }
  149. /**
  150. * Constructor for strictly defined blocks.
  151. *
  152. * @param start the start character of the range
  153. * @param end the end character of the range
  154. * @param name the block name
  155. */
  156. private UnicodeBlock(int start, int end, String name,
  157. String canonicalName)
  158. {
  159. super(name);
  160. this.start = start;
  161. this.end = end;
  162. this.canonicalName = canonicalName;
  163. }
  164. /**
  165. * Returns the Unicode character block which a character belongs to.
  166. * <strong>Note</strong>: This method does not support the use of
  167. * supplementary characters. For such support, <code>of(int)</code>
  168. * should be used instead.
  169. *
  170. * @param ch the character to look up
  171. * @return the set it belongs to, or null if it is not in one
  172. */
  173. public static UnicodeBlock of(char ch)
  174. {
  175. return of((int) ch);
  176. }
  177. /**
  178. * Returns the Unicode character block which a code point belongs to.
  179. *
  180. * @param codePoint the character to look up
  181. * @return the set it belongs to, or null if it is not in one.
  182. * @throws IllegalArgumentException if the specified code point is
  183. * invalid.
  184. * @since 1.5
  185. */
  186. public static UnicodeBlock of(int codePoint)
  187. {
  188. if (codePoint > MAX_CODE_POINT)
  189. throw new IllegalArgumentException("The supplied integer value is " +
  190. "too large to be a codepoint.");
  191. // Simple binary search for the correct block.
  192. int low = 0;
  193. int hi = sets.length - 1;
  194. while (low <= hi)
  195. {
  196. int mid = (low + hi) >> 1;
  197. UnicodeBlock b = sets[mid];
  198. if (codePoint < b.start)
  199. hi = mid - 1;
  200. else if (codePoint > b.end)
  201. low = mid + 1;
  202. else
  203. return b;
  204. }
  205. return null;
  206. }
  207. /**
  208. * <p>
  209. * Returns the <code>UnicodeBlock</code> with the given name, as defined
  210. * by the Unicode standard. The version of Unicode in use is defined by
  211. * the <code>Character</code> class, and the names are given in the
  212. * <code>Blocks-<version>.txt</code> file corresponding to that version.
  213. * The name may be specified in one of three ways:
  214. * </p>
  215. * <ol>
  216. * <li>The canonical, human-readable name used by the Unicode standard.
  217. * This is the name with all spaces and hyphens retained. For example,
  218. * `Basic Latin' retrieves the block, UnicodeBlock.BASIC_LATIN.</li>
  219. * <li>The canonical name with all spaces removed e.g. `BasicLatin'.</li>
  220. * <li>The name used for the constants specified by this class, which
  221. * is the canonical name with all spaces and hyphens replaced with
  222. * underscores e.g. `BASIC_LATIN'</li>
  223. * </ol>
  224. * <p>
  225. * The names are compared case-insensitively using the case comparison
  226. * associated with the U.S. English locale. The method recognises the
  227. * previous names used for blocks as well as the current ones. At
  228. * present, this simply means that the deprecated `SURROGATES_AREA'
  229. * will be recognised by this method (the <code>of()</code> methods
  230. * only return one of the three new surrogate blocks).
  231. * </p>
  232. *
  233. * @param blockName the name of the block to look up.
  234. * @return the specified block.
  235. * @throws NullPointerException if the <code>blockName</code> is
  236. * <code>null</code>.
  237. * @throws IllegalArgumentException if the name does not match any Unicode
  238. * block.
  239. * @since 1.5
  240. */
  241. public static final UnicodeBlock forName(String blockName)
  242. {
  243. NameType type;
  244. if (blockName.indexOf(' ') != -1)
  245. type = NameType.CANONICAL;
  246. else if (blockName.indexOf('_') != -1)
  247. type = NameType.CONSTANT;
  248. else
  249. type = NameType.NO_SPACES;
  250. Collator usCollator = Collator.getInstance(Locale.US);
  251. usCollator.setStrength(Collator.PRIMARY);
  252. /* Special case for deprecated blocks not in sets */
  253. switch (type)
  254. {
  255. case CANONICAL:
  256. if (usCollator.compare(blockName, "Surrogates Area") == 0)
  257. return SURROGATES_AREA;
  258. break;
  259. case NO_SPACES:
  260. if (usCollator.compare(blockName, "SurrogatesArea") == 0)
  261. return SURROGATES_AREA;
  262. break;
  263. case CONSTANT:
  264. if (usCollator.compare(blockName, "SURROGATES_AREA") == 0)
  265. return SURROGATES_AREA;
  266. break;
  267. }
  268. /* Other cases */
  269. switch (type)
  270. {
  271. case CANONICAL:
  272. for (UnicodeBlock block : sets)
  273. if (usCollator.compare(blockName, block.canonicalName) == 0)
  274. return block;
  275. break;
  276. case NO_SPACES:
  277. for (UnicodeBlock block : sets)
  278. {
  279. String nsName = block.canonicalName.replaceAll(" ","");
  280. if (usCollator.compare(blockName, nsName) == 0)
  281. return block;
  282. }
  283. break;
  284. case CONSTANT:
  285. for (UnicodeBlock block : sets)
  286. if (usCollator.compare(blockName, block.toString()) == 0)
  287. return block;
  288. break;
  289. }
  290. throw new IllegalArgumentException("No Unicode block found for " +
  291. blockName + ".");
  292. }
  293. /**
  294. * Basic Latin.
  295. * 0x0000 - 0x007F.
  296. */
  297. public static final UnicodeBlock BASIC_LATIN
  298. = new UnicodeBlock(0x0000, 0x007F,
  299. "BASIC_LATIN",
  300. "Basic Latin");
  301. /**
  302. * Latin-1 Supplement.
  303. * 0x0080 - 0x00FF.
  304. */
  305. public static final UnicodeBlock LATIN_1_SUPPLEMENT
  306. = new UnicodeBlock(0x0080, 0x00FF,
  307. "LATIN_1_SUPPLEMENT",
  308. "Latin-1 Supplement");
  309. /**
  310. * Latin Extended-A.
  311. * 0x0100 - 0x017F.
  312. */
  313. public static final UnicodeBlock LATIN_EXTENDED_A
  314. = new UnicodeBlock(0x0100, 0x017F,
  315. "LATIN_EXTENDED_A",
  316. "Latin Extended-A");
  317. /**
  318. * Latin Extended-B.
  319. * 0x0180 - 0x024F.
  320. */
  321. public static final UnicodeBlock LATIN_EXTENDED_B
  322. = new UnicodeBlock(0x0180, 0x024F,
  323. "LATIN_EXTENDED_B",
  324. "Latin Extended-B");
  325. /**
  326. * IPA Extensions.
  327. * 0x0250 - 0x02AF.
  328. */
  329. public static final UnicodeBlock IPA_EXTENSIONS
  330. = new UnicodeBlock(0x0250, 0x02AF,
  331. "IPA_EXTENSIONS",
  332. "IPA Extensions");
  333. /**
  334. * Spacing Modifier Letters.
  335. * 0x02B0 - 0x02FF.
  336. */
  337. public static final UnicodeBlock SPACING_MODIFIER_LETTERS
  338. = new UnicodeBlock(0x02B0, 0x02FF,
  339. "SPACING_MODIFIER_LETTERS",
  340. "Spacing Modifier Letters");
  341. /**
  342. * Combining Diacritical Marks.
  343. * 0x0300 - 0x036F.
  344. */
  345. public static final UnicodeBlock COMBINING_DIACRITICAL_MARKS
  346. = new UnicodeBlock(0x0300, 0x036F,
  347. "COMBINING_DIACRITICAL_MARKS",
  348. "Combining Diacritical Marks");
  349. /**
  350. * Greek.
  351. * 0x0370 - 0x03FF.
  352. */
  353. public static final UnicodeBlock GREEK
  354. = new UnicodeBlock(0x0370, 0x03FF,
  355. "GREEK",
  356. "Greek");
  357. /**
  358. * Cyrillic.
  359. * 0x0400 - 0x04FF.
  360. */
  361. public static final UnicodeBlock CYRILLIC
  362. = new UnicodeBlock(0x0400, 0x04FF,
  363. "CYRILLIC",
  364. "Cyrillic");
  365. /**
  366. * Cyrillic Supplementary.
  367. * 0x0500 - 0x052F.
  368. * @since 1.5
  369. */
  370. public static final UnicodeBlock CYRILLIC_SUPPLEMENTARY
  371. = new UnicodeBlock(0x0500, 0x052F,
  372. "CYRILLIC_SUPPLEMENTARY",
  373. "Cyrillic Supplementary");
  374. /**
  375. * Armenian.
  376. * 0x0530 - 0x058F.
  377. */
  378. public static final UnicodeBlock ARMENIAN
  379. = new UnicodeBlock(0x0530, 0x058F,
  380. "ARMENIAN",
  381. "Armenian");
  382. /**
  383. * Hebrew.
  384. * 0x0590 - 0x05FF.
  385. */
  386. public static final UnicodeBlock HEBREW
  387. = new UnicodeBlock(0x0590, 0x05FF,
  388. "HEBREW",
  389. "Hebrew");
  390. /**
  391. * Arabic.
  392. * 0x0600 - 0x06FF.
  393. */
  394. public static final UnicodeBlock ARABIC
  395. = new UnicodeBlock(0x0600, 0x06FF,
  396. "ARABIC",
  397. "Arabic");
  398. /**
  399. * Syriac.
  400. * 0x0700 - 0x074F.
  401. * @since 1.4
  402. */
  403. public static final UnicodeBlock SYRIAC
  404. = new UnicodeBlock(0x0700, 0x074F,
  405. "SYRIAC",
  406. "Syriac");
  407. /**
  408. * Thaana.
  409. * 0x0780 - 0x07BF.
  410. * @since 1.4
  411. */
  412. public static final UnicodeBlock THAANA
  413. = new UnicodeBlock(0x0780, 0x07BF,
  414. "THAANA",
  415. "Thaana");
  416. /**
  417. * Devanagari.
  418. * 0x0900 - 0x097F.
  419. */
  420. public static final UnicodeBlock DEVANAGARI
  421. = new UnicodeBlock(0x0900, 0x097F,
  422. "DEVANAGARI",
  423. "Devanagari");
  424. /**
  425. * Bengali.
  426. * 0x0980 - 0x09FF.
  427. */
  428. public static final UnicodeBlock BENGALI
  429. = new UnicodeBlock(0x0980, 0x09FF,
  430. "BENGALI",
  431. "Bengali");
  432. /**
  433. * Gurmukhi.
  434. * 0x0A00 - 0x0A7F.
  435. */
  436. public static final UnicodeBlock GURMUKHI
  437. = new UnicodeBlock(0x0A00, 0x0A7F,
  438. "GURMUKHI",
  439. "Gurmukhi");
  440. /**
  441. * Gujarati.
  442. * 0x0A80 - 0x0AFF.
  443. */
  444. public static final UnicodeBlock GUJARATI
  445. = new UnicodeBlock(0x0A80, 0x0AFF,
  446. "GUJARATI",
  447. "Gujarati");
  448. /**
  449. * Oriya.
  450. * 0x0B00 - 0x0B7F.
  451. */
  452. public static final UnicodeBlock ORIYA
  453. = new UnicodeBlock(0x0B00, 0x0B7F,
  454. "ORIYA",
  455. "Oriya");
  456. /**
  457. * Tamil.
  458. * 0x0B80 - 0x0BFF.
  459. */
  460. public static final UnicodeBlock TAMIL
  461. = new UnicodeBlock(0x0B80, 0x0BFF,
  462. "TAMIL",
  463. "Tamil");
  464. /**
  465. * Telugu.
  466. * 0x0C00 - 0x0C7F.
  467. */
  468. public static final UnicodeBlock TELUGU
  469. = new UnicodeBlock(0x0C00, 0x0C7F,
  470. "TELUGU",
  471. "Telugu");
  472. /**
  473. * Kannada.
  474. * 0x0C80 - 0x0CFF.
  475. */
  476. public static final UnicodeBlock KANNADA
  477. = new UnicodeBlock(0x0C80, 0x0CFF,
  478. "KANNADA",
  479. "Kannada");
  480. /**
  481. * Malayalam.
  482. * 0x0D00 - 0x0D7F.
  483. */
  484. public static final UnicodeBlock MALAYALAM
  485. = new UnicodeBlock(0x0D00, 0x0D7F,
  486. "MALAYALAM",
  487. "Malayalam");
  488. /**
  489. * Sinhala.
  490. * 0x0D80 - 0x0DFF.
  491. * @since 1.4
  492. */
  493. public static final UnicodeBlock SINHALA
  494. = new UnicodeBlock(0x0D80, 0x0DFF,
  495. "SINHALA",
  496. "Sinhala");
  497. /**
  498. * Thai.
  499. * 0x0E00 - 0x0E7F.
  500. */
  501. public static final UnicodeBlock THAI
  502. = new UnicodeBlock(0x0E00, 0x0E7F,
  503. "THAI",
  504. "Thai");
  505. /**
  506. * Lao.
  507. * 0x0E80 - 0x0EFF.
  508. */
  509. public static final UnicodeBlock LAO
  510. = new UnicodeBlock(0x0E80, 0x0EFF,
  511. "LAO",
  512. "Lao");
  513. /**
  514. * Tibetan.
  515. * 0x0F00 - 0x0FFF.
  516. */
  517. public static final UnicodeBlock TIBETAN
  518. = new UnicodeBlock(0x0F00, 0x0FFF,
  519. "TIBETAN",
  520. "Tibetan");
  521. /**
  522. * Myanmar.
  523. * 0x1000 - 0x109F.
  524. * @since 1.4
  525. */
  526. public static final UnicodeBlock MYANMAR
  527. = new UnicodeBlock(0x1000, 0x109F,
  528. "MYANMAR",
  529. "Myanmar");
  530. /**
  531. * Georgian.
  532. * 0x10A0 - 0x10FF.
  533. */
  534. public static final UnicodeBlock GEORGIAN
  535. = new UnicodeBlock(0x10A0, 0x10FF,
  536. "GEORGIAN",
  537. "Georgian");
  538. /**
  539. * Hangul Jamo.
  540. * 0x1100 - 0x11FF.
  541. */
  542. public static final UnicodeBlock HANGUL_JAMO
  543. = new UnicodeBlock(0x1100, 0x11FF,
  544. "HANGUL_JAMO",
  545. "Hangul Jamo");
  546. /**
  547. * Ethiopic.
  548. * 0x1200 - 0x137F.
  549. * @since 1.4
  550. */
  551. public static final UnicodeBlock ETHIOPIC
  552. = new UnicodeBlock(0x1200, 0x137F,
  553. "ETHIOPIC",
  554. "Ethiopic");
  555. /**
  556. * Cherokee.
  557. * 0x13A0 - 0x13FF.
  558. * @since 1.4
  559. */
  560. public static final UnicodeBlock CHEROKEE
  561. = new UnicodeBlock(0x13A0, 0x13FF,
  562. "CHEROKEE",
  563. "Cherokee");
  564. /**
  565. * Unified Canadian Aboriginal Syllabics.
  566. * 0x1400 - 0x167F.
  567. * @since 1.4
  568. */
  569. public static final UnicodeBlock UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS
  570. = new UnicodeBlock(0x1400, 0x167F,
  571. "UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS",
  572. "Unified Canadian Aboriginal Syllabics");
  573. /**
  574. * Ogham.
  575. * 0x1680 - 0x169F.
  576. * @since 1.4
  577. */
  578. public static final UnicodeBlock OGHAM
  579. = new UnicodeBlock(0x1680, 0x169F,
  580. "OGHAM",
  581. "Ogham");
  582. /**
  583. * Runic.
  584. * 0x16A0 - 0x16FF.
  585. * @since 1.4
  586. */
  587. public static final UnicodeBlock RUNIC
  588. = new UnicodeBlock(0x16A0, 0x16FF,
  589. "RUNIC",
  590. "Runic");
  591. /**
  592. * Tagalog.
  593. * 0x1700 - 0x171F.
  594. * @since 1.5
  595. */
  596. public static final UnicodeBlock TAGALOG
  597. = new UnicodeBlock(0x1700, 0x171F,
  598. "TAGALOG",
  599. "Tagalog");
  600. /**
  601. * Hanunoo.
  602. * 0x1720 - 0x173F.
  603. * @since 1.5
  604. */
  605. public static final UnicodeBlock HANUNOO
  606. = new UnicodeBlock(0x1720, 0x173F,
  607. "HANUNOO",
  608. "Hanunoo");
  609. /**
  610. * Buhid.
  611. * 0x1740 - 0x175F.
  612. * @since 1.5
  613. */
  614. public static final UnicodeBlock BUHID
  615. = new UnicodeBlock(0x1740, 0x175F,
  616. "BUHID",
  617. "Buhid");
  618. /**
  619. * Tagbanwa.
  620. * 0x1760 - 0x177F.
  621. * @since 1.5
  622. */
  623. public static final UnicodeBlock TAGBANWA
  624. = new UnicodeBlock(0x1760, 0x177F,
  625. "TAGBANWA",
  626. "Tagbanwa");
  627. /**
  628. * Khmer.
  629. * 0x1780 - 0x17FF.
  630. * @since 1.4
  631. */
  632. public static final UnicodeBlock KHMER
  633. = new UnicodeBlock(0x1780, 0x17FF,
  634. "KHMER",
  635. "Khmer");
  636. /**
  637. * Mongolian.
  638. * 0x1800 - 0x18AF.
  639. * @since 1.4
  640. */
  641. public static final UnicodeBlock MONGOLIAN
  642. = new UnicodeBlock(0x1800, 0x18AF,
  643. "MONGOLIAN",
  644. "Mongolian");
  645. /**
  646. * Limbu.
  647. * 0x1900 - 0x194F.
  648. * @since 1.5
  649. */
  650. public static final UnicodeBlock LIMBU
  651. = new UnicodeBlock(0x1900, 0x194F,
  652. "LIMBU",
  653. "Limbu");
  654. /**
  655. * Tai Le.
  656. * 0x1950 - 0x197F.
  657. * @since 1.5
  658. */
  659. public static final UnicodeBlock TAI_LE
  660. = new UnicodeBlock(0x1950, 0x197F,
  661. "TAI_LE",
  662. "Tai Le");
  663. /**
  664. * Khmer Symbols.
  665. * 0x19E0 - 0x19FF.
  666. * @since 1.5
  667. */
  668. public static final UnicodeBlock KHMER_SYMBOLS
  669. = new UnicodeBlock(0x19E0, 0x19FF,
  670. "KHMER_SYMBOLS",
  671. "Khmer Symbols");
  672. /**
  673. * Phonetic Extensions.
  674. * 0x1D00 - 0x1D7F.
  675. * @since 1.5
  676. */
  677. public static final UnicodeBlock PHONETIC_EXTENSIONS
  678. = new UnicodeBlock(0x1D00, 0x1D7F,
  679. "PHONETIC_EXTENSIONS",
  680. "Phonetic Extensions");
  681. /**
  682. * Latin Extended Additional.
  683. * 0x1E00 - 0x1EFF.
  684. */
  685. public static final UnicodeBlock LATIN_EXTENDED_ADDITIONAL
  686. = new UnicodeBlock(0x1E00, 0x1EFF,
  687. "LATIN_EXTENDED_ADDITIONAL",
  688. "Latin Extended Additional");
  689. /**
  690. * Greek Extended.
  691. * 0x1F00 - 0x1FFF.
  692. */
  693. public static final UnicodeBlock GREEK_EXTENDED
  694. = new UnicodeBlock(0x1F00, 0x1FFF,
  695. "GREEK_EXTENDED",
  696. "Greek Extended");
  697. /**
  698. * General Punctuation.
  699. * 0x2000 - 0x206F.
  700. */
  701. public static final UnicodeBlock GENERAL_PUNCTUATION
  702. = new UnicodeBlock(0x2000, 0x206F,
  703. "GENERAL_PUNCTUATION",
  704. "General Punctuation");
  705. /**
  706. * Superscripts and Subscripts.
  707. * 0x2070 - 0x209F.
  708. */
  709. public static final UnicodeBlock SUPERSCRIPTS_AND_SUBSCRIPTS
  710. = new UnicodeBlock(0x2070, 0x209F,
  711. "SUPERSCRIPTS_AND_SUBSCRIPTS",
  712. "Superscripts and Subscripts");
  713. /**
  714. * Currency Symbols.
  715. * 0x20A0 - 0x20CF.
  716. */
  717. public static final UnicodeBlock CURRENCY_SYMBOLS
  718. = new UnicodeBlock(0x20A0, 0x20CF,
  719. "CURRENCY_SYMBOLS",
  720. "Currency Symbols");
  721. /**
  722. * Combining Marks for Symbols.
  723. * 0x20D0 - 0x20FF.
  724. */
  725. public static final UnicodeBlock COMBINING_MARKS_FOR_SYMBOLS
  726. = new UnicodeBlock(0x20D0, 0x20FF,
  727. "COMBINING_MARKS_FOR_SYMBOLS",
  728. "Combining Marks for Symbols");
  729. /**
  730. * Letterlike Symbols.
  731. * 0x2100 - 0x214F.
  732. */
  733. public static final UnicodeBlock LETTERLIKE_SYMBOLS
  734. = new UnicodeBlock(0x2100, 0x214F,
  735. "LETTERLIKE_SYMBOLS",
  736. "Letterlike Symbols");
  737. /**
  738. * Number Forms.
  739. * 0x2150 - 0x218F.
  740. */
  741. public static final UnicodeBlock NUMBER_FORMS
  742. = new UnicodeBlock(0x2150, 0x218F,
  743. "NUMBER_FORMS",
  744. "Number Forms");
  745. /**
  746. * Arrows.
  747. * 0x2190 - 0x21FF.
  748. */
  749. public static final UnicodeBlock ARROWS
  750. = new UnicodeBlock(0x2190, 0x21FF,
  751. "ARROWS",
  752. "Arrows");
  753. /**
  754. * Mathematical Operators.
  755. * 0x2200 - 0x22FF.
  756. */
  757. public static final UnicodeBlock MATHEMATICAL_OPERATORS
  758. = new UnicodeBlock(0x2200, 0x22FF,
  759. "MATHEMATICAL_OPERATORS",
  760. "Mathematical Operators");
  761. /**
  762. * Miscellaneous Technical.
  763. * 0x2300 - 0x23FF.
  764. */
  765. public static final UnicodeBlock MISCELLANEOUS_TECHNICAL
  766. = new UnicodeBlock(0x2300, 0x23FF,
  767. "MISCELLANEOUS_TECHNICAL",
  768. "Miscellaneous Technical");
  769. /**
  770. * Control Pictures.
  771. * 0x2400 - 0x243F.
  772. */
  773. public static final UnicodeBlock CONTROL_PICTURES
  774. = new UnicodeBlock(0x2400, 0x243F,
  775. "CONTROL_PICTURES",
  776. "Control Pictures");
  777. /**
  778. * Optical Character Recognition.
  779. * 0x2440 - 0x245F.
  780. */
  781. public static final UnicodeBlock OPTICAL_CHARACTER_RECOGNITION
  782. = new UnicodeBlock(0x2440, 0x245F,
  783. "OPTICAL_CHARACTER_RECOGNITION",
  784. "Optical Character Recognition");
  785. /**
  786. * Enclosed Alphanumerics.
  787. * 0x2460 - 0x24FF.
  788. */
  789. public static final UnicodeBlock ENCLOSED_ALPHANUMERICS
  790. = new UnicodeBlock(0x2460, 0x24FF,
  791. "ENCLOSED_ALPHANUMERICS",
  792. "Enclosed Alphanumerics");
  793. /**
  794. * Box Drawing.
  795. * 0x2500 - 0x257F.
  796. */
  797. public static final UnicodeBlock BOX_DRAWING
  798. = new UnicodeBlock(0x2500, 0x257F,
  799. "BOX_DRAWING",
  800. "Box Drawing");
  801. /**
  802. * Block Elements.
  803. * 0x2580 - 0x259F.
  804. */
  805. public static final UnicodeBlock BLOCK_ELEMENTS
  806. = new UnicodeBlock(0x2580, 0x259F,
  807. "BLOCK_ELEMENTS",
  808. "Block Elements");
  809. /**
  810. * Geometric Shapes.
  811. * 0x25A0 - 0x25FF.
  812. */
  813. public static final UnicodeBlock GEOMETRIC_SHAPES
  814. = new UnicodeBlock(0x25A0, 0x25FF,
  815. "GEOMETRIC_SHAPES",
  816. "Geometric Shapes");
  817. /**
  818. * Miscellaneous Symbols.
  819. * 0x2600 - 0x26FF.
  820. */
  821. public static final UnicodeBlock MISCELLANEOUS_SYMBOLS
  822. = new UnicodeBlock(0x2600, 0x26FF,
  823. "MISCELLANEOUS_SYMBOLS",
  824. "Miscellaneous Symbols");
  825. /**
  826. * Dingbats.
  827. * 0x2700 - 0x27BF.
  828. */
  829. public static final UnicodeBlock DINGBATS
  830. = new UnicodeBlock(0x2700, 0x27BF,
  831. "DINGBATS",
  832. "Dingbats");
  833. /**
  834. * Miscellaneous Mathematical Symbols-A.
  835. * 0x27C0 - 0x27EF.
  836. * @since 1.5
  837. */
  838. public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A
  839. = new UnicodeBlock(0x27C0, 0x27EF,
  840. "MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A",
  841. "Miscellaneous Mathematical Symbols-A");
  842. /**
  843. * Supplemental Arrows-A.
  844. * 0x27F0 - 0x27FF.
  845. * @since 1.5
  846. */
  847. public static final UnicodeBlock SUPPLEMENTAL_ARROWS_A
  848. = new UnicodeBlock(0x27F0, 0x27FF,
  849. "SUPPLEMENTAL_ARROWS_A",
  850. "Supplemental Arrows-A");
  851. /**
  852. * Braille Patterns.
  853. * 0x2800 - 0x28FF.
  854. * @since 1.4
  855. */
  856. public static final UnicodeBlock BRAILLE_PATTERNS
  857. = new UnicodeBlock(0x2800, 0x28FF,
  858. "BRAILLE_PATTERNS",
  859. "Braille Patterns");
  860. /**
  861. * Supplemental Arrows-B.
  862. * 0x2900 - 0x297F.
  863. * @since 1.5
  864. */
  865. public static final UnicodeBlock SUPPLEMENTAL_ARROWS_B
  866. = new UnicodeBlock(0x2900, 0x297F,
  867. "SUPPLEMENTAL_ARROWS_B",
  868. "Supplemental Arrows-B");
  869. /**
  870. * Miscellaneous Mathematical Symbols-B.
  871. * 0x2980 - 0x29FF.
  872. * @since 1.5
  873. */
  874. public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B
  875. = new UnicodeBlock(0x2980, 0x29FF,
  876. "MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B",
  877. "Miscellaneous Mathematical Symbols-B");
  878. /**
  879. * Supplemental Mathematical Operators.
  880. * 0x2A00 - 0x2AFF.
  881. * @since 1.5
  882. */
  883. public static final UnicodeBlock SUPPLEMENTAL_MATHEMATICAL_OPERATORS
  884. = new UnicodeBlock(0x2A00, 0x2AFF,
  885. "SUPPLEMENTAL_MATHEMATICAL_OPERATORS",
  886. "Supplemental Mathematical Operators");
  887. /**
  888. * Miscellaneous Symbols and Arrows.
  889. * 0x2B00 - 0x2BFF.
  890. * @since 1.5
  891. */
  892. public static final UnicodeBlock MISCELLANEOUS_SYMBOLS_AND_ARROWS
  893. = new UnicodeBlock(0x2B00, 0x2BFF,
  894. "MISCELLANEOUS_SYMBOLS_AND_ARROWS",
  895. "Miscellaneous Symbols and Arrows");
  896. /**
  897. * CJK Radicals Supplement.
  898. * 0x2E80 - 0x2EFF.
  899. * @since 1.4
  900. */
  901. public static final UnicodeBlock CJK_RADICALS_SUPPLEMENT
  902. = new UnicodeBlock(0x2E80, 0x2EFF,
  903. "CJK_RADICALS_SUPPLEMENT",
  904. "CJK Radicals Supplement");
  905. /**
  906. * Kangxi Radicals.
  907. * 0x2F00 - 0x2FDF.
  908. * @since 1.4
  909. */
  910. public static final UnicodeBlock KANGXI_RADICALS
  911. = new UnicodeBlock(0x2F00, 0x2FDF,
  912. "KANGXI_RADICALS",
  913. "Kangxi Radicals");
  914. /**
  915. * Ideographic Description Characters.
  916. * 0x2FF0 - 0x2FFF.
  917. * @since 1.4
  918. */
  919. public static final UnicodeBlock IDEOGRAPHIC_DESCRIPTION_CHARACTERS
  920. = new UnicodeBlock(0x2FF0, 0x2FFF,
  921. "IDEOGRAPHIC_DESCRIPTION_CHARACTERS",
  922. "Ideographic Description Characters");
  923. /**
  924. * CJK Symbols and Punctuation.
  925. * 0x3000 - 0x303F.
  926. */
  927. public static final UnicodeBlock CJK_SYMBOLS_AND_PUNCTUATION
  928. = new UnicodeBlock(0x3000, 0x303F,
  929. "CJK_SYMBOLS_AND_PUNCTUATION",
  930. "CJK Symbols and Punctuation");
  931. /**
  932. * Hiragana.
  933. * 0x3040 - 0x309F.
  934. */
  935. public static final UnicodeBlock HIRAGANA
  936. = new UnicodeBlock(0x3040, 0x309F,
  937. "HIRAGANA",
  938. "Hiragana");
  939. /**
  940. * Katakana.
  941. * 0x30A0 - 0x30FF.
  942. */
  943. public static final UnicodeBlock KATAKANA
  944. = new UnicodeBlock(0x30A0, 0x30FF,
  945. "KATAKANA",
  946. "Katakana");
  947. /**
  948. * Bopomofo.
  949. * 0x3100 - 0x312F.
  950. */
  951. public static final UnicodeBlock BOPOMOFO
  952. = new UnicodeBlock(0x3100, 0x312F,
  953. "BOPOMOFO",
  954. "Bopomofo");
  955. /**
  956. * Hangul Compatibility Jamo.
  957. * 0x3130 - 0x318F.
  958. */
  959. public static final UnicodeBlock HANGUL_COMPATIBILITY_JAMO
  960. = new UnicodeBlock(0x3130, 0x318F,
  961. "HANGUL_COMPATIBILITY_JAMO",
  962. "Hangul Compatibility Jamo");
  963. /**
  964. * Kanbun.
  965. * 0x3190 - 0x319F.
  966. */
  967. public static final UnicodeBlock KANBUN
  968. = new UnicodeBlock(0x3190, 0x319F,
  969. "KANBUN",
  970. "Kanbun");
  971. /**
  972. * Bopomofo Extended.
  973. * 0x31A0 - 0x31BF.
  974. * @since 1.4
  975. */
  976. public static final UnicodeBlock BOPOMOFO_EXTENDED
  977. = new UnicodeBlock(0x31A0, 0x31BF,
  978. "BOPOMOFO_EXTENDED",
  979. "Bopomofo Extended");
  980. /**
  981. * Katakana Phonetic Extensions.
  982. * 0x31F0 - 0x31FF.
  983. * @since 1.5
  984. */
  985. public static final UnicodeBlock KATAKANA_PHONETIC_EXTENSIONS
  986. = new UnicodeBlock(0x31F0, 0x31FF,
  987. "KATAKANA_PHONETIC_EXTENSIONS",
  988. "Katakana Phonetic Extensions");
  989. /**
  990. * Enclosed CJK Letters and Months.
  991. * 0x3200 - 0x32FF.
  992. */
  993. public static final UnicodeBlock ENCLOSED_CJK_LETTERS_AND_MONTHS
  994. = new UnicodeBlock(0x3200, 0x32FF,
  995. "ENCLOSED_CJK_LETTERS_AND_MONTHS",
  996. "Enclosed CJK Letters and Months");
  997. /**
  998. * CJK Compatibility.
  999. * 0x3300 - 0x33FF.
  1000. */
  1001. public static final UnicodeBlock CJK_COMPATIBILITY
  1002. = new UnicodeBlock(0x3300, 0x33FF,
  1003. "CJK_COMPATIBILITY",
  1004. "CJK Compatibility");
  1005. /**
  1006. * CJK Unified Ideographs Extension A.
  1007. * 0x3400 - 0x4DBF.
  1008. * @since 1.4
  1009. */
  1010. public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
  1011. = new UnicodeBlock(0x3400, 0x4DBF,
  1012. "CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A",
  1013. "CJK Unified Ideographs Extension A");
  1014. /**
  1015. * Yijing Hexagram Symbols.
  1016. * 0x4DC0 - 0x4DFF.
  1017. * @since 1.5
  1018. */
  1019. public static final UnicodeBlock YIJING_HEXAGRAM_SYMBOLS
  1020. = new UnicodeBlock(0x4DC0, 0x4DFF,
  1021. "YIJING_HEXAGRAM_SYMBOLS",
  1022. "Yijing Hexagram Symbols");
  1023. /**
  1024. * CJK Unified Ideographs.
  1025. * 0x4E00 - 0x9FFF.
  1026. */
  1027. public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS
  1028. = new UnicodeBlock(0x4E00, 0x9FFF,
  1029. "CJK_UNIFIED_IDEOGRAPHS",
  1030. "CJK Unified Ideographs");
  1031. /**
  1032. * Yi Syllables.
  1033. * 0xA000 - 0xA48F.
  1034. * @since 1.4
  1035. */
  1036. public static final UnicodeBlock YI_SYLLABLES
  1037. = new UnicodeBlock(0xA000, 0xA48F,
  1038. "YI_SYLLABLES",
  1039. "Yi Syllables");
  1040. /**
  1041. * Yi Radicals.
  1042. * 0xA490 - 0xA4CF.
  1043. * @since 1.4
  1044. */
  1045. public static final UnicodeBlock YI_RADICALS
  1046. = new UnicodeBlock(0xA490, 0xA4CF,
  1047. "YI_RADICALS",
  1048. "Yi Radicals");
  1049. /**
  1050. * Hangul Syllables.
  1051. * 0xAC00 - 0xD7AF.
  1052. */
  1053. public static final UnicodeBlock HANGUL_SYLLABLES
  1054. = new UnicodeBlock(0xAC00, 0xD7AF,
  1055. "HANGUL_SYLLABLES",
  1056. "Hangul Syllables");
  1057. /**
  1058. * High Surrogates.
  1059. * 0xD800 - 0xDB7F.
  1060. * @since 1.5
  1061. */
  1062. public static final UnicodeBlock HIGH_SURROGATES
  1063. = new UnicodeBlock(0xD800, 0xDB7F,
  1064. "HIGH_SURROGATES",
  1065. "High Surrogates");
  1066. /**
  1067. * High Private Use Surrogates.
  1068. * 0xDB80 - 0xDBFF.
  1069. * @since 1.5
  1070. */
  1071. public static final UnicodeBlock HIGH_PRIVATE_USE_SURROGATES
  1072. = new UnicodeBlock(0xDB80, 0xDBFF,
  1073. "HIGH_PRIVATE_USE_SURROGATES",
  1074. "High Private Use Surrogates");
  1075. /**
  1076. * Low Surrogates.
  1077. * 0xDC00 - 0xDFFF.
  1078. * @since 1.5
  1079. */
  1080. public static final UnicodeBlock LOW_SURROGATES
  1081. = new UnicodeBlock(0xDC00, 0xDFFF,
  1082. "LOW_SURROGATES",
  1083. "Low Surrogates");
  1084. /**
  1085. * Private Use Area.
  1086. * 0xE000 - 0xF8FF.
  1087. */
  1088. public static final UnicodeBlock PRIVATE_USE_AREA
  1089. = new UnicodeBlock(0xE000, 0xF8FF,
  1090. "PRIVATE_USE_AREA",
  1091. "Private Use Area");
  1092. /**
  1093. * CJK Compatibility Ideographs.
  1094. * 0xF900 - 0xFAFF.
  1095. */
  1096. public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS
  1097. = new UnicodeBlock(0xF900, 0xFAFF,
  1098. "CJK_COMPATIBILITY_IDEOGRAPHS",
  1099. "CJK Compatibility Ideographs");
  1100. /**
  1101. * Alphabetic Presentation Forms.
  1102. * 0xFB00 - 0xFB4F.
  1103. */
  1104. public static final UnicodeBlock ALPHABETIC_PRESENTATION_FORMS
  1105. = new UnicodeBlock(0xFB00, 0xFB4F,
  1106. "ALPHABETIC_PRESENTATION_FORMS",
  1107. "Alphabetic Presentation Forms");
  1108. /**
  1109. * Arabic Presentation Forms-A.
  1110. * 0xFB50 - 0xFDFF.
  1111. */
  1112. public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_A
  1113. = new UnicodeBlock(0xFB50, 0xFDFF,
  1114. "ARABIC_PRESENTATION_FORMS_A",
  1115. "Arabic Presentation Forms-A");
  1116. /**
  1117. * Variation Selectors.
  1118. * 0xFE00 - 0xFE0F.
  1119. * @since 1.5
  1120. */
  1121. public static final UnicodeBlock VARIATION_SELECTORS
  1122. = new UnicodeBlock(0xFE00, 0xFE0F,
  1123. "VARIATION_SELECTORS",
  1124. "Variation Selectors");
  1125. /**
  1126. * Combining Half Marks.
  1127. * 0xFE20 - 0xFE2F.
  1128. */
  1129. public static final UnicodeBlock COMBINING_HALF_MARKS
  1130. = new UnicodeBlock(0xFE20, 0xFE2F,
  1131. "COMBINING_HALF_MARKS",
  1132. "Combining Half Marks");
  1133. /**
  1134. * CJK Compatibility Forms.
  1135. * 0xFE30 - 0xFE4F.
  1136. */
  1137. public static final UnicodeBlock CJK_COMPATIBILITY_FORMS
  1138. = new UnicodeBlock(0xFE30, 0xFE4F,
  1139. "CJK_COMPATIBILITY_FORMS",
  1140. "CJK Compatibility Forms");
  1141. /**
  1142. * Small Form Variants.
  1143. * 0xFE50 - 0xFE6F.
  1144. */
  1145. public static final UnicodeBlock SMALL_FORM_VARIANTS
  1146. = new UnicodeBlock(0xFE50, 0xFE6F,
  1147. "SMALL_FORM_VARIANTS",
  1148. "Small Form Variants");
  1149. /**
  1150. * Arabic Presentation Forms-B.
  1151. * 0xFE70 - 0xFEFF.
  1152. */
  1153. public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_B
  1154. = new UnicodeBlock(0xFE70, 0xFEFF,
  1155. "ARABIC_PRESENTATION_FORMS_B",
  1156. "Arabic Presentation Forms-B");
  1157. /**
  1158. * Halfwidth and Fullwidth Forms.
  1159. * 0xFF00 - 0xFFEF.
  1160. */
  1161. public static final UnicodeBlock HALFWIDTH_AND_FULLWIDTH_FORMS
  1162. = new UnicodeBlock(0xFF00, 0xFFEF,
  1163. "HALFWIDTH_AND_FULLWIDTH_FORMS",
  1164. "Halfwidth and Fullwidth Forms");
  1165. /**
  1166. * Specials.
  1167. * 0xFFF0 - 0xFFFF.
  1168. */
  1169. public static final UnicodeBlock SPECIALS
  1170. = new UnicodeBlock(0xFFF0, 0xFFFF,
  1171. "SPECIALS",
  1172. "Specials");
  1173. /**
  1174. * Linear B Syllabary.
  1175. * 0x10000 - 0x1007F.
  1176. * @since 1.5
  1177. */
  1178. public static final UnicodeBlock LINEAR_B_SYLLABARY
  1179. = new UnicodeBlock(0x10000, 0x1007F,
  1180. "LINEAR_B_SYLLABARY",
  1181. "Linear B Syllabary");
  1182. /**
  1183. * Linear B Ideograms.
  1184. * 0x10080 - 0x100FF.
  1185. * @since 1.5
  1186. */
  1187. public static final UnicodeBlock LINEAR_B_IDEOGRAMS
  1188. = new UnicodeBlock(0x10080, 0x100FF,
  1189. "LINEAR_B_IDEOGRAMS",
  1190. "Linear B Ideograms");
  1191. /**
  1192. * Aegean Numbers.
  1193. * 0x10100 - 0x1013F.
  1194. * @since 1.5
  1195. */
  1196. public static final UnicodeBlock AEGEAN_NUMBERS
  1197. = new UnicodeBlock(0x10100, 0x1013F,
  1198. "AEGEAN_NUMBERS",
  1199. "Aegean Numbers");
  1200. /**
  1201. * Old Italic.
  1202. * 0x10300 - 0x1032F.
  1203. * @since 1.5
  1204. */
  1205. public static final UnicodeBlock OLD_ITALIC
  1206. = new UnicodeBlock(0x10300, 0x1032F,
  1207. "OLD_ITALIC",
  1208. "Old Italic");
  1209. /**
  1210. * Gothic.
  1211. * 0x10330 - 0x1034F.
  1212. * @since 1.5
  1213. */
  1214. public static final UnicodeBlock GOTHIC
  1215. = new UnicodeBlock(0x10330, 0x1034F,
  1216. "GOTHIC",
  1217. "Gothic");
  1218. /**
  1219. * Ugaritic.
  1220. * 0x10380 - 0x1039F.
  1221. * @since 1.5
  1222. */
  1223. public static final UnicodeBlock UGARITIC
  1224. = new UnicodeBlock(0x10380, 0x1039F,
  1225. "UGARITIC",
  1226. "Ugaritic");
  1227. /**
  1228. * Deseret.
  1229. * 0x10400 - 0x1044F.
  1230. * @since 1.5
  1231. */
  1232. public static final UnicodeBlock DESERET
  1233. = new UnicodeBlock(0x10400, 0x1044F,
  1234. "DESERET",
  1235. "Deseret");
  1236. /**
  1237. * Shavian.
  1238. * 0x10450 - 0x1047F.
  1239. * @since 1.5
  1240. */
  1241. public static final UnicodeBlock SHAVIAN
  1242. = new UnicodeBlock(0x10450, 0x1047F,
  1243. "SHAVIAN",
  1244. "Shavian");
  1245. /**
  1246. * Osmanya.
  1247. * 0x10480 - 0x104AF.
  1248. * @since 1.5
  1249. */
  1250. public static final UnicodeBlock OSMANYA
  1251. = new UnicodeBlock(0x10480, 0x104AF,
  1252. "OSMANYA",
  1253. "Osmanya");
  1254. /**
  1255. * Cypriot Syllabary.
  1256. * 0x10800 - 0x1083F.
  1257. * @since 1.5
  1258. */
  1259. public static final UnicodeBlock CYPRIOT_SYLLABARY
  1260. = new UnicodeBlock(0x10800, 0x1083F,
  1261. "CYPRIOT_SYLLABARY",
  1262. "Cypriot Syllabary");
  1263. /**
  1264. * Byzantine Musical Symbols.
  1265. * 0x1D000 - 0x1D0FF.
  1266. * @since 1.5
  1267. */
  1268. public static final UnicodeBlock BYZANTINE_MUSICAL_SYMBOLS
  1269. = new UnicodeBlock(0x1D000, 0x1D0FF,
  1270. "BYZANTINE_MUSICAL_SYMBOLS",
  1271. "Byzantine Musical Symbols");
  1272. /**
  1273. * Musical Symbols.
  1274. * 0x1D100 - 0x1D1FF.
  1275. * @since 1.5
  1276. */
  1277. public static final UnicodeBlock MUSICAL_SYMBOLS
  1278. = new UnicodeBlock(0x1D100, 0x1D1FF,
  1279. "MUSICAL_SYMBOLS",
  1280. "Musical Symbols");
  1281. /**
  1282. * Tai Xuan Jing Symbols.
  1283. * 0x1D300 - 0x1D35F.
  1284. * @since 1.5
  1285. */
  1286. public static final UnicodeBlock TAI_XUAN_JING_SYMBOLS
  1287. = new UnicodeBlock(0x1D300, 0x1D35F,
  1288. "TAI_XUAN_JING_SYMBOLS",
  1289. "Tai Xuan Jing Symbols");
  1290. /**
  1291. * Mathematical Alphanumeric Symbols.
  1292. * 0x1D400 - 0x1D7FF.
  1293. * @since 1.5
  1294. */
  1295. public static final UnicodeBlock MATHEMATICAL_ALPHANUMERIC_SYMBOLS
  1296. = new UnicodeBlock(0x1D400, 0x1D7FF,
  1297. "MATHEMATICAL_ALPHANUMERIC_SYMBOLS",
  1298. "Mathematical Alphanumeric Symbols");
  1299. /**
  1300. * CJK Unified Ideographs Extension B.
  1301. * 0x20000 - 0x2A6DF.
  1302. * @since 1.5
  1303. */
  1304. public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
  1305. = new UnicodeBlock(0x20000, 0x2A6DF,
  1306. "CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B",
  1307. "CJK Unified Ideographs Extension B");
  1308. /**
  1309. * CJK Compatibility Ideographs Supplement.
  1310. * 0x2F800 - 0x2FA1F.
  1311. * @since 1.5
  1312. */
  1313. public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT
  1314. = new UnicodeBlock(0x2F800, 0x2FA1F,
  1315. "CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT",
  1316. "CJK Compatibility Ideographs Supplement");
  1317. /**
  1318. * Tags.
  1319. * 0xE0000 - 0xE007F.
  1320. * @since 1.5
  1321. */
  1322. public static final UnicodeBlock TAGS
  1323. = new UnicodeBlock(0xE0000, 0xE007F,
  1324. "TAGS",
  1325. "Tags");
  1326. /**
  1327. * Variation Selectors Supplement.
  1328. * 0xE0100 - 0xE01EF.
  1329. * @since 1.5
  1330. */
  1331. public static final UnicodeBlock VARIATION_SELECTORS_SUPPLEMENT
  1332. = new UnicodeBlock(0xE0100, 0xE01EF,
  1333. "VARIATION_SELECTORS_SUPPLEMENT",
  1334. "Variation Selectors Supplement");
  1335. /**
  1336. * Supplementary Private Use Area-A.
  1337. * 0xF0000 - 0xFFFFF.
  1338. * @since 1.5
  1339. */
  1340. public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_A
  1341. = new UnicodeBlock(0xF0000, 0xFFFFF,
  1342. "SUPPLEMENTARY_PRIVATE_USE_AREA_A",
  1343. "Supplementary Private Use Area-A");
  1344. /**
  1345. * Supplementary Private Use Area-B.
  1346. * 0x100000 - 0x10FFFF.
  1347. * @since 1.5
  1348. */
  1349. public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_B
  1350. = new UnicodeBlock(0x100000, 0x10FFFF,
  1351. "SUPPLEMENTARY_PRIVATE_USE_AREA_B",
  1352. "Supplementary Private Use Area-B");
  1353. /**
  1354. * Surrogates Area.
  1355. * 'D800' - 'DFFF'.
  1356. * @deprecated As of 1.5, the three areas,
  1357. * <a href="#HIGH_SURROGATES">HIGH_SURROGATES</a>,
  1358. * <a href="#HIGH_PRIVATE_USE_SURROGATES">HIGH_PRIVATE_USE_SURROGATES</a>
  1359. * and <a href="#LOW_SURROGATES">LOW_SURROGATES</a>, as defined
  1360. * by the Unicode standard, should be used in preference to
  1361. * this. These are also returned from calls to <code>of(int)</code>
  1362. * and <code>of(char)</code>.
  1363. */
  1364. @Deprecated
  1365. public static final UnicodeBlock SURROGATES_AREA
  1366. = new UnicodeBlock(0xD800, 0xDFFF,
  1367. "SURROGATES_AREA",
  1368. "Surrogates Area");
  1369. /**
  1370. * The defined subsets.
  1371. */
  1372. private static final UnicodeBlock sets[] = {
  1373. BASIC_LATIN,
  1374. LATIN_1_SUPPLEMENT,
  1375. LATIN_EXTENDED_A,
  1376. LATIN_EXTENDED_B,
  1377. IPA_EXTENSIONS,
  1378. SPACING_MODIFIER_LETTERS,
  1379. COMBINING_DIACRITICAL_MARKS,
  1380. GREEK,
  1381. CYRILLIC,
  1382. CYRILLIC_SUPPLEMENTARY,
  1383. ARMENIAN,
  1384. HEBREW,
  1385. ARABIC,
  1386. SYRIAC,
  1387. THAANA,
  1388. DEVANAGARI,
  1389. BENGALI,
  1390. GURMUKHI,
  1391. GUJARATI,
  1392. ORIYA,
  1393. TAMIL,
  1394. TELUGU,
  1395. KANNADA,
  1396. MALAYALAM,
  1397. SINHALA,
  1398. THAI,
  1399. LAO,
  1400. TIBETAN,
  1401. MYANMAR,
  1402. GEORGIAN,
  1403. HANGUL_JAMO,
  1404. ETHIOPIC,
  1405. CHEROKEE,
  1406. UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS,
  1407. OGHAM,
  1408. RUNIC,
  1409. TAGALOG,
  1410. HANUNOO,
  1411. BUHID,
  1412. TAGBANWA,
  1413. KHMER,
  1414. MONGOLIAN,
  1415. LIMBU,
  1416. TAI_LE,
  1417. KHMER_SYMBOLS,
  1418. PHONETIC_EXTENSIONS,
  1419. LATIN_EXTENDED_ADDITIONAL,
  1420. GREEK_EXTENDED,
  1421. GENERAL_PUNCTUATION,
  1422. SUPERSCRIPTS_AND_SUBSCRIPTS,
  1423. CURRENCY_SYMBOLS,
  1424. COMBINING_MARKS_FOR_SYMBOLS,
  1425. LETTERLIKE_SYMBOLS,
  1426. NUMBER_FORMS,
  1427. ARROWS,
  1428. MATHEMATICAL_OPERATORS,
  1429. MISCELLANEOUS_TECHNICAL,
  1430. CONTROL_PICTURES,
  1431. OPTICAL_CHARACTER_RECOGNITION,
  1432. ENCLOSED_ALPHANUMERICS,
  1433. BOX_DRAWING,
  1434. BLOCK_ELEMENTS,
  1435. GEOMETRIC_SHAPES,
  1436. MISCELLANEOUS_SYMBOLS,
  1437. DINGBATS,
  1438. MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A,
  1439. SUPPLEMENTAL_ARROWS_A,
  1440. BRAILLE_PATTERNS,
  1441. SUPPLEMENTAL_ARROWS_B,
  1442. MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B,
  1443. SUPPLEMENTAL_MATHEMATICAL_OPERATORS,
  1444. MISCELLANEOUS_SYMBOLS_AND_ARROWS,
  1445. CJK_RADICALS_SUPPLEMENT,
  1446. KANGXI_RADICALS,
  1447. IDEOGRAPHIC_DESCRIPTION_CHARACTERS,
  1448. CJK_SYMBOLS_AND_PUNCTUATION,
  1449. HIRAGANA,
  1450. KATAKANA,
  1451. BOPOMOFO,
  1452. HANGUL_COMPATIBILITY_JAMO,
  1453. KANBUN,
  1454. BOPOMOFO_EXTENDED,
  1455. KATAKANA_PHONETIC_EXTENSIONS,
  1456. ENCLOSED_CJK_LETTERS_AND_MONTHS,
  1457. CJK_COMPATIBILITY,
  1458. CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A,
  1459. YIJING_HEXAGRAM_SYMBOLS,
  1460. CJK_UNIFIED_IDEOGRAPHS,
  1461. YI_SYLLABLES,
  1462. YI_RADICALS,
  1463. HANGUL_SYLLABLES,
  1464. HIGH_SURROGATES,
  1465. HIGH_PRIVATE_USE_SURROGATES,
  1466. LOW_SURROGATES,
  1467. PRIVATE_USE_AREA,
  1468. CJK_COMPATIBILITY_IDEOGRAPHS,
  1469. ALPHABETIC_PRESENTATION_FORMS,
  1470. ARABIC_PRESENTATION_FORMS_A,
  1471. VARIATION_SELECTORS,
  1472. COMBINING_HALF_MARKS,
  1473. CJK_COMPATIBILITY_FORMS,
  1474. SMALL_FORM_VARIANTS,
  1475. ARABIC_PRESENTATION_FORMS_B,
  1476. HALFWIDTH_AND_FULLWIDTH_FORMS,
  1477. SPECIALS,
  1478. LINEAR_B_SYLLABARY,
  1479. LINEAR_B_IDEOGRAMS,
  1480. AEGEAN_NUMBERS,
  1481. OLD_ITALIC,
  1482. GOTHIC,
  1483. UGARITIC,
  1484. DESERET,
  1485. SHAVIAN,
  1486. OSMANYA,
  1487. CYPRIOT_SYLLABARY,
  1488. BYZANTINE_MUSICAL_SYMBOLS,
  1489. MUSICAL_SYMBOLS,
  1490. TAI_XUAN_JING_SYMBOLS,
  1491. MATHEMATICAL_ALPHANUMERIC_SYMBOLS,
  1492. CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B,
  1493. CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT,
  1494. TAGS,
  1495. VARIATION_SELECTORS_SUPPLEMENT,
  1496. SUPPLEMENTARY_PRIVATE_USE_AREA_A,
  1497. SUPPLEMENTARY_PRIVATE_USE_AREA_B,
  1498. };
  1499. } // class UnicodeBlock
  1500. /**
  1501. * The immutable value of this Character.
  1502. *
  1503. * @serial the value of this Character
  1504. */
  1505. private final char value;
  1506. /**
  1507. * Compatible with JDK 1.0+.
  1508. */
  1509. private static final long serialVersionUID = 3786198910865385080L;
  1510. /**
  1511. * Smallest value allowed for radix arguments in Java. This value is 2.
  1512. *
  1513. * @see #digit(char, int)
  1514. * @see #forDigit(int, int)
  1515. * @see Integer#toString(int, int)
  1516. * @see Integer#valueOf(String)
  1517. */
  1518. public static final int MIN_RADIX = 2;
  1519. /**
  1520. * Largest value allowed for radix arguments in Java. This value is 36.
  1521. *
  1522. * @see #digit(char, int)
  1523. * @see #forDigit(int, int)
  1524. * @see Integer#toString(int, int)
  1525. * @see Integer#valueOf(String)
  1526. */
  1527. public static final int MAX_RADIX = 36;
  1528. /**
  1529. * The minimum value the char data type can hold.
  1530. * This value is <code>'\\u0000'</code>.
  1531. */
  1532. public static final char MIN_VALUE = '\u0000';
  1533. /**
  1534. * The maximum value the char data type can hold.
  1535. * This value is <code>'\\uFFFF'</code>.
  1536. */
  1537. public static final char MAX_VALUE = '\uFFFF';
  1538. /**
  1539. * The minimum Unicode 4.0 code point. This value is <code>0</code>.
  1540. * @since 1.5
  1541. */
  1542. public static final int MIN_CODE_POINT = 0;
  1543. /**
  1544. * The maximum Unicode 4.0 code point, which is greater than the range
  1545. * of the char data type.
  1546. * This value is <code>0x10FFFF</code>.
  1547. * @since 1.5
  1548. */
  1549. public static final int MAX_CODE_POINT = 0x10FFFF;
  1550. /**
  1551. * The minimum Unicode high surrogate code unit, or
  1552. * <emph>leading-surrogate</emph>, in the UTF-16 character encoding.
  1553. * This value is <code>'\uD800'</code>.
  1554. * @since 1.5
  1555. */
  1556. public static final char MIN_HIGH_SURROGATE = '\uD800';
  1557. /**
  1558. * The maximum Unicode high surrogate code unit, or
  1559. * <emph>leading-surrogate</emph>, in the UTF-16 character encoding.
  1560. * This value is <code>'\uDBFF'</code>.
  1561. * @since 1.5
  1562. */
  1563. public static final char MAX_HIGH_SURROGATE = '\uDBFF';
  1564. /**
  1565. * The minimum Unicode low surrogate code unit, or
  1566. * <emph>trailing-surrogate</emph>, in the UTF-16 character encoding.
  1567. * This value is <code>'\uDC00'</code>.
  1568. * @since 1.5
  1569. */
  1570. public static final char MIN_LOW_SURROGATE = '\uDC00';
  1571. /**
  1572. * The maximum Unicode low surrogate code unit, or
  1573. * <emph>trailing-surrogate</emph>, in the UTF-16 character encoding.
  1574. * This value is <code>'\uDFFF'</code>.
  1575. * @since 1.5
  1576. */
  1577. public static final char MAX_LOW_SURROGATE = '\uDFFF';
  1578. /**
  1579. * The minimum Unicode surrogate code unit in the UTF-16 character encoding.
  1580. * This value is <code>'\uD800'</code>.
  1581. * @since 1.5
  1582. */
  1583. public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE;
  1584. /**
  1585. * The maximum Unicode surrogate code unit in the UTF-16 character encoding.
  1586. * This value is <code>'\uDFFF'</code>.
  1587. * @since 1.5
  1588. */
  1589. public static final char MAX_SURROGATE = MAX_LOW_SURROGATE;
  1590. /**
  1591. * The lowest possible supplementary Unicode code point (the first code
  1592. * point outside the basic multilingual plane (BMP)).
  1593. * This value is <code>0x10000</code>.
  1594. */
  1595. public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x10000;
  1596. /**
  1597. * Class object representing the primitive char data type.
  1598. *
  1599. * @since 1.1
  1600. */
  1601. public static final Class<Character> TYPE = (Class<Character>) VMClassLoader.getPrimitiveClass('C');
  1602. /**
  1603. * The number of bits needed to represent a <code>char</code>.
  1604. * @since 1.5
  1605. */
  1606. public static final int SIZE = 16;
  1607. // This caches some Character values, and is used by boxing
  1608. // conversions via valueOf(). We must cache at least 0..127;
  1609. // this constant controls how much we actually cache.
  1610. private static final int MAX_CACHE = 127;
  1611. private static Character[] charCache = new Character[MAX_CACHE + 1];
  1612. /**
  1613. * Lu = Letter, Uppercase (Informative).
  1614. *
  1615. * @since 1.1
  1616. */
  1617. public static final byte UPPERCASE_LETTER = 1;
  1618. /**
  1619. * Ll = Letter, Lowercase (Informative).
  1620. *
  1621. * @since 1.1
  1622. */
  1623. public static final byte LOWERCASE_LETTER = 2;
  1624. /**
  1625. * Lt = Letter, Titlecase (Informative).
  1626. *
  1627. * @since 1.1
  1628. */
  1629. public static final byte TITLECASE_LETTER = 3;
  1630. /**
  1631. * Mn = Mark, Non-Spacing (Normative).
  1632. *
  1633. * @since 1.1
  1634. */
  1635. public static final byte NON_SPACING_MARK = 6;
  1636. /**
  1637. * Mc = Mark, Spacing Combining (Normative).
  1638. *
  1639. * @since 1.1
  1640. */
  1641. public static final byte COMBINING_SPACING_MARK = 8;
  1642. /**
  1643. * Me = Mark, Enclosing (Normative).
  1644. *
  1645. * @since 1.1
  1646. */
  1647. public static final byte ENCLOSING_MARK = 7;
  1648. /**
  1649. * Nd = Number, Decimal Digit (Normative).
  1650. *
  1651. * @since 1.1
  1652. */
  1653. public static final byte DECIMAL_DIGIT_NUMBER = 9;
  1654. /**
  1655. * Nl = Number, Letter (Normative).
  1656. *
  1657. * @since 1.1
  1658. */
  1659. public static final byte LETTER_NUMBER = 10;
  1660. /**
  1661. * No = Number, Other (Normative).
  1662. *
  1663. * @since 1.1
  1664. */
  1665. public static final byte OTHER_NUMBER = 11;
  1666. /**
  1667. * Zs = Separator, Space (Normative).
  1668. *
  1669. * @since 1.1
  1670. */
  1671. public static final byte SPACE_SEPARATOR = 12;
  1672. /**
  1673. * Zl = Separator, Line (Normative).
  1674. *
  1675. * @since 1.1
  1676. */
  1677. public static final byte LINE_SEPARATOR = 13;
  1678. /**
  1679. * Zp = Separator, Paragraph (Normative).
  1680. *
  1681. * @since 1.1
  1682. */
  1683. public static final byte PARAGRAPH_SEPARATOR = 14;
  1684. /**
  1685. * Cc = Other, Control (Normative).
  1686. *
  1687. * @since 1.1
  1688. */
  1689. public static final byte CONTROL = 15;
  1690. /**
  1691. * Cf = Other, Format (Normative).
  1692. *
  1693. * @since 1.1
  1694. */
  1695. public static final byte FORMAT = 16;
  1696. /**
  1697. * Cs = Other, Surrogate (Normative).
  1698. *
  1699. * @since 1.1
  1700. */
  1701. public static final byte SURROGATE = 19;
  1702. /**
  1703. * Co = Other, Private Use (Normative).
  1704. *
  1705. * @since 1.1
  1706. */
  1707. public static final byte PRIVATE_USE = 18;
  1708. /**
  1709. * Cn = Other, Not Assigned (Normative).
  1710. *
  1711. * @since 1.1
  1712. */
  1713. public static final byte UNASSIGNED = 0;
  1714. /**
  1715. * Lm = Letter, Modifier (Informative).
  1716. *
  1717. * @since 1.1
  1718. */
  1719. public static final byte MODIFIER_LETTER = 4;
  1720. /**
  1721. * Lo = Letter, Other (Informative).
  1722. *
  1723. * @since 1.1
  1724. */
  1725. public static final byte OTHER_LETTER = 5;
  1726. /**
  1727. * Pc = Punctuation, Connector (Informative).
  1728. *
  1729. * @since 1.1
  1730. */
  1731. public static final byte CONNECTOR_PUNCTUATION = 23;
  1732. /**
  1733. * Pd = Punctuation, Dash (Informative).
  1734. *
  1735. * @since 1.1
  1736. */
  1737. public static final byte DASH_PUNCTUATION = 20;
  1738. /**
  1739. * Ps = Punctuation, Open (Informative).
  1740. *
  1741. * @since 1.1
  1742. */
  1743. public static final byte START_PUNCTUATION = 21;
  1744. /**
  1745. * Pe = Punctuation, Close (Informative).
  1746. *
  1747. * @since 1.1
  1748. */
  1749. public static final byte END_PUNCTUATION = 22;
  1750. /**
  1751. * Pi = Punctuation, Initial Quote (Informative).
  1752. *
  1753. * @since 1.4
  1754. */
  1755. public static final byte INITIAL_QUOTE_PUNCTUATION = 29;
  1756. /**
  1757. * Pf = Punctuation, Final Quote (Informative).
  1758. *
  1759. * @since 1.4
  1760. */
  1761. public static final byte FINAL_QUOTE_PUNCTUATION = 30;
  1762. /**
  1763. * Po = Punctuation, Other (Informative).
  1764. *
  1765. * @since 1.1
  1766. */
  1767. public static final byte OTHER_PUNCTUATION = 24;
  1768. /**
  1769. * Sm = Symbol, Math (Informative).
  1770. *
  1771. * @since 1.1
  1772. */
  1773. public static final byte MATH_SYMBOL = 25;
  1774. /**
  1775. * Sc = Symbol, Currency (Informative).
  1776. *
  1777. * @since 1.1
  1778. */
  1779. public static final byte CURRENCY_SYMBOL = 26;
  1780. /**
  1781. * Sk = Symbol, Modifier (Informative).
  1782. *
  1783. * @since 1.1
  1784. */
  1785. public static final byte MODIFIER_SYMBOL = 27;
  1786. /**
  1787. * So = Symbol, Other (Informative).
  1788. *
  1789. * @since 1.1
  1790. */
  1791. public static final byte OTHER_SYMBOL = 28;
  1792. /**
  1793. * Undefined bidirectional character type. Undefined char values have
  1794. * undefined directionality in the Unicode specification.
  1795. *
  1796. * @since 1.4
  1797. */
  1798. public static final byte DIRECTIONALITY_UNDEFINED = -1;
  1799. /**
  1800. * Strong bidirectional character type "L".
  1801. *
  1802. * @since 1.4
  1803. */
  1804. public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0;
  1805. /**
  1806. * Strong bidirectional character type "R".
  1807. *
  1808. * @since 1.4
  1809. */
  1810. public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1;
  1811. /**
  1812. * Strong bidirectional character type "AL".
  1813. *
  1814. * @since 1.4
  1815. */
  1816. public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2;
  1817. /**
  1818. * Weak bidirectional character type "EN".
  1819. *
  1820. * @since 1.4
  1821. */
  1822. public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3;
  1823. /**
  1824. * Weak bidirectional character type "ES".
  1825. *
  1826. * @since 1.4
  1827. */
  1828. public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4;
  1829. /**
  1830. * Weak bidirectional character type "ET".
  1831. *
  1832. * @since 1.4
  1833. */
  1834. public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5;
  1835. /**
  1836. * Weak bidirectional character type "AN".
  1837. *
  1838. * @since 1.4
  1839. */
  1840. public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6;
  1841. /**
  1842. * Weak bidirectional character type "CS".
  1843. *
  1844. * @since 1.4
  1845. */
  1846. public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7;
  1847. /**
  1848. * Weak bidirectional character type "NSM".
  1849. *
  1850. * @since 1.4
  1851. */
  1852. public static final byte DIRECTIONALITY_NONSPACING_MARK = 8;
  1853. /**
  1854. * Weak bidirectional character type "BN".
  1855. *
  1856. * @since 1.4
  1857. */
  1858. public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9;
  1859. /**
  1860. * Neutral bidirectional character type "B".
  1861. *
  1862. * @since 1.4
  1863. */
  1864. public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10;
  1865. /**
  1866. * Neutral bidirectional character type "S".
  1867. *
  1868. * @since 1.4
  1869. */
  1870. public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11;
  1871. /**
  1872. * Strong bidirectional character type "WS".
  1873. *
  1874. * @since 1.4
  1875. */
  1876. public static final byte DIRECTIONALITY_WHITESPACE = 12;
  1877. /**
  1878. * Neutral bidirectional character type "ON".
  1879. *
  1880. * @since 1.4
  1881. */
  1882. public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13;
  1883. /**
  1884. * Strong bidirectional character type "LRE".
  1885. *
  1886. * @since 1.4
  1887. */
  1888. public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14;
  1889. /**
  1890. * Strong bidirectional character type "LRO".
  1891. *
  1892. * @since 1.4
  1893. */
  1894. public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15;
  1895. /**
  1896. * Strong bidirectional character type "RLE".
  1897. *
  1898. * @since 1.4
  1899. */
  1900. public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16;
  1901. /**
  1902. * Strong bidirectional character type "RLO".
  1903. *
  1904. * @since 1.4
  1905. */
  1906. public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17;
  1907. /**
  1908. * Weak bidirectional character type "PDF".
  1909. *
  1910. * @since 1.4
  1911. */
  1912. public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18;
  1913. /**
  1914. * Mask for grabbing the type out of the result of readChar.
  1915. * @see #readChar(char)
  1916. */
  1917. private static final int TYPE_MASK = 0x1F;
  1918. /**
  1919. * Mask for grabbing the non-breaking space flag out of the result of
  1920. * readChar.
  1921. * @see #readChar(char)
  1922. */
  1923. private static final int NO_BREAK_MASK = 0x20;
  1924. /**
  1925. * Mask for grabbing the mirrored directionality flag out of the result
  1926. * of readChar.
  1927. * @see #readChar(char)
  1928. */
  1929. private static final int MIRROR_MASK = 0x40;
  1930. /**
  1931. * Grabs an attribute offset from the Unicode attribute database. The lower
  1932. * 5 bits are the character type, the next 2 bits are flags, and the top
  1933. * 9 bits are the offset into the attribute tables. Note that the top 9
  1934. * bits are meaningless in this context; they are useful only in the native
  1935. * code.
  1936. *
  1937. * @param ch the character to look up
  1938. * @return the character's attribute offset and type
  1939. * @see #TYPE_MASK
  1940. * @see #NO_BREAK_MASK
  1941. * @see #MIRROR_MASK
  1942. */
  1943. private static native char readChar(char ch);
  1944. /**
  1945. * Grabs an attribute offset from the Unicode attribute database. The lower
  1946. * 5 bits are the character type, the next 2 bits are flags, and the top
  1947. * 9 bits are the offset into the attribute tables. Note that the top 9
  1948. * bits are meaningless in this context; they are useful only in the native
  1949. * code.
  1950. *
  1951. * @param codePoint the character to look up
  1952. * @return the character's attribute offset and type
  1953. * @see #TYPE_MASK
  1954. * @see #NO_BREAK_MASK
  1955. * @see #MIRROR_MASK
  1956. */
  1957. private static native char readCodePoint(int codePoint);
  1958. /**
  1959. * Wraps up a character.
  1960. *
  1961. * @param value the character to wrap
  1962. */
  1963. public Character(char value)
  1964. {
  1965. this.value = value;
  1966. }
  1967. /**
  1968. * Returns the character which has been wrapped by this class.
  1969. *
  1970. * @return the character wrapped
  1971. */
  1972. public char charValue()
  1973. {
  1974. return value;
  1975. }
  1976. /**
  1977. * Returns the numerical value (unsigned) of the wrapped character.
  1978. * Range of returned values: 0x0000-0xFFFF.
  1979. *
  1980. * @return the value of the wrapped character
  1981. */
  1982. public int hashCode()
  1983. {
  1984. return value;
  1985. }
  1986. /**
  1987. * Determines if an object is equal to this object. This is only true for
  1988. * another Character object wrapping the same value.
  1989. *
  1990. * @param o object to compare
  1991. * @return true if o is a Character with the same value
  1992. */
  1993. public boolean equals(Object o)
  1994. {
  1995. return o instanceof Character && value == ((Character) o).value;
  1996. }
  1997. /**
  1998. * Converts the wrapped character into a String.
  1999. *
  2000. * @return a String containing one character -- the wrapped character
  2001. * of this instance
  2002. */
  2003. public String toString()
  2004. {
  2005. // This assumes that String.valueOf(char) can create a single-character
  2006. // String more efficiently than through the public API.
  2007. return String.valueOf(value);
  2008. }
  2009. /**
  2010. * Returns a String of length 1 representing the specified character.
  2011. *
  2012. * @param ch the character to convert
  2013. * @return a String containing the character
  2014. * @since 1.4
  2015. */
  2016. public static String toString(char ch)
  2017. {
  2018. // This assumes that String.valueOf(char) can create a single-character
  2019. // String more efficiently than through the public API.
  2020. return String.valueOf(ch);
  2021. }
  2022. /**
  2023. * Determines if a character is a Unicode lowercase letter. For example,
  2024. * <code>'a'</code> is lowercase.
  2025. * <br>
  2026. * lowercase = [Ll]
  2027. *
  2028. * @param ch character to test
  2029. * @return true if ch is a Unicode lowercase letter, else false
  2030. * @see #isUpperCase(char)
  2031. * @see #isTitleCase(char)
  2032. * @see #toLowerCase(char)
  2033. * @see #getType(char)
  2034. */
  2035. public static boolean isLowerCase(char ch)
  2036. {
  2037. return getType(ch) == LOWERCASE_LETTER;
  2038. }
  2039. /**
  2040. * Determines if a character is a Unicode lowercase letter. For example,
  2041. * <code>'a'</code> is lowercase. Unlike isLowerCase(char), this method
  2042. * supports supplementary Unicode code points.
  2043. * <br>
  2044. * lowercase = [Ll]
  2045. *
  2046. * @param codePoint character to test
  2047. * @return true if codePoint is a Unicode lowercase letter, else false
  2048. * @see #isUpperCase(int)
  2049. * @see #isTitleCase(int)
  2050. * @see #toLowerCase(int)
  2051. * @see #getType(int)
  2052. * @since 1.5
  2053. */
  2054. public static boolean isLowerCase(int codePoint)
  2055. {
  2056. return getType(codePoint) == LOWERCASE_LETTER;
  2057. }
  2058. /**
  2059. * Determines if a character is a Unicode uppercase letter. For example,
  2060. * <code>'A'</code> is uppercase.
  2061. * <br>
  2062. * uppercase = [Lu]
  2063. *
  2064. * @param ch character to test
  2065. * @return true if ch is a Unicode uppercase letter, else false
  2066. * @see #isLowerCase(char)
  2067. * @see #isTitleCase(char)
  2068. * @see #toUpperCase(char)
  2069. * @see #getType(char)
  2070. */
  2071. public static boolean isUpperCase(char ch)
  2072. {
  2073. return getType(ch) == UPPERCASE_LETTER;
  2074. }
  2075. /**
  2076. * Determines if a character is a Unicode uppercase letter. For example,
  2077. * <code>'A'</code> is uppercase. Unlike isUpperCase(char), this method
  2078. * supports supplementary Unicode code points.
  2079. * <br>
  2080. * uppercase = [Lu]
  2081. *
  2082. * @param codePoint character to test
  2083. * @return true if codePoint is a Unicode uppercase letter, else false
  2084. * @see #isLowerCase(int)
  2085. * @see #isTitleCase(int)
  2086. * @see #toUpperCase(int)
  2087. * @see #getType(int)
  2088. * @since 1.5
  2089. */
  2090. public static boolean isUpperCase(int codePoint)
  2091. {
  2092. return getType(codePoint) == UPPERCASE_LETTER;
  2093. }
  2094. /**
  2095. * Determines if a character is a Unicode titlecase letter. For example,
  2096. * the character "Lj" (Latin capital L with small letter j) is titlecase.
  2097. * <br>
  2098. * titlecase = [Lt]
  2099. *
  2100. * @param ch character to test
  2101. * @return true if ch is a Unicode titlecase letter, else false
  2102. * @see #isLowerCase(char)
  2103. * @see #isUpperCase(char)
  2104. * @see #toTitleCase(char)
  2105. * @see #getType(char)
  2106. */
  2107. public static boolean isTitleCase(char ch)
  2108. {
  2109. return getType(ch) == TITLECASE_LETTER;
  2110. }
  2111. /**
  2112. * Determines if a character is a Unicode titlecase letter. For example,
  2113. * the character "Lj" (Latin capital L with small letter j) is titlecase.
  2114. * Unlike isTitleCase(char), this method supports supplementary Unicode
  2115. * code points.
  2116. * <br>
  2117. * titlecase = [Lt]
  2118. *
  2119. * @param codePoint character to test
  2120. * @return true if codePoint is a Unicode titlecase letter, else false
  2121. * @see #isLowerCase(int)
  2122. * @see #isUpperCase(int)
  2123. * @see #toTitleCase(int)
  2124. * @see #getType(int)
  2125. * @since 1.5
  2126. */
  2127. public static boolean isTitleCase(int codePoint)
  2128. {
  2129. return getType(codePoint) == TITLECASE_LETTER;
  2130. }
  2131. /**
  2132. * Determines if a character is a Unicode decimal digit. For example,
  2133. * <code>'0'</code> is a digit.
  2134. * <br>
  2135. * Unicode decimal digit = [Nd]
  2136. *
  2137. * @param ch character to test
  2138. * @return true if ch is a Unicode decimal digit, else false
  2139. * @see #digit(char, int)
  2140. * @see #forDigit(int, int)
  2141. * @see #getType(char)
  2142. */
  2143. public static boolean isDigit(char ch)
  2144. {
  2145. return getType(ch) == DECIMAL_DIGIT_NUMBER;
  2146. }
  2147. /**
  2148. * Determines if a character is a Unicode decimal digit. For example,
  2149. * <code>'0'</code> is a digit. Unlike isDigit(char), this method
  2150. * supports supplementary Unicode code points.
  2151. * <br>
  2152. * Unicode decimal digit = [Nd]
  2153. *
  2154. * @param codePoint character to test
  2155. * @return true if ccodePoint is a Unicode decimal digit, else false
  2156. * @see #digit(int, int)
  2157. * @see #forDigit(int, int)
  2158. * @see #getType(int)
  2159. * @since 1.5
  2160. */
  2161. public static boolean isDigit(int codePoint)
  2162. {
  2163. return getType(codePoint) == DECIMAL_DIGIT_NUMBER;
  2164. }
  2165. /**
  2166. * Determines if a character is part of the Unicode Standard. This is an
  2167. * evolving standard, but covers every character in the data file.
  2168. * <br>
  2169. * defined = not [Cn]
  2170. *
  2171. * @param ch character to test
  2172. * @return true if ch is a Unicode character, else false
  2173. * @see #isDigit(char)
  2174. * @see #isLetter(char)
  2175. * @see #isLetterOrDigit(char)
  2176. * @see #isLowerCase(char)
  2177. * @see #isTitleCase(char)
  2178. * @see #isUpperCase(char)
  2179. */
  2180. public static boolean isDefined(char ch)
  2181. {
  2182. return getType(ch) != UNASSIGNED;
  2183. }
  2184. /**
  2185. * Determines if a character is part of the Unicode Standard. This is an
  2186. * evolving standard, but covers every character in the data file. Unlike
  2187. * isDefined(char), this method supports supplementary Unicode code points.
  2188. * <br>
  2189. * defined = not [Cn]
  2190. *
  2191. * @param codePoint character to test
  2192. * @return true if codePoint is a Unicode character, else false
  2193. * @see #isDigit(int)
  2194. * @see #isLetter(int)
  2195. * @see #isLetterOrDigit(int)
  2196. * @see #isLowerCase(int)
  2197. * @see #isTitleCase(int)
  2198. * @see #isUpperCase(int)
  2199. * @since 1.5
  2200. */
  2201. public static boolean isDefined(int codePoint)
  2202. {
  2203. return getType(codePoint) != UNASSIGNED;
  2204. }
  2205. /**
  2206. * Determines if a character is a Unicode letter. Not all letters have case,
  2207. * so this may return true when isLowerCase and isUpperCase return false.
  2208. * <br>
  2209. * letter = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]
  2210. *
  2211. * @param ch character to test
  2212. * @return true if ch is a Unicode letter, else false
  2213. * @see #isDigit(char)
  2214. * @see #isJavaIdentifierStart(char)
  2215. * @see #isJavaLetter(char)
  2216. * @see #isJavaLetterOrDigit(char)
  2217. * @see #isLetterOrDigit(char)
  2218. * @see #isLowerCase(char)
  2219. * @see #isTitleCase(char)
  2220. * @see #isUnicodeIdentifierStart(char)
  2221. * @see #isUpperCase(char)
  2222. */
  2223. public static boolean isLetter(char ch)
  2224. {
  2225. return ((1 << getType(ch))
  2226. & ((1 << UPPERCASE_LETTER)
  2227. | (1 << LOWERCASE_LETTER)
  2228. | (1 << TITLECASE_LETTER)
  2229. | (1 << MODIFIER_LETTER)
  2230. | (1 << OTHER_LETTER))) != 0;
  2231. }
  2232. /**
  2233. * Determines if a character is a Unicode letter. Not all letters have case,
  2234. * so this may return true when isLowerCase and isUpperCase return false.
  2235. * Unlike isLetter(char), this method supports supplementary Unicode code
  2236. * points.
  2237. * <br>
  2238. * letter = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]
  2239. *
  2240. * @param codePoint character to test
  2241. * @return true if codePoint is a Unicode letter, else false
  2242. * @see #isDigit(int)
  2243. * @see #isJavaIdentifierStart(int)
  2244. * @see #isJavaLetter(int)
  2245. * @see #isJavaLetterOrDigit(int)
  2246. * @see #isLetterOrDigit(int)
  2247. * @see #isLowerCase(int)
  2248. * @see #isTitleCase(int)
  2249. * @see #isUnicodeIdentifierStart(int)
  2250. * @see #isUpperCase(int)
  2251. * @since 1.5
  2252. */
  2253. public static boolean isLetter(int codePoint)
  2254. {
  2255. return ((1 << getType(codePoint))
  2256. & ((1 << UPPERCASE_LETTER)
  2257. | (1 << LOWERCASE_LETTER)
  2258. | (1 << TITLECASE_LETTER)
  2259. | (1 << MODIFIER_LETTER)
  2260. | (1 << OTHER_LETTER))) != 0;
  2261. }
  2262. /**
  2263. * Returns the index into the given CharSequence that is offset
  2264. * <code>codePointOffset</code> code points from <code>index</code>.
  2265. * @param seq the CharSequence
  2266. * @param index the start position in the CharSequence
  2267. * @param codePointOffset the number of code points offset from the start
  2268. * position
  2269. * @return the index into the CharSequence that is codePointOffset code
  2270. * points offset from index
  2271. *
  2272. * @throws NullPointerException if seq is null
  2273. * @throws IndexOutOfBoundsException if index is negative or greater than the
  2274. * length of the sequence.
  2275. * @throws IndexOutOfBoundsException if codePointOffset is positive and the
  2276. * subsequence from index to the end of seq has fewer than codePointOffset
  2277. * code points
  2278. * @throws IndexOutOfBoundsException if codePointOffset is negative and the
  2279. * subsequence from the start of seq to index has fewer than
  2280. * (-codePointOffset) code points
  2281. * @since 1.5
  2282. */
  2283. public static int offsetByCodePoints(CharSequence seq,
  2284. int index,
  2285. int codePointOffset)
  2286. {
  2287. int len = seq.length();
  2288. if (index < 0 || index > len)
  2289. throw new IndexOutOfBoundsException();
  2290. int numToGo = codePointOffset;
  2291. int offset = index;
  2292. int adjust = 1;
  2293. if (numToGo >= 0)
  2294. {
  2295. for (; numToGo > 0; offset++)
  2296. {
  2297. numToGo--;
  2298. if (Character.isHighSurrogate(seq.charAt(offset))
  2299. && (offset + 1) < len
  2300. && Character.isLowSurrogate(seq.charAt(offset + 1)))
  2301. offset++;
  2302. }
  2303. return offset;
  2304. }
  2305. else
  2306. {
  2307. numToGo *= -1;
  2308. for (; numToGo > 0;)
  2309. {
  2310. numToGo--;
  2311. offset--;
  2312. if (Character.isLowSurrogate(seq.charAt(offset))
  2313. && (offset - 1) >= 0
  2314. && Character.isHighSurrogate(seq.charAt(offset - 1)))
  2315. offset--;
  2316. }
  2317. return offset;
  2318. }
  2319. }
  2320. /**
  2321. * Returns the index into the given char subarray that is offset
  2322. * <code>codePointOffset</code> code points from <code>index</code>.
  2323. * @param a the char array
  2324. * @param start the start index of the subarray
  2325. * @param count the length of the subarray
  2326. * @param index the index to be offset
  2327. * @param codePointOffset the number of code points offset from <code>index
  2328. * </code>
  2329. * @return the index into the char array
  2330. *
  2331. * @throws NullPointerException if a is null
  2332. * @throws IndexOutOfBoundsException if start or count is negative or if
  2333. * start + count is greater than the length of the array
  2334. * @throws IndexOutOfBoundsException if index is less than start or larger
  2335. * than start + count
  2336. * @throws IndexOutOfBoundsException if codePointOffset is positive and the
  2337. * subarray from index to start + count - 1 has fewer than codePointOffset
  2338. * code points.
  2339. * @throws IndexOutOfBoundsException if codePointOffset is negative and the
  2340. * subarray from start to index - 1 has fewer than (-codePointOffset) code
  2341. * points
  2342. * @since 1.5
  2343. */
  2344. public static int offsetByCodePoints(char[] a,
  2345. int start,
  2346. int count,
  2347. int index,
  2348. int codePointOffset)
  2349. {
  2350. int len = a.length;
  2351. int end = start + count;
  2352. if (start < 0 || count < 0 || end > len || index < start || index > end)
  2353. throw new IndexOutOfBoundsException();
  2354. int numToGo = codePointOffset;
  2355. int offset = index;
  2356. int adjust = 1;
  2357. if (numToGo >= 0)
  2358. {
  2359. for (; numToGo > 0; offset++)
  2360. {
  2361. numToGo--;
  2362. if (Character.isHighSurrogate(a[offset])
  2363. && (offset + 1) < len
  2364. && Character.isLowSurrogate(a[offset + 1]))
  2365. offset++;
  2366. }
  2367. return offset;
  2368. }
  2369. else
  2370. {
  2371. numToGo *= -1;
  2372. for (; numToGo > 0;)
  2373. {
  2374. numToGo--;
  2375. offset--;
  2376. if (Character.isLowSurrogate(a[offset])
  2377. && (offset - 1) >= 0
  2378. && Character.isHighSurrogate(a[offset - 1]))
  2379. offset--;
  2380. if (offset < start)
  2381. throw new IndexOutOfBoundsException();
  2382. }
  2383. return offset;
  2384. }
  2385. }
  2386. /**
  2387. * Returns the number of Unicode code points in the specified range of the
  2388. * given CharSequence. The first char in the range is at position
  2389. * beginIndex and the last one is at position endIndex - 1. Paired
  2390. * surrogates (supplementary characters are represented by a pair of chars -
  2391. * one from the high surrogates and one from the low surrogates)
  2392. * count as just one code point.
  2393. * @param seq the CharSequence to inspect
  2394. * @param beginIndex the beginning of the range
  2395. * @param endIndex the end of the range
  2396. * @return the number of Unicode code points in the given range of the
  2397. * sequence
  2398. * @throws NullPointerException if seq is null
  2399. * @throws IndexOutOfBoundsException if beginIndex is negative, endIndex is
  2400. * larger than the length of seq, or if beginIndex is greater than endIndex.
  2401. * @since 1.5
  2402. */
  2403. public static int codePointCount(CharSequence seq, int beginIndex,
  2404. int endIndex)
  2405. {
  2406. int len = seq.length();
  2407. if (beginIndex < 0 || endIndex > len || beginIndex > endIndex)
  2408. throw new IndexOutOfBoundsException();
  2409. int count = 0;
  2410. for (int i = beginIndex; i < endIndex; i++)
  2411. {
  2412. count++;
  2413. // If there is a pairing, count it only once.
  2414. if (isHighSurrogate(seq.charAt(i)) && (i + 1) < endIndex
  2415. && isLowSurrogate(seq.charAt(i + 1)))
  2416. i ++;
  2417. }
  2418. return count;
  2419. }
  2420. /**
  2421. * Returns the number of Unicode code points in the specified range of the
  2422. * given char array. The first char in the range is at position
  2423. * offset and the length of the range is count. Paired surrogates
  2424. * (supplementary characters are represented by a pair of chars -
  2425. * one from the high surrogates and one from the low surrogates)
  2426. * count as just one code point.
  2427. * @param a the char array to inspect
  2428. * @param offset the beginning of the range
  2429. * @param count the length of the range
  2430. * @return the number of Unicode code points in the given range of the
  2431. * array
  2432. * @throws NullPointerException if a is null
  2433. * @throws IndexOutOfBoundsException if offset or count is negative or if
  2434. * offset + countendIndex is larger than the length of a.
  2435. * @since 1.5
  2436. */
  2437. public static int codePointCount(char[] a, int offset,
  2438. int count)
  2439. {
  2440. int len = a.length;
  2441. int end = offset + count;
  2442. if (offset < 0 || count < 0 || end > len)
  2443. throw new IndexOutOfBoundsException();
  2444. int counter = 0;
  2445. for (int i = offset; i < end; i++)
  2446. {
  2447. counter++;
  2448. // If there is a pairing, count it only once.
  2449. if (isHighSurrogate(a[i]) && (i + 1) < end
  2450. && isLowSurrogate(a[i + 1]))
  2451. i ++;
  2452. }
  2453. return counter;
  2454. }
  2455. /**
  2456. * Determines if a character is a Unicode letter or a Unicode digit. This
  2457. * is the combination of isLetter and isDigit.
  2458. * <br>
  2459. * letter or digit = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nd]
  2460. *
  2461. * @param ch character to test
  2462. * @return true if ch is a Unicode letter or a Unicode digit, else false
  2463. * @see #isDigit(char)
  2464. * @see #isJavaIdentifierPart(char)
  2465. * @see #isJavaLetter(char)
  2466. * @see #isJavaLetterOrDigit(char)
  2467. * @see #isLetter(char)
  2468. * @see #isUnicodeIdentifierPart(char)
  2469. */
  2470. public static boolean isLetterOrDigit(char ch)
  2471. {
  2472. return ((1 << getType(ch))
  2473. & ((1 << UPPERCASE_LETTER)
  2474. | (1 << LOWERCASE_LETTER)
  2475. | (1 << TITLECASE_LETTER)
  2476. | (1 << MODIFIER_LETTER)
  2477. | (1 << OTHER_LETTER)
  2478. | (1 << DECIMAL_DIGIT_NUMBER))) != 0;
  2479. }
  2480. /**
  2481. * Determines if a character is a Unicode letter or a Unicode digit. This
  2482. * is the combination of isLetter and isDigit. Unlike isLetterOrDigit(char),
  2483. * this method supports supplementary Unicode code points.
  2484. * <br>
  2485. * letter or digit = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nd]
  2486. *
  2487. * @param codePoint character to test
  2488. * @return true if codePoint is a Unicode letter or a Unicode digit, else false
  2489. * @see #isDigit(int)
  2490. * @see #isJavaIdentifierPart(int)
  2491. * @see #isJavaLetter(int)
  2492. * @see #isJavaLetterOrDigit(int)
  2493. * @see #isLetter(int)
  2494. * @see #isUnicodeIdentifierPart(int)
  2495. * @since 1.5
  2496. */
  2497. public static boolean isLetterOrDigit(int codePoint)
  2498. {
  2499. return ((1 << getType(codePoint)
  2500. & ((1 << UPPERCASE_LETTER)
  2501. | (1 << LOWERCASE_LETTER)
  2502. | (1 << TITLECASE_LETTER)
  2503. | (1 << MODIFIER_LETTER)
  2504. | (1 << OTHER_LETTER)
  2505. | (1 << DECIMAL_DIGIT_NUMBER))) != 0);
  2506. }
  2507. /**
  2508. * Determines if a character can start a Java identifier. This is the
  2509. * combination of isLetter, any character where getType returns
  2510. * LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation
  2511. * (like '_').
  2512. *
  2513. * @param ch character to test
  2514. * @return true if ch can start a Java identifier, else false
  2515. * @deprecated Replaced by {@link #isJavaIdentifierStart(char)}
  2516. * @see #isJavaLetterOrDigit(char)
  2517. * @see #isJavaIdentifierStart(char)
  2518. * @see #isJavaIdentifierPart(char)
  2519. * @see #isLetter(char)
  2520. * @see #isLetterOrDigit(char)
  2521. * @see #isUnicodeIdentifierStart(char)
  2522. */
  2523. public static boolean isJavaLetter(char ch)
  2524. {
  2525. return isJavaIdentifierStart(ch);
  2526. }
  2527. /**
  2528. * Determines if a character can start a Java identifier. This is the
  2529. * combination of isLetter, any character where getType returns
  2530. * LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation
  2531. * (like '_'). Unlike isJavaIdentifierStart(char), this method supports
  2532. * supplementary Unicode code points.
  2533. * <br>
  2534. * Java identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]
  2535. *
  2536. * @param codePoint character to test
  2537. * @return true if codePoint can start a Java identifier, else false
  2538. * @see #isJavaIdentifierPart(int)
  2539. * @see #isLetter(int)
  2540. * @see #isUnicodeIdentifierStart(int)
  2541. * @since 1.5
  2542. */
  2543. public static boolean isJavaIdentifierStart(int codePoint)
  2544. {
  2545. return ((1 << getType(codePoint))
  2546. & ((1 << UPPERCASE_LETTER)
  2547. | (1 << LOWERCASE_LETTER)
  2548. | (1 << TITLECASE_LETTER)
  2549. | (1 << MODIFIER_LETTER)
  2550. | (1 << OTHER_LETTER)
  2551. | (1 << LETTER_NUMBER)
  2552. | (1 << CURRENCY_SYMBOL)
  2553. | (1 << CONNECTOR_PUNCTUATION))) != 0;
  2554. }
  2555. /**
  2556. * Determines if a character can follow the first letter in
  2557. * a Java identifier. This is the combination of isJavaLetter (isLetter,
  2558. * type of LETTER_NUMBER, currency, connecting punctuation) and digit,
  2559. * numeric letter (like Roman numerals), combining marks, non-spacing marks,
  2560. * or isIdentifierIgnorable.
  2561. *
  2562. * @param ch character to test
  2563. * @return true if ch can follow the first letter in a Java identifier
  2564. * @deprecated Replaced by {@link #isJavaIdentifierPart(char)}
  2565. * @see #isJavaLetter(char)
  2566. * @see #isJavaIdentifierStart(char)
  2567. * @see #isJavaIdentifierPart(char)
  2568. * @see #isLetter(char)
  2569. * @see #isLetterOrDigit(char)
  2570. * @see #isUnicodeIdentifierPart(char)
  2571. * @see #isIdentifierIgnorable(char)
  2572. */
  2573. public static boolean isJavaLetterOrDigit(char ch)
  2574. {
  2575. return isJavaIdentifierPart(ch);
  2576. }
  2577. /**
  2578. * Determines if a character can start a Java identifier. This is the
  2579. * combination of isLetter, any character where getType returns
  2580. * LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation
  2581. * (like '_').
  2582. * <br>
  2583. * Java identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]
  2584. *
  2585. * @param ch character to test
  2586. * @return true if ch can start a Java identifier, else false
  2587. * @see #isJavaIdentifierPart(char)
  2588. * @see #isLetter(char)
  2589. * @see #isUnicodeIdentifierStart(char)
  2590. * @since 1.1
  2591. */
  2592. public static boolean isJavaIdentifierStart(char ch)
  2593. {
  2594. return ((1 << getType(ch))
  2595. & ((1 << UPPERCASE_LETTER)
  2596. | (1 << LOWERCASE_LETTER)
  2597. | (1 << TITLECASE_LETTER)
  2598. | (1 << MODIFIER_LETTER)
  2599. | (1 << OTHER_LETTER)
  2600. | (1 << LETTER_NUMBER)
  2601. | (1 << CURRENCY_SYMBOL)
  2602. | (1 << CONNECTOR_PUNCTUATION))) != 0;
  2603. }
  2604. /**
  2605. * Determines if a character can follow the first letter in
  2606. * a Java identifier. This is the combination of isJavaLetter (isLetter,
  2607. * type of LETTER_NUMBER, currency, connecting punctuation) and digit,
  2608. * numeric letter (like Roman numerals), combining marks, non-spacing marks,
  2609. * or isIdentifierIgnorable.
  2610. * <br>
  2611. * Java identifier extender =
  2612. * [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]|[Mn]|[Mc]|[Nd]|[Cf]
  2613. * |U+0000-U+0008|U+000E-U+001B|U+007F-U+009F
  2614. *
  2615. * @param ch character to test
  2616. * @return true if ch can follow the first letter in a Java identifier
  2617. * @see #isIdentifierIgnorable(char)
  2618. * @see #isJavaIdentifierStart(char)
  2619. * @see #isLetterOrDigit(char)
  2620. * @see #isUnicodeIdentifierPart(char)
  2621. * @since 1.1
  2622. */
  2623. public static boolean isJavaIdentifierPart(char ch)
  2624. {
  2625. int category = getType(ch);
  2626. return ((1 << category)
  2627. & ((1 << UPPERCASE_LETTER)
  2628. | (1 << LOWERCASE_LETTER)
  2629. | (1 << TITLECASE_LETTER)
  2630. | (1 << MODIFIER_LETTER)
  2631. | (1 << OTHER_LETTER)
  2632. | (1 << NON_SPACING_MARK)
  2633. | (1 << COMBINING_SPACING_MARK)
  2634. | (1 << DECIMAL_DIGIT_NUMBER)
  2635. | (1 << LETTER_NUMBER)
  2636. | (1 << CURRENCY_SYMBOL)
  2637. | (1 << CONNECTOR_PUNCTUATION)
  2638. | (1 << FORMAT))) != 0
  2639. || (category == CONTROL && isIdentifierIgnorable(ch));
  2640. }
  2641. /**
  2642. * Determines if a character can follow the first letter in
  2643. * a Java identifier. This is the combination of isJavaLetter (isLetter,
  2644. * type of LETTER_NUMBER, currency, connecting punctuation) and digit,
  2645. * numeric letter (like Roman numerals), combining marks, non-spacing marks,
  2646. * or isIdentifierIgnorable. Unlike isJavaIdentifierPart(char), this method
  2647. * supports supplementary Unicode code points.
  2648. * <br>
  2649. * Java identifier extender =
  2650. * [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]|[Mn]|[Mc]|[Nd]|[Cf]
  2651. * |U+0000-U+0008|U+000E-U+001B|U+007F-U+009F
  2652. *
  2653. * @param codePoint character to test
  2654. * @return true if codePoint can follow the first letter in a Java identifier
  2655. * @see #isIdentifierIgnorable(int)
  2656. * @see #isJavaIdentifierStart(int)
  2657. * @see #isLetterOrDigit(int)
  2658. * @see #isUnicodeIdentifierPart(int)
  2659. * @since 1.5
  2660. */
  2661. public static boolean isJavaIdentifierPart(int codePoint)
  2662. {
  2663. int category = getType(codePoint);
  2664. return ((1 << category)
  2665. & ((1 << UPPERCASE_LETTER)
  2666. | (1 << LOWERCASE_LETTER)
  2667. | (1 << TITLECASE_LETTER)
  2668. | (1 << MODIFIER_LETTER)
  2669. | (1 << OTHER_LETTER)
  2670. | (1 << NON_SPACING_MARK)
  2671. | (1 << COMBINING_SPACING_MARK)
  2672. | (1 << DECIMAL_DIGIT_NUMBER)
  2673. | (1 << LETTER_NUMBER)
  2674. | (1 << CURRENCY_SYMBOL)
  2675. | (1 << CONNECTOR_PUNCTUATION)
  2676. | (1 << FORMAT))) != 0
  2677. || (category == CONTROL && isIdentifierIgnorable(codePoint));
  2678. }
  2679. /**
  2680. * Determines if a character can start a Unicode identifier. Only
  2681. * letters can start a Unicode identifier, but this includes characters
  2682. * in LETTER_NUMBER.
  2683. * <br>
  2684. * Unicode identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]
  2685. *
  2686. * @param ch character to test
  2687. * @return true if ch can start a Unicode identifier, else false
  2688. * @see #isJavaIdentifierStart(char)
  2689. * @see #isLetter(char)
  2690. * @see #isUnicodeIdentifierPart(char)
  2691. * @since 1.1
  2692. */
  2693. public static boolean isUnicodeIdentifierStart(char ch)
  2694. {
  2695. return ((1 << getType(ch))
  2696. & ((1 << UPPERCASE_LETTER)
  2697. | (1 << LOWERCASE_LETTER)
  2698. | (1 << TITLECASE_LETTER)
  2699. | (1 << MODIFIER_LETTER)
  2700. | (1 << OTHER_LETTER)
  2701. | (1 << LETTER_NUMBER))) != 0;
  2702. }
  2703. /**
  2704. * Determines if a character can start a Unicode identifier. Only
  2705. * letters can start a Unicode identifier, but this includes characters
  2706. * in LETTER_NUMBER. Unlike isUnicodeIdentifierStart(char), this method
  2707. * supports supplementary Unicode code points.
  2708. * <br>
  2709. * Unicode identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]
  2710. *
  2711. * @param codePoint character to test
  2712. * @return true if codePoint can start a Unicode identifier, else false
  2713. * @see #isJavaIdentifierStart(int)
  2714. * @see #isLetter(int)
  2715. * @see #isUnicodeIdentifierPart(int)
  2716. * @since 1.5
  2717. */
  2718. public static boolean isUnicodeIdentifierStart(int codePoint)
  2719. {
  2720. return ((1 << getType(codePoint))
  2721. & ((1 << UPPERCASE_LETTER)
  2722. | (1 << LOWERCASE_LETTER)
  2723. | (1 << TITLECASE_LETTER)
  2724. | (1 << MODIFIER_LETTER)
  2725. | (1 << OTHER_LETTER)
  2726. | (1 << LETTER_NUMBER))) != 0;
  2727. }
  2728. /**
  2729. * Determines if a character can follow the first letter in
  2730. * a Unicode identifier. This includes letters, connecting punctuation,
  2731. * digits, numeric letters, combining marks, non-spacing marks, and
  2732. * isIdentifierIgnorable.
  2733. * <br>
  2734. * Unicode identifier extender =
  2735. * [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Mn]|[Mc]|[Nd]|[Pc]|[Cf]|
  2736. * |U+0000-U+0008|U+000E-U+001B|U+007F-U+009F
  2737. *
  2738. * @param ch character to test
  2739. * @return true if ch can follow the first letter in a Unicode identifier
  2740. * @see #isIdentifierIgnorable(char)
  2741. * @see #isJavaIdentifierPart(char)
  2742. * @see #isLetterOrDigit(char)
  2743. * @see #isUnicodeIdentifierStart(char)
  2744. * @since 1.1
  2745. */
  2746. public static boolean isUnicodeIdentifierPart(char ch)
  2747. {
  2748. int category = getType(ch);
  2749. return ((1 << category)
  2750. & ((1 << UPPERCASE_LETTER)
  2751. | (1 << LOWERCASE_LETTER)
  2752. | (1 << TITLECASE_LETTER)
  2753. | (1 << MODIFIER_LETTER)
  2754. | (1 << OTHER_LETTER)
  2755. | (1 << NON_SPACING_MARK)
  2756. | (1 << COMBINING_SPACING_MARK)
  2757. | (1 << DECIMAL_DIGIT_NUMBER)
  2758. | (1 << LETTER_NUMBER)
  2759. | (1 << CONNECTOR_PUNCTUATION)
  2760. | (1 << FORMAT))) != 0
  2761. || (category == CONTROL && isIdentifierIgnorable(ch));
  2762. }
  2763. /**
  2764. * Determines if a character can follow the first letter in
  2765. * a Unicode identifier. This includes letters, connecting punctuation,
  2766. * digits, numeric letters, combining marks, non-spacing marks, and
  2767. * isIdentifierIgnorable. Unlike isUnicodeIdentifierPart(char), this method
  2768. * supports supplementary Unicode code points.
  2769. * <br>
  2770. * Unicode identifier extender =
  2771. * [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Mn]|[Mc]|[Nd]|[Pc]|[Cf]|
  2772. * |U+0000-U+0008|U+000E-U+001B|U+007F-U+009F
  2773. *
  2774. * @param codePoint character to test
  2775. * @return true if codePoint can follow the first letter in a Unicode
  2776. * identifier
  2777. * @see #isIdentifierIgnorable(int)
  2778. * @see #isJavaIdentifierPart(int)
  2779. * @see #isLetterOrDigit(int)
  2780. * @see #isUnicodeIdentifierStart(int)
  2781. * @since 1.5
  2782. */
  2783. public static boolean isUnicodeIdentifierPart(int codePoint)
  2784. {
  2785. int category = getType(codePoint);
  2786. return ((1 << category)
  2787. & ((1 << UPPERCASE_LETTER)
  2788. | (1 << LOWERCASE_LETTER)
  2789. | (1 << TITLECASE_LETTER)
  2790. | (1 << MODIFIER_LETTER)
  2791. | (1 << OTHER_LETTER)
  2792. | (1 << NON_SPACING_MARK)
  2793. | (1 << COMBINING_SPACING_MARK)
  2794. | (1 << DECIMAL_DIGIT_NUMBER)
  2795. | (1 << LETTER_NUMBER)
  2796. | (1 << CONNECTOR_PUNCTUATION)
  2797. | (1 << FORMAT))) != 0
  2798. || (category == CONTROL && isIdentifierIgnorable(codePoint));
  2799. }
  2800. /**
  2801. * Determines if a character is ignorable in a Unicode identifier. This
  2802. * includes the non-whitespace ISO control characters (<code>'\u0000'</code>
  2803. * through <code>'\u0008'</code>, <code>'\u000E'</code> through
  2804. * <code>'\u001B'</code>, and <code>'\u007F'</code> through
  2805. * <code>'\u009F'</code>), and FORMAT characters.
  2806. * <br>
  2807. * Unicode identifier ignorable = [Cf]|U+0000-U+0008|U+000E-U+001B
  2808. * |U+007F-U+009F
  2809. *
  2810. * @param ch character to test
  2811. * @return true if ch is ignorable in a Unicode or Java identifier
  2812. * @see #isJavaIdentifierPart(char)
  2813. * @see #isUnicodeIdentifierPart(char)
  2814. * @since 1.1
  2815. */
  2816. public static boolean isIdentifierIgnorable(char ch)
  2817. {
  2818. return (ch <= '\u009F' && (ch < '\t' || ch >= '\u007F'
  2819. || (ch <= '\u001B' && ch >= '\u000E')))
  2820. || getType(ch) == FORMAT;
  2821. }
  2822. /**
  2823. * Determines if a character is ignorable in a Unicode identifier. This
  2824. * includes the non-whitespace ISO control characters (<code>'\u0000'</code>
  2825. * through <code>'\u0008'</code>, <code>'\u000E'</code> through
  2826. * <code>'\u001B'</code>, and <code>'\u007F'</code> through
  2827. * <code>'\u009F'</code>), and FORMAT characters. Unlike
  2828. * isIdentifierIgnorable(char), this method supports supplementary Unicode
  2829. * code points.
  2830. * <br>
  2831. * Unicode identifier ignorable = [Cf]|U+0000-U+0008|U+000E-U+001B
  2832. * |U+007F-U+009F
  2833. *
  2834. * @param codePoint character to test
  2835. * @return true if codePoint is ignorable in a Unicode or Java identifier
  2836. * @see #isJavaIdentifierPart(int)
  2837. * @see #isUnicodeIdentifierPart(int)
  2838. * @since 1.5
  2839. */
  2840. public static boolean isIdentifierIgnorable(int codePoint)
  2841. {
  2842. return ((codePoint >= 0 && codePoint <= 0x0008)
  2843. || (codePoint >= 0x000E && codePoint <= 0x001B)
  2844. || (codePoint >= 0x007F && codePoint <= 0x009F)
  2845. || getType(codePoint) == FORMAT);
  2846. }
  2847. /**
  2848. * Converts a Unicode character into its lowercase equivalent mapping.
  2849. * If a mapping does not exist, then the character passed is returned.
  2850. * Note that isLowerCase(toLowerCase(ch)) does not always return true.
  2851. *
  2852. * @param ch character to convert to lowercase
  2853. * @return lowercase mapping of ch, or ch if lowercase mapping does
  2854. * not exist
  2855. * @see #isLowerCase(char)
  2856. * @see #isUpperCase(char)
  2857. * @see #toTitleCase(char)
  2858. * @see #toUpperCase(char)
  2859. */
  2860. public static native char toLowerCase(char ch);
  2861. /**
  2862. * Converts a Unicode character into its lowercase equivalent mapping.
  2863. * If a mapping does not exist, then the character passed is returned.
  2864. * Note that isLowerCase(toLowerCase(codePoint)) does not always return true.
  2865. * Unlike toLowerCase(char), this method supports supplementary Unicode
  2866. * code points.
  2867. *
  2868. * @param codePoint character to convert to lowercase
  2869. * @return lowercase mapping of codePoint, or codePoint if lowercase
  2870. * mapping does not exist
  2871. * @see #isLowerCase(int)
  2872. * @see #isUpperCase(int)
  2873. * @see #toTitleCase(int)
  2874. * @see #toUpperCase(int)
  2875. * @since 1.5
  2876. */
  2877. public static native int toLowerCase(int codePoint);
  2878. /**
  2879. * Converts a Unicode character into its uppercase equivalent mapping.
  2880. * If a mapping does not exist, then the character passed is returned.
  2881. * Note that isUpperCase(toUpperCase(ch)) does not always return true.
  2882. *
  2883. * @param ch character to convert to uppercase
  2884. * @return uppercase mapping of ch, or ch if uppercase mapping does
  2885. * not exist
  2886. * @see #isLowerCase(char)
  2887. * @see #isUpperCase(char)
  2888. * @see #toLowerCase(char)
  2889. * @see #toTitleCase(char)
  2890. */
  2891. public static native char toUpperCase(char ch);
  2892. /**
  2893. * Converts a Unicode character into its uppercase equivalent mapping.
  2894. * If a mapping does not exist, then the character passed is returned.
  2895. * Note that isUpperCase(toUpperCase(codePoint)) does not always return true.
  2896. * Unlike toUpperCase(char), this method supports supplementary
  2897. * Unicode code points.
  2898. *
  2899. * @param codePoint character to convert to uppercase
  2900. * @return uppercase mapping of codePoint, or codePoint if uppercase
  2901. * mapping does not exist
  2902. * @see #isLowerCase(int)
  2903. * @see #isUpperCase(int)
  2904. * @see #toLowerCase(int)
  2905. * @see #toTitleCase(int)
  2906. * @since 1.5
  2907. */
  2908. public static native int toUpperCase(int codePoint);
  2909. /**
  2910. * Converts a Unicode character into its titlecase equivalent mapping.
  2911. * If a mapping does not exist, then the character passed is returned.
  2912. * Note that isTitleCase(toTitleCase(ch)) does not always return true.
  2913. *
  2914. * @param ch character to convert to titlecase
  2915. * @return titlecase mapping of ch, or ch if titlecase mapping does
  2916. * not exist
  2917. * @see #isTitleCase(char)
  2918. * @see #toLowerCase(char)
  2919. * @see #toUpperCase(char)
  2920. */
  2921. public static native char toTitleCase(char ch);
  2922. /**
  2923. * Converts a Unicode character into its titlecase equivalent mapping.
  2924. * If a mapping does not exist, then the character passed is returned.
  2925. * Note that isTitleCase(toTitleCase(codePoint)) does not always return true.
  2926. * Unlike toTitleCase(char), this method supports supplementary
  2927. * Unicode code points.
  2928. *
  2929. * @param codePoint character to convert to titlecase
  2930. * @return titlecase mapping of codePoint, or codePoint if titlecase
  2931. * mapping does not exist
  2932. * @see #isTitleCase(int)
  2933. * @see #toLowerCase(int)
  2934. * @see #toUpperCase(int)
  2935. * @since 1.5
  2936. */
  2937. public static native int toTitleCase(int codePoint);
  2938. /**
  2939. * Converts a character into a digit of the specified radix. If the radix
  2940. * exceeds MIN_RADIX or MAX_RADIX, or if the result of getNumericValue(ch)
  2941. * exceeds the radix, or if ch is not a decimal digit or in the case
  2942. * insensitive set of 'a'-'z', the result is -1.
  2943. * <br>
  2944. * character argument boundary = [Nd]|U+0041-U+005A|U+0061-U+007A
  2945. * |U+FF21-U+FF3A|U+FF41-U+FF5A
  2946. *
  2947. * @param ch character to convert into a digit
  2948. * @param radix radix in which ch is a digit
  2949. * @return digit which ch represents in radix, or -1 not a valid digit
  2950. * @see #MIN_RADIX
  2951. * @see #MAX_RADIX
  2952. * @see #forDigit(int, int)
  2953. * @see #isDigit(char)
  2954. * @see #getNumericValue(char)
  2955. */
  2956. public static native int digit(char ch, int radix);
  2957. /**
  2958. * Converts a character into a digit of the specified radix. If the radix
  2959. * exceeds MIN_RADIX or MAX_RADIX, or if the result of getNumericValue(int)
  2960. * exceeds the radix, or if codePoint is not a decimal digit or in the case
  2961. * insensitive set of 'a'-'z', the result is -1. Unlike digit(char, int),
  2962. * this method supports supplementary Unicode code points.
  2963. * <br>
  2964. * character argument boundary = [Nd]|U+0041-U+005A|U+0061-U+007A
  2965. * |U+FF21-U+FF3A|U+FF41-U+FF5A
  2966. *
  2967. * @param codePoint character to convert into a digit
  2968. * @param radix radix in which codePoint is a digit
  2969. * @return digit which codePoint represents in radix, or -1 not a valid digit
  2970. * @see #MIN_RADIX
  2971. * @see #MAX_RADIX
  2972. * @see #forDigit(int, int)
  2973. * @see #isDigit(int)
  2974. * @see #getNumericValue(int)
  2975. * @since 1.5
  2976. */
  2977. public static native int digit(int codePoint, int radix);
  2978. /**
  2979. * Returns the Unicode numeric value property of a character. For example,
  2980. * <code>'\\u216C'</code> (the Roman numeral fifty) returns 50.
  2981. *
  2982. * <p>This method also returns values for the letters A through Z, (not
  2983. * specified by Unicode), in these ranges: <code>'\u0041'</code>
  2984. * through <code>'\u005A'</code> (uppercase); <code>'\u0061'</code>
  2985. * through <code>'\u007A'</code> (lowercase); and <code>'\uFF21'</code>
  2986. * through <code>'\uFF3A'</code>, <code>'\uFF41'</code> through
  2987. * <code>'\uFF5A'</code> (full width variants).
  2988. *
  2989. * <p>If the character lacks a numeric value property, -1 is returned.
  2990. * If the character has a numeric value property which is not representable
  2991. * as a nonnegative integer, such as a fraction, -2 is returned.
  2992. *
  2993. * character argument boundary = [Nd]|[Nl]|[No]|U+0041-U+005A|U+0061-U+007A
  2994. * |U+FF21-U+FF3A|U+FF41-U+FF5A
  2995. *
  2996. * @param ch character from which the numeric value property will
  2997. * be retrieved
  2998. * @return the numeric value property of ch, or -1 if it does not exist, or
  2999. * -2 if it is not representable as a nonnegative integer
  3000. * @see #forDigit(int, int)
  3001. * @see #digit(char, int)
  3002. * @see #isDigit(char)
  3003. * @since 1.1
  3004. */
  3005. public static native int getNumericValue(char ch);
  3006. /**
  3007. * Returns the Unicode numeric value property of a character. For example,
  3008. * <code>'\\u216C'</code> (the Roman numeral fifty) returns 50.
  3009. *
  3010. * <p>This method also returns values for the letters A through Z, (not
  3011. * specified by Unicode), in these ranges: <code>'\u0041'</code>
  3012. * through <code>'\u005A'</code> (uppercase); <code>'\u0061'</code>
  3013. * through <code>'\u007A'</code> (lowercase); and <code>'\uFF21'</code>
  3014. * through <code>'\uFF3A'</code>, <code>'\uFF41'</code> through
  3015. * <code>'\uFF5A'</code> (full width variants).
  3016. *
  3017. * <p>If the character lacks a numeric value property, -1 is returned.
  3018. * If the character has a numeric value property which is not representable
  3019. * as a nonnegative integer, such as a fraction, -2 is returned.
  3020. *
  3021. * Unlike getNumericValue(char), this method supports supplementary Unicode
  3022. * code points.
  3023. *
  3024. * character argument boundary = [Nd]|[Nl]|[No]|U+0041-U+005A|U+0061-U+007A
  3025. * |U+FF21-U+FF3A|U+FF41-U+FF5A
  3026. *
  3027. * @param codePoint character from which the numeric value property will
  3028. * be retrieved
  3029. * @return the numeric value property of codePoint, or -1 if it does not
  3030. * exist, or -2 if it is not representable as a nonnegative integer
  3031. * @see #forDigit(int, int)
  3032. * @see #digit(int, int)
  3033. * @see #isDigit(int)
  3034. * @since 1.5
  3035. */
  3036. public static native int getNumericValue(int codePoint);
  3037. /**
  3038. * Determines if a character is a ISO-LATIN-1 space. This is only the five
  3039. * characters <code>'\t'</code>, <code>'\n'</code>, <code>'\f'</code>,
  3040. * <code>'\r'</code>, and <code>' '</code>.
  3041. * <br>
  3042. * Java space = U+0020|U+0009|U+000A|U+000C|U+000D
  3043. *
  3044. * @param ch character to test
  3045. * @return true if ch is a space, else false
  3046. * @deprecated Replaced by {@link #isWhitespace(char)}
  3047. * @see #isSpaceChar(char)
  3048. * @see #isWhitespace(char)
  3049. */
  3050. public static boolean isSpace(char ch)
  3051. {
  3052. // Performing the subtraction up front alleviates need to compare longs.
  3053. return ch-- <= ' ' && ((1 << ch)
  3054. & ((1 << (' ' - 1))
  3055. | (1 << ('\t' - 1))
  3056. | (1 << ('\n' - 1))
  3057. | (1 << ('\r' - 1))
  3058. | (1 << ('\f' - 1)))) != 0;
  3059. }
  3060. /**
  3061. * Determines if a character is a Unicode space character. This includes
  3062. * SPACE_SEPARATOR, LINE_SEPARATOR, and PARAGRAPH_SEPARATOR.
  3063. * <br>
  3064. * Unicode space = [Zs]|[Zp]|[Zl]
  3065. *
  3066. * @param ch character to test
  3067. * @return true if ch is a Unicode space, else false
  3068. * @see #isWhitespace(char)
  3069. * @since 1.1
  3070. */
  3071. public static boolean isSpaceChar(char ch)
  3072. {
  3073. return ((1 << getType(ch))
  3074. & ((1 << SPACE_SEPARATOR)
  3075. | (1 << LINE_SEPARATOR)
  3076. | (1 << PARAGRAPH_SEPARATOR))) != 0;
  3077. }
  3078. /**
  3079. * Determines if a character is a Unicode space character. This includes
  3080. * SPACE_SEPARATOR, LINE_SEPARATOR, and PARAGRAPH_SEPARATOR. Unlike
  3081. * isSpaceChar(char), this method supports supplementary Unicode code points.
  3082. * <br>
  3083. * Unicode space = [Zs]|[Zp]|[Zl]
  3084. *
  3085. * @param codePoint character to test
  3086. * @return true if codePoint is a Unicode space, else false
  3087. * @see #isWhitespace(int)
  3088. * @since 1.5
  3089. */
  3090. public static boolean isSpaceChar(int codePoint)
  3091. {
  3092. return ((1 << getType(codePoint))
  3093. & ((1 << SPACE_SEPARATOR)
  3094. | (1 << LINE_SEPARATOR)
  3095. | (1 << PARAGRAPH_SEPARATOR))) != 0;
  3096. }
  3097. /**
  3098. * Determines if a character is Java whitespace. This includes Unicode
  3099. * space characters (SPACE_SEPARATOR, LINE_SEPARATOR, and
  3100. * PARAGRAPH_SEPARATOR) except the non-breaking spaces
  3101. * (<code>'\u00A0'</code>, <code>'\u2007'</code>, and <code>'\u202F'</code>);
  3102. * and these characters: <code>'\u0009'</code>, <code>'\u000A'</code>,
  3103. * <code>'\u000B'</code>, <code>'\u000C'</code>, <code>'\u000D'</code>,
  3104. * <code>'\u001C'</code>, <code>'\u001D'</code>, <code>'\u001E'</code>,
  3105. * and <code>'\u001F'</code>.
  3106. * <br>
  3107. * Java whitespace = ([Zs] not Nb)|[Zl]|[Zp]|U+0009-U+000D|U+001C-U+001F
  3108. *
  3109. * @param ch character to test
  3110. * @return true if ch is Java whitespace, else false
  3111. * @see #isSpaceChar(char)
  3112. * @since 1.1
  3113. */
  3114. public static boolean isWhitespace(char ch)
  3115. {
  3116. int attr = readChar(ch);
  3117. return ((((1 << (attr & TYPE_MASK))
  3118. & ((1 << SPACE_SEPARATOR)
  3119. | (1 << LINE_SEPARATOR)
  3120. | (1 << PARAGRAPH_SEPARATOR))) != 0)
  3121. && (attr & NO_BREAK_MASK) == 0)
  3122. || (ch <= '\u001F' && ((1 << ch)
  3123. & ((1 << '\t')
  3124. | (1 << '\n')
  3125. | (1 << '\u000B')
  3126. | (1 << '\u000C')
  3127. | (1 << '\r')
  3128. | (1 << '\u001C')
  3129. | (1 << '\u001D')
  3130. | (1 << '\u001E')
  3131. | (1 << '\u001F'))) != 0);
  3132. }
  3133. /**
  3134. * Determines if a character is Java whitespace. This includes Unicode
  3135. * space characters (SPACE_SEPARATOR, LINE_SEPARATOR, and
  3136. * PARAGRAPH_SEPARATOR) except the non-breaking spaces
  3137. * (<code>'\u00A0'</code>, <code>'\u2007'</code>, and <code>'\u202F'</code>);
  3138. * and these characters: <code>'\u0009'</code>, <code>'\u000A'</code>,
  3139. * <code>'\u000B'</code>, <code>'\u000C'</code>, <code>'\u000D'</code>,
  3140. * <code>'\u001C'</code>, <code>'\u001D'</code>, <code>'\u001E'</code>,
  3141. * and <code>'\u001F'</code>. Unlike isWhitespace(char), this method
  3142. * supports supplementary Unicode code points.
  3143. * <br>
  3144. * Java whitespace = ([Zs] not Nb)|[Zl]|[Zp]|U+0009-U+000D|U+001C-U+001F
  3145. *
  3146. * @param codePoint character to test
  3147. * @return true if codePoint is Java whitespace, else false
  3148. * @see #isSpaceChar(int)
  3149. * @since 1.5
  3150. */
  3151. public static boolean isWhitespace(int codePoint)
  3152. {
  3153. int plane = codePoint >>> 16;
  3154. if (plane > 2 && plane != 14)
  3155. return false;
  3156. int attr = readCodePoint(codePoint);
  3157. return ((((1 << (attr & TYPE_MASK))
  3158. & ((1 << SPACE_SEPARATOR)
  3159. | (1 << LINE_SEPARATOR)
  3160. | (1 << PARAGRAPH_SEPARATOR))) != 0)
  3161. && (attr & NO_BREAK_MASK) == 0)
  3162. || (codePoint <= '\u001F' && ((1 << codePoint)
  3163. & ((1 << '\t')
  3164. | (1 << '\n')
  3165. | (1 << '\u000B')
  3166. | (1 << '\u000C')
  3167. | (1 << '\r')
  3168. | (1 << '\u001C')
  3169. | (1 << '\u001D')
  3170. | (1 << '\u001E')
  3171. | (1 << '\u001F'))) != 0);
  3172. }
  3173. /**
  3174. * Determines if a character has the ISO Control property.
  3175. * <br>
  3176. * ISO Control = [Cc]
  3177. *
  3178. * @param ch character to test
  3179. * @return true if ch is an ISO Control character, else false
  3180. * @see #isSpaceChar(char)
  3181. * @see #isWhitespace(char)
  3182. * @since 1.1
  3183. */
  3184. public static boolean isISOControl(char ch)
  3185. {
  3186. return getType(ch) == CONTROL;
  3187. }
  3188. /**
  3189. * Determines if a character has the ISO Control property. Unlike
  3190. * isISOControl(char), this method supports supplementary unicode
  3191. * code points.
  3192. * <br>
  3193. * ISO Control = [Cc]
  3194. *
  3195. * @param codePoint character to test
  3196. * @return true if codePoint is an ISO Control character, else false
  3197. * @see #isSpaceChar(int)
  3198. * @see #isWhitespace(int)
  3199. * @since 1.5
  3200. */
  3201. public static boolean isISOControl(int codePoint)
  3202. {
  3203. return getType(codePoint) == CONTROL;
  3204. }
  3205. /**
  3206. * Returns the Unicode general category property of a character.
  3207. *
  3208. * @param ch character from which the general category property will
  3209. * be retrieved
  3210. * @return the character category property of ch as an integer
  3211. * @see #UNASSIGNED
  3212. * @see #UPPERCASE_LETTER
  3213. * @see #LOWERCASE_LETTER
  3214. * @see #TITLECASE_LETTER
  3215. * @see #MODIFIER_LETTER
  3216. * @see #OTHER_LETTER
  3217. * @see #NON_SPACING_MARK
  3218. * @see #ENCLOSING_MARK
  3219. * @see #COMBINING_SPACING_MARK
  3220. * @see #DECIMAL_DIGIT_NUMBER
  3221. * @see #LETTER_NUMBER
  3222. * @see #OTHER_NUMBER
  3223. * @see #SPACE_SEPARATOR
  3224. * @see #LINE_SEPARATOR
  3225. * @see #PARAGRAPH_SEPARATOR
  3226. * @see #CONTROL
  3227. * @see #FORMAT
  3228. * @see #PRIVATE_USE
  3229. * @see #SURROGATE
  3230. * @see #DASH_PUNCTUATION
  3231. * @see #START_PUNCTUATION
  3232. * @see #END_PUNCTUATION
  3233. * @see #CONNECTOR_PUNCTUATION
  3234. * @see #OTHER_PUNCTUATION
  3235. * @see #MATH_SYMBOL
  3236. * @see #CURRENCY_SYMBOL
  3237. * @see #MODIFIER_SYMBOL
  3238. * @see #INITIAL_QUOTE_PUNCTUATION
  3239. * @see #FINAL_QUOTE_PUNCTUATION
  3240. * @since 1.1
  3241. */
  3242. public static native int getType(char ch);
  3243. /**
  3244. * Returns the Unicode general category property of a character. Supports
  3245. * supplementary Unicode code points.
  3246. *
  3247. * @param codePoint character from which the general category property will
  3248. * be retrieved
  3249. * @return the character category property of codePoint as an integer
  3250. * @see #UNASSIGNED
  3251. * @see #UPPERCASE_LETTER
  3252. * @see #LOWERCASE_LETTER
  3253. * @see #TITLECASE_LETTER
  3254. * @see #MODIFIER_LETTER
  3255. * @see #OTHER_LETTER
  3256. * @see #NON_SPACING_MARK
  3257. * @see #ENCLOSING_MARK
  3258. * @see #COMBINING_SPACING_MARK
  3259. * @see #DECIMAL_DIGIT_NUMBER
  3260. * @see #LETTER_NUMBER
  3261. * @see #OTHER_NUMBER
  3262. * @see #SPACE_SEPARATOR
  3263. * @see #LINE_SEPARATOR
  3264. * @see #PARAGRAPH_SEPARATOR
  3265. * @see #CONTROL
  3266. * @see #FORMAT
  3267. * @see #PRIVATE_USE
  3268. * @see #SURROGATE
  3269. * @see #DASH_PUNCTUATION
  3270. * @see #START_PUNCTUATION
  3271. * @see #END_PUNCTUATION
  3272. * @see #CONNECTOR_PUNCTUATION
  3273. * @see #OTHER_PUNCTUATION
  3274. * @see #MATH_SYMBOL
  3275. * @see #CURRENCY_SYMBOL
  3276. * @see #MODIFIER_SYMBOL
  3277. * @see #INITIAL_QUOTE_PUNCTUATION
  3278. * @see #FINAL_QUOTE_PUNCTUATION
  3279. * @since 1.5
  3280. */
  3281. public static native int getType(int codePoint);
  3282. /**
  3283. * Converts a digit into a character which represents that digit
  3284. * in a specified radix. If the radix exceeds MIN_RADIX or MAX_RADIX,
  3285. * or the digit exceeds the radix, then the null character <code>'\0'</code>
  3286. * is returned. Otherwise the return value is in '0'-'9' and 'a'-'z'.
  3287. * <br>
  3288. * return value boundary = U+0030-U+0039|U+0061-U+007A
  3289. *
  3290. * @param digit digit to be converted into a character
  3291. * @param radix radix of digit
  3292. * @return character representing digit in radix, or '\0'
  3293. * @see #MIN_RADIX
  3294. * @see #MAX_RADIX
  3295. * @see #digit(char, int)
  3296. */
  3297. public static char forDigit(int digit, int radix)
  3298. {
  3299. if (radix < MIN_RADIX || radix > MAX_RADIX
  3300. || digit < 0 || digit >= radix)
  3301. return '\0';
  3302. return (char) (digit < 10 ? ('0' + digit) : ('a' - 10 + digit));
  3303. }
  3304. /**
  3305. * Returns the Unicode directionality property of the character. This
  3306. * is used in the visual ordering of text.
  3307. *
  3308. * @param ch the character to look up
  3309. * @return the directionality constant, or DIRECTIONALITY_UNDEFINED
  3310. * @see #DIRECTIONALITY_UNDEFINED
  3311. * @see #DIRECTIONALITY_LEFT_TO_RIGHT
  3312. * @see #DIRECTIONALITY_RIGHT_TO_LEFT
  3313. * @see #DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
  3314. * @see #DIRECTIONALITY_EUROPEAN_NUMBER
  3315. * @see #DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
  3316. * @see #DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
  3317. * @see #DIRECTIONALITY_ARABIC_NUMBER
  3318. * @see #DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
  3319. * @see #DIRECTIONALITY_NONSPACING_MARK
  3320. * @see #DIRECTIONALITY_BOUNDARY_NEUTRAL
  3321. * @see #DIRECTIONALITY_PARAGRAPH_SEPARATOR
  3322. * @see #DIRECTIONALITY_SEGMENT_SEPARATOR
  3323. * @see #DIRECTIONALITY_WHITESPACE
  3324. * @see #DIRECTIONALITY_OTHER_NEUTRALS
  3325. * @see #DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING
  3326. * @see #DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE
  3327. * @see #DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
  3328. * @see #DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
  3329. * @see #DIRECTIONALITY_POP_DIRECTIONAL_FORMAT
  3330. * @since 1.4
  3331. */
  3332. public static native byte getDirectionality(char ch);
  3333. /**
  3334. * Returns the Unicode directionality property of the character. This
  3335. * is used in the visual ordering of text. Unlike getDirectionality(char),
  3336. * this method supports supplementary Unicode code points.
  3337. *
  3338. * @param codePoint the character to look up
  3339. * @return the directionality constant, or DIRECTIONALITY_UNDEFINED
  3340. * @see #DIRECTIONALITY_UNDEFINED
  3341. * @see #DIRECTIONALITY_LEFT_TO_RIGHT
  3342. * @see #DIRECTIONALITY_RIGHT_TO_LEFT
  3343. * @see #DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
  3344. * @see #DIRECTIONALITY_EUROPEAN_NUMBER
  3345. * @see #DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
  3346. * @see #DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
  3347. * @see #DIRECTIONALITY_ARABIC_NUMBER
  3348. * @see #DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
  3349. * @see #DIRECTIONALITY_NONSPACING_MARK
  3350. * @see #DIRECTIONALITY_BOUNDARY_NEUTRAL
  3351. * @see #DIRECTIONALITY_PARAGRAPH_SEPARATOR
  3352. * @see #DIRECTIONALITY_SEGMENT_SEPARATOR
  3353. * @see #DIRECTIONALITY_WHITESPACE
  3354. * @see #DIRECTIONALITY_OTHER_NEUTRALS
  3355. * @see #DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING
  3356. * @see #DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE
  3357. * @see #DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
  3358. * @see #DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
  3359. * @see #DIRECTIONALITY_POP_DIRECTIONAL_FORMAT
  3360. * @since 1.5
  3361. */
  3362. public static native byte getDirectionality(int codePoint);
  3363. /**
  3364. * Determines whether the character is mirrored according to Unicode. For
  3365. * example, <code>\u0028</code> (LEFT PARENTHESIS) appears as '(' in
  3366. * left-to-right text, but ')' in right-to-left text.
  3367. *
  3368. * @param ch the character to look up
  3369. * @return true if the character is mirrored
  3370. * @since 1.4
  3371. */
  3372. public static boolean isMirrored(char ch)
  3373. {
  3374. return (readChar(ch) & MIRROR_MASK) != 0;
  3375. }
  3376. /**
  3377. * Determines whether the character is mirrored according to Unicode. For
  3378. * example, <code>\u0028</code> (LEFT PARENTHESIS) appears as '(' in
  3379. * left-to-right text, but ')' in right-to-left text. Unlike
  3380. * isMirrored(char), this method supports supplementary Unicode code points.
  3381. *
  3382. * @param codePoint the character to look up
  3383. * @return true if the character is mirrored
  3384. * @since 1.5
  3385. */
  3386. public static boolean isMirrored(int codePoint)
  3387. {
  3388. int plane = codePoint >>> 16;
  3389. if (plane > 2 && plane != 14)
  3390. return false;
  3391. return (readCodePoint(codePoint) & MIRROR_MASK) != 0;
  3392. }
  3393. /**
  3394. * Compares another Character to this Character, numerically.
  3395. *
  3396. * @param anotherCharacter Character to compare with this Character
  3397. * @return a negative integer if this Character is less than
  3398. * anotherCharacter, zero if this Character is equal, and
  3399. * a positive integer if this Character is greater
  3400. * @throws NullPointerException if anotherCharacter is null
  3401. * @since 1.2
  3402. */
  3403. public int compareTo(Character anotherCharacter)
  3404. {
  3405. return value - anotherCharacter.value;
  3406. }
  3407. /**
  3408. * Returns an <code>Character</code> object wrapping the value.
  3409. * In contrast to the <code>Character</code> constructor, this method
  3410. * will cache some values. It is used by boxing conversion.
  3411. *
  3412. * @param val the value to wrap
  3413. * @return the <code>Character</code>
  3414. *
  3415. * @since 1.5
  3416. */
  3417. public static Character valueOf(char val)
  3418. {
  3419. if (val > MAX_CACHE)
  3420. return new Character(val);
  3421. synchronized (charCache)
  3422. {
  3423. if (charCache[val - MIN_VALUE] == null)
  3424. charCache[val - MIN_VALUE] = new Character(val);
  3425. return charCache[val - MIN_VALUE];
  3426. }
  3427. }
  3428. /**
  3429. * Reverse the bytes in val.
  3430. * @since 1.5
  3431. */
  3432. public static char reverseBytes(char val)
  3433. {
  3434. return (char) (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
  3435. }
  3436. /**
  3437. * Converts a unicode code point to a UTF-16 representation of that
  3438. * code point.
  3439. *
  3440. * @param codePoint the unicode code point
  3441. *
  3442. * @return the UTF-16 representation of that code point
  3443. *
  3444. * @throws IllegalArgumentException if the code point is not a valid
  3445. * unicode code point
  3446. *
  3447. * @since 1.5
  3448. */
  3449. public static char[] toChars(int codePoint)
  3450. {
  3451. if (!isValidCodePoint(codePoint))
  3452. throw new IllegalArgumentException("Illegal Unicode code point : "
  3453. + codePoint);
  3454. char[] result = new char[charCount(codePoint)];
  3455. int ignore = toChars(codePoint, result, 0);
  3456. return result;
  3457. }
  3458. /**
  3459. * Converts a unicode code point to its UTF-16 representation.
  3460. *
  3461. * @param codePoint the unicode code point
  3462. * @param dst the target char array
  3463. * @param dstIndex the start index for the target
  3464. *
  3465. * @return number of characters written to <code>dst</code>
  3466. *
  3467. * @throws IllegalArgumentException if <code>codePoint</code> is not a
  3468. * valid unicode code point
  3469. * @throws NullPointerException if <code>dst</code> is <code>null</code>
  3470. * @throws IndexOutOfBoundsException if <code>dstIndex</code> is not valid
  3471. * in <code>dst</code> or if the UTF-16 representation does not
  3472. * fit into <code>dst</code>
  3473. *
  3474. * @since 1.5
  3475. */
  3476. public static int toChars(int codePoint, char[] dst, int dstIndex)
  3477. {
  3478. if (!isValidCodePoint(codePoint))
  3479. {
  3480. throw new IllegalArgumentException("not a valid code point: "
  3481. + codePoint);
  3482. }
  3483. int result;
  3484. if (isSupplementaryCodePoint(codePoint))
  3485. {
  3486. // Write second char first to cause IndexOutOfBoundsException
  3487. // immediately.
  3488. final int cp2 = codePoint - 0x10000;
  3489. dst[dstIndex + 1] = (char) ((cp2 % 0x400) + (int) MIN_LOW_SURROGATE);
  3490. dst[dstIndex] = (char) ((cp2 / 0x400) + (int) MIN_HIGH_SURROGATE);
  3491. result = 2;
  3492. }
  3493. else
  3494. {
  3495. dst[dstIndex] = (char) codePoint;
  3496. result = 1;
  3497. }
  3498. return result;
  3499. }
  3500. /**
  3501. * Return number of 16-bit characters required to represent the given
  3502. * code point.
  3503. *
  3504. * @param codePoint a unicode code point
  3505. *
  3506. * @return 2 if codePoint >= 0x10000, 1 otherwise.
  3507. *
  3508. * @since 1.5
  3509. */
  3510. public static int charCount(int codePoint)
  3511. {
  3512. return
  3513. (codePoint >= MIN_SUPPLEMENTARY_CODE_POINT)
  3514. ? 2
  3515. : 1;
  3516. }
  3517. /**
  3518. * Determines whether the specified code point is
  3519. * in the range 0x10000 .. 0x10FFFF, i.e. the character is within the Unicode
  3520. * supplementary character range.
  3521. *
  3522. * @param codePoint a Unicode code point
  3523. *
  3524. * @return <code>true</code> if code point is in supplementary range
  3525. *
  3526. * @since 1.5
  3527. */
  3528. public static boolean isSupplementaryCodePoint(int codePoint)
  3529. {
  3530. return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT
  3531. && codePoint <= MAX_CODE_POINT;
  3532. }
  3533. /**
  3534. * Determines whether the specified code point is
  3535. * in the range 0x0000 .. 0x10FFFF, i.e. it is a valid Unicode code point.
  3536. *
  3537. * @param codePoint a Unicode code point
  3538. *
  3539. * @return <code>true</code> if code point is valid
  3540. *
  3541. * @since 1.5
  3542. */
  3543. public static boolean isValidCodePoint(int codePoint)
  3544. {
  3545. return codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT;
  3546. }
  3547. /**
  3548. * Return true if the given character is a high surrogate.
  3549. * @param ch the character
  3550. * @return true if the character is a high surrogate character
  3551. *
  3552. * @since 1.5
  3553. */
  3554. public static boolean isHighSurrogate(char ch)
  3555. {
  3556. return ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE;
  3557. }
  3558. /**
  3559. * Return true if the given character is a low surrogate.
  3560. * @param ch the character
  3561. * @return true if the character is a low surrogate character
  3562. *
  3563. * @since 1.5
  3564. */
  3565. public static boolean isLowSurrogate(char ch)
  3566. {
  3567. return ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE;
  3568. }
  3569. /**
  3570. * Return true if the given characters compose a surrogate pair.
  3571. * This is true if the first character is a high surrogate and the
  3572. * second character is a low surrogate.
  3573. * @param ch1 the first character
  3574. * @param ch2 the first character
  3575. * @return true if the characters compose a surrogate pair
  3576. *
  3577. * @since 1.5
  3578. */
  3579. public static boolean isSurrogatePair(char ch1, char ch2)
  3580. {
  3581. return isHighSurrogate(ch1) && isLowSurrogate(ch2);
  3582. }
  3583. /**
  3584. * Given a valid surrogate pair, this returns the corresponding
  3585. * code point.
  3586. * @param high the high character of the pair
  3587. * @param low the low character of the pair
  3588. * @return the corresponding code point
  3589. *
  3590. * @since 1.5
  3591. */
  3592. public static int toCodePoint(char high, char low)
  3593. {
  3594. return ((high - MIN_HIGH_SURROGATE) * 0x400) +
  3595. (low - MIN_LOW_SURROGATE) + 0x10000;
  3596. }
  3597. /**
  3598. * Get the code point at the specified index in the CharSequence.
  3599. * This is like CharSequence#charAt(int), but if the character is
  3600. * the start of a surrogate pair, and there is a following
  3601. * character, and this character completes the pair, then the
  3602. * corresponding supplementary code point is returned. Otherwise,
  3603. * the character at the index is returned.
  3604. *
  3605. * @param sequence the CharSequence
  3606. * @param index the index of the codepoint to get, starting at 0
  3607. * @return the codepoint at the specified index
  3608. * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
  3609. * @since 1.5
  3610. */
  3611. public static int codePointAt(CharSequence sequence, int index)
  3612. {
  3613. int len = sequence.length();
  3614. if (index < 0 || index >= len)
  3615. throw new IndexOutOfBoundsException();
  3616. char high = sequence.charAt(index);
  3617. if (! isHighSurrogate(high) || ++index >= len)
  3618. return high;
  3619. char low = sequence.charAt(index);
  3620. if (! isLowSurrogate(low))
  3621. return high;
  3622. return toCodePoint(high, low);
  3623. }
  3624. /**
  3625. * Get the code point at the specified index in the CharSequence.
  3626. * If the character is the start of a surrogate pair, and there is a
  3627. * following character, and this character completes the pair, then
  3628. * the corresponding supplementary code point is returned.
  3629. * Otherwise, the character at the index is returned.
  3630. *
  3631. * @param chars the character array in which to look
  3632. * @param index the index of the codepoint to get, starting at 0
  3633. * @return the codepoint at the specified index
  3634. * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
  3635. * @since 1.5
  3636. */
  3637. public static int codePointAt(char[] chars, int index)
  3638. {
  3639. return codePointAt(chars, index, chars.length);
  3640. }
  3641. /**
  3642. * Get the code point at the specified index in the CharSequence.
  3643. * If the character is the start of a surrogate pair, and there is a
  3644. * following character within the specified range, and this
  3645. * character completes the pair, then the corresponding
  3646. * supplementary code point is returned. Otherwise, the character
  3647. * at the index is returned.
  3648. *
  3649. * @param chars the character array in which to look
  3650. * @param index the index of the codepoint to get, starting at 0
  3651. * @param limit the limit past which characters should not be examined
  3652. * @return the codepoint at the specified index
  3653. * @throws IndexOutOfBoundsException if index is negative or &gt;=
  3654. * limit, or if limit is negative or &gt;= the length of the array
  3655. * @since 1.5
  3656. */
  3657. public static int codePointAt(char[] chars, int index, int limit)
  3658. {
  3659. if (index < 0 || index >= limit || limit < 0 || limit > chars.length)
  3660. throw new IndexOutOfBoundsException();
  3661. char high = chars[index];
  3662. if (! isHighSurrogate(high) || ++index >= limit)
  3663. return high;
  3664. char low = chars[index];
  3665. if (! isLowSurrogate(low))
  3666. return high;
  3667. return toCodePoint(high, low);
  3668. }
  3669. /**
  3670. * Get the code point before the specified index. This is like
  3671. * #codePointAt(char[], int), but checks the characters at
  3672. * <code>index-1</code> and <code>index-2</code> to see if they form
  3673. * a supplementary code point. If they do not, the character at
  3674. * <code>index-1</code> is returned.
  3675. *
  3676. * @param chars the character array
  3677. * @param index the index just past the codepoint to get, starting at 0
  3678. * @return the codepoint at the specified index
  3679. * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
  3680. * @since 1.5
  3681. */
  3682. public static int codePointBefore(char[] chars, int index)
  3683. {
  3684. return codePointBefore(chars, index, 1);
  3685. }
  3686. /**
  3687. * Get the code point before the specified index. This is like
  3688. * #codePointAt(char[], int), but checks the characters at
  3689. * <code>index-1</code> and <code>index-2</code> to see if they form
  3690. * a supplementary code point. If they do not, the character at
  3691. * <code>index-1</code> is returned. The start parameter is used to
  3692. * limit the range of the array which may be examined.
  3693. *
  3694. * @param chars the character array
  3695. * @param index the index just past the codepoint to get, starting at 0
  3696. * @param start the index before which characters should not be examined
  3697. * @return the codepoint at the specified index
  3698. * @throws IndexOutOfBoundsException if index is &gt; start or &gt;
  3699. * the length of the array, or if limit is negative or &gt;= the
  3700. * length of the array
  3701. * @since 1.5
  3702. */
  3703. public static int codePointBefore(char[] chars, int index, int start)
  3704. {
  3705. if (index < start || index > chars.length
  3706. || start < 0 || start >= chars.length)
  3707. throw new IndexOutOfBoundsException();
  3708. --index;
  3709. char low = chars[index];
  3710. if (! isLowSurrogate(low) || --index < start)
  3711. return low;
  3712. char high = chars[index];
  3713. if (! isHighSurrogate(high))
  3714. return low;
  3715. return toCodePoint(high, low);
  3716. }
  3717. /**
  3718. * Get the code point before the specified index. This is like
  3719. * #codePointAt(CharSequence, int), but checks the characters at
  3720. * <code>index-1</code> and <code>index-2</code> to see if they form
  3721. * a supplementary code point. If they do not, the character at
  3722. * <code>index-1</code> is returned.
  3723. *
  3724. * @param sequence the CharSequence
  3725. * @param index the index just past the codepoint to get, starting at 0
  3726. * @return the codepoint at the specified index
  3727. * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
  3728. * @since 1.5
  3729. */
  3730. public static int codePointBefore(CharSequence sequence, int index)
  3731. {
  3732. int len = sequence.length();
  3733. if (index < 1 || index > len)
  3734. throw new IndexOutOfBoundsException();
  3735. --index;
  3736. char low = sequence.charAt(index);
  3737. if (! isLowSurrogate(low) || --index < 0)
  3738. return low;
  3739. char high = sequence.charAt(index);
  3740. if (! isHighSurrogate(high))
  3741. return low;
  3742. return toCodePoint(high, low);
  3743. }
  3744. } // class Character