1    package com.instantbank.servicing.setParameterXValue.web;
2    
3    import java.io.*;
4    import java.net.*;
5    import java.util.*;
6    import javax.naming.*;
7    import javax.rmi.*;
8    import javax.servlet.http.HttpServletRequest;
9    
10   import oracle.xml.parser.v2.*;
11   import org.w3c.dom.*;
12   import org.xml.sax.*;
13   import com.instantbank.servicing.control.util.WebKeys;
14   import com.instantbank.common.utilcomponents.CodeDescription;
15   import com.instantbank.common.utilcomponents.Debug;
16   import com.instantbank.component.parameter.util.*;
17   
18   /**
19    *  Set Parameter Values usecase: helper class for setParameterXValueMain.jsp
20    *
21    * @author Instant-bank (Jorge Cardenas)
22    * @created October 2002
23    */
24   public class SetParameterXValueTranslator
25       implements Serializable {
26   
27     // input data for the jsp: elements of ser paramater values
28     private ArrayList point1;
29     private ArrayList point2;
30     private String[] valuePoint1;
31     private String[] valuePoint2;
32     private int point1Length;
33     private int point2Length;
34   
35     private Debug debug = null;
36   
37   
38     /**
39      *  gets parameter values from request and creates input data for the jsp
40      *  setting values are two itemsArray.
41      *
42      * @param request of MainServlet
43      */
44     public void setData(HttpServletRequest request) {
45   
46       debug = new Debug();
47       debug.setDebugginOn(true);
48       debug.setPreMessage("** SetParameterXValueTranslator: ");
49   
50       try {
51         ParameterModel parm = (ParameterModel)
52           request.getAttribute(WebKeys.SetParameterXValueList);
53   
54         point1 = parm.getLevel1Point();
55         point2 = parm.getLevel2Point();
56   
57         point1Length = point1.size();
58         point2Length = point2.size();
59   
60         debug.println("parameter values obtained");
61   
62         valuePoint1 = new String[point1Length];
63         valuePoint2 = new String[point2Length];
64   
65         for(int i = 0; i < point1Length; i++) {
66           valuePoint1[i] = (String)point1.get(i);
67         }
68   
69         for(int i = 0; i < point2Length; i++) {
70           valuePoint2[i] = (String)point2.get(i);
71         }
72       }
73       catch(Exception e) {
74         debug.println("Exception unexpected:" + e.getMessage());
75       }
76     }
77   
78   
79     /**
80      *  extends the onLoad() javaScript method initializing itemsArrayPoint1 according
81      *  to input data of the jsp
82      *
83      * @return String to append to onLoad()
84      */
85     public String getPoint1Array() {
86       String Head = null;
87       String Body = null;
88       char Ch = '"';
89   
90       Head = "numberOfItemsPoint1 = " + point1Length + "; \n";
91       Body = "";
92       for(int i = 0; i < point1Length; i++) {
93         Body = Body +
94           "itemsArrayPoint1[" + i
95           + "] = new ItemPoint1("
96           + Ch + valuePoint1[i] + Ch +
97           ");\n";
98       }
99       return (Head + Body);
100    }
101  
102  
103    /**
104     *  extends the onLoad() javaScript method initializing itemsArrayPoint2 according
105     *  to input data of the jsp
106     *
107     * @return String to append to onLoad()
108     */
109    public String getPoint2Array() {
110      String Head = null;
111      String Body = null;
112      char Ch = '"';
113  
114      Head = "numberOfItemsPoint2 = " + point2Length + "; \n";
115      Body = "";
116      for(int i = 0; i < point2Length; i++) {
117        Body = Body +
118          "itemsArrayPoint2[" + i
119          + "] = new ItemPoint2("
120          + Ch + valuePoint2[i] + Ch +
121          ");\n";
122      }
123      return (Head + Body);
124    }
125  
126  }
127  
128