Connecting Tech Pros Worldwide Forums | Help | Site Map

Reusable lookup tables

Ronald Verbeek
Guest
 
Posts: n/a
#1: Jun 26 '07
I have to deal with several lookup tables like for example:
Quality SpecificWeight Hardness TearStrength

So I would create a Quality Class to store the values for a single
record.

I know it would be possible to use a HashMap<String, Qualityand fill it
with the appropriate data. All examples I find use the main method for
this.

However I need to reuse the same lookup tables for different
applications. So my idea is to put this lookup tables in a library jar
file that can be shared by this applications.

What is the best approach?

Regards,

Ronald.

Robert Larsen
Guest
 
Posts: n/a
#2: Jun 27 '07

re: Reusable lookup tables


Ronald Verbeek wrote:
Quote:
What is the best approach?
>
Regards,
>
Ronald.
That depends. How does a Quality object look like ?
You could probably use a property file instead of hardcoding the table.

java.util.Property can read its content using an InputStream.

Best,
Robert
Ronald Verbeek
Guest
 
Posts: n/a
#3: Jun 28 '07

re: Reusable lookup tables


Op Wed, 27 Jun 2007 09:55:14 +0200, schreef Robert Larsen:
Quote:
Ronald Verbeek wrote:
Quote:
>What is the best approach?
>>
>Regards,
>>
>Ronald.
That depends. How does a Quality object look like ? You could probably
use a property file instead of hardcoding the table.
>
java.util.Property can read its content using an InputStream.
>
Best,
Robert
Typical data lookup objects like the Quality object have a String key and
several double values and sometimes String values and the appropriate get
methods to retrieve the values.

I already found that it is possible and workable to use a static
initializer block to initialize the HashMap or TreeMap (I want some
lookups sorted for use in a JComboBox). But if someone can suggest a
better approach it is still much appreciated.

Regards,

Ronald.

Closed Thread