public static short [ ] parseVersion ( final String version ) { final short [ ] values = new short [ ] { 0 , 0 , 0 , 0 } ; if ( version != null ) { final StringBuffer buf = new StringBuffer ( version ) ; int start = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { int end = version . indexOf ( ' ' , start ) ; if ( end <= 0 ) { end = version . length ( ) ; for ( int j = end ; j > start ; j -- ) { final String part = buf . substring ( start , end ) ; try { values [ i ] = Short . parseShort ( part ) ; break ; } catch ( final NumberFormatException ex ) { values [ i ] = 0 ; } } break ; } else { final String part = buf . substring ( start , end ) ; try { values [ i ] = Short . parseShort ( part ) ; start = end + 1 ; } catch ( final NumberFormatException ex ) { break ; } } } } return values ; }
Parse version string into array of four short values .