Java tutorial
//package com.java2s; /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * The set of exceptions to the normal rules used by * <code>createManagedBean()</code>. The first element of each pair * is a class name, and the second element is the managed bean name. */ private static final String exceptions[][] = { { "org.apache.catalina.users.MemoryGroup", "Group" }, { "org.apache.catalina.users.MemoryRole", "Role" }, { "org.apache.catalina.users.MemoryUser", "User" }, }; /** * Create and return the name of the <code>ManagedBean</code> that * corresponds to this Catalina component. * * @param component The component for which to create a name */ static String createManagedName(Object component) { // Deal with exceptions to the standard rule String className = component.getClass().getName(); for (int i = 0; i < exceptions.length; i++) { if (className.equals(exceptions[i][0])) { return (exceptions[i][1]); } } // Perform the standard transformation int period = className.lastIndexOf('.'); if (period >= 0) className = className.substring(period + 1); return (className); } }