KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > util > jmx > NoOpAttributeNameMapper


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.appserv.management.util.jmx;
24
25 import java.util.Set JavaDoc;
26 import java.util.Collections JavaDoc;
27
28 import com.sun.appserv.management.util.misc.GSetUtil;
29 import com.sun.appserv.management.util.misc.GSetUtil;
30
31 /**
32     A mapper that maps every name to itself.
33  */

34 public final class NoOpAttributeNameMapper implements AttributeNameMapper
35 {
36     final Set JavaDoc<String JavaDoc> mAttributeSet;
37     
38     /**
39         Create a new instance which will map (as necessary) the specified
40         Attribute names.
41         Same as AttributeNameMapperImpl( attributeNames, new AttributeNameManglerImpl() )
42      */

43         public
44     NoOpAttributeNameMapper( final String JavaDoc[] originalNames )
45     {
46         mAttributeSet = GSetUtil.newStringSet( originalNames );
47     }
48     
49
50         public String JavaDoc
51     matchName(
52         final String JavaDoc derivedName,
53         final String JavaDoc[] candidates )
54     {
55         throw new UnsupportedOperationException JavaDoc( "matchName" );
56     }
57     
58         public void
59     dontMap( final String JavaDoc originalName )
60     {
61         addMapping( originalName, originalName );
62     }
63     
64         public void
65     deriveAll( final String JavaDoc[] originalNames )
66     {
67         GSetUtil.addArray( mAttributeSet, originalNames );
68     }
69     
70         public void
71     addMapping(
72         final String JavaDoc originalName,
73         final String JavaDoc derivedName )
74     {
75         if ( ! originalName.equals( derivedName ) )
76         {
77             throw new IllegalArgumentException JavaDoc( derivedName );
78         }
79         
80         mAttributeSet.add( originalName );
81     }
82     
83         public boolean
84     requiresMapping( final String JavaDoc originalName )
85     {
86         return( false );
87     }
88     
89         public String JavaDoc
90     originalToDerived( final String JavaDoc originalName )
91     {
92         return( originalName );
93     }
94     
95         public String JavaDoc
96     derivedToOriginal( final String JavaDoc derivedName )
97     {
98         return( derivedName );
99     }
100     
101         public Set JavaDoc<String JavaDoc>
102     getAttributeNames( )
103     {
104         return( Collections.unmodifiableSet( mAttributeSet ) );
105     }
106 }
107
Popular Tags