[java-support] branch master updated: Remove questionable xml:lang to Locale converter.
Scott Cantor
cantor.2 at osu.edu
Wed Jun 5 19:34:53 EDT 2019
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-support.
View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=7a0d509df89076bdc9ada956112adc4ecdcbfae0
The following commit(s) were added to refs/heads/master by this push:
new 7a0d509 Remove questionable xml:lang to Locale converter.
7a0d509 is described below
commit 7a0d509df89076bdc9ada956112adc4ecdcbfae0
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jun 5 19:34:47 2019 -0400
Remove questionable xml:lang to Locale converter.
---
.../java/support/xml/AttributeSupport.java | 26 ----------------------
.../java/support/xml/AttributeSupportTest.java | 17 --------------
2 files changed, 43 deletions(-)
diff --git a/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java b/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java
index 0899ea9..946e949 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/xml/AttributeSupport.java
@@ -21,7 +21,6 @@ import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
import java.util.List;
-import java.util.Locale;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -440,31 +439,6 @@ public final class AttributeSupport {
}
/**
- * Gets the locale currently active for the element. This is done by looking for an xml:lang attribute and parsing
- * its content. If no xml:lang attribute is present the default locale is returned. This method only uses the
- * language primary tag, as defined by RFC3066.
- *
- * @param element element to retrieve local information for
- *
- * @return the active local of the element
- */
- @Nullable public static Locale getXMLLangAsLocale(@Nullable final Element element) {
- if (element == null) {
- return null;
- }
-
- String lang = StringSupport.trimOrNull(getXMLLang(element));
- if (lang != null) {
- if (lang.contains("-")) {
- lang = lang.substring(0, lang.indexOf("-"));
- }
- return new Locale(lang.toUpperCase());
- } else {
- return Locale.getDefault();
- }
- }
-
- /**
* Gets the <code>xml:space</code> attribute from a given Element.
*
* @param element the element from which to extract the attribute
diff --git a/src/test/java/net/shibboleth/utilities/java/support/xml/AttributeSupportTest.java b/src/test/java/net/shibboleth/utilities/java/support/xml/AttributeSupportTest.java
index 54c79bb..e8b0f30 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/xml/AttributeSupportTest.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/xml/AttributeSupportTest.java
@@ -23,7 +23,6 @@ import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.List;
-import java.util.Locale;
import javax.annotation.Nonnull;
import javax.xml.namespace.QName;
@@ -263,22 +262,6 @@ public class AttributeSupportTest {
Assert.assertEquals(AttributeSupport.getXMLLang(goodBaseIdSpaceLang), "fr-ca", "xml:lang mismatch");
Assert.assertNull(AttributeSupport.getXMLLang(noBaseIdSpaceLang), "xml:lang found erroneously");
- Locale locale = AttributeSupport.getXMLLangAsLocale(goodBaseIdSpaceLang);
-
- // Assert.assertEquals(locale.getCountry(), "ca", "getXMLLangAsLocale test (country)");
- Assert.assertEquals(locale.getLanguage(), "fr", "getXMLLangAsLocale test (country)");
-
- Locale current = Locale.getDefault();
- Locale testLocale = new Locale("en", "gb");
-
- try {
- Locale.setDefault(testLocale);
- Assert.assertEquals(AttributeSupport.getXMLLangAsLocale(noBaseIdSpaceLang), testLocale,
- "Defaulting behavior of getXMLLangAsLocale");
- } finally {
- Locale.setDefault(current);
- }
-
// test Add
boolean thrown = false;
try {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list