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

org.databene.edifatto.definition.SegmentGroupItemDefinition Maven / Gradle / Ivy

/*
 * Copyright (C) 2013-2015 Volker Bergmann ([email protected]).
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.databene.edifatto.definition;

import org.databene.edifatto.util.EdiUtil;

/**
 * Parent class for the constraint specifications of all EDI items 
 * that may be contained in a segment group: 
 * {@link SegmentDefinition} and {@link SegmentGroupDefinition}.
 * Created: 10.10.2013 17:26:38
 * @since 1.0
 * @author Volker Bergmann
 */

public abstract class SegmentGroupItemDefinition implements Definition {

	private static final long serialVersionUID = 1L;

	private String pos;
	private String tag;
	private String name;
	private String documentation;
	private int minCardinality;
	private int maxCardinality;
	
	public SegmentGroupItemDefinition() {
		this(null, null, null, 0, 0);
	}

	public SegmentGroupItemDefinition(String pos, String tag, String documentation, int minCardinality, int maxCardinality) {
		this.pos = pos;
		this.tag = tag;
		this.name = null;
		this.documentation = documentation;
		this.minCardinality = minCardinality;
		this.maxCardinality = maxCardinality;
	}

	public String getPos() {
		return pos;
	}

	public void setPos(String pos) {
		this.pos = pos;
	}

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	@Override
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return the {@link #documentation}
	 */
	@Override
	public String getDocumentation() {
		return documentation;
	}
	
	/**
	 * @param documentation the documentation to set
	 */
	public void setDocumentation(String documentation) {
		this.documentation = documentation;
	}
	
	public int getMinCardinality() {
		return minCardinality;
	}

	public void setMinCardinality(int minCardinality) {
		this.minCardinality = minCardinality;
	}

	public int getMaxCardinality() {
		return maxCardinality;
	}

	public void setMaxCardinality(int maxCardinality) {
		this.maxCardinality = maxCardinality;
	}
	
	public abstract void printRecursively(String indent);
	
	@Override
	public String toString() {
		return 	name + '\t' + 
				(tag != null ? tag : "   ") + '\t' + 
				(pos != null ? pos + '\t' : "") + 
				(documentation != null ? documentation : "") + '\t' + 
				EdiUtil.formatCardinalities(minCardinality, maxCardinality);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy