001package ca.uhn.hl7v2.model;
002
003/**
004 * An unspecified segment that has an undefined number of fields, each 
005 * of which is a Varies.  The primary intended use is to store data from 
006 * Z segments.  More precisely, any unknown segment that is encountered during
007 * parsing will be handled with this class.  This includes segments that do 
008 * not start with Z but nevertheless do not appear in the stated version 
009 * of HL7.  Also, this class is not used to handle Z segments that have been 
010 * explicitly defined and declared (see Parser.packageList() ).  
011 * @author Bryan Tripp
012 */
013@SuppressWarnings("serial")
014public class GenericSegment extends AbstractSegment {
015    
016    private String name;
017
018    /**
019     * Creates a genric segment
020     * @param parent parent group
021     * @param name name of the segment
022     */
023    public GenericSegment(Group parent, String name) {
024        super(parent, null);
025        this.name = name;
026    }
027    
028    /**
029     * Returns the name specified at construction time. 
030     * @see Structure#getName() 
031     */
032    public String getName() {
033        return this.name;
034    }
035
036
037    /**
038     * {@inheritDoc}
039     */
040        protected Type createNewTypeWithoutReflection(int field) {
041                return new Varies(getMessage());
042        }
043    
044}