9

Is there a handy-dandy equivalent to org.apache.commons.beanutils.PropertyUtils on Android?

I can't seem to use bean utils in my android app due to some dependencies on PropertyDescriptor,and IndexedPropertyDescriptor. So I'm wondering if there are any alternatives?

Basically all I want to do is use a method name as a string "someMethod" and feed that into setMethod(anObject, "someMethod", value), much like PropertyUtils does; but without having to resort to the nasties of reflection...

Or are my hands tied and I need to use Reflection?

skaffman
  • 398,947
  • 96
  • 818
  • 769
user830914
  • 568
  • 5
  • 9
  • Hey did you ever find a solution to this problem? The answer below provides some info, but it'd be great to know if you found a full blown way of doing key/value coding on Android. – Gowiem Aug 14 '13 at 20:11

2 Answers2

10

There is bridge library which works on Android: android-java-air-bridge.jar. Just include into project path and use all apache beanutils features in your Android project as you could use in ordinary java application. Moreover, there are lot of other classes which moved to this Android supporting library. Look at the list.

Valery Viktorovsky
  • 6,487
  • 3
  • 39
  • 47
Robertas Setkus
  • 3,075
  • 6
  • 31
  • 54
1

There is a possibilty to use libraries or write own code depending on the PropertyUtils. But it sure isn't dandy. You can get the general idea about what has to be done in this thread.

There are apparently some projects who have successfully solved the issue, so you can study thier solution. Take a look at Drawingpad-base and libgdx. You can find PropertyUtils in the package com.madrobot.beans in the first project and com.badlogic.gdx.beans in the second.

kostja
  • 60,521
  • 48
  • 179
  • 224