static protected String extractTemplateUrl ( String viewName ) { int i1 = - 1 ; int i2 = - 1 ; int i3 = - 1 ; int i4 = - 1 ; i1 = viewName . indexOf ( LEFT_BRACKET ) ; if ( i1 != - 1 ) { i2 = viewName . indexOf ( LEFT_BRACKET , i1 + 1 ) ; } i4 = viewName . lastIndexOf ( RIGHT_BRACKET ) ; if ( i4 != - 1 ) { i3 = viewName . lastIndexOf ( RIGHT_BRACKET , i4 - 1 ) ; } if ( ( i1 == - 1 || i4 == - 1 ) // no starting or ending || ( i2 * i3 < 0 ) // not matching || ( i2 > i3 ) ) { // not matching return viewName ; // no valid template descriptor } //////// the format is guaranteed to be valid after this point String url = null ; if ( i2 != - 1 ) { url = viewName . substring ( i1 + 1 , i2 ) ; // prefix{url{...}}postfix } else { url = viewName . substring ( i1 + 1 , i4 ) ; // prefix{url}postfix } if ( i1 > 0 ) { String prefix = viewName . substring ( 0 , i1 ) ; url = prefix + url ; } if ( i4 < viewName . length ( ) - 1 ) { String postfix = viewName . substring ( i4 + 1 ) ; url = url + postfix ; } return url ; }
Parse the template descriptor to extract template URL