本文整理汇总了Java中com.ibm.icu.lang.UScript.INVALID_CODE属性的典型用法代码示例。如果您正苦于以下问题:Java UScript.INVALID_CODE属性的具体用法?Java UScript.INVALID_CODE怎么用?Java UScript.INVALID_CODE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.ibm.icu.lang.UScript
的用法示例。
在下文中一共展示了UScript.INVALID_CODE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scriptNameToCode
/**
* 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
}
}
示例2: Spec
public Spec(String theSpec) {
top = theSpec;
spec = null;
scriptName = null;
try{
// Canonicalize script name. If top is a script name then
// script != UScript.INVALID_CODE.
int script = UScript.getCodeFromName(top);
// Canonicalize script name -or- do locale->script mapping
int[] s = UScript.getCode(top);
if (s != null) {
scriptName = UScript.getName(s[0]);
// If the script name is the same as top then it's redundant
if (scriptName.equalsIgnoreCase(top)) {
scriptName = null;
}
}
isSpecLocale = false;
res = null;
// If 'top' is not a script name, try a locale lookup
if (script == UScript.INVALID_CODE) {
Locale toploc = LocaleUtility.getLocaleFromName(top);
res = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUData.ICU_TRANSLIT_BASE_NAME,toploc);
// Make sure we got the bundle we wanted; otherwise, don't use it
if (res!=null && LocaleUtility.isFallbackOf(res.getULocale().toString(), top)) {
isSpecLocale = true;
}
}
}catch(MissingResourceException e){
///CLOVER:OFF
// The constructor is called from multiple private methods
// that protects an invalid scriptName
scriptName = null;
///CLOVER:ON
}
// assert(spec != top);
reset();
}
示例3: setText
/**
* 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;
}
示例4: setText
/**
* 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;
}
示例5: setText
/**
* 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;
}
示例6: register
/**
* 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);
}
}
}
}
示例7: next
/**
* 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;
}