@Test public void testIsAttributeNameValid() { assertFalse( SchemaUtils.isAttributeNameValid( null ) ); assertFalse( SchemaUtils.isAttributeNameValid( "" ) ); assertFalse( SchemaUtils.isAttributeNameValid( " " ) ); assertTrue( SchemaUtils.isAttributeNameValid( "a" ) ); assertTrue( SchemaUtils.isAttributeNameValid( "ObjectClass-text_test123" ) ); assertFalse( SchemaUtils.isAttributeNameValid( "-text_test123" ) ); assertFalse( SchemaUtils.isAttributeNameValid( "text_te&st123" ) ); assertFalse( SchemaUtils.isAttributeNameValid( "text_te st123" ) ); assertTrue( SchemaUtils.isAttributeNameValid( "0" ) ); assertTrue( SchemaUtils.isAttributeNameValid( "0" ) ); assertFalse( SchemaUtils.isAttributeNameValid( "00.1.2.3" ) ); assertFalse( SchemaUtils.isAttributeNameValid( "0.1.2..3" ) ); assertFalse( SchemaUtils.isAttributeNameValid( "0.01.2.3" ) ); }
public static boolean isAttributeNameValid( String attributeName ) { if ( Strings.isEmpty( attributeName ) ) { return false; } boolean descr; boolean zero = false; boolean dot = false; char c = attributeName.charAt( 0 ); if ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) ) { descr = true; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { descr = false; zero = c == '0'; } else { return false; } for ( int i = 1; i < attributeName.length(); i++ ) { c = attributeName.charAt( i ); if ( descr ) { if ( ( ( c < 'a' ) || ( c > 'z' ) ) && ( ( c < 'A' ) || ( c > 'Z' ) ) && ( ( c < '0' ) || ( c > '9' ) ) && ( c != '-' ) && ( c != '_' ) ) { return false; } } else { if ( c == '.' ) { if ( dot ) { return false; } dot = true; zero = false; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { dot = false; if ( zero ) { return false; } else if ( c == '0' ) { zero = true; } } else { return false; } } } return true; }
SchemaUtils { public static boolean isAttributeNameValid( String attributeName ) { if ( Strings.isEmpty( attributeName ) ) { return false; } boolean descr; boolean zero = false; boolean dot = false; char c = attributeName.charAt( 0 ); if ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) ) { descr = true; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { descr = false; zero = c == '0'; } else { return false; } for ( int i = 1; i < attributeName.length(); i++ ) { c = attributeName.charAt( i ); if ( descr ) { if ( ( ( c < 'a' ) || ( c > 'z' ) ) && ( ( c < 'A' ) || ( c > 'Z' ) ) && ( ( c < '0' ) || ( c > '9' ) ) && ( c != '-' ) && ( c != '_' ) ) { return false; } } else { if ( c == '.' ) { if ( dot ) { return false; } dot = true; zero = false; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { dot = false; if ( zero ) { return false; } else if ( c == '0' ) { zero = true; } } else { return false; } } } return true; } }
SchemaUtils { public static boolean isAttributeNameValid( String attributeName ) { if ( Strings.isEmpty( attributeName ) ) { return false; } boolean descr; boolean zero = false; boolean dot = false; char c = attributeName.charAt( 0 ); if ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) ) { descr = true; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { descr = false; zero = c == '0'; } else { return false; } for ( int i = 1; i < attributeName.length(); i++ ) { c = attributeName.charAt( i ); if ( descr ) { if ( ( ( c < 'a' ) || ( c > 'z' ) ) && ( ( c < 'A' ) || ( c > 'Z' ) ) && ( ( c < '0' ) || ( c > '9' ) ) && ( c != '-' ) && ( c != '_' ) ) { return false; } } else { if ( c == '.' ) { if ( dot ) { return false; } dot = true; zero = false; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { dot = false; if ( zero ) { return false; } else if ( c == '0' ) { zero = true; } } else { return false; } } } return true; } private  SchemaUtils(); }
SchemaUtils { public static boolean isAttributeNameValid( String attributeName ) { if ( Strings.isEmpty( attributeName ) ) { return false; } boolean descr; boolean zero = false; boolean dot = false; char c = attributeName.charAt( 0 ); if ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) ) { descr = true; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { descr = false; zero = c == '0'; } else { return false; } for ( int i = 1; i < attributeName.length(); i++ ) { c = attributeName.charAt( i ); if ( descr ) { if ( ( ( c < 'a' ) || ( c > 'z' ) ) && ( ( c < 'A' ) || ( c > 'Z' ) ) && ( ( c < '0' ) || ( c > '9' ) ) && ( c != '-' ) && ( c != '_' ) ) { return false; } } else { if ( c == '.' ) { if ( dot ) { return false; } dot = true; zero = false; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { dot = false; if ( zero ) { return false; } else if ( c == '0' ) { zero = true; } } else { return false; } } } return true; } private  SchemaUtils(); static Entry getTargetEntry( List<? extends Modification> mods, Entry entry ); static StringBuilder render( StringBuilder buf, List<String> qdescrs ); static StringBuilder render( ObjectClass[] ocs ); static StringBuilder render( StringBuilder buf, ObjectClass[] ocs ); static StringBuilder render( AttributeType[] ats ); static StringBuilder render( StringBuilder buf, AttributeType[] ats ); static StringBuilder render( Map<String, List<String>> extensions ); static String render( LoadableSchemaObject description ); static String stripOptions( String attributeId ); static Set<String> getOptions( String attributeId ); static byte[] uuidToBytes( UUID uuid ); static boolean isAttributeNameValid( String attributeName ); }
SchemaUtils { public static boolean isAttributeNameValid( String attributeName ) { if ( Strings.isEmpty( attributeName ) ) { return false; } boolean descr; boolean zero = false; boolean dot = false; char c = attributeName.charAt( 0 ); if ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) ) { descr = true; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { descr = false; zero = c == '0'; } else { return false; } for ( int i = 1; i < attributeName.length(); i++ ) { c = attributeName.charAt( i ); if ( descr ) { if ( ( ( c < 'a' ) || ( c > 'z' ) ) && ( ( c < 'A' ) || ( c > 'Z' ) ) && ( ( c < '0' ) || ( c > '9' ) ) && ( c != '-' ) && ( c != '_' ) ) { return false; } } else { if ( c == '.' ) { if ( dot ) { return false; } dot = true; zero = false; } else if ( ( c >= '0' ) && ( c <= '9' ) ) { dot = false; if ( zero ) { return false; } else if ( c == '0' ) { zero = true; } } else { return false; } } } return true; } private  SchemaUtils(); static Entry getTargetEntry( List<? extends Modification> mods, Entry entry ); static StringBuilder render( StringBuilder buf, List<String> qdescrs ); static StringBuilder render( ObjectClass[] ocs ); static StringBuilder render( StringBuilder buf, ObjectClass[] ocs ); static StringBuilder render( AttributeType[] ats ); static StringBuilder render( StringBuilder buf, AttributeType[] ats ); static StringBuilder render( Map<String, List<String>> extensions ); static String render( LoadableSchemaObject description ); static String stripOptions( String attributeId ); static Set<String> getOptions( String attributeId ); static byte[] uuidToBytes( UUID uuid ); static boolean isAttributeNameValid( String attributeName );  }