public ChqPrepare(String bankId, String name, String amount, String chequeDate) throws TaskFailedException { // this.con=con; textBean = new ChqContent(); this.bankId = bankId; textBean.setRs(amount); textBean.setDate(chequeDate); textBean.setName1(name.toUpperCase()); textBean = getChqContent(); }
/** * @return ChqContent object * @throws TaskFailedException This Method reads the data to be printed on the cheque. based on * the length of the field data may be printed in single line devided to 2 lines . example * 'name' will be of two lines or 'amount in words' may be of two lines the return will be * ready to print contents of cheque with positions and modified data */ public ChqContent getChqContent() throws TaskFailedException { position = getChqPositions(bankId); StringBuffer sb = new StringBuffer(); StringBuffer sb1 = new StringBuffer(); String rupees = textBean.getRs(); textBean.amount1 = ntow.convertToWord(rupees); sb1.append(" "); int nocharpercm = 5; if ((int) position.amount1.l < textBean.amount1.length()) { int length = 0; StringTokenizer st = new StringTokenizer(textBean.amount1.toUpperCase()); while (st.hasMoreTokens()) { String s = st.nextToken(); length = length + s.length() + 1; if (length <= (int) position.amount1.l * nocharpercm) { sb.append(s); sb.append(" "); } else { sb1.append(s); sb1.append(" "); textBean.setAmount2(new String(sb1).toUpperCase()); } } textBean.setAmount1(new String(sb).toUpperCase()); // textBean.setAmount2(new String(sb1)); } StringBuffer nb = new StringBuffer(); StringBuffer nb1 = new StringBuffer(); nb1.append(" "); nocharpercm = 5; // Number of charcters printed per centimeter of cheque // this decides the data can be printed in single line or two lines if ((int) position.name1.l < textBean.name1.length()) { int length = 0; StringTokenizer st = new StringTokenizer(textBean.name1.toUpperCase()); while (st.hasMoreTokens()) { String s = st.nextToken(); length = length + s.length() + 1; if (length <= (int) position.name1.l * nocharpercm) { nb.append(s); nb.append(" "); } else { nb1.append(s); nb1.append(" "); textBean.setName2(new String(nb1).toUpperCase()); } } textBean.setName1(new String(nb).toUpperCase()); } return textBean; }