KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > pageflow > scoping > internal > ScopedAttributeContainer


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

18 package org.apache.beehive.netui.pageflow.scoping.internal;
19
20 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
21
22
23 /**
24  * Base class for wrapper objects that keep their own scoped attributes, ignoring the attributes
25  * of the wrapped objects.
26  */

27 public class ScopedAttributeContainer extends AttributeContainer
28 {
29     private Object JavaDoc _scopeKey;
30
31     public ScopedAttributeContainer( Object JavaDoc scopeKey )
32     {
33         _scopeKey = scopeKey;
34     }
35
36     public final String JavaDoc getScopedName( String JavaDoc baseName )
37     {
38         return ScopedServletUtils.getScopedName( baseName, _scopeKey );
39     }
40
41     public boolean isInScope( String JavaDoc keyName )
42     {
43         return isInScope( keyName, _scopeKey );
44     }
45
46     public static boolean isInScope( String JavaDoc keyName, Object JavaDoc scopeKey )
47     {
48         return keyName.startsWith( scopeKey.toString() );
49     }
50
51     public String JavaDoc removeScope( String JavaDoc keyName )
52     {
53         return removeScope( keyName, _scopeKey );
54     }
55     
56     public static String JavaDoc removeScope( String JavaDoc keyName, Object JavaDoc scopeKey )
57     {
58         assert keyName.startsWith( scopeKey.toString() ) : keyName;
59         return keyName.substring( scopeKey.toString().length() );
60     }
61     
62     public final Object JavaDoc getScopeKey()
63     {
64         return _scopeKey;
65     }
66
67     public void renameScope( Object JavaDoc newScopeKey )
68     {
69         _scopeKey = newScopeKey;
70     }
71 }
72
Popular Tags