001/** 002The contents of this file are subject to the Mozilla Public License Version 1.1 003(the "License"); you may not use this file except in compliance with the License. 004You may obtain a copy of the License at http://www.mozilla.org/MPL/ 005Software distributed under the License is distributed on an "AS IS" basis, 006WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 007specific language governing rights and limitations under the License. 008 009The Original Code is "Pointer.java". Description: 010"A Pointer is a placeholder used in parsing traditionally encoded messages 011 (which do not explicitly identify segment groups)" 012 013The Initial Developer of the Original Code is University Health Network. Copyright (C) 0142001. All Rights Reserved. 015 016Contributor(s): ______________________________________. 017 018Alternatively, the contents of this file may be used under the terms of the 019GNU General Public License (the "GPL"), in which case the provisions of the GPL are 020applicable instead of those above. If you wish to allow use of your version of this 021file only under the terms of the GPL and not to allow others to use your version 022of this file under the MPL, indicate your decision by deleting the provisions above 023and replace them with the notice and other provisions required by the GPL License. 024If you do not delete the provisions above, a recipient may use your version of 025this file under either the MPL or the GPL. 026 027*/ 028 029package ca.uhn.hl7v2.parser; 030 031import ca.uhn.hl7v2.HL7Exception; 032import ca.uhn.hl7v2.model.Group; 033 034/** 035 * <p>A Pointer is a placeholder used in parsing traditionally encoded messages 036 * (which do not explicitly identify segment groups). Implementations of Pointer 037 * include SegmentPointer, which "points" to a Segment slot. This pointer can 038 * exist whether or not the underlying Segment object has been created. There is 039 * only one pointer per slot - multiple repetitions are accessed through the 040 * same pointer. <code>prepNewInstance</code> is used to create a new rep. 041 * <code>setSegment(String segment)</code> is responsible for parsing the given 042 * segment string <i>into</i> the current rep of the underlying Segment. Similarly 043 * there is a subclass called GroupPointer that points to a Group slot. 044 * GroupPointer's <code>setSegment(...)</code> method just forwards the request to 045 * it's children (which are GroupPointers and SegmentPointers). </p> 046 * @author Bryan Tripp (bryan_tripp@sourceforge.net) 047 * @deprecated 048 */ 049public abstract class Pointer { 050 051 public static final int FILL_FAILED_WRONG_SEGMENT = 0; 052 public static final int FILL_FAILED_FULL = 1; 053 public static final int FILL_OK = 2; 054 public static final int FILL_FAILED_OUT_OF_ORDER = 3; 055 056 protected Group parent; 057 protected int position; 058 protected boolean repeating; 059 protected EncodingCharacters encodingChars; 060 061 /** 062 * Parses the given String, which must contain a single traditionally encoded 063 * message segment, into the current repetition of the message Structure 064 * underlying this Pointer. 065 * @param segment the segment to parse 066 * @param correctOrder false if this segment should not actually be parsed because the 067 * current location precedes the location of a segment that has already been 068 * parsed. In this case, the return value should be either FILL_FAILED_FULL, 069 * FILL_FAILED_WRONG_SEGMENT, or FILL_FAILED_OUT_OF_ORDER, but the segment should not 070 * be parsed. 071 * @return an int indicating the success or flavours of failure of the request 072 */ 073 public abstract int setSegment(String segment, boolean correctOrder) throws HL7Exception; 074 075}