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 CustomerRolesTransformer 14 implements Serializable { 15 private String[] code; 16 private String[] description; 17 private String[] screenType; 18 private String[] allowMultiple; 19 private NodeList nlCode; 20 private NodeList nlDescription; 21 private NodeList nlScreenType; 22 private NodeList nlAllowMultiple; 23 private int nlLength; 24 private String prData; 25 26 27 public String getAllowMultiple(int i) { 28 return allowMultiple[i]; 29 } 30 31 32 public String getCode(int i) { 33 return code[i]; 34 } 35 36 37 public String getDescription(int i) { 38 return description[i]; 39 } 40 41 42 public long getNumberOfRoles() { 43 return nlLength; 44 } 45 46 47 public String getScreenType(int i) { 48 return screenType[i]; 49 } 50 51 52 public void setData(String data) throws XMLParseException, XSLException, SAXException, IOException { 53 DOMParser docParser = new DOMParser(); 54 ByteArrayInputStream stream; 55 XMLDocument xmlDoc = null; 56 try { 57 prData = data; 58 stream = new ByteArrayInputStream(data.getBytes()); 59 docParser.setValidationMode(false); 60 docParser.parse(stream); 61 xmlDoc = docParser.getDocument(); 62 nlCode = xmlDoc.selectNodes("/CustomerRolesList/CustomerRole/code/text()"); 63 nlDescription = xmlDoc.selectNodes("/CustomerRolesList/CustomerRole/description/text()"); 64 nlScreenType = xmlDoc.selectNodes("/CustomerRolesList/CustomerRole/screentype/text()"); 65 nlAllowMultiple = xmlDoc.selectNodes("/CustomerRolesList/CustomerRole/allowmultiple/text()"); 66 nlLength = nlCode.getLength(); 67 code = new String[nlLength]; 68 description = new String[nlLength]; 69 screenType = new String[nlLength]; 70 allowMultiple = new String[nlLength]; 71 for(int i = 0; i < nlLength; i++) { 72 code[i] = nlCode.item(i).getNodeValue(); 73 description[i] = nlDescription.item(i).getNodeValue(); 74 screenType[i] = nlScreenType.item(i).getNodeValue(); 75 allowMultiple[i] = nlAllowMultiple.item(i).getNodeValue(); 76 } 77 } 78 catch(Exception e) {} 79 } 80 } 81