从给定的合格参考值中提取名称。
/******************************************************************************* * Copyright (c) 2004 Actuate Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Actuate Corporation - initial API and implementation *******************************************************************************///时 代 Java - nowjava.com public class Main{ public static void main(String[] argv){ String qualifiedName = "nowjava.com"; System.out.println(extractName(qualifiedName)); } /** * Extracts the name from the given qualified reference value. * * <p> * For example, * <ul> * <li>"style1" is extracted from "LibA.style1" * <li>"style1" is returned from "style1" * </ul> * * @param qualifiedName * the qualified reference value * @return the name */ public static String extractName(String qualifiedName) { if (qualifiedName == null) return null; int pos = qualifiedName.indexOf('.'); if (pos == -1) /* from nowjava.com - 时 代 Java */ return qualifiedName; return trimString(qualifiedName.substring(pos + 1)); } /** * Trim a string. Removes leading and trailing blanks. If the resulting * string is empty, normalizes the string to an null string. * * @param value * the string to trim * @return the trimmed string, or null if the string is empty */