public static VersionSpecification parseVersionSpecification ( String s ) { if ( s == null ) return null ; if ( s . length ( ) == 0 ) return null ; char c = s . charAt ( 0 ) ; if ( c == ' ' ) { int i = s . indexOf ( ' ' ) ; boolean excluded = false ; if ( i < 0 ) { i = s . indexOf ( ' ' ) ; if ( i > 0 ) excluded = true ; } if ( i < 0 ) { // no end ? consider a unique version return new VersionSpecification . SingleVersion ( new Version ( s ) ) ; } String range = s . substring ( 1 , i ) . trim ( ) ; i = range . indexOf ( ' ' ) ; if ( i < 0 ) { // unique version return new VersionSpecification . SingleVersion ( new Version ( range ) ) ; } Version min = new Version ( range . substring ( 0 , i ) . trim ( ) ) ; range = range . substring ( i + 1 ) . trim ( ) ; Version max ; if ( range . length ( ) == 0 && excluded ) max = null ; else max = new Version ( range ) ; return new VersionSpecification . Range ( new VersionRange ( min , max , ! excluded ) ) ; } // TODO Version v = new Version ( s ) ; return new VersionSpecification . RangeWithRecommended ( new VersionRange ( v , null , false ) , v ) ; }
Parse a version specification in POM format .