KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > impl > ElementsProxyList


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.impl;
16
17 import java.util.AbstractList JavaDoc;
18 import java.util.List JavaDoc;
19
20 import org.apache.hivemind.HiveMind;
21 import org.apache.hivemind.events.RegistryShutdownListener;
22
23 /**
24  * The List implementation visible to the client code. It defers
25  * to another inner implementation of List; initially this is
26  * a {@link org.apache.hivemind.impl.ElementsInnerProxyList}, but the
27  * inner proxy replaces itself with a real List implementation containing
28  * the actual configuration elements.
29  *
30  * @author Howard Lewis Ship
31  */

32 public final class ElementsProxyList extends AbstractList JavaDoc implements RegistryShutdownListener
33 {
34     private List JavaDoc _inner;
35     private boolean _shutdown;
36
37     public void registryDidShutdown()
38     {
39         _shutdown = true;
40         _inner = null;
41     }
42
43     private void checkShutdown()
44     {
45         if (_shutdown)
46             throw HiveMind.createRegistryShutdownException();
47     }
48
49     public Object JavaDoc get(int index)
50     {
51         checkShutdown();
52
53         return _inner.get(index);
54     }
55
56     public int size()
57     {
58         checkShutdown();
59
60         return _inner.size();
61     }
62
63     public String JavaDoc toString()
64     {
65         return _inner.toString();
66     }
67
68     public boolean equals(Object JavaDoc o)
69     {
70         return _inner.equals(o);
71     }
72
73     public int hashCode()
74     {
75         return _inner.hashCode();
76     }
77
78     public void setInner(List JavaDoc list)
79     {
80         _inner = list;
81     }
82
83 }
84
Popular Tags