users@jaxb.java.net

Problem with xs:element->xs:annotation->xs:documentation for a simple type

From: Sandy McP <sandy.mcpherson_at_xs4all.nl>
Date: Tue, 10 Mar 2009 03:24:56 -0700 (PDT)

Hi
I am using jaxb-xjc 2.1.9.

I am writing a plugin to get at the element documentation (the get method
javadoc). So that I can use this as a default title for GUI components in my
JSF pages. I have written a plugin to get the javadoc and write the method.

public class GetLabelSingleField extends SingleField {

        public GetLabelSingleField(ClassOutlineImpl context,
                        CPropertyInfo prop) {
                super(context, prop);
                GetLabelMethodHelper.writeLabelMethod(context, prop);
        }
}

public class GetLabelMethodHelper {
       public static void writeLabelMethod(ClassOutlineImpl context,
CPropertyInfo prop) {
                   String methodLabel = prop.getName(true);
                String label = prop.javadoc.isEmpty() ? methodLabel : prop.javadoc;
                System.out.println(label);
                      MethodWriter writer = context.createMethodWriter();
                      JMethod getLabel = writer.declareMethod(String.class
,"get"+methodLabel+"Label" );
                      getLabel.body().directStatement("return
\""+label+"\";");
         }


This works perfectly for the following schema fragment

<xs:element ref="SET:VESSDAT" minOccurs="0">
    <xs:annotation>
        <xs:documentation>Hello World</xs:documentation>
   </xs:annotation>
</xs:element>

giviing

       /**
         * Hello World
         *
         * @return
         * possible object is
         * {_at_link Vessdat }
         *
         */
        public Vessdat getVessdat() {
            return vessdat;
        }

        /**
         * Sets the value of the vessdat property.
         *
         * @param value
         * allowed object is
         * {_at_link Vessdat }
         *
         */
        public void setVessdat(Vessdat value) {
            this.vessdat = value;
        }

        public String getVessdatLabel() {
            return "Hello World";
        }


However I also have the following schema fragment.

<xs:element name="MINING_GEAR_AVAILABILITY" type="BT:BOOLEAN" minOccurs="0">
  <xs:annotation>
    <xs:documentation>AVAILABILITY OF MINING GEAR</xs:documentation>
  </xs:annotation>
</xs:element>


I would have thought "AVAILABILITY OF MINING GEAR" would turn up in the
prop.javadoc, but the value of javadoc is "".

Also the documentation is not appearing in the javadoc of the element getter

    /**
     * Gets the value of the miningGearAvailability property.
     *
     * @return
     * possible object is
     * {_at_link Boolean }
     *
     */
    public Boolean isMiningGearAvailability() {
        return miningGearAvailability;
    }

    public String getMiningGearAvailabilityLabel() {
        return "MiningGearAvailability";
    }


I ran without plugins to check what happens and the documentation is still
not turning up in the javadoc.


Anyone any ideas?


Sandy
-- 
View this message in context: http://www.nabble.com/Problem-with-xs%3Aelement-%3Exs%3Aannotation-%3Exs%3Adocumentation-for-a-simple-type-tp22431465p22431465.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.