Java Code Examples for sun.util.locale.ParseStatus#isError()

The following examples show how to use sun.util.locale.ParseStatus#isError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommonUtil.java    From singleton with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * validate that an argument is a well-formed BCP 47 tag
 *
 * @param languageTag
 * @return true if the format is fine
 */
public static boolean isLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        return false;
    }
    return true;
}
 
Example 2
Source File: LocaleUtils.java    From singleton with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * validate that an argument is a well-formed BCP 47 tag
 * 
 * @param languageTag
 * @return true if the format is fine
 */
public static boolean isLanguageTag(String languageTag) {
	ParseStatus sts = new ParseStatus();
	LanguageTag.parse(languageTag, sts);
	if (sts.isError()) {
		return false;
	}
	return true;
}
 
Example 3
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 4
Source File: Locale.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 5
Source File: Locale.java    From jdk-1.7-annotated with Apache License 2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 6
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 7
Source File: Locale.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 8
Source File: Locale.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 9
Source File: Locale.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 10
Source File: Locale.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 11
Source File: Locale.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 12
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 13
Source File: Locale.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 14
Source File: Locale.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike {@code Locale.forLanguageTag}, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if {@code languageTag} is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 15
Source File: Locale.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 16
Source File: Locale.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 17
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 18
Source File: Locale.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 19
Source File: Locale.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}
 
Example 20
Source File: Locale.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Resets the Builder to match the provided IETF BCP 47
 * language tag.  Discards the existing state.  Null and the
 * empty string cause the builder to be reset, like {@link
 * #clear}.  Grandfathered tags (see {@link
 * Locale#forLanguageTag}) are converted to their canonical
 * form before being processed.  Otherwise, the language tag
 * must be well-formed (see {@link Locale}) or an exception is
 * thrown (unlike <code>Locale.forLanguageTag</code>, which
 * just discards ill-formed and following portions of the
 * tag).
 *
 * @param languageTag the language tag
 * @return This builder.
 * @throws IllformedLocaleException if <code>languageTag</code> is ill-formed
 * @see Locale#forLanguageTag(String)
 */
public Builder setLanguageTag(String languageTag) {
    ParseStatus sts = new ParseStatus();
    LanguageTag tag = LanguageTag.parse(languageTag, sts);
    if (sts.isError()) {
        throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
    }
    localeBuilder.setLanguageTag(tag);
    return this;
}