public static Version getVersion(String version) { return getVersion( version, true ); }
public static Version getVersion(String version) { return getVersion( version, true ); }
public static Version getVersion(String version) { return getVersion( version, true ); }
public static Version getVersion(String version) { return getVersion( version, true ); }
@Override public int compare(String v1, String v2) { return VersionTable.getVersion(v1).compareTo(VersionTable.getVersion(v2)); } };
public static String transform(String macro, String value) { if (macro.startsWith("${") && macro.endsWith("}")) { String[] args = macro.substring(2, macro.length() - 1).split(";"); switch (args[0]) { case "version": if (args.length != 2) { throw new IllegalArgumentException("Invalid syntax for macro: " + macro); } return version(args[1], VersionTable.getVersion(value)); case "range": if (args.length != 2) { throw new IllegalArgumentException("Invalid syntax for macro: " + macro); } return range(args[1], VersionTable.getVersion(value)); default: throw new IllegalArgumentException("Unknown macro: " + macro); } } return value; }
private static Object parseAttribute(String value, String type) { if ("String".equals(type)) { return value; } else if ("Version".equals(type)) { return VersionTable.getVersion(value); } else if ("Long".equals(type)) { return Long.parseLong(value.trim()); } else if ("Double".equals(type)) { return Double.parseDouble(value.trim()); } else if (type.startsWith("List<") && type.endsWith(">")) { type = type.substring("List<".length(), type.length() - 1); List<Object> list = new ArrayList<>(); for (String s : value.split(",")) { list.add(parseAttribute(s.trim(), type)); } return list; } else { throw new IllegalStateException("Unexpected type: '" + type + "'"); } }
private static Object parseAttribute(String value, String type) { if ("String".equals(type)) { return value; } else if ("Version".equals(type)) { return VersionTable.getVersion(value); } else if ("Long".equals(type)) { return Long.parseLong(value.trim()); } else if ("Double".equals(type)) { return Double.parseDouble(value.trim()); } else if (type.startsWith("List<") && type.endsWith(">")) { type = type.substring("List<".length(), type.length() - 1); List<Object> list = new ArrayList<>(); for (String s : value.split(",")) { list.add(parseAttribute(s.trim(), type)); } return list; } else { throw new IllegalStateException("Unexpected type: '" + type + "'"); } }
public static String toFeatureCapability(String feature) { String[] parts = feature.split("/"); Map<String, String> dirs = Collections.emptyMap(); Map<String, Object> attrs = new StringArrayMap<>(parts.length > 1 ? 3 : 2); attrs.put(IDENTITY_NAMESPACE, parts[0]); attrs.put(CAPABILITY_TYPE_ATTRIBUTE, TYPE_FEATURE); if (parts.length > 1) { attrs.put(CAPABILITY_VERSION_ATTRIBUTE, VersionTable.getVersion(parts[1])); } return new CapabilityImpl(null, IDENTITY_NAMESPACE, dirs, attrs).toString(); } }
public static Version getVersion(int major, int minor, int micro, String qualifier) { String key; if ( qualifier == null || qualifier.length() == 0 ) { key = major + "." + minor + "." + micro; } else { key = major + "." + minor + "." + micro + "." + qualifier; } synchronized( versions ) { Version v = (Version) versions.get(key); if ( v == null ) { v = new Version(major, minor, micro, qualifier); versions.put(key, v); } return v; } } }
public static Version getVersion(int major, int minor, int micro, String qualifier) { String key; if ( qualifier == null || qualifier.length() == 0 ) { key = major + "." + minor + "." + micro; } else { key = major + "." + minor + "." + micro + "." + qualifier; } synchronized( versions ) { Version v = (Version) versions.get(key); if ( v == null ) { v = new Version(major, minor, micro, qualifier); versions.put(key, v); } return v; } } }
FilterImpl(int operation, String attr, Object value) { this.op = operation; this.attr = attr; this.value = value; Object conv = null; try { if (op == SUBSET || op == SUPERSET) { conv = getSet(value); } else if ("version".equalsIgnoreCase(attr)) { if (value instanceof String) { conv = VersionTable.getVersion((String) value); } else if (value instanceof Version) { conv = (Version) value; } } } catch (Throwable t) { // Ignore any conversion issue } converted = conv; }
FilterImpl(int operation, String attr, Object value) { this.op = operation; this.attr = attr; this.value = value; Object conv = null; try { if (op == SUBSET || op == SUPERSET) { conv = getSet(value); } else if ("version".equalsIgnoreCase(attr)) { if (value instanceof String) { conv = VersionTable.getVersion((String) value); } else if (value instanceof Version) { conv = value; } } } catch (Throwable t) { // Ignore any conversion issue } converted = conv; }
public static Version getVersion(int major, int minor, int micro, String qualifier) { String key; if ( qualifier == null || qualifier.length() == 0 ) { key = major + "." + minor + "." + micro; } else { key = major + "." + minor + "." + micro + "." + qualifier; } synchronized( versions ) { Version v = (Version) versions.get(key); if ( v == null ) { v = new Version(major, minor, micro, qualifier); versions.put(key, v); } return v; } } }
private static ParsedHeaderClause parseBundleSymbolicName(Map<String, String> headerMap) throws BundleException { List<ParsedHeaderClause> clauses = parseStandardHeader(headerMap.get(Constants.BUNDLE_SYMBOLICNAME)); if (clauses.size() > 0) { if (clauses.size() > 1 || clauses.get(0).paths.size() > 1) { throw new BundleException("Cannot have multiple symbolic names: " + headerMap.get(Constants.BUNDLE_SYMBOLICNAME)); } // Get bundle version. Version bundleVersion = Version.emptyVersion; if (headerMap.get(Constants.BUNDLE_VERSION) != null) { bundleVersion = VersionTable.getVersion(headerMap.get(Constants.BUNDLE_VERSION)); } // Create a require capability and return it. ParsedHeaderClause clause = clauses.get(0); String symName = clause.paths.get(0); clause.attrs.put(BundleRevision.BUNDLE_NAMESPACE, symName); clause.attrs.put(Constants.BUNDLE_VERSION_ATTRIBUTE, bundleVersion); return clause; } return null; }
private static ParsedHeaderClause parseBundleSymbolicName(Map<String, String> headerMap) throws BundleException { List<ParsedHeaderClause> clauses = parseStandardHeader(headerMap.get(Constants.BUNDLE_SYMBOLICNAME)); if (clauses.size() > 0) { if (clauses.size() > 1 || clauses.get(0).paths.size() > 1) { throw new BundleException("Cannot have multiple symbolic names: " + headerMap.get(Constants.BUNDLE_SYMBOLICNAME)); } // Get bundle version. Version bundleVersion = Version.emptyVersion; if (headerMap.get(Constants.BUNDLE_VERSION) != null) { bundleVersion = VersionTable.getVersion(headerMap.get(Constants.BUNDLE_VERSION)); } // Create a require capability and return it. ParsedHeaderClause clause = clauses.get(0); String symName = clause.paths.get(0); clause.attrs.put(BundleRevision.BUNDLE_NAMESPACE, symName); clause.attrs.put(Constants.BUNDLE_VERSION_ATTRIBUTE, bundleVersion); return clause; } return null; }
public static Version getVersion(int major, int minor, int micro, String qualifier) { String key; if ( qualifier == null || qualifier.length() == 0 ) { key = major + "." + minor + "." + micro; } else { key = major + "." + minor + "." + micro + "." + qualifier; } synchronized( versions ) { Version v = (Version) versions.get(key); if ( v == null ) { v = new Version(major, minor, micro, qualifier); versions.put(key, v); } return v; } } }
FilterImpl(int operation, String attr, Object value) { this.op = operation; this.attr = attr; this.value = value; Object conv = null; try { if (op == SUBSET || op == SUPERSET) { conv = getSet(value); } else if ("version".equalsIgnoreCase(attr)) { if (value instanceof String) { conv = VersionTable.getVersion((String) value); } else if (value instanceof Version) { conv = value; } } } catch (Throwable t) { // Ignore any conversion issue } converted = conv; }
try { if (lhs instanceof Version) { rhs = VersionTable.getVersion(rhsString, false); } else
try { if (lhs instanceof Version) { rhs = VersionTable.getVersion(rhsString, false); } else