Forums Register Login

Load an object runtime

+Pie Number of slices to send: Send

Hello Guys,

I have a small doubt.
Is there anyway to get an object on runtime.

Something like this:
I have a class say Employee and has following properties name, addrees, id

Now i have an object of Employee but I have to get one of the property depending on certain conditon.

So it may be emp.getName() or emp.getID on runtime.

How do I achieve this?


Regards,
Amit
+Pie Number of slices to send: Send
 

King Amit wrote:
Hello Guys,

I have a small doubt.
Is there anyway to get an object on runtime.



That's the only way to get an object.

Something like this:
I have a class say Employee and has following properties name, addrees, id

Now i have an object of Employee but I have to get one of the property depending on certain conditon.

So it may be emp.getName() or emp.getID on runtime.

How do I achieve this?



It's hard to say without more details. Depending on your specific requirements and use cases, it might be as simple as


Or it might be that you'll want to use reflection or JavaBeans property introspection to get a property based on its name that isn't known until runtime.
+Pie Number of slices to send: Send
No its not that simple actually.

There are hundred of properties and too multilevel.

I have to use these properties to be compared for their values depending upon what property user selects at runtime.

so it may be emp.getName.getLastName
or if he chooses country's zip code
it would be emp.getCountry.getState.getZipCode()

+Pie Number of slices to send: Send
Well, again, there's not much detail to go on, but based on what you've said, it sounds like a candidate for reflection or introspection.
+Pie Number of slices to send: Send
Are we talking about Java objects serialized somewhere that you want to read in and query?

It is really very simple if serialized objects are stored in a Serializable collection.

Bill
What are you doing? You are supposed to be reading this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 516 times.
Similar Threads
EJB3 org.hibernate.LazyInitializationException:failed to lazily initialize a collection of role
Passing Set<java.lang.Object> and List<java.lang.Object> in Axis 2.0
java:12: cannot find symbol
Doubt in Mapping Associations
Custom Search With ArrayList
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:27:06.