View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/interfaces/IDOMFactory.java,v 1.1 2005/12/02 12:35:47 hkollmann Exp $
3    * $Revision: 1.1 $
4    * $Date: 2005/12/02 12:35:47 $
5    *
6    * DbForms - a Rapid Application Development Framework
7    * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8    *
9    * This library is free software; you can redistribute it and/or
10   * modify it under the terms of the GNU Lesser General Public
11   * License as published by the Free Software Foundation; either
12   * version 2.1 of the License, or (at your option) any later version.
13   *
14   * This library is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this library; if not, write to the Free Software
21   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22   */
23  
24  package org.dbforms.interfaces;
25  
26  import org.w3c.dom.Document;
27  import org.w3c.dom.Element;
28  import org.w3c.dom.xpath.XPathEvaluator;
29  
30  import java.io.IOException;
31  import java.io.InputStream;
32  import java.io.OutputStream;
33  
34  /***
35   * abstract class to hide the implemtation details of the various dom
36   * implementations.
37   * 
38   * @author Henner Kollmann
39   */
40  public interface IDOMFactory {
41  
42  	/***
43  	 * Creates a string representation of the given DOMDocument
44  	 * 
45  	 * @param doc
46  	 *            The document to transform
47  	 * 
48  	 * @return string representation
49  	 */
50  	public String DOM2String(Document doc);
51  
52  	/***
53  	 * Creates an new DOMDocument from the given string
54  	 * 
55  	 * @param data
56  	 *            the string to parse
57  	 * 
58  	 * @return The new DOMDocument
59  	 */
60  	public Document String2DOM(String data);
61  
62  	/***
63  	 * Creates a new empty DOMDocument
64  	 * 
65  	 * @return An empty DOMDocument
66  	 */
67  	public Document newDOMDocument();
68  
69  	/***
70  	 * Reads a DOMDocument from given InputStream
71  	 * 
72  	 * @param in
73  	 *            The InputStream to read
74  	 * 
75  	 * @return The new parsed DOMDocument
76  	 */
77  	public Document read(InputStream in);
78  
79  	/***
80  	 * Reads a DOMDocument from given url
81  	 * 
82  	 * @param url
83  	 *            the url to read from
84  	 * 
85  	 * @return The new parsed DOMDocument
86  	 */
87  	public Document read(String url);
88  
89  	/***
90  	 * Writes a DOMElement into an OutputStream
91  	 * 
92  	 * @param out
93  	 *            OutputStream to write into
94  	 * @param root
95  	 *            root element to start writing
96  	 */
97  	public void write(OutputStream out, Element root) throws IOException;
98  
99  	/***
100 	 * Writes a DOMDocument into an OutputStream
101 	 * 
102 	 * @param out
103 	 *            OutputStream to write into
104 	 * @param doc
105 	 *            doc to write
106 	 */
107 	public void write(OutputStream out, Document doc) throws IOException;
108 
109 	/***
110 	 * Writes an DOMDocument into a file
111 	 * 
112 	 * @param url
113 	 *            The url to write to
114 	 * @param doc
115 	 *            The document to write
116 	 */
117 	public void write(String url, Document doc) throws IOException;
118 
119 	/***
120 	 * Writes an DOMElement into a file
121 	 * 
122 	 * @param url
123 	 *            The url to write to
124 	 * @param root
125 	 *            root element to start writing
126 	 */
127 	public void write(String url, Element root) throws IOException;
128 
129 	/***
130 	 * returns an new created XPathEvaluator
131 	 * 
132 	 * @return the new XPathEvaluator
133 	 */
134 	public XPathEvaluator newXPathEvaluator();
135 
136 }