KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > config > Alias


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o.config;
22
23 /**
24  * Implement this interface when implementing special custom Aliases
25  * for classes, packages or namespaces.
26  * <br><br>Aliases can be used to persist classes in the running
27  * application to different persistent classes in a database file
28  * or on a db4o server.
29  * <br><br>Two simple Alias implementations are supplied along with
30  * db4o:<br>
31  * - {@link TypeAlias} provides an #equals() resolver to match
32  * names directly.<br>
33  * - {@link WildcardAlias} allows simple pattern matching
34  * with one single '*' wildcard character.<br>
35  * <br>
36  * It is possible to create
37  * own complex {@link Alias} constructs by creating own resolvers
38  * that implement the {@link Alias} interface.
39  * <br><br>
40  * Four examples of concrete usecases:
41  * <br><br>
42  * <code>
43  * <b>// Creating an Alias for a single class</b><br>
44  * Db4o.configure().addAlias(<br>
45  * &#160;&#160;new TypeAlias("com.f1.Pilot", "com.f1.Driver"));<br>
46  * <br><br>
47  * <b>// Accessing a .NET assembly from a Java package</b><br>
48  * Db4o.configure().addAlias(<br>
49  * &#160;&#160;new WildcardAlias(<br>
50  * &#160;&#160;&#160;&#160;"com.f1.*, F1RaceAssembly",<br>
51  * &#160;&#160;&#160;&#160;"com.f1.*"));<br>
52  * <br><br>
53  * <b>// Using a different local .NET assembly</b><br>
54  * Db4o.configure().addAlias(<br>
55  * &#160;&#160;new WildcardAlias(<br>
56  * &#160;&#160;&#160;&#160;"com.f1.*, F1RaceAssembly",<br>
57  * &#160;&#160;&#160;&#160;"com.f1.*, RaceClient"));<br>
58  * <br><br>
59  * <b>// Mapping a Java package onto another</b><br>
60  * Db4o.configure().addAlias(<br>
61  * &#160;&#160;new WildcardAlias(<br>
62  * &#160;&#160;&#160;&#160;"com.f1.*",<br>
63  * &#160;&#160;&#160;&#160;"com.f1.client*"));<br></code>
64  * <br><br>Aliases that translate the persistent name of a class to
65  * a name that already exists as a persistent name in the database
66  * (or on the server) are not permitted and will throw an exception
67  * when the database file is opened.
68  * <br><br>Aliases should be configured before opening a database file
69  * or connecting to a server.
70  */

71 public interface Alias {
72     
73     /**
74      * return the stored name for a runtime name or null if not handled.
75      */

76     public String JavaDoc resolveRuntimeName(String JavaDoc runtimeTypeName);
77     
78     /**
79      * return the runtime name for a stored name or null if not handled.
80      */

81     public String JavaDoc resolveStoredName(String JavaDoc storedTypeName);
82     
83
84 }
85
Popular Tags