1    package com.instantbank.servicing.parmLevel1Values.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   
17   /**
18    *  Parameter Level1 Values usecase: helper class for ParmLevel1ValuesMain.jsp
19    *
20    * @author Instant-bank (Jorge Cardenas)
21    * @created September 2002
22    */
23   public class ParmLevel1ValuesTranslator
24       implements Serializable {
25   
26     // input data for the jsp: elements of paramater level 1 values
27     private String[] code;
28     private String[] name;
29     private int nlLength;
30   
31     private Debug debug = null;
32   
33   
34     /**
35      *  gets parameter level 1 value from request and creates input data for the jsp
36      *  setting values of code and name Strings
37      *
38      * @param request of MainServlet
39      */
40     public void setData(HttpServletRequest request) {
41   
42       debug = new Debug();
43       debug.setDebugginOn(true);
44       debug.setPreMessage("** ParmLevel1ValuesTranslator: ");
45   
46       try {
47         CodeDescription[] cd = (CodeDescription[])
48           request.getAttribute(WebKeys.ParmLevel1ValuesList);
49         debug.println("parameter level1 values obtained");
50         nlLength = cd.length;
51         code = new String[nlLength];
52         name = new String[nlLength];
53   
54         for(int i = 0; i < nlLength; i++) {
55           code[i] = String.valueOf(cd[i].getCode());
56           name[i] = cd[i].getDescription();
57         }
58       }
59       catch(Exception e) {
60         debug.println("Exception unexpected:" + e.getMessage());
61       }
62     }
63   
64   
65     /**
66      *  extends the onLoad() javaScript method initializing itemsArrays according
67      *  to input data of the jsp
68      *
69      * @return String to append to onLoad()
70      */
71     public String getParmLevel1ValuesArray() {
72       String Head = null;
73       String Body = null;
74       char Ch = '"';
75   
76       Head = "numberOfItems = " + nlLength + "; \n" +
77         "numberOfDeleted=0;\n";
78       Body = "";
79       for(int i = 0; i < nlLength; i++) {
80         Body = Body +
81           "itemsArray[" + i + "] = new Item("
82           + Ch + code[i] + Ch + ","
83           + Ch + name[i] + Ch + ","
84           + Ch + "N" + Ch +
85         // status "N" means "not modified"
86           ");\n";
87       }
88       //debug.println ("Body="+ Body);
89       return (Head + Body);
90     }
91   }
92   
93