dev@jsr311.java.net

Re: svn commit: r351 - trunk/src/jsr311-api/src/javax/ws/rs/core

From: Stephan Koops <Stephan.Koops_at_web.de>
Date: Wed, 04 Jun 2008 10:12:45 +0200

Hi Marc,

what about rename UriInfo.getConnegExtension() to getConnegExtensions(),
because it could be more than one (also the language)?
At least the javadoc should reflect, that their could be more than one
extension (use extensions instead of extension).

best regards
   Stephan

mhadley_at_dev.java.net schrieb:
> Author: mhadley
> Date: 2008-06-03 15:59:18+0000
> New Revision: 351
>
> Modified:
> trunk/src/jsr311-api/src/javax/ws/rs/core/UriBuilder.java
> trunk/src/jsr311-api/src/javax/ws/rs/core/UriInfo.java
>
> Log:
> Updated to support URIs following URI-based conneg preprocessing. UriBuilder#extension is now floating until build time rather than being tied to current final path segment at call time.
>
> Modified: trunk/src/jsr311-api/src/javax/ws/rs/core/UriBuilder.java
> Url: https://jsr311.dev.java.net/source/browse/jsr311/trunk/src/jsr311-api/src/javax/ws/rs/core/UriBuilder.java?view=diff&rev=351&p1=trunk/src/jsr311-api/src/javax/ws/rs/core/UriBuilder.java&p2=trunk/src/jsr311-api/src/javax/ws/rs/core/UriBuilder.java&r1=350&r2=351
> ==============================================================================
> --- trunk/src/jsr311-api/src/javax/ws/rs/core/UriBuilder.java (original)
> +++ trunk/src/jsr311-api/src/javax/ws/rs/core/UriBuilder.java 2008-06-03 15:59:18+0000
> @@ -320,18 +320,39 @@
> public abstract UriBuilder path(Method... methods) throws IllegalArgumentException;
>
> /**
> - * Set the extension of the current final path segment to the supplied value
> - * appending an initial "." if necessary. The extension is everything
> - * following the first "." in the current final path segment of the URI
> - * excluding any matrix parameters that might be present after the extension
> - * @param extension the extension, a null value will unset an existing
> - * extension including a trailing "." if necessary
> + * Set the extension that will be appended to the final path segment at
> + * build time. An initial "." will be appended if necessary. If the final
> + * path segment already contains an extension, it will be retained and the
> + * supplied extension will be appended to it as a new extension. E.g.:
> + *
> + * <ul>
> + * <li><code>UriBuilder.fromPath("foo").extension("bar").build()</code>
> + * returns "foo.bar".</li>
> + * <li><code>UriBuilder.fromPath("foo.baz").extension("bar").build()</code>
> + * returns "foo.baz.bar".</li>
> + * <li><code>UriBuilder.fromPath("foo").extension("bar").path(baz).build()</code>
> + * returns "foo/baz.bar".</li>
> + * </ul>
> + *
> + * <p>Note that the extension will be appended to the path component,
> + * matrix and query parameters will follow any appended extension.</p>
> + *
> + * @param extension the extension to append at build time, a null value
> + * will result in no extension being appended.
> * @return the updated UriBuilder
> - * @see UriInfo#getPathExtension
> */
> public abstract UriBuilder extension(String extension);
>
> /**
> + * Get the current value of the extension that will be appended to the
> + * final path segment at build time.
> + * @return the extension that will be appended to the final path segment at
> + * build time
> + * @see #extension(java.lang.String)
> + */
> + public abstract String getExtension();
> +
> + /**
> * Set the matrix parameters of the current final segment of the current URI path.
> * This method will overwrite any existing matrix parameters on the current final
> * segment of the current URI path. Note that the matrix parameters
>
> Modified: trunk/src/jsr311-api/src/javax/ws/rs/core/UriInfo.java
> Url: https://jsr311.dev.java.net/source/browse/jsr311/trunk/src/jsr311-api/src/javax/ws/rs/core/UriInfo.java?view=diff&rev=351&p1=trunk/src/jsr311-api/src/javax/ws/rs/core/UriInfo.java&p2=trunk/src/jsr311-api/src/javax/ws/rs/core/UriInfo.java&r1=350&r2=351
> ==============================================================================
> --- trunk/src/jsr311-api/src/javax/ws/rs/core/UriInfo.java (original)
> +++ trunk/src/jsr311-api/src/javax/ws/rs/core/UriInfo.java 2008-06-03 15:59:18+0000
> @@ -30,7 +30,16 @@
> * <p>All methods except {_at_link #getBaseUri} and
> * {_at_link #getBaseUriBuilder} throw <code>java.lang.IllegalStateException</code>
> * if called outside the scope of a request (e.g. from a provider constructor).</p>
> + *
> + * <p>Note that the URIs obtained from the methods of this interface provide
> + * access to request URIs after URI-based content negotiation preprocessing. E.g.
> + * if the request URI is "foo.xml" and {_at_link ApplicationConfig#getMediaTypeMappings()}
> + * includes a mapping for "xml", then {_at_link #getPath()} will return "foo", not
> + * "foo.xml". The removed "xml" extension is available via {_at_link #getConnegExtension}.</p>
> + *
> * @see Context
> + * @see ApplicationConfig#getLanguageMappings()
> + * @see ApplicationConfig#getMediaTypeMappings()
> */
> public interface UriInfo {
>
> @@ -94,29 +103,16 @@
> public URI getRequestUri();
>
> /**
> - * Get the absolute request URI in the form of a UriBuilder.
> + * Get the absolute request URI in the form of a UriBuilder. The returned
> + * builder will have its extension initialized with
> + * <code>extension(getConnegExtension())</code>.
> * @return a UriBuilder initialized with the absolute request URI
> * @throws java.lang.IllegalStateException if called outside the scope of a request
> + * @see UriBuilder#extension(java.lang.String)
> */
> public UriBuilder getRequestUriBuilder();
>
> /**
> - * Get the absolute platonic request URI in the form of a UriBuilder. The
> - * platonic request URI is the request URI minus any extensions that were
> - * removed during request pre-processing for the purposes of URI-based
> - * content negotiation. E.g. if the request URI was:
> - * <pre>http://example.com/resource.xml</pre>
> - * <p>and an applications implementation of
> - * {_at_link ApplicationConfig#getMediaTypeMappings} returned a map
> - * that included "xml" as a key then the platonic request URI would be:</p>
> - * <pre>http://example.com/resource</pre>
> - *
> - * @return a UriBuilder initialized with the absolute platonic request URI
> - * @throws java.lang.IllegalStateException if called outside the scope of a request
> - */
> - public UriBuilder getPlatonicRequestUriBuilder();
> -
> - /**
> * Get the absolute path of the request. This includes everything preceding
> * the path (host, port etc) but excludes query parameters and fragment.
> * This is a shortcut for
> @@ -128,10 +124,12 @@
>
> /**
> * Get the absolute path of the request in the form of a UriBuilder.
> - * This includes everything preceding
> - * the path (host, port etc) but excludes query parameters and fragment.
> + * This includes everything preceding the path (host, port etc) but excludes
> + * query parameters and fragment. The returned builder will have its
> + * extension initialized with <code>extension(getConnegExtension())</code>.
> * @return a UriBuilder initialized with the absolute path of the request
> * @throws java.lang.IllegalStateException if called outside the scope of a request
> + * @see UriBuilder#extension(java.lang.String)
> */
> public UriBuilder getAbsolutePathBuilder();
>
> @@ -143,25 +141,25 @@
> public URI getBaseUri();
>
> /**
> - * Get the base URI of the application in the form of a UriBuilder.
> + * Get the base URI of the application in the form of a UriBuilder. If
> + * called within the scope of a request, the builder will have its extension
> + * initialized with <code>extension(getConnegExtension())</code>.
> * @return a UriBuilder initialized with the base URI of the application.
> + * @see UriBuilder#extension(java.lang.String)
> */
> public UriBuilder getBaseUriBuilder();
>
> /**
> - * Get the request URI extension, this includes everything following the
> - * first "." in the final path segment of the URI excluding any matrix
> - * parameters that might be present after the extension). The returned
> - * string includes any extensions removed during request pre-processing for
> - * the purposes of URI-based content negotiation. E.g. if the request URI was:
> - * <pre>http://example.com/resource.xml.en</pre>
> - * <p>this method would return "xml.en" even if an applications
> - * implementation of
> - * {_at_link ApplicationConfig#getMediaTypeMappings} returned a map
> - * that included "xml" as a key
> - * @return the request URI extension or null if there isn't one
> + * Get the request URI extension that was removed during URI-based content
> + * negotiation preprocessing. The extension does not include the leading "."
> + * nor any matrix parameters that might be present after the extension.
> + * E.g. if the request URI is "foo.xml" and
> + * {_at_link ApplicationConfig#getMediaTypeMappings()} includes a mapping for
> + * "xml", then this method will return "xml".
> + * @return the URI extension that was removed during URI-based content
> + * negotiation preprocessing or null if nothing was removed
> */
> - public String getPathExtension();
> + public String getConnegExtension();
>
> /**
> * Get the values of any embedded URI template parameters.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commits-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: commits-help_at_jsr311.dev.java.net
>
>