{
lowerBoundInclusive = false;
}
else
{
throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
+ ", a range must start with either [ or (" );
}
if ( range.endsWith( "]" ) )
{
upperBoundInclusive = true;
}
else if ( range.endsWith( ")" ) )
{
upperBoundInclusive = false;
}
else
{
throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
+ ", a range must end with either [ or (" );
}
process = process.substring( 1, process.length() - 1 );
int index = process.indexOf( "," );
if ( index < 0 )
{
if ( !lowerBoundInclusive || !upperBoundInclusive )
{
throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
+ ", single version must be surrounded by []" );
}
lowerBound = upperBound = new GenericVersion( process.trim() );
}
else
{
String parsedLowerBound = process.substring( 0, index ).trim();
String parsedUpperBound = process.substring( index + 1 ).trim();
// more than two bounds, e.g. (1,2,3)
if ( parsedUpperBound.contains( "," ) )
{
throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
+ ", bounds may not contain additional ','" );
}
lowerBound = parsedLowerBound.length() > 0 ? new GenericVersion( parsedLowerBound ) : null;
upperBound = parsedUpperBound.length() > 0 ? new GenericVersion( parsedUpperBound ) : null;
if ( upperBound != null && lowerBound != null )
{
if ( upperBound.compareTo( lowerBound ) < 0 )
{
throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
+ ", lower bound must not be greater than upper bound" );
}
}
}
}