private Map < String , String [ ] > extractArgout ( final String [ ] result , final int startingPoint ) { final Map < String , String [ ] > map = new CaseInsensitiveMap < String [ ] > ( ) ; if ( result . length > 4 ) { // System.out.println(result[0]);// device name // System.out.println(Integer.valueOf(result[1]));// prop size // System.out.println(result[2]);// prop name int i = startingPoint ; int nextSize = Integer . valueOf ( result [ i + 1 ] ) ; while ( i < result . length ) { // System.out.println("i " + i); if ( nextSize > 0 ) { final String name = result [ i ] . toLowerCase ( Locale . ENGLISH ) ; final String [ ] propValues = Arrays . copyOfRange ( result , i + 2 , nextSize + i + 2 ) ; map . put ( name , propValues ) ; // System.out.println("name " + name); // System.out.println("prop1 " + Arrays.toString(propValues)); } final int idxNextPropSize ; if ( nextSize == 0 ) { // System.out.println("zero"); idxNextPropSize = i + 4 ; i = i + 3 ; } else { idxNextPropSize = nextSize + i + 3 ; i = nextSize + i + 2 ; } // System.out.println("idxNextPropSize " + idxNextPropSize); if ( idxNextPropSize >= result . length ) { break ; } // System.out.println("idxNextPropSize value " + // result[idxNextPropSize]); nextSize = Integer . valueOf ( result [ idxNextPropSize ] ) ; // System.out.println("nextSize " + nextSize); } } return map ; }
Return a map of properties with name as key and value as entry