afpdev / alpheusafpparser

Library & parser for IBM Advanced Function Presentation (AFP) document/print stream format
GNU General Public License v3.0
16 stars 11 forks source link

UtilReflection.getFieldValue buggy? #13

Closed michaelknigge closed 8 years ago

michaelknigge commented 8 years ago

The method UtilReflection.getFieldValue() tries (as a "fallback" try) to get the field value by calling a getter method. I guess this part of the function is (more or less) useless, because (if I got things right) your field names always begin with a lower case letter, but the getters are in camel case.

so for a field "name" (like in StructuredFieldBaseName) you would try to call a getter "getname" - which of couse does not exist because the letter after the "get" is always upper case.

Are there corner cases I've missed? If not, I would recommend removing this obsolete part.

bye, michael

afpdev commented 8 years ago

the search for the getter method is case insensitive:

String methodName = "get" + field.getName();
(...)
if (methodName.equalsIgnoreCase(method.getName())) {

So, unless we have more than one method with a similar name (eg. getname, getName, and getNAME) we should be fine. Can you agree with that?

michaelknigge commented 8 years ago

Aaaarrrggghhhh, sorry.... you are right.... Shame on me, I've missed the "equalsIgnoreCase" :-(