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.OutputStream;
20 import java.io.Writer;
21
22 import javax.xml.transform.Result;
23
24 /**
25 * Interface for creating an externalized version of an internal object model.
26 *
27 * @author Christian Ohr
28 *
29 * @param <T>
30 * the external representation
31 */
32 public interface Renderer<T> {
33
34 /**
35 * Renders the model into its external representation.
36 *
37 * @param model
38 * @param params
39 * dynamic information used during rendering. See the respective
40 * implementation class documentation if this is required or
41 * supported.
42 * @return the external representation of the model
43 * @throws RenderException
44 */
45 Result render(final T model, Result result, final Object... params) throws IOException;
46
47 /**
48 * Renders the model into its external representation.
49 *
50 * @param model
51 * @param params
52 * dynamic information used during rendering. See the respective
53 * implementation class documentation if this is required or
54 * supported.
55 * @return the external representation of the model
56 * @throws RenderException
57 */
58 OutputStream render(final T model, OutputStream result, final Object... params) throws IOException;
59
60 /**
61 * Renders the model into its external representation.
62 *
63 * @param model
64 * @param params
65 * dynamic information used during rendering. See the respective
66 * implementation class documentation if this is required or
67 * supported.
68 * @return the external representation of the model
69 * @throws RenderException
70 */
71 Writer render(final T model, Writer result, final Object... params) throws IOException;
72
73 /**
74 * Renders the model into its external representation.
75 *
76 * @param model
77 * @param params
78 * dynamic information used during rendering. See the respective
79 * implementation class documentation if this is required or
80 * supported.
81 * @return the external representation of the model
82 * @throws RenderException
83 */
84 String render(final T model, final Object... params);
85
86 }