]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db/src/org/simantics/db/ResourceSerializer.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / ResourceSerializer.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.db;\r
13 \r
14 import org.simantics.db.exception.DatabaseException;\r
15 import org.simantics.db.exception.InvalidResourceReferenceException;\r
16 import org.simantics.db.service.SerialisationSupport;\r
17 \r
18 /**\r
19  * @deprecated use {@link SerialisationSupport} instead\r
20  */\r
21 @Deprecated\r
22 public interface ResourceSerializer {\r
23 \r
24     /**\r
25      * Allocates and returns an identifier that can be stored persistently over\r
26      * time in a client and the database will be able to give you the\r
27      * corresponding Resource at a later time, until all statements of the\r
28      * resource are removed or the identifier is released by\r
29      * {@link #releaseRandomAccessForResource(String)}.\r
30      * \r
31      * <p>\r
32      * If random access is requested multiple times for a particular resource,\r
33      * the allocated ID's should be separate and each need to be released\r
34      * separately.\r
35      * \r
36      * <p>\r
37      * The format of the generated ID's should be such that they do not contain\r
38      * ':' characters.\r
39      * \r
40      * <p>\r
41      * To retrieve the Resource for the generated ID later a read transaction is\r
42      * needed where {@link ReadGraph#getResource(String)} can be used.\r
43      * \r
44      * @param resource\r
45      * @return a persistent identifier\r
46      * @throws InvalidResourceReferenceException ??? does this ever need to be\r
47      *         thrown ???\r
48      */\r
49     @Deprecated // in favor of getRandomAccessId\r
50     String createRandomAccessId(Resource resource)\r
51     throws InvalidResourceReferenceException;\r
52 \r
53     long getRandomAccessId(Resource resource) throws DatabaseException;\r
54     int getTransientId(Resource resource) throws DatabaseException;\r
55 \r
56     /**\r
57      * \r
58      * @param id\r
59      * @return\r
60      * @throws InvalidResourceReferenceException\r
61      */\r
62     @Deprecated // in favor of getResource(long)\r
63     Resource getResource(String randomAccessId)\r
64     throws InvalidResourceReferenceException;\r
65 \r
66     Resource getResource(long randomAccessId) throws DatabaseException;\r
67 \r
68     Resource getResource(int transientId) throws DatabaseException;\r
69 \r
70     /**\r
71      * @param identifier an identifier for a previously created random access\r
72      *        resource id using\r
73      *        {@link #createRandomAccessForResource(Resource)}.\r
74      * @return <code>true</code> if the id was successfully released and\r
75      *         <code>false</code> if the id did not exist.\r
76      * @throws InvalidResourceReferenceException\r
77      */\r
78     boolean disposeRandomAccessId(String randomAccessId)\r
79     throws InvalidResourceReferenceException;\r
80 \r
81 }\r