Java Class Name Format classToInstance(String uriClass)

Here you can find the source of classToInstance(String uriClass)

Description

Constructs the URI for instance by the URI of class.

License

Open Source License

Parameter

Parameter Description
uriClass URI of a class

Return

URI for an instance

Declaration

public static String classToInstance(String uriClass) 

Method Source Code

//package com.java2s;
/**/*from w w w  .  jav  a2  s  . c o m*/
 * Copyright 2015 Pozna? Supercomputing and Networking Center
 *
 * Licensed under the GNU General Public License, Version 3.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.gnu.org/licenses/gpl-3.0.txt
 *
 * 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 {
    /**
     * Constructs the URI for instance by the URI of class.
     * 
     * @param uriClass
     *            URI of a class
     * @return URI for an instance
     */
    public static String classToInstance(String uriClass) {
        int sepidx = uriClass.indexOf('#');
        if (sepidx == -1) {
            sepidx = uriClass.lastIndexOf('/');
        }
        if (sepidx == -1) {
            sepidx = uriClass.lastIndexOf(':');
        }
        if (sepidx == -1) {
            throw new IllegalArgumentException("No separator character founds in URI: " + uriClass);
        }
        sepidx++;
        String className = uriClass.substring(sepidx);
        if (className.length() > 0) {
            className = className.substring(0, 1).toLowerCase().concat(className.substring(1));
        }
        return uriClass.substring(0, sepidx).concat(className).concat("Instance");
    }
}

Related

  1. classToAttributeName(Class clazz)
  2. classToFile(String name)
  3. classToFilename(Class clazz)
  4. classToFileName(String str)
  5. classToLDAPName(Class c)
  6. classToPath(Class clazz)
  7. classToPath(String name, boolean resource)
  8. classToResource(String className)