public List < String > sortedHeader ( @ NotNull final String header ) { String accept = getHeader ( header ) ; // accept anything when accept is not present if ( accept == null ) { return Collections . emptyList ( ) ; } // parse String [ ] items = accept . split ( " *, *" ) ; // sort on quality Arrays . sort ( items , ACCEPT_X_COMPARATOR ) ; List < String > list = new ArrayList <> ( items . length ) ; for ( String item : items ) { // find any ; e.g.: "application/json;q=0.8" int space = item . indexOf ( ' ' ) ; if ( space != - 1 ) { list . add ( item . substring ( 0 , space ) ) ; } else { list . add ( item ) ; } } return list ; }
Returns the array of accept - ? ordered by quality .