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

org.milyn.edi.unedifact.d94a.common.Relationship Maven / Gradle / Ivy

There is a newer version: 1.7.1.0
Show newest version
/**
 * This class was generated by Smooks EJC (http://www.smooks.org).
 */
package org.milyn.edi.unedifact.d94a.common;

import java.io.Serializable;    
import org.milyn.smooks.edi.EDIWritable;    
import org.milyn.edi.unedifact.d94a.common.field.RelationshipC941;    
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 Relationship implements Serializable, EDIWritable {

    private static final long serialVersionUID = 1L;

    private String relationshipQualifier;
    private RelationshipC941 relationship;

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

        List nodeTokens = new ArrayList();

        if(relationshipQualifier != null) {
            nodeWriter.write(delimiters.escape(relationshipQualifier.toString()));
            nodeTokens.add(nodeWriter.toString());
            ((StringWriter)nodeWriter).getBuffer().setLength(0);
        }
        nodeWriter.write(delimiters.getField());
        if(relationship != null) {
            relationship.write(nodeWriter, delimiters);
            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 String getRelationshipQualifier() {
        return relationshipQualifier;
    }

    public Relationship setRelationshipQualifier(String relationshipQualifier) {
        this.relationshipQualifier = relationshipQualifier;  return this;
    }

    public RelationshipC941 getRelationship() {
        return relationship;
    }

    public Relationship setRelationship(RelationshipC941 relationship) {
        this.relationship = relationship;  return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy