1 /**
2 * Copyright 2005-2006 the original author or authors.
3 *
4 * Licensed under the Gnu General Pubic License, Version 2.0 (the
5 * "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/gpl-license.php
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the Gnu General Public License for more details.
14 */
15 package org.figure8.join.core.persistence;
16
17 import org.figure8.join.core.InfrastructureException;
18
19 import java.io.Writer;
20 import java.io.InputStream;
21 import java.io.IOException;
22 import java.util.Collection;
23 /**
24 * This is an interface defining export/import methods for entity objects
25 * to/from the Xml format. Entities should loaded/saved from another mean
26 * before using these methods.
27 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
28 * @version $Revision: 1.1 $
29 */
30 public interface XmlDatabinder{
31
32
33
34 /**
35 * Load a collection of {@link org.figure8.join.core.EntityObject}s from a Xml stream
36 * @param is An input stream containing Xml exported form of entity objects
37 * @throws InfrastructureException if entity objects cannot be recreated from stream
38 * @throws IOException if stream cannot be correctly read
39 * @return A collection of {@link org.figure8.join.core.EntityObject}s
40 */
41 public abstract Collection loadFromXml(InputStream is) throws InfrastructureException, IOException;
42
43 /**
44 * Write a collection of {@link org.figure8.join.core.EntityObject}s using their Xml form
45 * @param writer The writer to use for outputing entity objects
46 * @param dao The data access objects from whom are retrievied entities (using the findAll() method)
47 * @throws InfrastructureException if entity objects cannot be exported corectly
48 * @throws IOException if writer cannot be correctly written
49 */
50 public abstract void writeToXml(Writer writer, ObjectDao dao) throws InfrastructureException, IOException;
51 }