TizianoCigerza / xmappr

Automatically exported from code.google.com/p/xmappr
0 stars 0 forks source link

Xmappr require 'getxxx' method for boolean field which should be 'isxxx' #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Define a boolean field in a Java bean
2. Annotate the boolean field with @Attribute
3. Run app with Xmappr

What version of the product are you using? On what operating system?
0.9.2(while 0.9.3 don't work at all)

Please provide any additional information below.
statck trace
org.xmappr.XmapprException: Could not find getter method for private field:
: org.hyk.sip.test.script.message.SendAction.getReliable()
    at org.xmappr.FieldAccessor.findAccessorMethod(FieldAccessor.java:84)
    at org.xmappr.FieldAccessor.<init>(FieldAccessor.java:26)
    at org.xmappr.mappers.AttributeMapper.<init>(AttributeMapper.java:29)
    at org.xmappr.MappingBuilder.processAttributes(MappingBuilder.java:475)
    at org.xmappr.MappingBuilder.createClassConverter(MappingBuilder.java:85)
    at org.xmappr.MappingContext.lookupElementConverter(MappingContext.java:162)
    at
org.xmappr.MappingBuilder.assignCollectionConverter(MappingBuilder.java:256)
    at org.xmappr.MappingBuilder.processElements(MappingBuilder.java:174)
    at org.xmappr.MappingBuilder.createClassConverter(MappingBuilder.java:89)
    at org.xmappr.MappingContext.lookupElementConverter(MappingContext.java:168)
    at org.xmappr.MappingBuilder.processConfiguration(MappingBuilder.java:37)
    at org.xmappr.MappingContext.addRootMapper(MappingContext.java:95)
    at org.xmappr.Xmappr.initialize(Xmappr.java:292)
    at org.xmappr.Xmappr.fromXML(Xmappr.java:129)
    at org.hyk.sip.test.HykSipUnitTestCase.proceed(HykSipUnitTestCase.java:75)
    at
org.hyk.sip.test.HykSipUnitTestCase.testSipMessage(HykSipUnitTestCase.java:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestR
eference.java:130)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:467)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:683)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java
:390)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav
a:197)
Caused by: java.lang.NoSuchMethodException:
org.hyk.sip.test.script.message.SendAction.getReliable()
    at java.lang.Class.getMethod(Unknown Source)
    at org.xmappr.FieldAccessor.findAccessorMethod(FieldAccessor.java:82)
    ... 33 more

Original issue reported on code.google.com by yinqiwen@gmail.com on 4 Mar 2010 at 1:08

GoogleCodeExporter commented 9 years ago
As of 0.9.3 the getter/setter handling has changed: getters/setters will not be 
any
more automatically mapped when annotations are used on private fields. In fact 
using
annotations on private fields is no longer supported.

Please see: http://code.google.com/p/xmappr/wiki/GettersSetters

in your case if a method name for example is "isReliable()" and the XML element 
name
is <reliable>, then you could do:

@Element("reliable")
public boolean isReliable();

Original comment by peter.kn...@gmail.com on 4 Mar 2010 at 2:34

GoogleCodeExporter commented 9 years ago
I have another question: why Xmappr require 'getter/setter' both? In most 
situation,
users just want to generate java bean from xml, it seems that there is no need 
to
annotate 'getter'(While JAXB don't have that restriction)

Original comment by yinqiwen@gmail.com on 5 Mar 2010 at 6:28

GoogleCodeExporter commented 9 years ago
Since 0.9.3, Xmappr does not require getters/setters any more for private 
fields. In
fact private fields are not supported any more.

You must now explicitly put annotations on methods.

Please see: http://code.google.com/p/xmappr/wiki/GettersSetters

Original comment by peter.kn...@gmail.com on 5 Mar 2010 at 7:08

GoogleCodeExporter commented 9 years ago

Original comment by peter.kn...@gmail.com on 5 Mar 2010 at 7:09