Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / persistence / PersistenceFactory.java @ 330

History | View | Annotate | Download (5.56 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
import java.util.List;
34

    
35
import org.gvsig.tools.dynobject.DynObject;
36
import org.gvsig.tools.dynobject.DynStruct;
37
import org.gvsig.tools.persistence.exception.PersistenceException;
38

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

    
54
//        /**
55
//         * <p>
56
//         * Create a instance of <code>classToUse</code> from <code>state</code>
57
//         * data.
58
//         * </p>
59
//         * <p>
60
//         * <b>Note:</b>If possible, this method should only create the object 
61
//         * instance and set the object properties in the
62
//         * {@link #loadFromState(PersistentState, Object)} method, as it will
63
//         * be called afterwards.
64
//         * </p>
65
//         *
66
//         *
67
//         * @param state
68
//         * @param classToUse
69
//         * @return new instante of <code>classToUse</code>
70
//         * @deprecated use instead {@link #createFromState(PersistentState)} 
71
//         */
72
//        public Object createFromState(PersistentState state, Class classToUse)
73
//        throws PersistenceException;
74

    
75
        /**
76
         * Create an instance of the object represented by the state.
77
         * 
78
         * This method can't call {@link #loadFromState(PersistentState, Object)} only create 
79
         * the object. 
80
         * 
81
         * @param state
82
         * @return the object
83
         */
84
        public Object createFromState(PersistentState state)        throws PersistenceException;
85

    
86
        
87
        /**
88
         * Load a instance of <code>classToUse</code> from <code>state</code> data.
89
         *
90
         * @param state
91
         * @param object
92
         */
93
        public void loadFromState(PersistentState state, Object object)
94
                        throws PersistenceException;
95

    
96
        /**
97
         * Fill <code>state</code> with data to persist of <code>obj</code>.
98
         * 
99
         * @param state
100
         * @param obj
101
         * @throws PersistenceException
102
         */
103
        public void saveToState(PersistentState state, Object obj)
104
                        throws PersistenceException;
105

    
106
        /**
107
         * Informs if <code>object</code> is managed by this factory.
108
         *
109
         * @param object
110
         * @return true if the object is managed by the factory.
111
         */
112
        public boolean manages(Object object);
113

    
114
        /**
115
         * Informs if <code>theClass</code> is managed by this factory.
116
         *
117
         * @param class to check.
118
         * @return true if the class is managed by the factory.
119
         */
120
        public boolean manages(Class theClass);
121

    
122
        /**
123
         * Informs if this factory can recreate the object represented by
124
         * <code>state</code>.
125
         *
126
         * @param object
127
         * @return
128
         */
129
        public boolean manages(PersistentState state);
130

    
131
        /**
132
         * Return a List of the definition managed by this factory where the key is
133
         * <code>className</code> and value is <code>definition</code>
134
         *
135
         * @return Map<String, DynStruct>
136
         */
137
        public List getDefinitions();
138
                
139
        /**
140
         * Returns the associated definition to the java class name
141
         * @param className of a java Class
142
         * @return the related definition or null if not managed by this factory
143
         */
144
        public DynStruct getDefinition(String className);
145
        
146
        /**
147
         * Returns the domain name of the objects persisted by this factory.
148
         * @return the domain name
149
         */
150
        public String getDomainName();
151
        
152
        /**
153
         * Returns the domain URL to use for the schema.
154
         * @return the domain URL
155
         */
156
        public String getDomainURL();
157
        
158
        /**
159
         * Return the list of classes or interfaces managed by this
160
         * factory. 
161
         * Can return null if factory not use it.
162
         * 
163
         * @return List of interfaces the factory manage
164
         */
165
        public List getManagedClasses();
166
        
167
        /**
168
         * Return the class or interface the factory asociate to
169
         * the object.
170
         * Can return null if factory not asociate an interface to
171
         * the object.
172
         * 
173
         * @param object
174
         * @return interface the factory manage asociated to the object.
175
         */
176
        public Class getManagedClass(Object object);
177
        
178
        /**
179
         * Return the name class or interface the factory asociate to
180
         * the object.
181
         * Can return null if factory not asociate an interface to
182
         * the object.
183
         * 
184
         * @param object
185
         * @return interface the factory manage asociated to the object.
186
         */
187
        public String getManagedClassName(Object object);
188

    
189
        /**
190
         * Return the class or interface the factory asociate to
191
         * the object.
192
         * Can return null if factory not asociate an interface to
193
         * the object.
194
         * 
195
         * @param state
196
         * @return interface or class  the factory manage asociated to the state.
197
         */
198
        public Class getManagedClass(PersistentState state);
199

    
200
        /**
201
         * Return the class or interface the factory asociate to
202
         * the java class name.
203
         * Can return null if factory not asociate an interface to
204
         * that name.
205
         * 
206
         * @param name
207
         * @return interface or class the factory manage asociated to the name.
208
         */
209
        public Class getManagedClass(String name);
210
        
211
}