Can you examine a java class for defined literals?


This may sound a little crazy, but I’ll give it a try. We have a java
swing app that is multilingual. To do this, each button, title, etc has
a translation to occur similar to the way rails does it with a
name/value pair. The name being a tag in the user dictionary to the
value to use. A tag is defined for a particular component and is
compiled as part of the java class. Now the good part is these tags
follow defined patterns like SomeDictionary.TITLE or
<java.classname-of-the-internalframe>.TTILE for say the title of the
frame. Is there a way to get these out of the java class using jruby?
Or, am I nuts going down this path? This way we can help ourselves and
user to translate the given frame by listing all the translation “tags”
of a given frame.

Just curious if this is even possible by loading the class in jruby or
maybe even examining the class file itself. I know using a command line
tool like grep or vim I can see the literal in the compiled code, but I
like to get these in a list. I tried in jirb to do
FrameClass.constants. But, these constants are not defined in say this
class but in imported classes.



Do you know how you would accomplish this in plain old Java? Or could
post an example of your Java source code? I’m having a hard time
what your code would look like.

The basic answer would be that anything you can accomplish with Java you
do via JRuby.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs