Path: blob/master/src/java.base/share/classes/sun/text/Normalizer.java
41152 views
/*1* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.text;2627import jdk.internal.icu.lang.UCharacter;28import jdk.internal.icu.text.NormalizerBase;2930/**31* This Normalizer is for Unicode 3.2 support for IDNA only.32* Developers should not use this class.33*34* @since 1.635*/36public final class Normalizer {3738private Normalizer() {};3940/**41* Option to select Unicode 3.2 (without corrigendum 4 corrections) for42* normalization.43*/44public static final int UNICODE_3_2 = NormalizerBase.UNICODE_3_2_0_ORIGINAL;4546/**47* Normalize a sequence of char values.48* The sequence will be normalized according to the specified normalization49* from.50* @param src The sequence of char values to normalize.51* @param form The normalization form; one of52* {@link java.text.Normalizer.Form#NFC},53* {@link java.text.Normalizer.Form#NFD},54* {@link java.text.Normalizer.Form#NFKC},55* {@link java.text.Normalizer.Form#NFKD}56* @param option The normalization option;57* {@link sun.text.Normalizer#UNICODE_3_2}58* @return The normalized String59* @throws NullPointerException If <code>src</code> or <code>form</code>60* is null.61*/62public static String normalize(CharSequence src,63java.text.Normalizer.Form form,64int option) {65return NormalizerBase.normalize(src.toString(), form, option);66};6768/**69* Determines if the given sequence of char values is normalized.70* @param src The sequence of char values to be checked.71* @param form The normalization form; one of72* {@link java.text.Normalizer.Form#NFC},73* {@link java.text.Normalizer.Form#NFD},74* {@link java.text.Normalizer.Form#NFKC},75* {@link java.text.Normalizer.Form#NFKD}76* @param option The normalization option;77* {@link sun.text.Normalizer#UNICODE_3_2}78* @return true if the sequence of char values is normalized;79* false otherwise.80* @throws NullPointerException If <code>src</code> or <code>form</code>81* is null.82*/83public static boolean isNormalized(CharSequence src,84java.text.Normalizer.Form form,85int option) {86return NormalizerBase.isNormalized(src.toString(), form, option);87}8889/**90* Returns the combining class of the given character91* @param ch character to retrieve combining class of92* @return combining class of the given character93*/94public static final int getCombiningClass(int ch) {95return UCharacter.getCombiningClass(ch);96}97}9899100