public static Version createMinVersion() { if (minimumVersion == null) minimumVersion = new OmniVersion(Collections.<Comparable<?>> singletonList(null), null, null); return minimumVersion; }
public int getMajor() { return getIntElement(0); }
public static final Version MAX_VERSION = OmniVersion.createMaxVersion(); public static final Version emptyVersion = OmniVersion.createMinVersion();
/** * Parse but do not assign this format as the Version format nor the version * string as the original. */ public Version parse(String version) { List<Comparable<?>> vector = parse(version, 0, version.length()); return OmniVersion.fromVector(vector, null, null); }
/** * Checks if this version is in compliance with the OSGi version spec. * @return A flag indicating whether the version is OSGi compatible or not. */ public boolean isOSGiCompatible() { if (vector.length < 3 || vector.length > 4) return (this == emptyVersion || this == MAX_VERSION); if (getPad() != null) return false; for (int i = 0; i < 3; ++i) { Object e = vector[i]; if (!(e instanceof Integer && ((Integer) e).intValue() >= 0)) return false; } if (vector.length == 3) return true; // No qualifier. Still compatible return OSGiVersion.isValidOSGiQualifier(vector[3]); }
/** * Appends the string representation of this version onto the * <code>sb</code> StringBuffer. * @param sb The buffer that will receive the version string */ public void toString(StringBuffer sb) { if (this == emptyVersion) sb.append("0.0.0"); //$NON-NLS-1$ else { sb.append(RAW_PREFIX); VersionVector.toString(sb, vector, padValue, false); if (format != null || original != null) { sb.append('/'); if (format != null) format.toString(sb); if (original != null) { sb.append(':'); originalToString(sb, false); } } } }
public Version parse(String version) { List<Comparable<?>> vector = parse(version, 0, version.length()); return (this == OSGI_FORMAT) ? OSGiVersion.fromVector(vector) : OmniVersion.fromVector(vector, this, version); }
/** * Parse a version string using the {@link #RAW_FORMAT} parser. * * @param version The version to parse. * @param originalFormat The original format to assign to the created version. Can be <code>null</code>. * @param original The original version string to assign to the created version. Can be <code>null</code>. * @return A created version * @throws IllegalArgumentException If the version string could not be parsed. */ public static BasicVersion parseRaw(String version, IVersionFormat originalFormat, String original) { List<Comparable<?>> vector = RAW_FORMAT.parse(version, 0, version.length()); return (originalFormat == OSGI_FORMAT) ? OSGiVersion.fromVector(vector) : OmniVersion.fromVector(vector, originalFormat, original); }
public static Version createMaxVersion() { if (maximumVersion == null) maximumVersion = new OmniVersion(Collections.<Comparable<?>> singletonList(VersionVector.MAX_VALUE), null, null); return maximumVersion; }
public int getMinor() { return getIntElement(1); }
return OmniVersion.fromVector(vector, null, null); return fmt == VersionFormat.OSGI_FORMAT ? OSGiVersion.fromVector(vector) : OmniVersion.fromVector(vector, fmt, null); return fmt == VersionFormat.OSGI_FORMAT ? OSGiVersion.fromVector(vector) : OmniVersion.fromVector(vector, fmt, version.substring(pos));
static BasicVersion fromVector(List<Comparable<?>> vector, IVersionFormat format, String original) { int vtop = vector.size() - 1; Comparable<?> padValue = vector.get(vtop); if (vtop == 0) { if (padValue == null) return (BasicVersion) emptyVersion; if (padValue == VersionVector.MAX_VALUE) return (BasicVersion) MAX_VERSION; } if (vtop == 3 && padValue == null && vector.get(0) == VersionParser.ZERO_INT && vector.get(1) == VersionParser.ZERO_INT && vector.get(2) == VersionParser.ZERO_INT) return (BasicVersion) emptyVersion; return new OmniVersion(vector, format, original); }
public int getMicro() { return getIntElement(2); }