01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file ../GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15: package org.griphyn.vdl.dbschema;
16:
17: import org.griphyn.vdl.parser.*;
18: import org.griphyn.vdl.util.Logging;
19: import org.griphyn.vdl.classes.*;
20:
21: /**
22: * This class adds a given Definition from the parser's callback into
23: * the fresh in-memory storage. It is a streamlined version of the more
24: * versatile {@link MemoryStorage} handler. End-users should not use
25: * this class.
26: *
27: * @author Jens-S. Vöckler
28: * @author Yong Zhao
29: * @version $Revision: 50 $
30: */
31: class MyCallbackHandler implements FinalizerHandler {
32: /**
33: * This is a reference to the already established in-memory storage.
34: */
35: private Definition m_memory;
36:
37: /**
38: * The c'tor initializes the references to a single Definition.
39: */
40: public MyCallbackHandler() {
41: this .m_memory = null;
42: }
43:
44: /**
45: * Returns the value stored by the XML reader's callback function.
46: *
47: * @return a single Definition that was read, or <code>null</code>.
48: */
49: public Definition getDefinition() {
50: return this .m_memory;
51: }
52:
53: /**
54: * This method adds the given Definition to whatever storage is
55: * implemented underneath.
56: *
57: * @param d is the Definition that is ready to be stored.
58: * @return true, if new version was stored and database modified
59: */
60: public boolean store(VDL d) {
61: if (d instanceof Definition) {
62: this .m_memory = (Definition) d;
63: Logging.instance().log("chunk", 0,
64: "found " + m_memory.shortID());
65: return true;
66: } else {
67: Logging.instance().log("chunk", 0,
68: "not a definition: " + d.toString());
69: return false;
70: }
71: }
72: }
|