/** * Checks if the given version is in this range. * @param v the version to check * @return {@code true} if the given version is in this range. */ public boolean isInRange(Version v) { if (low != null) { int comp = v.compareTo(low); if (comp < 0 || comp == 0 && !lowIncl) { return false; } } if (high != null) { int comp = v.compareTo(high); if (comp > 0 || comp == 0 && !highIncl) { return false; } } return true; }
/** * Creates a new package id * @param group group id * @param name name * @param version version */ public PackageId(String group, String name, String version) { this(group, name, Version.create(version)); }
private Version normalizeVersion(final Version version) { final int numVersionSegments = 3; final String[] normalizedSegments = version.getNormalizedSegments(); final String[] segments = new String[numVersionSegments]; if (normalizedSegments.length <= 0) { segments[0] = "1"; } else { segments[0] = normalizedSegments[0]; } if (normalizedSegments.length <= 1) { segments[1] = "0"; } else { segments[1] = normalizedSegments[1]; } if (normalizedSegments.length <= 2) { segments[2] = "0"; } else { segments[2] = normalizedSegments[2]; } return Version.create(segments); }
final String version) throws RepositoryException { final Node packageRoot = jcrPackageManager.getPackageRoot(false); final Version configVersion = Version.create(version); log.debug(packageVersion.toString() + " compareTo " + latestVersion.toString() + " = " + packageVersion.compareTo(latestVersion)); if (packageVersion.compareTo(latestVersion) >= 1) { latestVersion = packageVersion; log.debug("Found a new latest version: {}", latestVersion.toString()); } else if (packageVersion.compareTo(configVersion) == 0) { configVersionEligible = false; log.debug("Found a package with the same version as the config version"); log.debug("Current latest version: {}", latestVersion.toString()); if (configVersionEligible && latestVersion.equals(configVersion)) { final String[] segments = latestVersion.getNormalizedSegments(); final Version nextVersion = Version.create(segments); log.debug("Next version: {}", nextVersion); return nextVersion;
public int compareTo(PackId o) { if (o == null) { return -1; } if (this.getGroup().equals(o.getGroup())) { if (this.getName().equals(o.getName())) { if (this.getVersion().equals(o.getVersion())) { return 0; } else { return Version.create(this.getVersion()).compareTo(Version.create(o.getVersion())); } } else { return this.getName().compareTo(o.getName()); } } else { return this.getGroup().compareTo(o.getGroup()); } }
/** * Returns the version of this package or and empty string if n/a. * @return the version of this package * @since 2.0 */ public String getVersionString() { return version.toString(); }
String[] oSegs = o.getNormalizedSegments(); for (int i=0; i< Math.min(segments.length, oSegs.length); i++) { String s1 = segments[i];
return new Version(str.toString(), segs.toArray(new String[segs.size()]));
/** * Returns a download name in the form * {@code name [ "-" version ] ".zip"} * @return the download name * @since 2.0 */ public String getDownloadName() { StringBuilder str = new StringBuilder(name); if (version.toString().length() > 0) { str.append("-").append(version); } str.append(".zip"); return str.toString(); }
/** * Same as with {@link #compareTo(Version)}. * * @param o the other version * @return a negative integer, zero, or a positive integer as this version is less than, equal to, or greater than the specified version. * @deprecated since 3.1.32. use {@link #compareTo(Version)}. See JCRVLT-146 */ @Deprecated public int osgiCompareTo(Version o) { return compareTo(o); } }
/** * Creates a new package id * @param path path of the package * @param version version of the package * * @deprecated As of 3.1.42, the storage location is implementation details. */ @Deprecated public PackageId(String path, String version) { this(path, Version.create(version)); }
/** * Checks if this package id is valid in respect to JCR names. * @return {@code true} if the names are valid */ public boolean isValid() { return PackageId.isValid(group, name, version == null ? null : version.toString()); }
int comp = low.compareTo(high); if (comp > 0) { throw new IllegalArgumentException("lower bound must be less or equal to upper bound.");
/** * Creates a new version from the given string. * * @param str the version string. * @return the new version or {@link Version#EMPTY} if {@code str} is an empty string. * @since 2.2.4 */ @Nonnull public static Version create(@Nullable String str) { if (str == null || str.length() == 0) { return Version.EMPTY; } return Version.create(Text.explode(str, '.')); }
/** * Internally get the string representation, colon separated. * @param group group name * @param name name * @param version version * @return string version */ private static String getString(String group, String name, Version version) { return getString(group, name, version == null ? "" : version.toString()); }
/** * {@inheritDoc} * * Compares this id with the given one. */ public int compareTo(PackageId o) { int comp = group.compareTo(o.getGroup()); if (comp != 0) { return comp; } comp = name.compareTo(o.getName()); if (comp != 0) { return comp; } return version.compareTo(o.getVersion()); }
/** * Returns the path of this package. please note that since 2.3 this also * includes the version, but never the extension (.zip). * * @return the path of this package * @since 2.2 * @deprecated As of 3.1.42, the storage location is implementation details. */ @Deprecated public String getInstallationPath() { StringBuilder b = new StringBuilder(ETC_PACKAGES_PREFIX); if (group.length() > 0) { b.append(group); b.append("/"); } b.append(name); if (version.toString().length() > 0) { b.append("-").append(version); } return b.toString(); }
if (bestId == null || id.getVersion().compareTo(bestId.getVersion()) > 0) { bestId = id;
this.version = Version.create(str.toString());