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


Java Normalizer.isNormalized方法代码示例

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


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

示例1: encode_UTF8

import java.text.Normalizer; //导入方法依赖的package包/类
/**
 * Encodes a string containing non ASCII characters using an UTF-8 encoder.
 * 
 * @param s
 *            The string the encode (assuming ASCII characters only)
 * @param e
 *            A character that does not require encoding if found in the
 *            string.
 */
private static String encode_UTF8(String s, char e) {
	// TODO: Normalizer requires Java 6!
	String n = (Normalizer.isNormalized(s, Form.NFKC)) ? s : Normalizer.normalize(s, Form.NFKC);
	// convert String to UTF-8
	ByteBuffer bb = UTF8.encode(n);
	// URI encode
	StringBuffer sb = new StringBuffer();

	while (bb.hasRemaining()) {
		int b = bb.get() & 0xff;

		if (isUnreserved(b) || b == e) {
			sb.append((char) b);
		} else {
			appendEscape(sb, (byte) b);
		}
	}
	return sb.toString();
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:29,代码来源:URICoder.java

示例2: minimalEncode_UTF8

import java.text.Normalizer; //导入方法依赖的package包/类
/**
 * Encodes a string containing non ASCII characters using an UTF-8 encoder.
 * 
 * @param s
 *            The string the encode (assuming ASCII characters only)
 */
private static String minimalEncode_UTF8(String s) {
	// TODO: Normalizer requires Java 6!
	String n = (Normalizer.isNormalized(s, Form.NFKC)) ? s : Normalizer.normalize(s, Form.NFKC);
	// convert String to UTF-8
	ByteBuffer bb = UTF8.encode(n);
	// URI encode
	StringBuffer sb = new StringBuffer();

	while (bb.hasRemaining()) {
		int b = bb.get() & 0xff;

		if (isLegal(b)) {
			sb.append((char) b);
		} else {
			appendEscape(sb, (byte) b);
		}
	}
	return sb.toString();
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:26,代码来源:URICoder.java

示例3: normalize

import java.text.Normalizer; //导入方法依赖的package包/类
/**
 * Normalize a String 
 * 
 * @param value the value to normalize
 * @return The normalized value
 */
public static String normalize( String value )
{
    if ( !Normalizer.isNormalized( value, Normalizer.Form.NFKC ) )
    {
        return Normalizer.normalize( value, Normalizer.Form.NFKC );
    }
    else
    {
        return value;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:18,代码来源:PrepareString.java

示例4: normalize

import java.text.Normalizer; //导入方法依赖的package包/类
public CharSequence normalize(final CharSequence name) {
    if(!Normalizer.isNormalized(name, Normalizer.Form.NFC)) {
        // Canonical decomposition followed by canonical composition (default)
        final String normalized = Normalizer.normalize(name, Normalizer.Form.NFC);
        if(log.isDebugEnabled()) {
            log.debug(String.format("Normalized string %s to %s", name, normalized));
        }
        return normalized;
    }
    return name;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:12,代码来源:NFCNormalizer.java

示例5: isNameCompatible

import java.text.Normalizer; //导入方法依赖的package包/类
@Override
public boolean isNameCompatible(String cn, JavaFileObject.Kind kind) {
    cn.getClass();
    // null check
    if (kind == Kind.OTHER && getKind() != kind) {
        return false;
    }
    String n = cn + kind.extension;
    if (name.equals(n)) {
        return true;
    }
    if (isMacOS && Normalizer.isNormalized(name, Normalizer.Form.NFD)
        && Normalizer.isNormalized(n, Normalizer.Form.NFC)) {
        // On Mac OS X it is quite possible to file name and class
        // name normalized in a different way - in that case we have to normalize file name
        // to the Normal Form Compised (NFC)
        String normName = Normalizer.normalize(name, Normalizer.Form.NFC);
        if (normName.equals(n)) {
            this.name = normName;
            return true;
        }
    }

        if (name.equalsIgnoreCase(n)) {
        try {
            // allow for Windows
            return file.getCanonicalFile().getName().equals(n);
        } catch (IOException e) {
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:RegularFileObject.java

示例6: isPathNameCompatible

import java.text.Normalizer; //导入方法依赖的package包/类
protected boolean isPathNameCompatible(Path p, String simpleName, Kind kind) {
    Objects.requireNonNull(simpleName);
    Objects.requireNonNull(kind);

    if (kind == Kind.OTHER && BaseFileManager.getKind(p) != kind) {
        return false;
    }

    String sn = simpleName + kind.extension;
    String pn = p.getFileName().toString();
    if (pn.equals(sn)) {
        return true;
    }

    if (p.getFileSystem() == defaultFileSystem) {
        if (isMacOS) {
            if (Normalizer.isNormalized(pn, Normalizer.Form.NFD)
                    && Normalizer.isNormalized(sn, Normalizer.Form.NFC)) {
                // On Mac OS X it is quite possible to have the file name and the
                // given simple name normalized in different ways.
                // In that case we have to normalize file name to the
                // Normal Form Composed (NFC).
                String normName = Normalizer.normalize(pn, Normalizer.Form.NFC);
                if (normName.equals(sn)) {
                    return true;
                }
            }
        }

        if (pn.equalsIgnoreCase(sn)) {
            try {
                // allow for Windows
                return p.toRealPath(LinkOption.NOFOLLOW_LINKS).getFileName().toString().equals(sn);
            } catch (IOException e) {
            }
        }
    }

    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:PathFileObject.java

示例7: checkAndLoadMain

import java.text.Normalizer; //导入方法依赖的package包/类
/**
 * This method does the following:
 * 1. gets the classname from a Jar's manifest, if necessary
 * 2. loads the class using the System ClassLoader
 * 3. ensures the availability and accessibility of the main method,
 *    using signatureDiagnostic method.
 *    a. does the class exist
 *    b. is there a main
 *    c. is the main public
 *    d. is the main static
 *    e. does the main take a String array for args
 * 4. if no main method and if the class extends FX Application, then call
 *    on FXHelper to determine the main class to launch
 * 5. and off we go......
 *
 * @param printToStderr if set, all output will be routed to stderr
 * @param mode LaunchMode as determined by the arguments passed on the
 * command line
 * @param what either the jar file to launch or the main class when using
 * LM_CLASS mode
 * @return the application's main class
 */
public static Class<?> checkAndLoadMain(boolean printToStderr,
                                        int mode,
                                        String what) {
    initOutput(printToStderr);
    // get the class name
    String cn = null;
    switch (mode) {
        case LM_CLASS:
            cn = what;
            break;
        case LM_JAR:
            cn = getMainClassFromJar(what);
            break;
        default:
            // should never happen
            throw new InternalError("" + mode + ": Unknown launch mode");
    }
    cn = cn.replace('/', '.');
    Class<?> mainClass = null;
    try {
        mainClass = scloader.loadClass(cn);
    } catch (NoClassDefFoundError | ClassNotFoundException cnfe) {
        if (System.getProperty("os.name", "").contains("OS X")
            && Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
            try {
                // On Mac OS X since all names with diacretic symbols are given as decomposed it
                // is possible that main class name comes incorrectly from the command line
                // and we have to re-compose it
                mainClass = scloader.loadClass(Normalizer.normalize(cn, Normalizer.Form.NFC));
            } catch (NoClassDefFoundError | ClassNotFoundException cnfe1) {
                abort(cnfe, "java.launcher.cls.error1", cn);
            }
        } else {
            abort(cnfe, "java.launcher.cls.error1", cn);
        }
    }
    // set to mainClass
    appClass = mainClass;

    /*
     * Check if FXHelper can launch it using the FX launcher. In an FX app,
     * the main class may or may not have a main method, so do this before
     * validating the main class.
     */
    if (mainClass.equals(FXHelper.class) ||
            FXHelper.doesExtendFXApplication(mainClass)) {
        // Will abort() if there are problems with the FX runtime
        FXHelper.setFXLaunchParameters(what, mode);
        return FXHelper.class;
    }

    validateMainClass(mainClass);
    return mainClass;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:77,代码来源:LauncherHelper.java

示例8: loadModuleMainClass

import java.text.Normalizer; //导入方法依赖的package包/类
/**
 * Returns the main class for a module. The query is either a module name
 * or module-name/main-class. For the former then the module's main class
 * is obtained from the module descriptor (MainClass attribute).
 */
private static Class<?> loadModuleMainClass(String what) {
    int i = what.indexOf('/');
    String mainModule;
    String mainClass;
    if (i == -1) {
        mainModule = what;
        mainClass = null;
    } else {
        mainModule = what.substring(0, i);
        mainClass = what.substring(i+1);
    }

    // main module is in the boot layer
    ModuleLayer layer = ModuleLayer.boot();
    Optional<Module> om = layer.findModule(mainModule);
    if (!om.isPresent()) {
        // should not happen
        throw new InternalError("Module " + mainModule + " not in boot Layer");
    }
    Module m = om.get();

    // get main class
    if (mainClass == null) {
        Optional<String> omc = m.getDescriptor().mainClass();
        if (!omc.isPresent()) {
            abort(null, "java.launcher.module.error1", mainModule);
        }
        mainClass = omc.get();
    }

    // load the class from the module
    Class<?> c = null;
    try {
        c = Class.forName(m, mainClass);
        if (c == null && System.getProperty("os.name", "").contains("OS X")
                && Normalizer.isNormalized(mainClass, Normalizer.Form.NFD)) {

            String cn = Normalizer.normalize(mainClass, Normalizer.Form.NFC);
            c = Class.forName(m, cn);
        }
    } catch (LinkageError le) {
        abort(null, "java.launcher.module.error3", mainClass, m.getName(),
                le.getClass().getName() + ": " + le.getLocalizedMessage());
    }
    if (c == null) {
        abort(null, "java.launcher.module.error2", mainClass, mainModule);
    }

    System.setProperty("jdk.module.main.class", c.getName());
    return c;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:57,代码来源:LauncherHelper.java

示例9: loadMainClass

import java.text.Normalizer; //导入方法依赖的package包/类
/**
 * Loads the main class from the class path (LM_CLASS or LM_JAR).
 */
private static Class<?> loadMainClass(int mode, String what) {
    // get the class name
    String cn;
    switch (mode) {
        case LM_CLASS:
            cn = what;
            break;
        case LM_JAR:
            cn = getMainClassFromJar(what);
            break;
        default:
            // should never happen
            throw new InternalError("" + mode + ": Unknown launch mode");
    }

    // load the main class
    cn = cn.replace('/', '.');
    Class<?> mainClass = null;
    ClassLoader scl = ClassLoader.getSystemClassLoader();
    try {
        try {
            mainClass = Class.forName(cn, false, scl);
        } catch (NoClassDefFoundError | ClassNotFoundException cnfe) {
            if (System.getProperty("os.name", "").contains("OS X")
                    && Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
                try {
                    // On Mac OS X since all names with diacritical marks are
                    // given as decomposed it is possible that main class name
                    // comes incorrectly from the command line and we have
                    // to re-compose it
                    String ncn = Normalizer.normalize(cn, Normalizer.Form.NFC);
                    mainClass = Class.forName(ncn, false, scl);
                } catch (NoClassDefFoundError | ClassNotFoundException cnfe1) {
                    abort(cnfe1, "java.launcher.cls.error1", cn,
                            cnfe1.getClass().getCanonicalName(), cnfe1.getMessage());
                }
            } else {
                abort(cnfe, "java.launcher.cls.error1", cn,
                        cnfe.getClass().getCanonicalName(), cnfe.getMessage());
            }
        }
    } catch (LinkageError le) {
        abort(le, "java.launcher.cls.error6", cn,
                le.getClass().getName() + ": " + le.getLocalizedMessage());
    }
    return mainClass;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:LauncherHelper.java


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