1 package com.instantbank.collections.basicInfo.web;
2
3 import java.io.ByteArrayInputStream;
4 import java.io.IOException;
5 import java.io.Serializable;
6 import oracle.xml.parser.v2.DOMParser;
7 import oracle.xml.parser.v2.XMLDocument;
8 import oracle.xml.parser.v2.XMLParseException;
9 import oracle.xml.parser.v2.XSLException;
10 import org.w3c.dom.NodeList;
11 import org.xml.sax.SAXException;
12
13 public class AddressTypesTransformer
14 implements Serializable {
15 private String[] code;
16 private String[] description;
17 private NodeList nlCode;
18 private NodeList nlDescription;
19 private int nlLength;
20 private String prData;
21
22
23 public String getCode(int i) {
24 return code[i];
25 }
26
27
28 public String getDescription(int i) {
29 return description[i];
30 }
31
32
33 public long getNumberOfTypes() {
34 return nlLength;
35 }
36
37
38 public void setData(String data) throws XMLParseException, XSLException, SAXException, IOException {
39 DOMParser docParser = new DOMParser();
40 ByteArrayInputStream stream;
41 XMLDocument xmlDoc = null;
42 try {
43 prData = data;
44 stream = new ByteArrayInputStream(data.getBytes());
45 docParser.setValidationMode(false);
46 docParser.parse(stream);
47 xmlDoc = docParser.getDocument();
48 nlCode = xmlDoc.selectNodes("/AddressTypesList/AddressType/code/text()");
49 nlDescription = xmlDoc.selectNodes("/AddressTypesList/AddressType/description/text()");
50 nlLength = nlCode.getLength();
51 code = new String[nlLength];
52 description = new String[nlLength];
53 for(int i = 0; i < nlLength; i++) {
54 code[i] = nlCode.item(i).getNodeValue();
55 description[i] = nlDescription.item(i).getNodeValue();
56 }
57 }
58 catch(Exception e) {}
59 }
60 }
61