/** * Sets the region. * * <p>See RFC 5646 section 2.2.4. * * @param region The region, as a two-letter ISO 3166-1 code or a three- * digit UN M.49 code. {@code null} if not defined. * * @throws LangTagException If the region syntax is invalid. */ public void setRegion(final String region) throws LangTagException { if (region == null) { this.region = null; return; } ensureMaxLength(region); if (! isRegion(region)) throw new LangTagException("Invalid region subtag: Must be a two-letter ISO 3166-1 code or a three-digit UN M.49 code"); this.region = region.toUpperCase(); }
if (pos < subtags.length && isRegion(subtags[pos])) langTag.setRegion(subtags[pos++]);