/*******************************************************************************
 *  Copyright 2017 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 *  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 cdac.medinfo.sdk.hl7282.baselibs.datatypefactory;

import cdac.medinfo.sdk.hl7282.utils.IComponentItem;

/**
 * ComponentItem class is the implementation of IComponentItem.
 * ComponentItem represents structure of a Components of a DataType as per defined in HL7 standard.
 */
public final class ComponentItem implements IComponentItem
{
	
	private String strFieldName;
	private int iSequenceNo;
	private int iMinLength = 0;
	private int iMaxLength = 0;
	private String strCLength = null;
	private String strDataType;
	private int[] iTableNo = null;
	private boolean bOptional;

	/**
	 * Default Constructor for ComponentItem.
	 */
	public ComponentItem()
	{}

	/**
	 * Parameterized constructor for RowDescriptor which initializes different fields of an item.
	 * @param strFieldName Name of Field name
	 * @param intSeq Integer value of Sequence number of an Item ID
	 * @param intLen Integer value of Length of an Item ID
	 * @param iMinLen Integer value of Minimum Length of an Item ID
	 * @param iMaxLen Integer value of Maximum Length of an Item ID
	 * @param strCLen String value of Conformance Length of an Item ID
	 * @param strDataType String value of Data type of an Item ID
	 * @param intTableNo Integer value of  Table number of an Item ID
	 * @param bRepeatable Show status of an Item whether repeatable or not
	 * @param bOptional Show status of an Item whether optional or not
	 */
	public ComponentItem(String strFieldName,int intSeq, int iMinLen, int iMaxLen, String strCLen, String strDataType, int[] intTableNo, boolean bOptional)
	{
		this.strFieldName = strFieldName;
		this.iSequenceNo = intSeq;
		this.iMinLength = iMinLen; 
		this.iMaxLength = iMaxLen;
		this.strCLength = strCLen;
		this.strDataType = strDataType;
		this.iTableNo = intTableNo;
		this.bOptional = bOptional;
	}
	
	/**
	 * Parameterized constructor for RowDescriptor which initializes different fields of an item.
	 * @param strFieldName Name of Field name.
	 * @param intSeq Integer value of Sequence number of an Item ID.
	 * @param iMinLen Integer value of Minimum Length of an Item ID
	 * @param iMaxLen Integer value of Maximum Length of an Item ID
	 * @param strCLen String value of Conformance Length of an Item ID
	 * @param strDataType Integer value of Data type of an Item ID.
	 */
	public ComponentItem(String strFieldName,int intSeq, int iMinLen, int iMaxLen, String strCLen, String strDataType)
	{
		this.strFieldName = strFieldName;
		this.iSequenceNo = intSeq;
		this.iMinLength = iMinLen; 
		this.iMaxLength = iMaxLen;
		this.strCLength = strCLen; 
		this.strDataType = strDataType;
	}

	/**
	 * Retrieves name of Component
	 * @return String - name of Component
	 */
	public String getFieldName()
	{
		return strFieldName;
	}

	/**
	 * Sets name of Component
	 * @param strName name of Component
	 */
	public void setFieldName(String strName) 
	{
		this.strFieldName = strName;
	}

	/**
	 * Retrieves sequence number for Component defined by HL7 standard in segment
	 * @return int - value of sequence index
	 */
	public int getSequenceNo()
	{
		return iSequenceNo;
	}

	/**
	 * Sets sequence number for Component defined by HL7 standard in segment
	 * @param intSeq value of sequence index
	 */
	public void setSequenceNo(int intSeq)
	{
		this.iSequenceNo = intSeq;
	}

	/**
	 * Retrieves Minimum Length for Component defined by HL7 standard in segment
	 * @return int - value of Minimum length
	 */
	public int getMinimunLength()
	{
		return iMinLength;
	}

	/**
	 * Sets Minimum Length for Component defined by HL7 standard in segment
	 * @param minLen Minimum length value
	 */
	public void setMinimumLength(int minLen)
	{
		this.iMinLength = minLen;
	}
	
	/**
	 * Retrieves Maximum Length for Component defined by HL7 standard in segment
	 * @return int - value of Maximum length
	 */
	public int getMaximumLength()
	{
		return iMaxLength;
	}

	/**
	 * Sets Maximum Length for Component defined by HL7 standard in segment
	 * @param maxLen Maximum length value
	 */
	public void setMaximumLength(int maxLen)
	{
		this.iMaxLength = maxLen;
	}

	/**
	 * retrieves Conformance Length for Component defined by defined HL7 Standard in Segment
	 * @return String -value of Conformance Length
	 */
	public String getConformanceLength()
	{
		return strCLength;
	}
	
	/**
	 * Set Conformance Length for component defined by Hl7 standard in Segment
	 * @param strCLength Conformance Length value
	 */
	public void setConformanceLength(String strCLength)
	{
		this.strCLength = strCLength;
	}
	
	/**
	 * Retrieves Data Type for Component defined by HL7 standard in segment
	 * @return String name of DataType
	 */
	public String getDataType()
	{
		return strDataType;
	}

	/**
	 * Sets Datatype for Component defined by HL7 standard in segment
	 * @param strDataType name of Component
	 */
	public void setDataType(String strDataType)
	{
		this.strDataType = strDataType;
	}

	/**
	 * Retrieves Table number for Component defined by HL7 standard in segment
	 * @return int[] - array of table number
	 */
	public int[] getTableNo() 
	{
		return iTableNo;
	}

	/**
	 * Sets Table number for Component defined by HL7 standard in segment
	 * @param intTableNo array of table number
	 */
	public void setTableNo(int[] intTableNo)
	{
		this.iTableNo = intTableNo;
	}

	/**
	 * Shows optionality status for Component defined by HL7 standard in segment
	 * @return boolean - status as true or false
	 */
	public boolean isOptional()
	{
		return this.bOptional;
	}

	/**
	 * Sets optionality status for Component defined by HL7 standard in segment
	 * @param bOptional status as true or false
	 */
	public void setOptional(boolean bOptional)
	{
		this.bOptional = bOptional;
	}
}
