1 package com.instantbank.lettertemplate.categories.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.lettertemplate.control.util.WebKeys;
14 import com.instantbank.common.utilcomponents.CodeDescription;
15 import com.instantbank.common.utilcomponents.Debug;
16
17
23 public class CategoryTranslator
24 implements Serializable {
25
26
27 private String[] code;
28 private String[] name;
29 private int nlLength;
30
31 private Debug debug = null;
32
33
34
40 public void setData(HttpServletRequest request) {
41
42 debug = new Debug();
43 debug.setDebugginOn(true);
44 debug.setPreMessage("** CategoryTranslator: ");
45
46 try {
47 CodeDescription[] cd = (CodeDescription[])
48 request.getAttribute(WebKeys.CategoryList);
49 debug.println("categories list 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
71 public String getCategoriesArray() {
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
86 ");\n";
87 }
88
89 return (Head + Body);
90 }
91 }
92
93