public String toString() { StringBuffer buf = new StringBuffer(20); toString(buf); return buf.toString(); }
/** * Creates an OSGi version identifier from the specified numerical components. * * <p> * The qualifier is set to the empty string. * * @param major Major component of the version identifier. * @param minor Minor component of the version identifier. * @param micro Micro component of the version identifier. * @throws IllegalArgumentException If the numerical components are * negative. */ public static Version createOSGi(int major, int minor, int micro) { return createOSGi(major, minor, micro, null); }
private static String getQualifier(Version v) { int segCount = v.getSegmentCount(); if (segCount == 0) return null; Object seg = v.getSegment(segCount - 1); return seg instanceof String ? (String) seg : null; }
public FeatureEntry(String id, String version, boolean isPlugin) { this.id = id; this.versionOrRange = Version.parseVersion(version).toString(); this.isPlugin = isPlugin; }
/** * Returns a version range which includes "equivalent" versions, i.e. versions with the same * major, minor, and micro version. */ private static VersionRange getRangeOfEquivalentVersions(Version version) { Integer major = (Integer) version.getSegment(0); Integer minor = (Integer) version.getSegment(1); Integer micro = (Integer) version.getSegment(2); VersionRange range = new VersionRange(Version.createOSGi(major, minor, micro), true, Version.createOSGi(major, minor, micro + 1), false); return range; }
/** * Creates a new versioned id with the given id and version. * * @param id The identifier * @param version The version * @throws IllegalArgumentException If <code>version</code> is improperly * formatted. */ public VersionedId(String id, String version) { this.id = id; this.version = Version.parseVersion(version); }
private int compare(Version versionA, Version versionB) { if (versionA != null && versionB != null) return versionA.compareTo(versionB); return 0; }
Version version = Version.parseVersion(properties.getProperty(VERSION)); if (version.compareTo(Version.createOSGi(1, 0, 0)) < 0) return new LocationProperties(); if (version.compareTo(Version.createOSGi(1, 0, 0)) == 0) { if (locationProperties.initVersion1(properties)) return locationProperties;
@Override public int compare(Object o1, Object o2) { BundleInfo b1 = ((TargetBundle) o1).getBundleInfo(); BundleInfo b2 = ((TargetBundle) o2).getBundleInfo(); try { Version v1 = Version.create(b1.getVersion()); Version v2 = Version.create(b2.getVersion()); return v1.compareTo(v2); } catch (IllegalArgumentException e) { // If one of the bundles has a bad version PDECore.log(e); return b1.getVersion().compareTo(b2.getVersion()); } } });
public FeatureEntry(String id, String version, boolean isPlugin) { this.id = id; this.versionOrRange = Version.parseVersion(version).toString(); this.isPlugin = isPlugin; }
private void checkAdviceVersion(String adviceVersion) { Version version = Version.parseVersion(adviceVersion); if (!VERSION_TOLERANCE.isIncluded(version)) throw new IllegalStateException("bad version: " + version + ". Expected range was " + VERSION_TOLERANCE); //$NON-NLS-1$ //$NON-NLS-2$ }
public int compare(Version o1, Version o2) { return o1.compareTo(o2); }
private static int getIntSegment(Version v, int segment) { int segCount = v.getSegmentCount(); if (segCount <= segment) return 0; Object seg = v.getSegment(segment); return seg instanceof Integer ? ((Integer) seg).intValue() : 0; }
public static org.eclipse.tycho.ArtifactKey toTychoArtifact(IInstallableUnit unit) { // TODO 428889 unit test & add more cases if (Boolean.valueOf(unit.getProperty(InstallableUnitDescription.PROP_TYPE_GROUP))) { // TODO 428889 check suffix String id = unit.getId(); return new DefaultArtifactKey(ArtifactType.TYPE_ECLIPSE_FEATURE, id.substring(0, id.length() - ".feature.group".length()), unit.getVersion().toString()); } throw new IllegalArgumentException(unit.toString()); }
public static IProvidedCapability makeTranslationCapability(String hostId, Locale locale) { return MetadataFactory.createProvidedCapability(NAMESPACE_IU_LOCALIZATION, locale.toString(), Version.createOSGi(1, 0, 0)); }
public FeatureEntry(String id, String version, boolean isPlugin) { this.id = id; this.versionOrRange = Version.parseVersion(version).toString(); this.isPlugin = isPlugin; }
protected Version createVersion(String version) { return Version.create(version); }
public static Version parseAsOSGiVersion(String version) throws IllegalArtifactReferenceException { try { return Version.parseVersion(version); } catch (IllegalArgumentException e) { throw new IllegalArtifactReferenceException("The string \"" + version + "\" is not a valid OSGi version"); } }
private void validateRange() { int cmp = minVersion.compareTo(maxVersion); if (!(cmp < 0 || (cmp == 0 && includeMin && includeMax))) throw new IllegalArgumentException(NLS.bind(Messages.range_min_0_is_not_less_then_range_max_1, minVersion, maxVersion)); }