public Map < Integer , String > getCategories ( ) { if ( categories == null ) { categories = new TreeMap <> ( ) ; } Map < String , Object > responseMap = super . getAttributes ( ) ; for ( Entry < String , Object > response : responseMap . entrySet ( ) ) { String key = response . getKey ( ) ; if ( key . toLowerCase ( Locale . US ) . contains ( "category" ) ) { String [ ] keyParts = key . split ( "-" ) ; // if it doesn't have at least category-XXXXXX, skip if ( keyParts . length < 2 ) continue ; // try to get the number of this category, skip if we mess up Integer categoryNumber ; try { categoryNumber = Integer . parseInt ( keyParts [ 1 ] ) ; } catch ( Exception exception ) { continue ; } categories . put ( categoryNumber , ( String ) response . getValue ( ) ) ; } } return categories ; }
Returns the map of category numbers to category names .