1 package com.instantbank.collections.creditInfo.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.XMLNode; 9 import oracle.xml.parser.v2.XMLParseException; 10 import oracle.xml.parser.v2.XSLException; 11 import org.xml.sax.SAXException; 12 import com.instantbank.collections.util.StringFormat; 13 14 public class AccountMaintenanceTransformer 15 implements Serializable { 16 private XMLDocument xml; 17 private XMLNode nAgreement; 18 private XMLNode nCollateral; 19 private XMLNode nMaintenance; 20 21 22 public String getAgrmCode() throws XSLException, Exception { 23 return nMaintenance.valueOf("/Maintenance/agrmcode"); 24 } 25 26 27 public String getAgrmId() throws XSLException, Exception { 28 return nMaintenance.valueOf("/Maintenance/agrmid"); 29 } 30 31 32 public String getCollId() throws XSLException, Exception { 33 return nCollateral.valueOf("./collid"); 34 } 35 36 37 public String getCurrentPrice() throws XSLException, Exception { 38 return nCollateral.valueOf("./currentprice"); 39 } 40 41 42 public String getMake() throws XSLException, Exception { 43 return StringFormat.toSafeJavaString(nCollateral.valueOf("./make")); 44 } 45 46 47 public String getMiscAlert() throws XSLException, Exception { 48 return StringFormat.toSafeJavaString(nAgreement.valueOf("./miscalert")); 49 } 50 51 52 public String getModel() throws XSLException, Exception { 53 return StringFormat.toSafeJavaString(nCollateral.valueOf("./model")); 54 } 55 56 57 public String getNewOrUsed() throws XSLException, Exception { 58 return nCollateral.valueOf("./neworused"); 59 } 60 61 62 public String getOldAccount() throws XSLException, Exception { 63 return StringFormat.toSafeJavaString(nAgreement.valueOf("./oldaccount")); 64 } 65 66 67 public String getOriginalPrice() throws XSLException, Exception { 68 return nCollateral.valueOf("./originalprice"); 69 } 70 71 72 public String getReviewTimeH() throws XSLException, Exception { 73 String cadena = " "; 74 75 cadena = StringFormat.toSafeJavaString(nAgreement.valueOf("./permanentreviewtime")); 76 if(cadena.length() < 5) { 77 return cadena; 78 } 79 else { 80 return cadena.substring(0, 2); 81 } 82 } 83 84 85 public String getReviewTimeM() throws XSLException, Exception { 86 String cadena = " "; 87 88 cadena = StringFormat.toSafeJavaString(nAgreement.valueOf("./permanentreviewtime")); 89 if(cadena.length() < 5) { 90 return cadena; 91 } 92 else { 93 return cadena.substring(3, 5); 94 } 95 } 96 97 98 public String getReviewTimeb() throws XSLException, Exception { 99 String cadena = " "; 100 cadena = StringFormat.toSafeJavaString(nAgreement.valueOf("./permanentreviewtime")); 101 if(cadena.length() < 7) { 102 return " "; 103 } 104 else { 105 return cadena.substring(5, 7); 106 } 107 } 108 109 110 public String getType() throws XSLException, Exception { 111 return nCollateral.valueOf("./type"); 112 } 113 114 115 public String getVehiId() throws XSLException, Exception { 116 return nCollateral.valueOf("./vehiid"); 117 } 118 119 120 public String getVin() throws XSLException, Exception { 121 return StringFormat.toSafeJavaString(nCollateral.valueOf("./vin")); 122 } 123 124 125 public String getYear() throws XSLException, Exception { 126 return nCollateral.valueOf("./year"); 127 } 128 129 130 public XMLDocument parseInfo(String data) throws XMLParseException, XSLException, SAXException, IOException { 131 DOMParser docParser = new DOMParser(); 132 ByteArrayInputStream stream; 133 XMLDocument xmlDoc = null; 134 try { 135 stream = new ByteArrayInputStream(data.getBytes()); 136 docParser.setValidationMode(false); 137 docParser.parse(stream); 138 xmlDoc = docParser.getDocument(); 139 } 140 catch(Exception e) { 141 } 142 return xmlDoc; 143 } 144 145 146 public void setData(String data) throws XMLParseException, XSLException, SAXException, IOException { 147 xml = parseInfo(data); 148 try { 149 nMaintenance = (XMLNode)(xml.getElementsByTagName("Maintenance").item(0).getFirstChild()); 150 nCollateral = (XMLNode)(xml.getElementsByTagName("CollateralsList").item(0).getFirstChild()); 151 nAgreement = (XMLNode)(xml.getElementsByTagName("AgreementDetailsList").item(0).getFirstChild()); 152 } 153 catch(Exception e) { 154 } 155 } 156 } 157