public int getIndex ( String expression ) { if ( expression == null || expression . length ( ) == 0 ) { return - 1 ; } for ( int i = 0 ; i < expression . length ( ) ; i ++ ) { char c = expression . charAt ( i ) ; if ( c == Nested || c == MappedStart ) { return - 1 ; } else if ( c == IndexedStart ) { int end = expression . indexOf ( IndexedEnd , i ) ; if ( end < 0 ) { throw new IllegalArgumentException ( "Missing End Delimiter" ) ; } String value = expression . substring ( i + 1 , end ) ; if ( value . length ( ) == 0 ) { throw new IllegalArgumentException ( "No Index Value" ) ; } int index = 0 ; try { index = Integer . parseInt ( value , 10 ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Invalid index value '" + value + "'" ) ; } return index ; } } return - 1 ; }
Return the index value from the property expression or - 1 .