View Javadoc
1   /*
2    * Copyright 2008 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.core.modules.api;
17  
18  import java.io.IOException;
19  import java.io.InputStream;
20  import java.io.Reader;
21  
22  import javax.xml.transform.Source;
23  
24  /**
25   * Defines methods for parsing a external representation of information into an
26   * internal model.
27   * 
28   * @author Christian Ohr
29   * 
30   * @param <S>
31   *            the internal model
32   */
33  public interface Parser<S> {
34  
35      /**
36       * Parses a message and returns an internal representation of the
37       * information.
38       * 
39       * @param message
40       * @param params
41       * @return the parsed message
42       * @throws ParseException
43       */
44      S parse(String message, Object... params);
45  
46      /**
47       * Parses a message and returns an internal representation of the
48       * information.
49       * 
50       * @param message
51       * @param params
52       * @return the parsed message
53       * @throws IOException
54       *             if reading from stream fails
55       * @throws ParseException
56       */
57      S parse(InputStream message, Object... params) throws IOException;
58  
59      /**
60       * Parses a message and returns an internal representation of the
61       * information.
62       * 
63       * @param source
64       * @param params
65       * @return the parsed message
66       * @throws IOException
67       *             if reading from stream fails
68       * @throws ParseException
69       */
70      S parse(Source source, Object... params) throws IOException;
71  
72      /**
73       * Parses a message and returns an internal representation of the
74       * information.
75       * 
76       * @param params
77       * @return the parsed message
78       * @throws IOException
79       *             if reading from stream fails
80       * @throws ParseException
81       */
82      S parse(Reader reader, Object... params) throws IOException;
83  
84  }