KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > engines > EngineParams


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

13 //
14
// EngineParams
15
// EV 03.12.2000
16
//
17
// getParameter( key )
18
//
19
//
20

21 package org.jahia.engines;
22
23 import java.util.Hashtable JavaDoc;
24
25
26 public class EngineParams {
27
28     public static final String JavaDoc PARAM_TOKEN = "���";
29     public static final String JavaDoc VALUE_TOKEN = "***";
30
31     /**
32      * @associates String
33      */

34     private Hashtable JavaDoc theParams = new Hashtable JavaDoc ();
35
36
37     /**
38      * constructor EV 03.12.2000
39      */

40     public EngineParams (String JavaDoc paramStr) {
41         decomposeParams (paramStr);
42     } // end constructor
43

44
45     /**
46      * decomposeParams EV 03.12.2000
47      */

48     private void decomposeParams (String JavaDoc tempStr) {
49         if (tempStr != null) {
50             String JavaDoc paramStr = tempStr;
51             int startpos = paramStr.indexOf (VALUE_TOKEN);
52             int endpos = -1;
53             while (startpos != -1) {
54                 endpos = paramStr.indexOf (PARAM_TOKEN);
55                 if (endpos == -1) {
56                     endpos = paramStr.length ();
57                 }
58                 String JavaDoc keyStr = paramStr.substring (0, startpos);
59                 String JavaDoc valStr = paramStr.substring (startpos + VALUE_TOKEN.length (), endpos);
60                 if ((keyStr != "") && (valStr != "")) {
61                     theParams.put (keyStr, valStr);
62                 }
63                 paramStr = paramStr.substring (endpos, paramStr.length ());
64                 startpos = paramStr.indexOf (VALUE_TOKEN);
65             }
66         }
67     } // end decomposeParams
68

69
70     /**
71      * getParameter EV 03.12.2000
72      */

73     public String JavaDoc getParameter (String JavaDoc keyStr) {
74         return (String JavaDoc) theParams.get (keyStr);
75     } // end getParams
76

77
78 } // end EngineParams
Popular Tags