1 2 Previous Next 15 Replies Latest reply on Oct 31, 2005 11:25 AM by aloubyansky

    setNotValue

      There is a comment in the code (and an error message) about not supporting
      overriding property names of a simple type. It just supports a setValue()

      I tried to hack around the issue with a "null" convertor that takes a string
      and outputs the same string, but this just looks to have confused it,
      so there is probably more to it or I have found another problem? :-)

       <xsd:complexType name="beanType">
       <xsd:annotation>
       <xsd:appinfo>
       <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractBeanMetaData"/>
       </xsd:appinfo>
       </xsd:annotation>
       <xsd:sequence>
      ...
       <xsd:element name="supply" type="supplyType" minOccurs="0" maxOccurs="unbounded">
       <xsd:annotation>
       <xsd:appinfo>
       <jbxb:property name="supplies" collectionType="java.util.HashSet"/>
       </xsd:appinfo>
       </xsd:annotation>
       </xsd:element>
       </xsd:sequence>
      ...
       </xsd:complexType>
      
      
       <xsd:complexType name="supplyType">
       <xsd:annotation>
       <xsd:appinfo>
       <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractSupplyMetaData"/>
       <jbxb:characters>
       <jbxb:property name="supply"/>
       <jbxb:value unmarshalMethod="org.jboss.test.xml.pojoserver.metadata.StringDataTypeConverter.unmarshalStringValue"/>
       </jbxb:characters>
       </xsd:appinfo>
       </xsd:annotation>
       <xsd:simpleContent>
       <xsd:extension base="xsd:string"/>
       </xsd:simpleContent>
       </xsd:complexType>
      


      2005-10-25 18:10:26,781 TRACE [org.jboss.xb.binding.sunday.unmarshalling.ModelGroupBinding] startElement {urn:jboss:bean-deployer}supply in org.jboss.xb.binding.sunday
      .unmarshalling.SequenceBinding@15856a5, 10: {urn:jboss:bean-deployer}annotation {urn:jboss:bean-deployer}constructor {urn:jboss:bean-deployer}property {urn:jboss:bean-
      deployer}create {urn:jboss:bean-deployer}start {urn:jboss:bean-deployer}stop {urn:jboss:bean-deployer}destroy {urn:jboss:bean-deployer}depends {urn:jboss:bean-deployer
      }demand {urn:jboss:bean-deployer}supply ]
      2005-10-25 18:10:26,781 TRACE [org.jboss.xb.binding.sunday.unmarshalling.ModelGroupBinding] found {urn:jboss:bean-deployer}supply in org.jboss.xb.binding.sunday.unmars
      halling.SequenceBinding@15856a5
      2005-10-25 18:10:26,781 TRACE [org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler] pushed cursor org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding$
      1@1fd5e2
      2005-10-25 18:10:26,783 TRACE [org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler] pushed {urn:jboss:bean-deployer}supply=org.jboss.test.xml.pojoserver.met
      adata.AbstractSupplyMetaData@106fc94, binding=org.jboss.xb.binding.sunday.unmarshalling.ElementBinding@1b06041[{urn:jboss:bean-deployer}supply]
      2005-10-25 18:10:26,783 TRACE [org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler] poped {urn:jboss:bean-deployer}supply=org.jboss.xb.binding.sunday.unmars
      halling.ParticleBinding@7f5580
      
      !! This should be going into the HashSet on the AbstractBeanMetaData!!
      
      2005-10-25 18:10:26,784 WARN [org.jboss.xb.binding.sunday.unmarshalling.impl.runtime.RtUtil] Neither getter/setter nor field were found for field supplies in class or
      g.jboss.test.xml.pojoserver.metadata.AbstractSupplyMetaData
      


      I was a bit suspicous about this being the last element in a sequence,
      but that was just some bad debug logging. :-)

        • 1. Re: setNotValue

          It looks like an unhandled case in the characters handler?

          typeBinding.getCharacterMetaData().getProperty().getName() == "supply" - which is correct
          element.getPropertyMetaData().getName() == "supplies" - incorrect

          It takes the wrong path because type.isSimple() == true
          So it is trying to apply the characters directly into the HashSet?

          2005-10-25 19:03:31,492 DEBUG [org.jboss.xb.binding.sunday.unmarshalling.impl.runtime.RtCharactersHandler] supplies {urn:jboss:bean-deployer}supply
          2005-10-25 19:03:31,495 WARN [org.jboss.xb.binding.sunday.unmarshalling.impl.runtime.RtUtil] Neither getter/setter nor field were found for field supplies in class or
          g.jboss.test.xml.pojoserver.metadata.AbstractSupplyMetaData
          java.lang.NoSuchMethodException: org.jboss.test.xml.pojoserver.metadata.AbstractSupplyMetaData.isSupplies()
           at java.lang.Class.getMethod(Class.java:1581)
           at org.jboss.xb.binding.sunday.unmarshalling.impl.runtime.RtUtil.set(RtUtil.java:54)
           at org.jboss.xb.binding.sunday.unmarshalling.impl.runtime.RtCharactersHandler.setValue(RtCharactersHandler.java:201)
           at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.endElement(SundayContentHandler.java:488)
           at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.endElement(SundayContentHandler.java:109)
          


          • 2. Re: setNotValue

             

            "adrian@jboss.org" wrote:

            So it is trying to apply the characters directly into the HashSet?


            And fails because the stack is wrong.

            • 3. Re: setNotValue
              aloubyansky

              Right. If you cooment out jbxb:value, you will get an exception saying this case is not spported. I will work on a fix for this.

              • 4. Re: setNotValue

                Ok, I was actually just about to look at adding support for this case.
                I know it is supported through ObjectModel and SchemaBinding so it should just be
                a case of metadata?

                There is a separate issue of whether the simpleContent is handled correctly
                when there is a impl and data convertor?

                • 5. Re: setNotValue
                  aloubyansky

                   

                  "adrian@jboss.org" wrote:
                  Ok, I was actually just about to look at adding support for this case.


                  That's ok. If you do want then try (let me know in this case).

                  "adrian@jboss.org" wrote:
                  I know it is supported through ObjectModel and SchemaBinding so it should just be
                  a case of metadata?


                  Not sure what you mean by "supported in SchemaBinding" since it doesn't work. Yes, the metadata is there but is not used properly. I tried to fix it quickly but failed.

                  "adrian@jboss.org" wrote:
                  There is a separate issue of whether the simpleContent is handled correctly
                  when there is a impl and data convertor?


                  Right. The property in characters in your case is ignored and the one from the element's annotations is used.
                  In the current implementation it's also (partly) because of improper implementation of type.isSimple() (as you mentioned). Fixing which might also break other tests. That's why I wanted to spend more time on this.

                  • 6. Re: setNotValue

                     

                    "alex.loubyansky@jboss.com" wrote:

                    "adrian@jboss.org" wrote:
                    I know it is supported through ObjectModel and SchemaBinding so it should just be
                    a case of metadata?



                    I mean you can manually bind a character handler to deal with it.

                    • 7. Re: setNotValue
                      aloubyansky

                      Yes, right.

                      • 8. Re: setNotValue

                        This also works:

                         <xsd:appinfo>
                         <jbxb:characters>
                         <jbxb:value unmarshalMethod="org.jboss.test.xml.pojoserver.metadata.SupplyDatatypeConverter.unmarshalStringValue"/>
                         </jbxb:characters>
                         </xsd:appinfo>
                        



                        • 9. Re: setNotValue
                          aloubyansky

                          But then field 'supplies' is used instead of 'supply' to set the result on AbstractSupplyMetaData, isn't it?

                          • 10. Re: setNotValue

                            No. It uses the constructor and then adds it to the HashSet as "supplies".
                            There is no impl.

                            I don't think this solves the more general problem since I'd prefer to do everything
                            through annotations rather than writing a class just to set a simple property. :-)

                            • 11. Re: setNotValue

                              I'm also not sure how/whether this will work for demands which has an attribute:

                               <xsd:simpleContent>
                               <xsd:extension base="xsd:string">
                               <xsd:attribute name="whenRequired" type="controllerStateType" use="optional"/>
                               </xsd:extension>
                               </xsd:simpleContent>
                              


                              • 12. Re: setNotValue
                                aloubyansky

                                I have a fix for this problem. Can't connect to CVS currently, so, will commit in the evening.

                                • 13. Re: setNotValue
                                  aloubyansky

                                  Committed. The testcase is in the

                                  package org.jboss.test.xml;
                                  public class JbxbCharactersUnitTestCase

                                  • 14. Re: setNotValue

                                    The jaxb spec looks to be aiming to do this with
                                    javaType/xmlType mapping and parse/printMethod?

                                    There is also an XMLJavaTypeAdapter?

                                    1 2 Previous Next