0

Hi Folks,
So the problem im having is trying to make some code less clunky. I recieve a list of random codes in the form of an Enumeration. I then retrieve a number of codes i read in from a properties file going from most important at the top to least important at the bottom. I want to read in my enumerations and check them against the properties list and retrieve the highest ranking code.

Any ideas?

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by JamesCherrill
0
for (Enumeration codes = application.getCodes() ; codes.hasMoreElements();){
Object object =  codes.nextElement();
			    		
    if (object instanceof SomeObject) {
	SomeObject someObject = (SomeObject)object;
	if (someObject.getCode().equals(propertyCode1) ) {
	     response.setCode(propertyCode1)
	     break;
	}
}
}

This is the code so far. I use this again for each "propertyCode*" as long as the "response" is null.
Im trying to make it more efficeient

0

Don't try to write all this in one go. Break it down to tiny steps that you can test and fix before moving on. Eg start with a program that that reads the codes and prints them out. Test that until it's working because there's no point trying to use the codes it they haven't been read properly.
ps code tags use <> not []

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.