This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unused Keys  RSS feed

 
Sharadraj Caliamourthy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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?
 
Junilu Lacar
Sheriff
Posts: 10948
158
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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: 10948
158
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!