• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Unused Keys

 
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?
 
Marshal
Posts: 15570
263
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • 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
Marshal
Posts: 15570
263
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • 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?
 
Beware the other head of science - it bites! Nibble on this message:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic