Class VersionPackageConstraint


  • public class VersionPackageConstraint
    extends PackageConstraint
    Concrete implementation of PackageConstraint that encapsulates constraints related to version numbers. Handles equality = and open-ended inequalities (e.g. > x, < x, >= x, <= x).
    Version:
    $Revision: 51469 $
    Author:
    mhall (mhall{[at]}pentaho{[dot]}com)
    • Field Detail

      • VERSION_KEY

        public static java.lang.String VERSION_KEY
        The meta data key for the version number
    • Constructor Detail

      • VersionPackageConstraint

        public VersionPackageConstraint​(Package p)
    • Method Detail

      • compare

        public static VersionPackageConstraint.VersionComparison compare​(java.lang.String version1,
                                                                         java.lang.String version2)
        Returns a VersionComparison that represents the comparison between the supplied version 1 and version 2.
        Parameters:
        version1 - String containing version number 1.
        version2 - String containing version number 2.
        Returns:
        a VersionComparison object.
      • setVersionConstraint

        public void setVersionConstraint​(java.lang.String constraint)
      • checkConstraint

        public PackageConstraint checkConstraint​(PackageConstraint target)
                                          throws java.lang.Exception
        Check the target package constraint against the constraint embodied in this package constraint. Returns either the package constraint that covers both this and the target constraint, or null if this and the target are incompatible. Try and return the *least* restrictive constraint that satisfies this and the target.
        Specified by:
        checkConstraint in class PackageConstraint
        Parameters:
        target - the package constraint to compare against
        Returns:
        a package constraint that covers this and the supplied constraint, or null if they are incompatible.
        Throws:
        java.lang.Exception
      • checkConstraint

        public boolean checkConstraint​(Package target)
                                throws java.lang.Exception
        Check the target package against the constraint embodied in this PackageConstraint.
        Specified by:
        checkConstraint in class PackageConstraint
        Parameters:
        target - a package to check with respect to the encapsulated package and the constraint.
        Returns:
        true if the constraint is met by the target package with respect to the encapsulated package + constraint.
        Throws:
        java.lang.Exception - if the constraint can't be checked for some reason.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object