@Override
    public void generate(HashMap<String, String> sepaParams, OutputStream os, boolean validate) throws Exception {
        Integer maxIndex = SepaUtil.maxIndex(sepaParams);

        //Document
        Document doc = new Document();

        //Pain00100102
        doc.setPain00100102(new Pain00100102());

        doc.getPain00100102().setGrpHdr(new GroupHeaderSCT());

        String batch = SepaUtil.getProperty(sepaParams, "batchbook", null);
        if (batch != null)
            doc.getPain00100102().getGrpHdr().setBtchBookg(batch.equals("1"));

        final String sepaId = sepaParams.get("sepaid");
        final String pmtInfId = sepaParams.get("pmtinfid");

        //Group Header
        doc.getPain00100102().getGrpHdr().setMsgId(sepaId);
        doc.getPain00100102().getGrpHdr().setCreDtTm(SepaUtil.createCalendar(null));
        doc.getPain00100102().getGrpHdr().setNbOfTxs(String.valueOf(maxIndex != null ? maxIndex + 1 : 1));
        doc.getPain00100102().getGrpHdr().setCtrlSum(SepaUtil.sumBtgValue(sepaParams, maxIndex));
        doc.getPain00100102().getGrpHdr().setGrpg(Grouping1CodeSCT.MIXD);
        doc.getPain00100102().getGrpHdr().setInitgPty(new PartyIdentificationSCT1());
        doc.getPain00100102().getGrpHdr().getInitgPty().setNm(sepaParams.get("src.name"));

        //Payment Information
        ArrayList<PaymentInstructionInformationSCT> pmtInfs =
            (ArrayList<PaymentInstructionInformationSCT>) doc.getPain00100102().getPmtInf();
        PaymentInstructionInformationSCT pmtInf = new PaymentInstructionInformationSCT();
        pmtInfs.add(pmtInf);

        pmtInf.setPmtInfId(pmtInfId != null && pmtInfId.length() > 0 ? pmtInfId : sepaId);
        pmtInf.setPmtMtd(PaymentMethodSCTCode.TRF);

        // Payment Type Information
        pmtInf.setPmtTpInf(new PaymentTypeInformationSCT1());
        pmtInf.getPmtTpInf().setSvcLvl(new ServiceLevelSCT());
        pmtInf.getPmtTpInf().getSvcLvl().setCd(ServiceLevelSCTCode.SEPA);

        String date = sepaParams.get("date");
        if (date == null) date = SepaUtil.DATE_UNDEFINED;
        pmtInf.setReqdExctnDt(SepaUtil.createCalendar(date));
        pmtInf.setDbtr(new PartyIdentificationSCT2());
        pmtInf.setDbtrAcct(new CashAccountSCT1());
        pmtInf.setDbtrAgt(new BranchAndFinancialInstitutionIdentificationSCT());

        //Payment Information - Debtor
        pmtInf.getDbtr().setNm(sepaParams.get("src.name"));

        //Payment Information - DebtorAccount
        pmtInf.getDbtrAcct().setId(new AccountIdentificationSCT());
        pmtInf.getDbtrAcct().getId().setIBAN(sepaParams.get("src.iban"));

        //Payment Information - DebtorAgent
        pmtInf.getDbtrAgt().setFinInstnId(new FinancialInstitutionIdentificationSCT());
        pmtInf.getDbtrAgt().getFinInstnId().setBIC(sepaParams.get("src.bic"));

        //Payment Information - ChargeBearer
        pmtInf.setChrgBr(ChargeBearerTypeSCTCode.SLEV);

        //Payment Information - Credit Transfer Transaction Information
        ArrayList<CreditTransferTransactionInformationSCT> cdtTrxTxInfs =
            (ArrayList<CreditTransferTransactionInformationSCT>) pmtInf.getCdtTrfTxInf();
        if (maxIndex != null) {
            for (int tnr = 0; tnr <= maxIndex; tnr++) {
                cdtTrxTxInfs.add(createCreditTransferTransactionInformationSCT(sepaParams, tnr));
            }
        } else {
            cdtTrxTxInfs.add(createCreditTransferTransactionInformationSCT(sepaParams, null));
        }

        ObjectFactory of = new ObjectFactory();
        this.marshal(of.createDocument(doc), os, validate);
    }
