Hi All, I am using "Reflections API" for getting the contents of an Object. Thats fine.When going through the "getDeclaredFields" i get the list of the fields of the class whose object i am trying to read.
The issue is , one of the fields is "an Object of the class which i have created".. Now i need to read this object (get the details of the Class it respresents,it's parameters..etc) while at the same time ,i do not want to read other objects which are of type string ...
The only way I can see is either having a list of classes you want to inspect, or having a list of classes you want to ignore.
Joined: Jun 19, 2001
yes, we are listening. SOS. but we have daytime jobs too...
can your custom objects all extend from the same class ? or can you have them implement a interface (e.g. an empty marker interface ?) ? then you could check for the interface or parent class. like this you could avoid having the list.
Joined: Jul 29, 2003
Agreed Sir, Ofcourse we all have Jobs..some in the Day,others in the Night...(Actually Day is highly Over-rated...really doen't matter..anyways...)
So if i wish to check for the package level ,is there any method i can check against...can you post a patch of code..would be great...
What you should do is check the package of the class that you are inspecting. You should be able to put an if statement if your code checking to see if the package is your.allowable.package.names.here or some such.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Joined: Jul 29, 2003
Yes thats is possible..
But is it possible to differntiate between the Classes / objects provided by the Sun API and the one's developed by me.
Basically, Is it possible to just pass a object, and get the class details of that object and if that class has any object of any other customised class,i should be able to get the details of the class that this new object it represents..and on and on..
I understand ,i can hard code a bit (like use -- String.startsWith("package ")..)
but would like to make it as much as generic, so that it can figure on itself which one's are customized and which are from SUN api objects..