KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > util > NameUpdater


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/util/NameUpdater.java,v 1.5 2004/02/14 03:34:30 sebb Exp $
2
/*
3  * Copyright 2003-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 /*
20  * Created on Jun 13, 2003
21  */

22 package org.apache.jmeter.util;
23
24 import java.io.FileInputStream JavaDoc;
25 import java.util.Properties JavaDoc;
26
27 import org.apache.jorphan.logging.LoggingManager;
28 import org.apache.log.Logger;
29
30 /**
31  * @author ano ano
32  * @version $Revision: 1.5 $
33  */

34 public final class NameUpdater
35 {
36     private static Properties JavaDoc nameMap;
37     private static Logger log = LoggingManager.getLoggerForClass();
38     
39     static {
40         nameMap = new Properties JavaDoc();
41         try
42         {
43             nameMap.load(
44                 new FileInputStream JavaDoc(
45                     JMeterUtils.getJMeterHome()
46                         + JMeterUtils.getPropDefault(
47                             "upgrade_properties",
48                             "/bin/upgrade.properties")));
49         }
50         catch (Exception JavaDoc e)
51         {
52             log.error("Bad upgrade file",e);
53         }
54     }
55     
56     public static String JavaDoc getCurrentName(String JavaDoc className)
57     {
58         if (nameMap.containsKey(className))
59         {
60             String JavaDoc newName= nameMap.getProperty(className);
61             log.info("Upgrading class "+className+" to "+newName);
62             return newName;
63         }
64         return className;
65     }
66
67     public static String JavaDoc getCurrentName(String JavaDoc propertyName, String JavaDoc className)
68     {
69         String JavaDoc key= className+"/"+propertyName;
70         if (nameMap.containsKey(key))
71         {
72             String JavaDoc newName= nameMap.getProperty(key);
73             log.info("Upgrading property "+propertyName+" to "+newName);
74             return newName;
75         }
76         return propertyName;
77     }
78
79     public static String JavaDoc getCurrentName(String JavaDoc value, String JavaDoc propertyName, String JavaDoc className)
80     {
81         String JavaDoc key= className+"."+propertyName+"/"+value;
82         if (nameMap.containsKey(key))
83         {
84             String JavaDoc newValue= nameMap.getProperty(key);
85             log.info("Upgrading value "+value+" to "+newValue);
86             return newValue;
87         }
88         return value;
89     }
90
91     /**
92      * Private constructor to prevent instantiation.
93      */

94     private NameUpdater()
95     {
96     }
97 }
98
Popular Tags