01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: 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: *   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: *   new WildcardAlias(<br>
50: *     "Tutorial.F1.*, Tutorial",<br>
51: *     "com.f1.*"));<br>
52: * <br><br>
53: * <b>// Mapping a Java package onto another</b><br>
54: * Db4o.configure().addAlias(<br>
55: *   new WildcardAlias(<br>
56: *     "com.f1.*",<br>
57: *     "com.f1.client*"));<br></code>
58: * <br><br>Aliases that translate the persistent name of a class to
59: * a name that already exists as a persistent name in the database
60: * (or on the server) are not permitted and will throw an exception
61: * when the database file is opened.
62: * <br><br>Aliases should be configured before opening a database file
63: * or connecting to a server.
64: */
65: public interface Alias {
66:
67: /**
68: * return the stored name for a runtime name or null if not handled.
69: */
70: public String resolveRuntimeName(String runtimeTypeName);
71:
72: /**
73: * return the runtime name for a stored name or null if not handled.
74: */
75: public String resolveStoredName(String storedTypeName);
76:
77: }
|