• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unused Keys

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a java file,How to retrieve unused keys in this java file present in properties file using ruby program?
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, if I understand you correctly, you have a .java source file, a .properties file with some key/value pairs, and you want to search through the .java source file to see if there are keys in the .properties file that were not used? And you want to write a program in Ruby to do this?

Will you only be considering literal references to the keys? What if the keys are dynamically created, like so:

This would mean that the keys "s1", "s2", "s3", etc. are being used in this code.

You could have code that looks like:

Did you want to count references that are in comments in the .java source file? Did you only want to find matches of literals passed to the getProperty(key) method or do you also want to consider variables that can have a valid key value? What about constants that have key values?

Did you want to account for these usages, too? As you can see, there are many different variations you may need to account for.
 
Sharadraj Caliamourthy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Junilu,
Thanks for your response..You are correct, i have a .java source file, a .properties file with some key/value pairs. My key value pairs are only static.I dont need to count references that are in comments in the .java source file and want to consider variables that can have a valid key value.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suppose you could start with a simple text search or use regex matching on your .java file. What have you tried so far?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic