private static int compareNodes ( String node1 , String node2 ) { assert node1 != null ; assert node2 != null ; if ( node1 . equals ( node2 ) ) { return 0 ; } if ( node1 . length ( ) > 0 && node1 . charAt ( 0 ) == ' ' ) { if ( node2 . length ( ) > 0 && node2 . charAt ( 0 ) == ' ' ) { return 0 ; // Both nodes are parameters; names are irrelevant } return 1 ; // r1 is a parameter but r2 is not, so r2 should come first } if ( node2 . length ( ) > 0 && node2 . charAt ( 0 ) == ' ' ) { return - 1 ; // r2 is a parameter but r1 is not, so r1 should come first } return node1 . compareTo ( node2 ) ; // neither node is a parameter }
path nodes are query parameters . Either node can be empty but not null .