All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.milyn.edi.unedifact.d06b.common.BeginningOfMessage Maven / Gradle / Ivy

/**
 * This class was generated by Smooks EJC (http://www.smooks.org).
 */
package org.milyn.edi.unedifact.d06b.common;

import java.io.Serializable;    
import org.milyn.smooks.edi.EDIWritable;    
import org.milyn.edi.unedifact.d06b.common.field.DocumentMessageNameC002;    
import org.milyn.edi.unedifact.d06b.common.field.DocumentMessageIdentificationC106;    
import java.io.Writer;    
import org.milyn.edisax.model.internal.Delimiters;    
import java.io.IOException;    
import java.io.StringWriter;    
import java.util.List;    
import java.util.ArrayList;    
import org.milyn.edisax.util.EDIUtils;    
import org.milyn.edisax.model.internal.DelimiterType;    

public class BeginningOfMessage implements Serializable, EDIWritable {

    private static final long serialVersionUID = 1L;

    private DocumentMessageNameC002 documentMessageName;
    private DocumentMessageIdentificationC106 documentMessageIdentification;
    private String messageFunctionCode;
    private String responseTypeCode;

    public void write(Writer writer, Delimiters delimiters) throws IOException {
        
        Writer nodeWriter = new StringWriter();

        List nodeTokens = new ArrayList();

        if(documentMessageName != null) {
            documentMessageName.write(nodeWriter, delimiters);
            nodeTokens.add(nodeWriter.toString());
            ((StringWriter)nodeWriter).getBuffer().setLength(0);
        }
        nodeWriter.write(delimiters.getField());
        if(documentMessageIdentification != null) {
            documentMessageIdentification.write(nodeWriter, delimiters);
            nodeTokens.add(nodeWriter.toString());
            ((StringWriter)nodeWriter).getBuffer().setLength(0);
        }
        nodeWriter.write(delimiters.getField());
        if(messageFunctionCode != null) {
            nodeWriter.write(delimiters.escape(messageFunctionCode.toString()));
            nodeTokens.add(nodeWriter.toString());
            ((StringWriter)nodeWriter).getBuffer().setLength(0);
        }
        nodeWriter.write(delimiters.getField());
        if(responseTypeCode != null) {
            nodeWriter.write(delimiters.escape(responseTypeCode.toString()));
            nodeTokens.add(nodeWriter.toString());
            ((StringWriter)nodeWriter).getBuffer().setLength(0);
        }
        nodeTokens.add(nodeWriter.toString());
        writer.write(EDIUtils.concatAndTruncate(nodeTokens, DelimiterType.FIELD, delimiters));
        writer.write(delimiters.getSegmentDelimiter());
        writer.flush();
    }

    public DocumentMessageNameC002 getDocumentMessageName() {
        return documentMessageName;
    }

    public BeginningOfMessage setDocumentMessageName(DocumentMessageNameC002 documentMessageName) {
        this.documentMessageName = documentMessageName;  return this;
    }

    public DocumentMessageIdentificationC106 getDocumentMessageIdentification() {
        return documentMessageIdentification;
    }

    public BeginningOfMessage setDocumentMessageIdentification(DocumentMessageIdentificationC106 documentMessageIdentification) {
        this.documentMessageIdentification = documentMessageIdentification;  return this;
    }

    public String getMessageFunctionCode() {
        return messageFunctionCode;
    }

    public BeginningOfMessage setMessageFunctionCode(String messageFunctionCode) {
        this.messageFunctionCode = messageFunctionCode;  return this;
    }

    public String getResponseTypeCode() {
        return responseTypeCode;
    }

    public BeginningOfMessage setResponseTypeCode(String responseTypeCode) {
        this.responseTypeCode = responseTypeCode;  return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy