集册 Java实例教程 从给定的合格参考值中提取库名称空间。

从给定的合格参考值中提取库名称空间。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

559
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
从给定的合格参考值中提取库名称空间。
/** n o w j a v a . c o m 提 供 **/

/*******************************************************************************

 * 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

 *******************************************************************************/



public class Main{

    public static void main(String[] argv){

        String qualifiedName = "nowjava.com";

        System.out.println(extractNamespace(qualifiedName));

    }

    /**

     * Extracts the library namespace from the given qualified reference value.

     * <p>

     * For example,

     * <ul>

     * <li>"LibA" is extracted from "LibA.style1"

     * <li>null is returned from "style1"

     * </ul>

     * 

     * @param qualifiedName

     *            the qualified reference value

     * @return the library namespace

     */


    public static String extractNamespace(String qualifiedName) {

        if (qualifiedName == null)

            return null;


        int pos = qualifiedName.indexOf('.');

        if (pos == -1)

            return null;


        return trimString(qualifiedName.substring(0, pos));
        /* 
        *来 自
         时代Java
        */

    }

    /**

     * 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

     */


    
展开阅读全文