View Javadoc
1   /**
2   The contents of this file are subject to the Mozilla Public License Version 1.1 
3   (the "License"); you may not use this file except in compliance with the License. 
4   You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
5   Software distributed under the License is distributed on an "AS IS" basis, 
6   WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
7   specific language governing rights and limitations under the License. 
8   
9   The Original Code is "Type.java".  Description: 
10  "An HL7 datatype" 
11  
12  The Initial Developer of the Original Code is University Health Network. Copyright (C) 
13  2001.  All Rights Reserved. 
14  
15  Contributor(s): ______________________________________. 
16  
17  Alternatively, the contents of this file may be used under the terms of the 
18  GNU General Public License (the  �GPL�), in which case the provisions of the GPL are 
19  applicable instead of those above.  If you wish to allow use of your version of this 
20  file only under the terms of the GPL and not to allow others to use your version 
21  of this file under the MPL, indicate your decision by deleting  the provisions above 
22  and replace  them with the notice and other provisions required by the GPL License.  
23  If you do not delete the provisions above, a recipient may use your version of 
24  this file under either the MPL or the GPL. 
25  
26  */
27  
28  package ca.uhn.hl7v2.model;
29  
30  import ca.uhn.hl7v2.HL7Exception;
31  import java.io.Serializable;
32  
33  /**
34   * An HL7 datatype.  Datatypes normally implement either Composite or Primitive.    
35   * @author Bryan Tripp (bryan_tripp@sourceforge.net)
36   */
37  public interface Type extends Serializable, Visitable {
38  
39      /**
40       * Returns the name of the type (used in XML encoding and profile checking)
41       *
42       * @return the name of the type
43       */
44      String getName();
45      
46      /**
47       * Returns an object containing any extra (non-standard) components that 
48       * have been added to this type at run-time.  This object can also be used
49       * to add components.
50       *
51       * @return an object containing any extra (non-standard) components
52       */
53      ExtraComponents getExtraComponents();
54      
55      /**
56       * @return the message to which this Type belongs
57       */
58      Message getMessage();
59  
60      /**
61       * <p>
62       * Parses the string into this type and replaces the current contents with
63       * the parsed value. This method accepts HL7 encoded text and treats its
64       * input as such.
65       * </p>
66       * <p>
67       * Note that this method is subtly different from calling {@link Primitive#setValue(String)}, but
68       * can be quite powerful. For example, using the argument of "milk&cookies" on an ST datatype:
69       * <ul>
70       * <li>
71       * If you are using {@link Primitive#setValue(String)}, the ampersand is treated as an actual ampersand 
72       * in the text, and the field will be treated as a single field which is encoded as "milk\T\cookies" (\T\ is the 
73       * escape sequence for the subcomponent delimiter).
74       * </li>
75       * <li>
76       * If you are using parse(String), the ampersand is treated as a subcomponent delimiter, meaning that
77       * the value is set to "milk", and a second component is added with the value of "cookies".
78       * </li>
79       * </ul>
80       * </p>  
81       * <p>
82       * This method makes use of the parser which is stored within the enclosing {@link #getMessage() Message}.
83       * At this time, only PipeParsers are supported. 
84       * </p>
85       *
86       * @param string the message to be parsed
87       * @throws HL7Exception if errors occurred while parsing
88       */
89      void parse(String string) throws HL7Exception;
90  
91  
92      /**
93       * Encodes this type using HL7 encoding.
94       *
95       * @return the encoded message
96       * @throws HL7Exception if errors occurred while encoding
97       */
98      String encode() throws HL7Exception;
99  
100 
101 	/**
102 	 * Clears all data from this type
103 	 */
104 	void clear();
105 
106 }