6 Replies Latest reply on Jun 22, 2005 9:19 AM by dimitris

    Mapping comments?

    dimitris

      Wouldn't it make sense to be able to map also the comments from an xml file to a POJO model, as well? (and the reverse)

      From a deployment point of view, this would allow reading, modifiying and writing back an existing descriptor (e.g. xxx-service.xml) without destroying completely it's content (alhtough its formating for sure).

        • 1. Re: Mapping comments?
          starksm64

          Without javadoc annotations (which are scheduled for java6), I don't see how this can be done in general as we have no requirement for source code creation. I don't see that the current jaxb2.0 spec (Early Draft 2
          Tuesday, March 15, 2005) has any annotation for this purpose either. Perhaps that is something that could be suggested via an email to spec-comments@jsr222.dev.java.net

          • 2. Re: Mapping comments?
            aloubyansky

            I think, Dimitris meant to bind comments from XML content to, e.g., Java fields, not to Java comments.

            • 3. Re: Mapping comments?
              dimitris

              Yes, just a simple mapping of xml comments to fields. If this could be optionally mapped to annotations, thats fine.

              • 4. Re: Mapping comments?
                starksm64

                I guess I don't understand the difference between mapping to a java field and a java comment. Are you saying there should be treatment of comments as text to map onto an object the same as a text element?

                The problem is how is there a meaningful indexing of the comments to the java objects?

                • 5. Re: Mapping comments?
                  aloubyansky

                   

                  "Scott" wrote:
                  Are you saying there should be treatment of comments as text to map onto an object the same as a text element?


                  Yes.

                  "Scott" wrote:
                  The problem is how is there a meaningful indexing of the comments to the java objects?


                  I don't know any rule for that. But there are use-cases, e.g. if there is no element 'description' the text could appear in comments instead and be bound to a field 'description' in a class.

                  • 6. Re: Mapping comments?
                    dimitris

                    I was thinking of a simple binding that would let you get/set the comments before the beggining of an element (and after the end of the previous element).

                     ...
                     </prev-element>
                    
                     <!-- comment1 -->
                     <!-- comment2 -->
                     <element1>
                     ...
                     </element1>
                    
                    


                    public class PojoForElement1
                    {
                     String[] getComments()
                     void setComments(String[])
                     ...
                    }