KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > services > context > ContextImpl


1 /*
2
3    Derby - Class org.apache.derby.iapi.services.context.ContextImpl
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.services.context;
23
24 /**
25  * Contexts are created and used to manage the execution
26  * environment. They provide a convenient location for
27  * storing globals organized by the module using the
28  * globals.
29  * <p>
30  * We provide this abstract class for other implementations
31  * to use so that they can simply add fields and operations on
32  * them. To be usable by the context manager, the subclasses
33  * must define CleanupOnError and call super() in any constructor.
34  * <p>
35  * Contexts assist in cleanup
36  * when errors are caught in the outer block.
37  * <p>
38  * Contexts implement the sanity interface to check and provide
39  * information about their contents.
40  */

41 public abstract class ContextImpl
42     implements Context
43 {
44     private final String JavaDoc myIdName;
45     private final ContextManager myContextManager;
46
47     /*
48      * class interface
49      */

50     protected ContextImpl(ContextManager cm, String JavaDoc id) {
51         myIdName = id;
52         myContextManager = cm;
53         cm.pushContext(this);
54     }
55
56     /*
57      * Context interface
58      */

59     /**
60      * @see org.apache.derby.iapi.services.context.Context#getContextManager
61      */

62     final public ContextManager getContextManager()
63     {
64         return myContextManager;
65     }
66
67     /**
68      * @see org.apache.derby.iapi.services.context.Context#getIdName
69      */

70     final public String JavaDoc getIdName()
71     {
72         return myIdName;
73     }
74
75     final public void pushMe() {
76         getContextManager().pushContext(this);
77     }
78
79     /** @see Context#popMe */
80     final public void popMe() {
81         getContextManager().popContext(this);
82     }
83
84     /**
85      * @see Context#isLastHandler
86      */

87     public boolean isLastHandler(int severity)
88     {
89         return false;
90     }
91
92     public StringBuffer JavaDoc appendErrorInfo() {
93         return null;
94     }
95 }
96
Popular Tags