/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*******************************************************************************
* Copyright (C) 2009-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
public final class InternalLocaleBuilder {
public InternalLocaleBuilder() {
}
this.language = "";
} else {
}
}
return this;
}
this.script = "";
} else {
}
}
return this;
}
this.region = "";
} else {
}
}
return this;
}
this.variant = "";
} else {
// normalize separators to "_"
if (errIdx != -1) {
}
}
return this;
}
public InternalLocaleBuilder addUnicodeLocaleAttribute(String attribute) throws LocaleSyntaxException {
}
// Use case insensitive string to prevent duplication
if (uattributes == null) {
}
return this;
}
public InternalLocaleBuilder removeUnicodeLocaleAttribute(String attribute) throws LocaleSyntaxException {
}
if (uattributes != null) {
}
return this;
}
public InternalLocaleBuilder setUnicodeLocaleKeyword(String key, String type) throws LocaleSyntaxException {
}
// null type is used for remove the key
}
} else {
// normalize separator to "-"
// validate
if (!UnicodeLocaleExtension.isTypeSubtag(s)) {
throw new LocaleSyntaxException("Ill-formed Unicode locale keyword type: "
+ type,
itr.currentStart());
}
}
}
}
}
return this;
}
public InternalLocaleBuilder setExtension(char singleton, String value) throws LocaleSyntaxException {
// validate key
}
if (remove) {
// clear entire Unicode locale extension
if (uattributes != null) {
uattributes.clear();
}
}
} else {
}
}
} else {
// validate value
boolean validSubtag;
if (isBcpPrivateuse) {
} else {
}
if (!validSubtag) {
throw new LocaleSyntaxException("Ill-formed extension value: " + s,
itr.currentStart());
}
}
} else {
if (extensions == null) {
}
}
}
return this;
}
/*
*/
return this;
}
int parsed = 0;
int start;
// Make a list of extension subtags
if (LanguageTag.isExtensionSingleton(s)) {
if (LanguageTag.isExtensionSubtag(s)) {
} else {
break;
}
}
start);
}
if (extensions == null) {
}
} else {
break;
}
}
if (LanguageTag.isPrivateusePrefix(s)) {
if (!LanguageTag.isPrivateuseSubtag(s)) {
break;
}
}
throw new LocaleSyntaxException("Incomplete privateuse:"
start);
} else {
}
}
}
throw new LocaleSyntaxException("Ill-formed extension subtags:"
itr.currentStart());
}
}
/*
* Set a list of BCP47 extensions and private use subtags
* BCP47 extensions are already validated and well-formed, but may contain duplicates
*/
// ignore duplicates
// each extension string contains singleton, e.g. "a-abc-def"
} else {
if (extensions == null) {
}
}
}
}
}
// privateuse string contains prefix, e.g. "x-abc-def"
if (extensions == null) {
}
}
return this;
}
/*
* Reset Builder's internal state with the given language tag
*/
clear();
} else {
}
}
if (!bcpVariants.isEmpty()) {
for (int i = 1; i < size; i++) {
}
}
return this;
}
public InternalLocaleBuilder setLocale(BaseLocale base, LocaleExtensions localeExtensions) throws LocaleSyntaxException {
// Special backward compatibility support
// Exception 1 - ja_JP_JP
// When locale ja_JP_JP is created, ca-japanese is always there.
// The builder ignores the variant "JP"
variant = "";
}
// Exception 2 - th_TH_TH
// When locale th_TH_TH is created, nu-thai is always there.
// The builder ignores the variant "TH"
variant = "";
}
// Exception 3 - no_NO_NY
// no_NO_NY is a valid locale and used by Java 6 or older versions.
// The build ignores the variant "NY" and change the language to "nn".
language = "nn";
variant = "";
}
// Validate base locale fields before updating internal state.
// LocaleExtensions always store validated/canonicalized values,
// so no checks are necessary.
}
}
}
if (errIdx != -1) {
}
}
// The input locale is validated at this point.
// Now, updating builder's internal fields.
// map localeExtensions back to builder's internal format
if (e instanceof UnicodeLocaleExtension) {
if (uattributes == null) {
}
}
}
}
} else {
if (extensions == null) {
}
}
}
}
return this;
}
language = "";
script = "";
region = "";
variant = "";
return this;
}
if (extensions != null) {
extensions.clear();
}
if (uattributes != null) {
uattributes.clear();
}
}
return this;
}
// Special private use subtag sequence identified by "lvariant" will be
// interpreted as Java variant.
if (extensions != null) {
boolean sawPrefix = false;
int privVarStart = -1;
if (sawPrefix) {
break;
}
sawPrefix = true;
}
}
if (privVarStart != -1) {
}
BaseLocale.SEP));
}
}
}
}
return null;
}
}
/*
* Remove special private use subtag sequence identified by "lvariant"
* and return the rest. Only used by LocaleExtensions
*/
// Note: privateuse value "abc-lvariant" is unchanged
// because no subtags after "lvariant".
int prefixStart = -1;
boolean sawPrivuseVar = false;
if (prefixStart != -1) {
// Note: privateuse value "abc-lvariant" is unchanged
// because no subtags after "lvariant".
sawPrivuseVar = true;
break;
}
}
}
if (!sawPrivuseVar) {
return privuseVal;
}
}
/*
* Check if the given variant subtags separated by the given
* separator(s) are valid
*/
if (!LanguageTag.isVariant(s)) {
return itr.currentStart();
}
}
return -1;
}
/*
* Private methods parsing Unicode Locale Extension subtags.
* Duplicated attributes/keywords will be ignored.
* The input must be a valid extension subtags (excluding singleton).
*/
// wipe out existing attributes/keywords
if (uattributes != null) {
uattributes.clear();
}
}
// parse attributes
break;
}
if (uattributes == null) {
}
}
// parse keywords
int typeStart = -1;
int typeEnd = -1;
// next keyword - emit previous one
}
// reset keyword info
} else {
if (typeStart == -1) {
}
}
// 1. first keyword or
// 2. next keyword, but previous one was duplicate
// duplicate
}
}
// last keyword
}
}
break;
}
}
}
static final class CaseInsensitiveString {
str = s;
}
return str;
}
public int hashCode() {
}
if (this == obj) {
return true;
}
if (!(obj instanceof CaseInsensitiveString)) {
return false;
}
}
}
static final class CaseInsensitiveChar {
/**
* Constructs a CaseInsensitiveChar with the first char of the
* given s.
*/
this(s.charAt(0));
}
CaseInsensitiveChar(char c) {
ch = c;
}
public char value() {
return ch;
}
public int hashCode() {
return lowerCh;
}
if (this == obj) {
return true;
}
if (!(obj instanceof CaseInsensitiveChar)) {
return false;
}
}
}
}