Java Code Examples for com.ibm.icu.lang.UScript#INVALID_CODE
The following examples show how to use
com.ibm.icu.lang.UScript#INVALID_CODE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnyTransliterator.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Return the script code for a given name, or * UScript.INVALID_CODE if not found. */ private static int scriptNameToCode(String name) { try{ int[] codes = UScript.getCode(name); return codes != null ? codes[0] : UScript.INVALID_CODE; }catch( MissingResourceException e){ ///CLOVER:OFF return UScript.INVALID_CODE; ///CLOVER:ON } }
Example 2
Source File: ScriptIterator.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Set a new region of text to be examined by this iterator * * @param text text buffer to examine * @param start offset into buffer * @param length maximum length to examine */ void setText(char text[], int start, int length) { this.text = text; this.start = start; this.index = start; this.limit = start + length; this.scriptStart = start; this.scriptLimit = start; this.scriptCode = UScript.INVALID_CODE; }
Example 3
Source File: ScriptIterator.java From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 | 5 votes |
/** * Set a new region of text to be examined by this iterator. * * @param text text buffer to examine * @param start offset into buffer * @param length maximum length to examine */ void setText(char[] text, int start, int length) { this.text = text; this.start = start; this.index = start; this.limit = start + length; this.scriptStart = start; this.scriptLimit = start; this.scriptCode = UScript.INVALID_CODE; }
Example 4
Source File: AnyTransliterator.java From fitnotifications with Apache License 2.0 | 4 votes |
/** * Registers standard transliterators with the system. Called by * Transliterator during initialization. Scan all current targets * and register those that are scripts T as Any-T/V. */ static void register() { HashMap<String, Set<String>> seen = new HashMap<String, Set<String>>(); // old code used set, but was dependent on order for (Enumeration<String> s = Transliterator.getAvailableSources(); s.hasMoreElements(); ) { String source = s.nextElement(); // Ignore the "Any" source if (source.equalsIgnoreCase(ANY)) continue; for (Enumeration<String> t = Transliterator.getAvailableTargets(source); t.hasMoreElements(); ) { String target = t.nextElement(); // Get the script code for the target. If not a script, ignore. int targetScript = scriptNameToCode(target); if (targetScript == UScript.INVALID_CODE) { continue; } Set<String> seenVariants = seen.get(target); if (seenVariants == null) { seen.put(target, seenVariants = new HashSet<String>()); } for (Enumeration<String> v = Transliterator.getAvailableVariants(source, target); v.hasMoreElements(); ) { String variant = v.nextElement(); // Only process each target/variant pair once if (seenVariants.contains(variant)) { continue; } seenVariants.add(variant); String id; id = TransliteratorIDParser.STVtoID(ANY, target, variant); AnyTransliterator trans = new AnyTransliterator(id, target, variant, targetScript); Transliterator.registerInstance(trans); Transliterator.registerSpecialInverse(target, NULL_ID, false); } } } }
Example 5
Source File: AnyTransliterator.java From fitnotifications with Apache License 2.0 | 4 votes |
/** * Returns TRUE if there are any more runs. TRUE is always * returned at least once. Upon return, the caller should * examine scriptCode, start, and limit. */ public boolean next() { int ch; int s; scriptCode = UScript.INVALID_CODE; // don't know script yet start = limit; // Are we done? if (start == textLimit) { return false; } // Move start back to include adjacent COMMON or INHERITED // characters while (start > textStart) { ch = text.char32At(start - 1); // look back s = UScript.getScript(ch); if (s == UScript.COMMON || s == UScript.INHERITED) { --start; } else { break; } } // Move limit ahead to include COMMON, INHERITED, and characters // of the current script. while (limit < textLimit) { ch = text.char32At(limit); // look ahead s = UScript.getScript(ch); if (s != UScript.COMMON && s != UScript.INHERITED) { if (scriptCode == UScript.INVALID_CODE) { scriptCode = s; } else if (s != scriptCode) { break; } } ++limit; } // Return TRUE even if the entire text is COMMON / INHERITED, in // which case scriptCode will be UScript.INVALID_CODE. return true; }