KickJava   Java API By Example, From Geeks To Geeks.

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


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  
24 /*
25  * $Header: /cvs/glassfish/admin-core/mbeanapi/src/java/com/sun/appserv/management/util/jmx/AttributeNameMapper.java,v 1.5 2005/12/25 03:51:21 tcfujii Exp $
26  * $Revision: 1.5 $
27  * $Date: 2005/12/25 03:51:21 $
28  */

29
30 package com.sun.appserv.management.util.jmx;
31
32
33 import java.util.Set JavaDoc;
34
35 /**
36     Maps names to a derived name. An example use for this might be to map a JMX
37     Attribute "foo-bar" to a suiteable "FooBar" form so that it can be used
38     as a Java identifier.
39  */

40 public interface AttributeNameMapper
41 {
42     /**
43         Determine if the attribute name requires mapping.
44         
45         @param originalName the original name from which a derived name is made
46      */

47     //public boolean requiresMapping( String originalName );
48

49     /**
50         @param originalName the original/source/real name of the Attribute
51         @param derivedName the name by which it should be known
52      */

53     public void addMapping( final String JavaDoc originalName, final String JavaDoc derivedName );
54     
55     /**
56         Don't perform any mapping on this name. Equivalent to calling
57         addMapping( originalName, originalName )
58         
59         @param originalName the "real" name of the Attribute
60      */

61     public void dontMap( final String JavaDoc originalName );
62     
63     /**
64         Setup mapping for all specified Attribute names. These add to (or replace)
65         any existing mappings.
66         
67         @param originalNames all names from which should be derived names
68      */

69     public void deriveAll( final String JavaDoc[] originalNames );
70     
71     /**
72         Attempt to match the derived name to one of the candidates.
73         This facility is used when different runtime conditions
74         present different original names which must be mapped to the
75         same derived name.
76         <p>
77         If a name is matched it is added as a mapping and the
78         original name is returned.
79      */

80         public String JavaDoc
81     matchName(
82         final String JavaDoc derivedName,
83         final String JavaDoc[] candidates );
84         
85     /**
86         Maps Attribute names to another name.
87         <p>
88         A common use is to construct legal Java identifiers, so that they can
89         be exposed in an MBean proxy with get/set routines.
90         <p>
91         For example "classpath-prefix" is not legal in a Java API; it could not
92         generate the methods getclasspath-prefix() and setclasspath-prefix().
93         <p>
94         Any legal mapping is OK. Suggested possible mappings include:
95         ClasspathPrefix, classpathPrefix, classpath_prefix, etc. These would
96         result in the method names: getClasspathPrefix(), getclasspathPrefix(),
97         getclasspath_prefix(), etc.
98         
99         @param originalName original name
100      */

101     public String JavaDoc originalToDerived( String JavaDoc originalName );
102     
103     /**
104         Reverse the effect of originalToDerived()
105         
106         @param derivedName name derived from the original one
107      */

108     public String JavaDoc derivedToOriginal( String JavaDoc derivedName );
109     
110     
111     /**
112         Get the entire set of Attribute names, consisting of the names
113         that were derived, and the names that do not require mapping.
114      */

115     public Set JavaDoc<String JavaDoc> getAttributeNames( );
116 }
117
Popular Tags