aspose file tools*
The moose likes Beginning Java and the fly likes reflexion and enum Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "reflexion and enum" Watch "reflexion and enum" New topic
Author

reflexion and enum

mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 250
hi

i use this code



getGlass return an enum

is there a way to do that with reflexion?

thanks
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

is there a way to do that with reflexion?


Not sure what you are asking. Can you elaborate? enums are just objects, so the reflection library should work for them too.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 250
this line of code is in a class X who extends Y



this class Y have



Glass is an enum

so my question is how to be able to do the same thing then



but with reflexion?

i tried



but i'm not able to access the field (tickness)

any idea?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

mark smith wrote:
but i'm not able to access the field (tickness)

any idea?


Try...




BTW, if you know the exact method to execute, and the exact field to get, why do you need reflection? The way you are doing it now is much easier than using reflection.

Henry
mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 250
thanks Henry Wong that work...

the method can change... not the field...
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

mark smith wrote:thanks Henry Wong that work...

the method can change... not the field...


If the field doesn't change, then there is no reason to use reflection to get it... you can simply cast and dereference it.



Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reflexion and enum