/*******************************************************************************
 *  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.segments;

import cdac.medinfo.sdk.hl7282.baselibs.ID;
import cdac.medinfo.sdk.hl7282.baselibs.ST;
import cdac.medinfo.sdk.hl7282.commoninterface.IDataType;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.exceptions.InvalidSegmentException;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;

/**
 * DSC - continuation pointer segment<p>
 * The DSC segment is used in the continuation protocol. 
 * <p>Represents an HL7 DSC message segment. 
 * This segment has the following fields:</p><p>
 * DSC-1: Continuation Pointer (ST)<b>Optional</b><br> 
 * DSC-2: Continuation Style (ID)<b>Optional</b><br><p> 
 * This class provides mechanism to validate message against HL7 v 2.8.2 standard.
 * The class provides accessors & mutators for the elements mentioned above.
 * The class has validate method which validates Message against HL7 v 2.8.2 standard.
 *
 * <p>User can also create Segment through {@link SegmentFactory}
 */
 public class DSC extends Segment    
{
	

	/**
	 * Constructs the DSC segment.
	 */
	public DSC()
	{super(EnumSegments.HL7_SEG_DSC);
	}
	//Integer values used in getter/setter is unique item id defined 
	//for each attribute.


	/**
	 * Retrieves the Continuation Pointer.
	 * This field contains the continuation pointer. In an initial query, this field is not present.
	 * @return String - continuationPointer
	 */
	public ST getContinuationPointer() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(14);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Retrieves the Continuation Style.
	 * This field indicates whether this is a fragmented message or not.
	 * @return String - continuationStyle
	 */
	public ID getContinuationStyle() 
	{
		ISingleCollection<IDataType> objDataCollection =getDataType(1354);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Set the Continuation Pointer.
	 * This field contains the continuation pointer. In an initial query, this field is not present.
	 * @param strContinuationPointer Contains the continuation pointer. 
	 */ 
	public void setContinuationPointer(String strContinuationPointer)
	{
		ST continuationPointer  = (ST)getDataElement(14);
		continuationPointer.setValue(strContinuationPointer); 
		setContinuationPointer(continuationPointer);
	} 

	/** Set the Continuation Pointer.
	 * This field contains the continuation pointer. In an initial query, this field is not present.
	 * @param objcontinuationPointer object of Continuation Pointer. 
	 */ 
	public void setContinuationPointer(ST objcontinuationPointer)
	{
		setDataType(14,objcontinuationPointer);
	}
	/**
	 * Set the Continuation Style.
	 * This field indicates whether this is a fragmented message or not.
	 * @param strContinuationStyle Used for ContinuationStyle.
	 */ 
	public void setContinuationStyle(String strContinuationStyle)
	{
		ID continuationStyle  = (ID)getDataElement(1354);
		continuationStyle.setValue(strContinuationStyle); 
		setContinuationStyle(continuationStyle);
	} 

	/** Set the Continuation Style.
	 * This field indicates whether this is a fragmented message or not.
	 * @param objcontinuationStyle object of Continuation Style.
	 */ 
	public void setContinuationStyle(ID objcontinuationStyle)
	{
		setDataType(1354,objcontinuationStyle);
	}

	/**
	 * Validates HL7 Message objects .
	 * Validate method checks for validation each and every segments in side the Message object against specified message Structure. 
	 * Validation chcecks include optionality of segment or group.
	 * It also verifies the number of times segment or group is repeated in message.
	 * e.g 
	 * {PSH} while parsing PSH segment validate method will check for its mandatory presence.
	 * [PSH] in this case validate will throw exception if one tries to enter more than one PSH segment.
	 * @return boolean - true or false.
	 * @throws InvalidSegmentException Thrown when Segment Validation Fails.
	 */
	public boolean validate() throws InvalidSegmentException
	{
		//All fields are optional
		super.validate();
		return true;
	}
}