Java Class Name Format classToAttributeName(Class clazz)

Here you can find the source of classToAttributeName(Class clazz)

Description

Helper method to convert a class name into a suitable attribute name.

License

Open Source License

Parameter

Parameter Description
clazz the Class

Return

the attribute name

Declaration

public static String classToAttributeName(Class<?> clazz) 

Method Source Code

//package com.java2s;
// compliance with the InfoGrid license. The InfoGrid license and important

public class Main {
    /**/*from ww  w .  j  a v a 2 s . c  o  m*/
     * Helper method to convert a class name into a suitable attribute name.
     *
     * @param clazz the Class
     * @return the attribute name
     */
    public static String classToAttributeName(Class<?> clazz) {
        String ret = clazz.getName();
        ret = ret.replaceAll("\\.", "_");
        return ret;
    }

    /**
     * Helper method to convert a class name and a local fragment into a suitable attribute name.
     *
     * @param clazz the Class
     * @param fragment the fragment, or local id
     * @return the attribute name
     */
    public static String classToAttributeName(Class<?> clazz,
            String fragment) {
        String ret = clazz.getName();
        ret = ret.replaceAll("\\.", "_");
        ret = ret + "__" + fragment;
        return ret;
    }
}

Related

  1. classToFile(String name)
  2. classToFilename(Class clazz)
  3. classToFileName(String str)
  4. classToInstance(String uriClass)