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 "Pointer.java".  Description: 
10  "A Pointer is a placeholder used in parsing traditionally encoded messages 
11    (which do not explicitly identify segment groups)" 
12  
13  The Initial Developer of the Original Code is University Health Network. Copyright (C) 
14  2001.  All Rights Reserved. 
15  
16  Contributor(s): ______________________________________. 
17  
18  Alternatively, the contents of this file may be used under the terms of the 
19  GNU General Public License (the "GPL"), in which case the provisions of the GPL are 
20  applicable instead of those above.  If you wish to allow use of your version of this 
21  file only under the terms of the GPL and not to allow others to use your version 
22  of this file under the MPL, indicate your decision by deleting  the provisions above 
23  and replace  them with the notice and other provisions required by the GPL License.  
24  If you do not delete the provisions above, a recipient may use your version of 
25  this file under either the MPL or the GPL. 
26  
27  */
28  
29  package ca.uhn.hl7v2.parser;
30  
31  import ca.uhn.hl7v2.HL7Exception;
32  import ca.uhn.hl7v2.model.Group;
33  
34  /**
35   * <p>A Pointer is a placeholder used in parsing traditionally encoded messages 
36   * (which do not explicitly identify segment groups).  Implementations of Pointer 
37   * include SegmentPointer, which "points" to a Segment slot.  This pointer can 
38   * exist whether or not the underlying Segment object has been created.  There is 
39   * only one pointer per slot - multiple repetitions are accessed through the 
40   * same pointer.  <code>prepNewInstance</code> is used to create a new rep.  
41   * <code>setSegment(String segment)</code> is responsible for parsing the given 
42   * segment string <i>into</i> the current rep of the underlying Segment.  Similarly 
43   * there is a subclass called GroupPointer that points to a Group slot.  
44   * GroupPointer's <code>setSegment(...)</code> method just forwards the request to 
45   * it's children (which are GroupPointers and SegmentPointers). </p>
46   * @author Bryan Tripp (bryan_tripp@sourceforge.net)
47   * @deprecated
48   */
49  public abstract class Pointer {
50  
51      public static final int FILL_FAILED_WRONG_SEGMENT = 0;
52      public static final int FILL_FAILED_FULL = 1;
53      public static final int FILL_OK = 2;
54      public static final int FILL_FAILED_OUT_OF_ORDER = 3;
55  
56      protected Group parent;
57      protected int position;
58      protected boolean repeating;
59      protected EncodingCharacters encodingChars;
60  
61      /**
62       * Parses the given String, which must contain a single traditionally encoded 
63       * message segment, into the current repetition of the message Structure 
64       * underlying this Pointer.  
65       * @param segment the segment to parse 
66       * @param correctOrder false if this segment should not actually be parsed because the 
67       *      current location precedes the location of a segment that has already been 
68       *      parsed.  In this case, the return value should be either FILL_FAILED_FULL, 
69       *      FILL_FAILED_WRONG_SEGMENT, or FILL_FAILED_OUT_OF_ORDER, but the segment should not 
70       *      be parsed.  
71       * @return an int indicating the success or flavours of failure of the request
72       */
73      public abstract int setSegment(String segment, boolean correctOrder) throws HL7Exception;
74  
75  }