1 /*
2 * Copyright 2010 Capgemini
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.xmlfield.core.api;
17
18 import java.io.InputStream;
19 import java.io.Writer;
20
21 import org.xmlfield.core.exception.XmlFieldParsingException;
22
23 /**
24 * Interface of a xml field node parser.
25 *
26 * @author Guillaume Mary <guillaume.mary@capgemini.com>
27 * @author Nicolas Richeton
28 *
29 * @param <T>
30 * underlying xml node representation type
31 */
32 public interface XmlFieldNodeParser {
33
34 /**
35 * Transform an xml field object to an xml string.
36 *
37 * @param object
38 * xml field object
39 * @return xml string
40 * @throws XmlFieldParsingException
41 * parsing exception
42 */
43 // String nodeToXml(Object object) throws XmlFieldParsingException;
44
45 /**
46 * Transform an xml field node to an xml string.
47 *
48 * @param node
49 * xml field node
50 * @return xml string
51 * @throws XmlFieldParsingException
52 * parsing exception
53 */
54 String nodeToXml(XmlFieldNode node) throws XmlFieldParsingException;
55
56 void nodeToXml(XmlFieldNode node, Writer writer)
57 throws XmlFieldParsingException;
58
59 /**
60 * Transform an xml inputstream to an xml field node.
61 *
62 * @param xmlContent
63 * xml input stream
64 * @return xml field node
65 * @throws XmlFieldParsingException
66 * parsing exception
67 */
68 XmlFieldNode xmlToNode(InputStream xmlContent)
69 throws XmlFieldParsingException;
70
71 /**
72 * Transform an xml string to an xml field node.
73 *
74 * @param xml
75 * xml string
76 * @return xml field node
77 * @throws XmlFieldParsingException
78 * parsing exception
79 */
80 XmlFieldNode xmlToNode(String xml) throws XmlFieldParsingException;
81 }