Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 28675 invoked from network); 6 Nov 2007 03:54:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2007 03:54:29 -0000 Received: (qmail 58591 invoked by uid 500); 6 Nov 2007 03:54:16 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 58529 invoked by uid 500); 6 Nov 2007 03:54:16 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 58509 invoked by uid 99); 6 Nov 2007 03:54:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2007 19:54:16 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2007 03:54:27 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 72E821A9846; Mon, 5 Nov 2007 19:54:07 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r592256 [4/4] - in /maven/artifact/trunk/src/main/java/org/apache/maven/artifact: ./ deployer/ factory/ installer/ manager/ metadata/ repository/ repository/layout/ repository/metadata/ resolver/ resolver/conflict/ resolver/filter/ resolver... Date: Tue, 06 Nov 2007 03:53:47 -0000 To: commits@maven.apache.org From: jvanzyl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071106035407.72E821A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java?rev=592256&r1=592255&r2=592256&view=diff ============================================================================== --- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java (original) +++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java Mon Nov 5 19:53:41 2007 @@ -38,7 +38,8 @@ private final List restrictions; - private VersionRange( ArtifactVersion recommendedVersion, List restrictions ) + private VersionRange( ArtifactVersion recommendedVersion, + List restrictions ) { this.recommendedVersion = recommendedVersion; this.restrictions = restrictions; @@ -53,39 +54,40 @@ { return restrictions; } - + public VersionRange cloneOf() { List copiedRestrictions = null; - + if ( restrictions != null ) { copiedRestrictions = new ArrayList(); - + if ( !restrictions.isEmpty() ) { copiedRestrictions.addAll( restrictions ); } } - + return new VersionRange( recommendedVersion, copiedRestrictions ); } /** * Create a version range from a string representation - * + *

* Some spec examples are *

    - *
  • 1.0 Version 1.0
  • - *
  • [1.0,2.0) Versions 1.0 (included) to 2.0 (not included)
  • - *
  • [1.0,2.0] Versions 1.0 to 2.0 (both included)
  • - *
  • [1.5,) Versions 1.5 and higher
  • - *
  • (,1.0],[1.2,) Versions up to 1.0 (included) and 1.2 or higher
  • + *
  • 1.0 Version 1.0
  • + *
  • [1.0,2.0) Versions 1.0 (included) to 2.0 (not included)
  • + *
  • [1.0,2.0] Versions 1.0 to 2.0 (both included)
  • + *
  • [1.5,) Versions 1.5 and higher
  • + *
  • (,1.0],[1.2,) Versions up to 1.0 (included) and 1.2 or higher
  • *
- * + * * @param spec string representation of a version or version range * @return a new {@link VersionRange} object that represents the spec * @throws InvalidVersionSpecificationException + * */ public static VersionRange createFromVersionSpec( String spec ) throws InvalidVersionSpecificationException @@ -220,31 +222,32 @@ } /** - * Creates and returns a new VersionRange that is a restriction of this + * Creates and returns a new VersionRange that is a restriction of this * version range and the specified version range. *

- * Note: Precedence is given to the recommended version from this version range over the + * Note: Precedence is given to the recommended version from this version range over the * recommended version from the specified version range. *

+ * * @param restriction the VersionRange that will be used to restrict this version - * range. - * @return the VersionRange that is a restriction of this version range and the - * specified version range. - *

- * The restrictions of the returned version range will be an intersection of the restrictions - * of this version range and the specified version range if both version ranges have - * restrictions. Otherwise, the restrictions on the returned range will be empty. - *

- *

- * The recommended version of the returned version range will be the recommended version of - * this version range, provided that ranges falls within the intersected restrictions. If - * the restrictions are empty, this version range's recommended version is used if it is not - * null. If it is null, the specified version range's recommended - * version is used (provided it is non-null). If no recommended version can be - * obtained, the returned version range's recommended version is set to null. - *

- * @throws NullPointerException if the specified VersionRange is - * null. + * range. + * @return the VersionRange that is a restriction of this version range and the + * specified version range. + *

+ * The restrictions of the returned version range will be an intersection of the restrictions + * of this version range and the specified version range if both version ranges have + * restrictions. Otherwise, the restrictions on the returned range will be empty. + *

+ *

+ * The recommended version of the returned version range will be the recommended version of + * this version range, provided that ranges falls within the intersected restrictions. If + * the restrictions are empty, this version range's recommended version is used if it is not + * null. If it is null, the specified version range's recommended + * version is used (provided it is non-null). If no recommended version can be + * obtained, the returned version range's recommended version is set to null. + *

+ * @throws NullPointerException if the specified VersionRange is + * null. */ public VersionRange restrict( VersionRange restriction ) { @@ -288,7 +291,7 @@ // Use the original recommended version since it exists version = recommendedVersion; } - else if (restriction.recommendedVersion != null) + else if ( restriction.recommendedVersion != null ) { // Use the recommended version from the specified VersionRange since there is no // original recommended version @@ -304,7 +307,8 @@ return new VersionRange( version, restrictions ); } - private List intersection( List r1, List r2 ) + private List intersection( List r1, + List r2 ) { List restrictions = new ArrayList( r1.size() + r2.size() ); Iterator i1 = r1.iterator();