dev@jersey.java.net

RE: [Jersey] WebDAV "Depth" header and enum <was> Re: Developer role

From: Markus KARG <markus.karg_at_gmx.net>
Date: Sat, 10 Jan 2009 15:36:07 +0100

Paul,

 

thank you for your comments.

 

I wonder how to code an enum that has a value of "0"? Any idea?

 

For your last sentence, I just did not understand what you like to tell me.
Can you rephrase that?

 

Thanks

Markus

 

 

 

From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
Sent: Freitag, 9. Januar 2009 14:53
To: Markus KARG
Cc: dev_at_jersey.dev.java.net
Subject: [Jersey] WebDAV "Depth" header and enum <was> Re: Developer role

 

 

On Dec 30, 2008, at 7:13 PM, Markus KARG wrote:

I currently have defined header constants like "Depth", as defined by the
WebDAV spec. I have seen that some of them are defined in the WebDAV spec to
be actually not Strings but enums, i. e. for example, the WebDAV "Depth"
header must only be one of the Strings "0", "1" or "infinity". So to prevent
people from incidentially using "2", "3" or "infinte" as an invalid header
value, it would be great to make that particular header not a String but an
enum. Is that possible in JAX-RS? For example, can I use an enum in a method
as a @HeaderParam variable?

 

IIRC it is possible to use Enum classes, i recommend experimenting with a
simple class.

 





Like:

 

@PROPFIND

public MultiStatus propfind(@HeaderParam final DepthEnum depth)

 

   @HeaderParam("Depth")

 





 

Will Jersey be able to parse the header value "0" to inject Depth.ZERO here?

 

If "0" is the value of the enum constant then i think yes.

 





 

If possible, then I will overhaul the code once more before committing it,
since it is so much easier to work with enums. :-)

 

Is Depth associated with all forms of WebDAV method or with particular
methods.

 

The reason i ask is that you might be able to combine the request entity
with headers without your own special type and message body reader (as they
are also capable of getting request header information).

 

Paul.