Afplib

JAVA Library for reading & writing AFP

View project on GitHub

Welcome to AFP Lib

afplib - a JAVA Library for reading & writing AFP (Advanced Function Presentation) Files. See https://en.wikipedia.org/wiki/Advanced_Function_Presentation

afplib provides a low level API to transform AFP files, i.e. structured fields, triplets, ... into JAVA objects and vice versa. To make use of it you need to know MO:DCA (see http://afpcinc.org/wp-content/uploads/2014/04/modca08.pdf). afplib is build on top of EMF (Eclipse Modeling Framework) - http://www.eclipse.org/modeling/emf/

Quickstart

This is how easy it is to create a brand new (empty) AFP file:

public static void main(String[] args) {
        try (AfpOutputStream aout = new AfpOutputStream(new FileOutputStream("hello.afp"))) {

            BDT bdt = AfplibFactory.eINSTANCE.createBDT();
            bdt.setDocName("HELLOWLD");
            Comment comment = AfplibFactory.eINSTANCE.createComment();
            comment.setComment("My first AFPLib Program");
            bdt.getTriplets().add(comment);

            aout.writeStructuredField(bdt);

            EDT edt = AfplibFactory.eINSTANCE.createEDT();
            edt.setDocName("HELLOWLD");
            aout.writeStructuredField(edt);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Links