View Javadoc

1   /*
2    * Copyright (C) 2004 Christian Siefkes <christian@siefkes.net>.
3    * Development of this software is supported by the German Research Society,
4    * Berlin-Brandenburg Graduate School in Distributed Information Systems
5    * (DFG grant no. GRK 316).
6    *
7    * This library is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU Lesser General Public
9    * License as published by the Free Software Foundation; either
10   * version 2.1 of the License, or (at your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this library; if not, visit
19   * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21   */
22  package de.fu_berlin.ties.xml.io;
23  
24  /***
25   * Classes implementing this interface support serialization in a
26   * human-readable XML-based format.
27   *
28   * <p>Non-abstract implementations of this interface must support
29   * deserialization by providing a public constructor that accepts a
30   * {@link org.dom4j.Element} as single parameter that reads all
31   * relevant field values from the XML element. There is no way to enforce this
32   * convention (as interfaces cannot contain constructors), but
33   * deserialization via 
34   * {@link de.fu_berlin.ties.xml.io.ObjectElement#createObject(org.dom4j.Element,
35   * Class)} will fail when it is violated. Deserialization is based on a
36   * constructor instead of a "restore" or "init" method to allow the
37   * deserialization of immutable objects (whose fields cannot be changed after
38   * construction).
39   *
40   * @author Christian Siefkes
41   * @version $Revision: 1.1 $, $Date: 2004/12/06 18:00:41 $, $Author: siefkes $
42   */
43  public interface XMLStorable {
44  
45      /***
46       * Stores all relevant fields of this object in an XML element for
47       * serialization. An equivalent object can be created by calling {@link
48       * de.fu_berlin.ties.xml.io.ObjectElement#createObject(org.dom4j.Element,
49       * Class)} on the created element.
50       *
51       * @return the created XML element
52       */
53      ObjectElement toElement();
54  
55  }