public Map < Integer , String > getLines ( int categoryNumber ) { if ( lines == null ) { lines = 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 ( "line" ) ) { String [ ] keyParts = key . split ( "-" ) ; // if it doesn't have at least line-XXXXXX-XXXXXX, skip if ( keyParts . length < 3 ) { continue ; } // try to get the number of this category, skip if we mess up Integer potentialCategoryNumber ; try { potentialCategoryNumber = Integer . parseInt ( keyParts [ 1 ] ) ; } catch ( Exception exception ) { continue ; } // try to get the number of this line, skip if we mess up Integer potentialLineNumber ; try { potentialLineNumber = Integer . parseInt ( keyParts [ 2 ] ) ; } catch ( Exception exception ) { continue ; } // get the List out for placing stuff in Map < Integer , String > linesForCategory = lines . get ( potentialCategoryNumber ) ; if ( linesForCategory == null ) { linesForCategory = new TreeMap <> ( ) ; } // put the line we just parsed into the line map for this category linesForCategory . put ( potentialLineNumber , ( String ) response . getValue ( ) ) ; if ( ! lines . containsKey ( potentialCategoryNumber ) ) { lines . put ( potentialCategoryNumber , linesForCategory ) ; } } } return lines . get ( categoryNumber ) ; }
Returns the map of line number to line value for a given category .