If it is possible (as in, you're allowed to change the code), change those constants into an enum
. That way, you can easily code a "reverse lookup" function by having a value associated with each enum entry.
In theory, if you have each entry representing a number from 0..N, you could even use the number of the entry (it's given by the enum), but this isn't exactly a best-practice.
Since you cannot use an enum, you can hack it through reflection (warning, it's fugly).
Accessing Java static final ivar value through reflection
This thread has some code that accesses the public static final
values with reflection. You can use a Map to store this relationship, look it up in real time, or try and encapsulate this in an Enum, like Jon Skeet suggested, and use that enum from then on (with all the advantages that brings).