protected Iterator getKeyIterator ( final String base , final String modifier , final String key ) { return new Iterator ( ) { // The key ordering count always begins at the start of the ORDER array. private int i ; public boolean hasNext ( ) { return ( useDefaults ? ( ( i < ORDER . length ) && ( ORDER [ i ] > ENVIRONMENT_DEFAULTS_CUTOFF ) ) : ( i < ORDER . length ) ) ; } public Object next ( ) { // Check that there is a next element and return null if not. if ( ! hasNext ( ) ) { return null ; } // Get the next ordering count. int o = ORDER [ i ] ; // Do bit matching on the count to choose which elements to include in the key. String result = ( ( ( o & E ) != 0 ) ? ( environment + "." ) : "" ) + ( ( ( o & B ) != 0 ) ? ( base + "." ) : "" ) + ( ( ( o & M ) != 0 ) ? ( modifier + "." ) : "" ) + key ; // Increment the iterator to get the next key on the next call. i ++ ; return result ; } public void remove ( ) { // This method is not supported. throw new UnsupportedOperationException ( "remove() is not supported on this key order iterator as " + "the ordering cannot be changed" ) ; } } ; }
For a given environment base modifier and key and setting of the use of default environments feature this generates an iterator that walks over the order in which to try and access properties .