Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libTools / src / org / gvsig / tools / persistence / PersistenceFactory.java @ 30207

History | View | Annotate | Download (2.5 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

    
28
/**
29
 *
30
 */
31
package org.gvsig.tools.persistence;
32

    
33
/**
34
 * <p>
35
 * Interface for factories of objects that no implements {@link Persistent} and
36
 * must be supported by {@link PersistenceManager}.
37
 * </p>
38
 *
39
 * <p>
40
 * This can be used when the objects to persist can't be created by empty
41
 * constructor.
42
 *</p>
43
 *
44
 * @author jmvivo
45
 *
46
 *
47
 */
48
public interface PersistenceFactory {
49

    
50
        /**
51
         * <p>
52
         * Create a instance of <code>classToUse</code> from <code>state</code>
53
         * data.
54
         * </p>
55
         * <p>
56
         * <b>Note:</b>If is possible, creation must only instance the object and
57
         * load data must will do in
58
         * {@link #createFromState(PersistentState, Class)}
59
         * </p>
60
         * 
61
         *
62
         * @param state
63
         * @param classToUse
64
         * @return new instante of <code>classToUse</code>
65
         */
66
        public Object createFromState(PersistentState state, Class classToUse)
67
                        throws PersistenceException;
68

    
69
        /**
70
         * Load a instance of <code>classToUse</code> from <code>state</code> data.
71
         *
72
         * @param state
73
         * @param object
74
         */
75
        public void loadFromState(PersistentState state, Object object)
76
                        throws PersistenceException;
77

    
78
        /**
79
         * Fill <code>state</code> with data to persist of <code>obj</code>.
80
         *
81
         * @param state
82
         * @param obj
83
         */
84
        public void saveToState(PersistentState state, Object obj);
85

    
86
        /**
87
         * Informs if <code>object</code> is managed by this factory.
88
         *
89
         * @param object
90
         * @return
91
         */
92
        public boolean manages(Object object);
93

    
94
        /**
95
         * Informs if this factory can recreate the object represented by
96
         * <code>state</code>.
97
         *
98
         * @param object
99
         * @return
100
         */
101
        public boolean manages(PersistentState state);
102
}