1 package com.instantbank.lettertemplate.imagesRepository.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 ImageTranslator
24 implements Serializable {
25
26 private String[] code;
27 private String[] name;
28 private int nlLength;
29
30 private Debug debug = null;
31
32
33
39 public void setData(HttpServletRequest request) {
40
41 debug = new Debug();
42 debug.setDebugginOn(true);
43 debug.setPreMessage("** ImageTranslator: ");
44
45 try {
46
47 CodeDescription[] cd = (CodeDescription[])
48 request.getAttribute(WebKeys.ImagesRepositoryList);
49 debug.println("images 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 getImagesArray() {
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