private int parseTreeId ( HttpQuery query , final boolean required ) { try { if ( required ) { return Integer . parseInt ( query . getRequiredQueryStringParam ( "treeid" ) ) ; } else { if ( query . hasQueryStringParam ( "treeid" ) ) { return Integer . parseInt ( query . getQueryStringParam ( "treeid" ) ) ; } else { return 0 ; } } } catch ( NumberFormatException nfe ) { throw new BadRequestException ( "Unable to parse 'tree' value" , nfe ) ; } }
Parses the tree ID from a query Used often so it s been broken into it s own method