litesoft
@ 811
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.core.hierarchicaldata; import org.litesoft.core.typeutils.*; public class HierarchicalData { public static String validateName( String pWhatTypeName, String pName ) { String name = Strings.deNull( pName ).trim(); if ( name.length() != 0 ) { if ( Characters.isAlpha( name.charAt( 0 ) ) ) { boolean ok = true; for ( int i = 1; ok && (i < name.length()); i++ ) { char c = name.charAt( i ); ok = (c == '.') || (c == '_') || Characters.isAlphaNumeric( c ); } if ( ok ) { return name; } } } throw new IllegalArgumentException( "Unacceptable " + pWhatTypeName + " of '" + pName + "'" ); } } |