当前位置: 首页>>代码示例>>Java>>正文


Java Transliterator.transform方法代码示例

本文整理汇总了Java中com.ibm.icu.text.Transliterator.transform方法的典型用法代码示例。如果您正苦于以下问题:Java Transliterator.transform方法的具体用法?Java Transliterator.transform怎么用?Java Transliterator.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ibm.icu.text.Transliterator的用法示例。


在下文中一共展示了Transliterator.transform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transliterate

import com.ibm.icu.text.Transliterator; //导入方法依赖的package包/类
public static String transliterate(String text, String transliterationCode) {
    if (Str.isEmpty(text))
        return text;

    if (transliterationCode == null) {
        transliterationCode = DEFAULT_TRANSLITERATION_CODE;
    }

    String transliteratedText = text.replace(ae, transliterateReplaceChars.get(ae))
        .replace(oe, transliterateReplaceChars.get(oe)).replace(ue, transliterateReplaceChars.get(ue))
        .replace(Ae, transliterateReplaceChars.get(Ae)).replace(Oe, transliterateReplaceChars.get(Oe))
        .replace(Ue, transliterateReplaceChars.get(Ue)).replace(ss, transliterateReplaceChars.get(ss))
        .replace(Str.AT, transliterateReplaceChars.get(Str.AT))
        .replace(Str.AMPERSAND, transliterateReplaceChars.get(Str.AMPERSAND));

    Transliterator t = transliteratorCache.get(transliterationCode);

    if (t == null) {
        t = Transliterator.getInstance(transliterationCode);
        transliteratorCache.put(transliterationCode, t);
    }

    transliteratedText = t.transform(transliteratedText);

    return Normalizer.normalize(transliteratedText, Normalizer.Form.NFD);
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:27,代码来源:Strings.java

示例2: slugify

import com.ibm.icu.text.Transliterator; //导入方法依赖的package包/类
public static String slugify(String text, String transliterationCode) {
    if (Str.isEmpty(text))
        return text;

    if (transliterationCode == null)
        transliterationCode = DEFAULT_TRANSLITERATION_CODE;

    String transliteratedText = text.replace(ae, transliterateReplaceChars.get(ae))
        .replace(oe, transliterateReplaceChars.get(oe)).replace(ue, transliterateReplaceChars.get(ue))
        .replace(Ae, transliterateReplaceChars.get(Ae)).replace(Oe, transliterateReplaceChars.get(Oe))
        .replace(Ue, transliterateReplaceChars.get(Ue)).replace(ss, transliterateReplaceChars.get(ss))
        .replace(Str.AT, transliterateReplaceChars.get(Str.AT))
        .replace(Str.AMPERSAND, transliterateReplaceChars.get(Str.AMPERSAND));

    Transliterator t = transliteratorCache.get(transliterationCode);

    if (t == null) {
        t = Transliterator.getInstance(transliterationCode);
        transliteratorCache.put(transliterationCode, t);
    }

    transliteratedText = t.transform(transliteratedText);

    transliteratedText = Normalizer.normalize(transliteratedText, Normalizer.Form.NFD)
        .replace(Char.UNDERSCORE, Char.MINUS).replace(Char.SPACE, Char.MINUS).replace(Char.COMMA, Char.MINUS)
        .replace(Char.DOT, Char.MINUS);

    Matcher m1 = slugifyReplacePattern1.matcher(transliteratedText);
    transliteratedText = m1.replaceAll(Str.EMPTY);

    Matcher m2 = slugifyReplacePattern2.matcher(transliteratedText);
    transliteratedText = m2.replaceAll(Str.EMPTY);

    Matcher m3 = slugifyReplacePattern3.matcher(transliteratedText);
    transliteratedText = m3.replaceAll(Str.MINUS);

    Matcher m4 = slugifyReplacePattern4.matcher(transliteratedText);
    transliteratedText = m4.replaceAll(Str.SPACE);

    return transliteratedText.toLowerCase();
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:42,代码来源:Strings.java

示例3: slugify2

import com.ibm.icu.text.Transliterator; //导入方法依赖的package包/类
public static String slugify2(String text, String transliterationCode) {
    if (Str.isEmpty(text))
        return text;

    if (transliterationCode == null) {
        transliterationCode = DEFAULT_TRANSLITERATION_CODE;
    }

    String transliteratedText = text.replace(ae, transliterateReplaceChars.get(ae))
        .replace(oe, transliterateReplaceChars.get(oe)).replace(ue, transliterateReplaceChars.get(ue))
        .replace(Ae, transliterateReplaceChars.get(Ae)).replace(Oe, transliterateReplaceChars.get(Oe))
        .replace(Ue, transliterateReplaceChars.get(Ue)).replace(ss, transliterateReplaceChars.get(ss))
        .replace(Str.AT, transliterateReplaceChars.get(Str.AT))
        .replace(Str.AMPERSAND, transliterateReplaceChars.get(Str.AMPERSAND));

    Transliterator t = transliteratorCache.get(transliterationCode);

    if (t == null) {
        t = Transliterator.getInstance(transliterationCode);
        transliteratorCache.put(transliterationCode, t);
    }

    transliteratedText = t.transform(transliteratedText);

    transliteratedText = Normalizer.normalize(transliteratedText, Normalizer.Form.NFD)
        .replace(Char.UNDERSCORE, Char.MINUS).replace(Char.SPACE, Char.UNDERSCORE)
        .replace(Char.COMMA, Char.MINUS).replace(Char.DOT, Char.MINUS);

    Matcher m1 = slugifyReplacePattern1.matcher(transliteratedText);
    transliteratedText = m1.replaceAll(Str.EMPTY);

    Matcher m2 = slugifyReplacePattern2.matcher(transliteratedText);
    transliteratedText = m2.replaceAll(Str.MINUS);

    Matcher m3 = slugifyReplacePattern3.matcher(transliteratedText);
    transliteratedText = m3.replaceAll(Str.MINUS);

    Matcher m4 = slugifyReplacePattern4.matcher(transliteratedText);
    transliteratedText = m4.replaceAll(Str.SPACE);

    return transliteratedText.toLowerCase();
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:43,代码来源:Strings.java


注:本文中的com.ibm.icu.text.Transliterator.transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。