org.pentaho.packageManagement
Class VersionPackageConstraint

java.lang.Object
  extended by org.pentaho.packageManagement.PackageConstraint
      extended by org.pentaho.packageManagement.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)

Nested Class Summary
static class VersionPackageConstraint.VersionComparison
          Enumeration encapsulating version comparison operations
 
Field Summary
protected  VersionPackageConstraint.VersionComparison m_constraint
          The comparison operator for this constraint
static String VERSION_KEY
          The meta data key for the version number
 
Fields inherited from class org.pentaho.packageManagement.PackageConstraint
m_thePackage
 
Constructor Summary
VersionPackageConstraint(Package p)
           
 
Method Summary
 boolean checkConstraint(Package target)
          Check the target package against the constraint embodied in this PackageConstraint.
 PackageConstraint checkConstraint(PackageConstraint target)
          Check the target package constraint against the constraint embodied in this package constraint.
protected static boolean checkConstraint(String version1, VersionPackageConstraint.VersionComparison constraint, String version2)
          Evaluates the supplied constraint with respect to two supplied version numbers as strings.
protected static VersionPackageConstraint.VersionComparison compare(String version1, String version2)
          Returns a VersionComparison that represents the comparison between the supplied version 1 and version 2.
 VersionPackageConstraint.VersionComparison getVersionComparison()
           
protected static VersionPackageConstraint.VersionComparison getVersionComparison(String compOpp)
          Returns a VersionComparison equivalent to the supplied String operator.
protected static int[] parseVersion(String version)
          Parses a version number and returns major, minor and revision numbers in an array of integers.
 void setVersionConstraint(String constraint)
           
 void setVersionConstraint(VersionPackageConstraint.VersionComparison c)
           
 String toString()
           
 
Methods inherited from class org.pentaho.packageManagement.PackageConstraint
getPackage, setPackage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION_KEY

public static String VERSION_KEY
The meta data key for the version number


m_constraint

protected VersionPackageConstraint.VersionComparison m_constraint
The comparison operator for this constraint

Constructor Detail

VersionPackageConstraint

public VersionPackageConstraint(Package p)
Method Detail

getVersionComparison

protected static VersionPackageConstraint.VersionComparison getVersionComparison(String compOpp)
Returns a VersionComparison equivalent to the supplied String operator.

Parameters:
compOpp - the comparison operator as a string.
Returns:
a VersionComparison object.

parseVersion

protected static int[] parseVersion(String version)
Parses a version number and returns major, minor and revision numbers in an array of integers.

Parameters:
version - the version number as a string.
Returns:
an array of integers containing the major, minor and revision numbers.

checkConstraint

protected static boolean checkConstraint(String version1,
                                         VersionPackageConstraint.VersionComparison constraint,
                                         String version2)
Evaluates the supplied constraint with respect to two supplied version numbers as strings.

Parameters:
version1 - String containing version number 1
constraint - the constraint comparison to use
version2 - String containing version number 2
Returns:
true if version 1 is compatible with version two with respect to the constraint.

compare

protected static VersionPackageConstraint.VersionComparison compare(String version1,
                                                                    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(VersionPackageConstraint.VersionComparison c)

getVersionComparison

public VersionPackageConstraint.VersionComparison getVersionComparison()

setVersionConstraint

public void setVersionConstraint(String constraint)

checkConstraint

public PackageConstraint checkConstraint(PackageConstraint target)
                                  throws 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:
Exception

checkConstraint

public boolean checkConstraint(Package target)
                        throws 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:
Exception - if the constraint can't be checked for some reason.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.