Java Class Field Convert To fieldToColumnName(String name)

Here you can find the source of fieldToColumnName(String name)

Description

field To Column Name

License

Open Source License

Declaration

public static String fieldToColumnName(String name) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String fieldToColumnName(String name) {

        if (name == null || name.isEmpty()) {
            return name;
        }//from   w  w w.  j a  v a2  s .com

        StringBuffer buf = new StringBuffer(name.replace('.', '_'));
        for (int i = 1; i < buf.length() - 1; i++) {
            if ('_' != buf.charAt(i - 1) && Character.isUpperCase(buf.charAt(i))
                    && !Character.isUpperCase(buf.charAt(i + 1))) {
                buf.insert(i++, '_');
            }
        }
        return buf.toString().toUpperCase();
    }
}

Related

  1. fieldToGetMethod(String fieldName)
  2. fieldToProperty(String field)
  3. fieldToPropertyName(String name)
  4. fieldToString(String name, Object value)