protected void createArrayProperties ( ) { // Scan through all defined properties. for ( Object o : keySet ( ) ) { String key = ( String ) o ; String value = super . getProperty ( key ) ; // Split the property key into everything before the last '.' and after it. int lastDotIndex = key . lastIndexOf ( ' ' ) ; String keyEnding = key . substring ( lastDotIndex + 1 , key . length ( ) ) ; String keyStart = key . substring ( 0 , ( lastDotIndex == - 1 ) ? 0 : lastDotIndex ) ; // Check if the property key ends in an integer, in which case it is an array property. int index = 0 ; try { index = Integer . parseInt ( keyEnding ) ; } catch ( NumberFormatException e ) { // The ending is not an integer so its not an array. // Exception can be ignored as it means this property is not an array. e = null ; continue ; } // Check if an array property already exists for this base name and create one if not. ArrayList propArray = ( ArrayList ) arrayProperties . get ( keyStart ) ; if ( propArray == null ) { propArray = new ArrayList ( ) ; arrayProperties . put ( keyStart , propArray ) ; } // Add the new property value to the array property for the index. propArray . set ( index , value ) ; } }
Scans all the properties in the parent Properties object and creates arrays for any array property definitions .