@ Override public void generate ( HashMap < String , String > sepaParams , OutputStream os , boolean validate ) throws Exception { Integer maxIndex = SepaUtil . maxIndex ( sepaParams ) ; Document doc = new Document ( ) ; doc . setPain00100102 ( new Pain00100102 ( ) ) ; doc . getPain00100102 ( ) . setGrpHdr ( new GroupHeaderSCT ( ) ) ; String batch = SepaUtil . getProperty ( sepaParams , "batchbook" , null ) ; if ( batch != null ) doc . getPain00100102 ( ) . getGrpHdr ( ) . setBtchBookg ( batch . equals ( "1" ) ) ; final String sepaId = sepaParams . get ( "sepaid" ) ; final String pmtInfId = sepaParams . get ( "pmtinfid" ) ; doc . getPain00100102 ( ) . getGrpHdr ( ) . setMsgId ( sepaId ) ; doc . getPain00100102 ( ) . getGrpHdr ( ) . setCreDtTm ( SepaUtil . createCalendar ( null ) ) ; doc . getPain00100102 ( ) . getGrpHdr ( ) . setNbOfTxs ( String . valueOf ( maxIndex != null ? maxIndex + 1 : 1 ) ) ; doc . getPain00100102 ( ) . getGrpHdr ( ) . setCtrlSum ( SepaUtil . sumBtgValue ( sepaParams , maxIndex ) ) ; doc . getPain00100102 ( ) . getGrpHdr ( ) . setGrpg ( Grouping1CodeSCT . MIXD ) ; doc . getPain00100102 ( ) . getGrpHdr ( ) . setInitgPty ( new PartyIdentificationSCT1 ( ) ) ; doc . getPain00100102 ( ) . getGrpHdr ( ) . getInitgPty ( ) . setNm ( sepaParams . get ( "src.name" ) ) ; ArrayList < PaymentInstructionInformationSCT > pmtInfs = ( ArrayList < PaymentInstructionInformationSCT > ) doc . getPain00100102 ( ) . getPmtInf ( ) ; PaymentInstructionInformationSCT pmtInf = new PaymentInstructionInformationSCT ( ) ; pmtInfs . add ( pmtInf ) ; pmtInf . setPmtInfId ( pmtInfId != null && pmtInfId . length ( ) > 0 ? pmtInfId : sepaId ) ; pmtInf . setPmtMtd ( PaymentMethodSCTCode . TRF ) ; pmtInf . setPmtTpInf ( new PaymentTypeInformationSCT1 ( ) ) ; pmtInf . getPmtTpInf ( ) . setSvcLvl ( new ServiceLevelSCT ( ) ) ; pmtInf . getPmtTpInf ( ) . getSvcLvl ( ) . setCd ( ServiceLevelSCTCode . SEPA ) ; String date = sepaParams . get ( "date" ) ; if ( date == null ) date = SepaUtil . DATE_UNDEFINED ; pmtInf . setReqdExctnDt ( SepaUtil . createCalendar ( date ) ) ; pmtInf . setDbtr ( new PartyIdentificationSCT2 ( ) ) ; pmtInf . setDbtrAcct ( new CashAccountSCT1 ( ) ) ; pmtInf . setDbtrAgt ( new BranchAndFinancialInstitutionIdentificationSCT ( ) ) ; pmtInf . getDbtr ( ) . setNm ( sepaParams . get ( "src.name" ) ) ; pmtInf . getDbtrAcct ( ) . setId ( new AccountIdentificationSCT ( ) ) ; pmtInf . getDbtrAcct ( ) . getId ( ) . setIBAN ( sepaParams . get ( "src.iban" ) ) ; pmtInf . getDbtrAgt ( ) . setFinInstnId ( new FinancialInstitutionIdentificationSCT ( ) ) ; pmtInf . getDbtrAgt ( ) . getFinInstnId ( ) . setBIC ( sepaParams . get ( "src.bic" ) ) ; pmtInf . setChrgBr ( ChargeBearerTypeSCTCode . SLEV ) ; ArrayList < CreditTransferTransactionInformationSCT > cdtTrxTxInfs = ( ArrayList < CreditTransferTransactionInformationSCT > ) pmtInf . getCdtTrfTxInf ( ) ; if ( maxIndex != null ) { for ( int tnr = 0 ; tnr <= maxIndex ; tnr ++ ) { cdtTrxTxInfs . add ( createCreditTransferTransactionInformationSCT ( sepaParams , tnr ) ) ; } } else { cdtTrxTxInfs . add ( createCreditTransferTransactionInformationSCT ( sepaParams , null ) ) ; } ObjectFactory of = new ObjectFactory ( ) ; this . marshal ( of . createDocument ( doc ) , os , validate ) ; }
@see PainGeneratorIf#generate(Object, OutputStream, boolean)