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 "MessageVisitorSupport.java ".  Description:
10   "Base MessageVisitor implementation that just logs each call"
11  
12   The Initial Developer of the Original Code is University Health Network. Copyright (C)
13   2013.  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  package ca.uhn.hl7v2.model;
28  
29  import ca.uhn.hl7v2.HL7Exception;
30  import ca.uhn.hl7v2.Location;
31  
32  import org.slf4j.Logger;
33  import org.slf4j.LoggerFactory;
34  
35  /**
36   * Base MessageVisitor implementation that just logs each call with TRACE level
37   */
38  public class MessageVisitorSupport implements MessageVisitor {
39  
40      protected static final Logger LOG = LoggerFactory.getLogger(MessageVisitorSupport.class);
41  
42      public boolean start(Message message) throws HL7Exception {
43          LOG.trace("Enter message {}", message);
44          return true;
45      }
46  
47      public boolean end(Message message) throws HL7Exception {
48          LOG.trace("Leave message {}", message);
49          return true;
50      }
51      
52      public boolean start(Group group, Location location) throws HL7Exception {
53          LOG.trace("Enter group {} {}", group, location);
54          return true;
55      }
56  
57      public boolean end(Group group, Location location) throws HL7Exception {
58          LOG.trace("Leave group {} {}", group, location);
59          return true;
60      }
61  
62      public boolean start(Segment segment, Location location) throws HL7Exception {
63          LOG.trace("Enter segment {} {}", segment, location);
64          return true;
65      }
66  
67      public boolean end(Segment segment, Location location) throws HL7Exception {
68          LOG.trace("Leave segment {} {}", segment, location);
69          return true;
70      }
71  
72      public boolean start(Field field, Location location) throws HL7Exception {
73          LOG.trace("Enter field {} {}", field, location);
74          return true;
75      }
76  
77      public boolean end(Field field, Location location) throws HL7Exception {
78          LOG.trace("Leave field {} {}", field, location);
79          return true;
80      }
81      
82      public boolean start(Composite type, Location location) throws HL7Exception {
83          LOG.trace("Enter composite {} {}", type, location);
84          return true;
85      }
86  
87      public boolean end(Composite type, Location location) throws HL7Exception {
88          LOG.trace("Leave composite {} {}", type, location);
89          return true;
90      }
91  
92      public boolean visit(Primitive type, Location location) throws HL7Exception {
93          LOG.trace("Visit primitive {} {}", type, location);
94          return true;
95      }
96  }