Resolve issue 42. Switch from string to locale in http headers and variant. add locale methods in response.
svn path=/trunk/; revision=371
diff --git a/src/jsr311-api/src/javax/ws/rs/core/HttpHeaders.java b/src/jsr311-api/src/javax/ws/rs/core/HttpHeaders.java
index 7cad38f..7976190 100644
--- a/src/jsr311-api/src/javax/ws/rs/core/HttpHeaders.java
+++ b/src/jsr311-api/src/javax/ws/rs/core/HttpHeaders.java
@@ -19,6 +19,7 @@
package javax.ws.rs.core;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
/**
@@ -58,7 +59,7 @@
* @return a read-only list of acceptable languages
* @throws java.lang.IllegalStateException if called outside the scope of a request
*/
- public List<String> getAcceptableLanguages();
+ public List<Locale> getAcceptableLanguages();
/**
* Get the media type of the request entity
@@ -72,7 +73,7 @@
* @return the language of the entity or null if not specified
* @throws java.lang.IllegalStateException if called outside the scope of a request
*/
- public String getLanguage();
+ public Locale getLanguage();
/**
* Get any cookies that accompanied the request.
diff --git a/src/jsr311-api/src/javax/ws/rs/core/Response.java b/src/jsr311-api/src/javax/ws/rs/core/Response.java
index 0b1af52..2ab8c3d 100644
--- a/src/jsr311-api/src/javax/ws/rs/core/Response.java
+++ b/src/jsr311-api/src/javax/ws/rs/core/Response.java
@@ -22,6 +22,7 @@
import java.net.URI;
import java.util.Date;
import java.util.List;
+import java.util.Locale;
import javax.ws.rs.ext.RuntimeDelegate;
/**
@@ -307,8 +308,12 @@
* return Response.created(widgetId).build();
* }</pre>
*
- * Several methods have parameters of type URI, {@link UriBuilder} provides
- * convenient methods to create such values as does <code>URI.create()</code>.
+ * <p>Several methods have parameters of type URI, {@link UriBuilder} provides
+ * convenient methods to create such values as does <code>URI.create()</code>.</p>
+ *
+ * <p>Where multiple variants of the same method are provided, the type of
+ * the supplied parameter is retained in the metadata of the built
+ * {@code Response}.</p>
*
*/
public static abstract class ResponseBuilder {
@@ -419,6 +424,15 @@
public abstract ResponseBuilder language(String language);
/**
+ * Set the language on the ResponseBuilder.
+ *
+ *
+ * @param language the language of the response entity
+ * @return the updated ResponseBuilder
+ */
+ public abstract ResponseBuilder language(Locale language);
+
+ /**
* Set the location on the ResponseBuilder.
*
* @param location the location. If a relative URI is
diff --git a/src/jsr311-api/src/javax/ws/rs/core/Variant.java b/src/jsr311-api/src/javax/ws/rs/core/Variant.java
index ab83509..a1785b2 100644
--- a/src/jsr311-api/src/javax/ws/rs/core/Variant.java
+++ b/src/jsr311-api/src/javax/ws/rs/core/Variant.java
@@ -21,6 +21,7 @@
import java.io.StringWriter;
import java.util.List;
+import java.util.Locale;
import javax.ws.rs.ext.RuntimeDelegate;
/**
@@ -28,7 +29,7 @@
*/
public class Variant {
- private String language;
+ private Locale language;
private MediaType mediaType;
private String encoding;
@@ -38,7 +39,7 @@
* @param language the language of the variant - may be null
* @param encoding the content encoding of the variant - may be null
*/
- public Variant(MediaType mediaType, String language, String encoding) {
+ public Variant(MediaType mediaType, Locale language, String encoding) {
this.encoding = encoding;
this.language = language;
this.mediaType = mediaType;
@@ -48,7 +49,7 @@
* Get the language of the variant
* @return the language or null if none set
*/
- public String getLanguage() {
+ public Locale getLanguage() {
return language;
}
@@ -114,7 +115,7 @@
w.append("Variant[mediaType=");
w.append(mediaType==null ? "null" : mediaType.toString());
w.append(", language=");
- w.append(language==null ? "null" : language);
+ w.append(language==null ? "null" : language.toString());
w.append(", encoding=");
w.append(encoding==null ? "null" : encoding);
w.append("]");
@@ -168,7 +169,7 @@
* @param languages the available languages
* @return the updated builder
*/
- public abstract VariantListBuilder languages(String... languages);
+ public abstract VariantListBuilder languages(Locale... languages);
/**
* Set the encoding[s] for this variant.