public static String toHtml5DataName ( String headlessCamelCaseName ) { if ( StringUtils . isEmpty ( headlessCamelCaseName ) ) { throw new IllegalArgumentException ( "Property name is empty." ) ; } if ( ! isHeadlessCamelCaseName ( headlessCamelCaseName ) ) { throw new IllegalArgumentException ( "This is not a valid headless camel case property name: " + headlessCamelCaseName ) ; } StringBuilder html5DataName = new StringBuilder ( HTML5_DATA_PREFIX ) ; for ( int i = 0 ; i < headlessCamelCaseName . length ( ) ; i ++ ) { char c = headlessCamelCaseName . charAt ( i ) ; if ( CharUtils . isAsciiAlphaUpper ( c ) ) { html5DataName . append ( ' ' ) ; } html5DataName . append ( Character . toLowerCase ( c ) ) ; } return html5DataName . toString ( ) ; }
Converts a headless camel case property name to a HTML5 data attribute name including data - prefix .