KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > Capabilities


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.management;
24
25
26 import java.util.Map JavaDoc;
27 import java.util.HashMap JavaDoc;
28 import java.util.Collections JavaDoc;
29
30
31 /**
32  */

33 public final class Capabilities
34 {
35     private final HashMap JavaDoc<String JavaDoc,Object JavaDoc> mItems;
36     
37     public static final String JavaDoc OFFLINE_KEY = "Offline";
38     
39         public
40     Capabilities()
41     {
42         mItems = new HashMap JavaDoc<String JavaDoc,Object JavaDoc>();
43     }
44     
45         public
46     Capabilities( final Object JavaDoc[] pairs )
47     {
48         this();
49         for( int i = 0; i < pairs.length; i +=2 )
50         {
51             add( (String JavaDoc)pairs[ i ], pairs[ i + 1] );
52         }
53     }
54     
55         public Map JavaDoc<String JavaDoc,Object JavaDoc>
56     getAll()
57     {
58         return Collections.unmodifiableMap( mItems );
59     }
60     
61     
62     public boolean getOfflineCapable()
63     {
64         return "true".equals( "" + mItems.get( OFFLINE_KEY ) );
65     }
66     
67     public void setOfflineCapable( boolean value )
68     {
69         add( OFFLINE_KEY, "" + value );
70     }
71     
72         public void
73     add( final String JavaDoc key, final Object JavaDoc value )
74     {
75         assert( ! mItems.containsKey( key ) );
76         mItems.put( key, value );
77     }
78 };
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Popular Tags