D:\Hany\HalalFarms\HalalCentersHaulersJavaProject\HalalCentersHauler\src\java\utils\PropertyManager.java |
1
2
3
4
5
6 package utils;
7
8 import java.util.Properties;
9 import java.util.ResourceBundle;
10 import java.util.*;
11 import constants.*;
12
13 import java.util.Properties;
14 import java.io.*;
15
16
17
18 @author
19
20 public class PropertyManager
21 {
22 private static ResourceBundle resourceBundleHandle;
23
24 public static String getParameter( String parameterName )
25 {
26 if(resourceBundleHandle == null )
27
28 resourceBundleHandle = ResourceBundle.getBundle( "xx.properties");
29
30
31 return resourceBundleHandle.getString( parameterName );
32 }
33
34
35
36 public static void main (String[] args)
37 {
38 System.out.println( "sam = " + PropertyManager.getParameter("sam"));
39 int joe = 01;
40 }
41
42
43
44 public static Hashtable<String, Integer> getStaticNameID_HashTable(String propertiesFileName)
45 {
46 Hashtable<String, Integer> processNameID_HashTable = new Hashtable<String, Integer>();
47 Properties properties = new Properties();
48 try
49 {
50 properties.load(new FileInputStream(propertiesFileName));
51
52 for(String key : properties.stringPropertyNames())
53 {
54 String value = properties.getProperty(key);
55 Integer tempInteger = new Integer(value);
56 processNameID_HashTable.put(key, tempInteger);
57
58 }
59
60 }
61 catch(Exception eException)
62 {
63 System.out.println("Failed to read from " + " file.");
64 eException.printStackTrace();
65 return(null);
66 }
67 return(processNameID_HashTable);
68 }
69
70
71
72 public static Hashtable<String, String> getDynamicNameKey_HashTable(String propertiesFileName)
73 {
74 Hashtable<String, String> processNameID_HashTable = new Hashtable<String, String>();
75 Properties properties = new Properties();
76 try
77 {
78 properties.load(new FileInputStream(propertiesFileName));
79
80 for(String processName : properties.stringPropertyNames())
81 {
82 String value = properties.getProperty(processName);
83 processNameID_HashTable.put(processName, value);
84
85 }
86 }
87 catch(Exception eException)
88 {
89 System.out.println("Failed to read from " + " file.");
90 eException.printStackTrace();
91 return(null);
92 }
93 return(processNameID_HashTable);
94 }
95
96 }
97
98