Java Code Examples for org.osgi.framework.Constants#VERSION_ATTRIBUTE

The following examples show how to use org.osgi.framework.Constants#VERSION_ATTRIBUTE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WiringHTMLDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void appendVersionAndType(final StringBuffer sb,
                                  final BundleRequirement requirement)
{
  final String filter =
    requirement.getDirectives().get(Constants.FILTER_DIRECTIVE);

  try {
    final VersionRange vr =
      new VersionRange(filter, Constants.VERSION_ATTRIBUTE, false);
    sb.append(" ");
    sb.append(vr.toHtmlString());
  } catch (final IllegalArgumentException iae) {
  }

  final String type = getFilterValue(filter, "type");
  if (type != null) {
    sb.append(" ");
    sb.append(type);
  }
}
 
Example 2
Source File: WiringHTMLDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void appendVersionAndResolutionDirective(final StringBuffer sb,
                                                 final BundleRequirement requirement)
{
  final String filter =
    requirement.getDirectives().get(Constants.FILTER_DIRECTIVE);

  try {
    final VersionRange vr =
      new VersionRange(filter, Constants.VERSION_ATTRIBUTE, true);
    sb.append(" ");
    sb.append(vr.toHtmlString());
  } catch (final IllegalArgumentException iae) {
    System.err.println(iae.getMessage());
  }

  final String resolution =
    requirement.getDirectives().get(Constants.RESOLUTION_DIRECTIVE);
  if (resolution != null && resolution.length() > 0) {
    if (resolution.equals(Constants.RESOLUTION_MANDATORY)) {
      // Default, don't print
    } else {
      sb.append(" ");
      sb.append(resolution);
    }
  }
}
 
Example 3
Source File: WiringHTMLDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void appendVersion(final StringBuffer sb,
                           final BundleRequirement requirement)
{
  final String filter =
    requirement.getDirectives().get(Constants.FILTER_DIRECTIVE);

  try {
    final VersionRange vr =
      new VersionRange(filter, Constants.VERSION_ATTRIBUTE, true);
    sb.append(" ");
    sb.append(vr.toHtmlString());
  } catch (final IllegalArgumentException iae) {
    System.err.println(iae.getMessage());
  }
}
 
Example 4
Source File: ExportPkg.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * String describing package name and specification version, if specified.
 *
 * @return String.
 */
public String pkgString() {
  if (version != Version.emptyVersion) {
    return name + ";" + Constants.VERSION_ATTRIBUTE + "=" + version;
  } else {
    return name;
  }
}
 
Example 5
Source File: ImportPkg.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * String describing package name and specification version, if specified.
 *
 * @return String.
 */
public String pkgString() {
  // NYI! More info?
  if (packageRange != null) {
    return name + ";" + Constants.VERSION_ATTRIBUTE + "=" + packageRange;
  } else {
    return name;
  }
}
 
Example 6
Source File: ExportPkg.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Create an export package entry.
 */
ExportPkg(final String name, final HeaderEntry he, final BundlePackages b)
{
  this.bpkgs = b;
  this.name = name;
  if (name.startsWith("java.")) {
    throw new IllegalArgumentException("You can not export a java.* package");
  }
  this.uses = Util.parseEnumeration(Constants.USES_DIRECTIVE, he
      .getDirectives().get(Constants.USES_DIRECTIVE));
  this.mandatory = Util.parseEnumeration(Constants.MANDATORY_DIRECTIVE, he
      .getDirectives().get(Constants.MANDATORY_DIRECTIVE));
  this.include = Util.parseEnumeration(Constants.INCLUDE_DIRECTIVE, he
      .getDirectives().get(Constants.INCLUDE_DIRECTIVE));
  this.exclude = Util.parseEnumeration(Constants.EXCLUDE_DIRECTIVE, he
      .getDirectives().get(Constants.EXCLUDE_DIRECTIVE));
  final String versionStr = (String) he.getAttributes()
      .remove(Constants.VERSION_ATTRIBUTE);
  @SuppressWarnings("deprecation")
  final String SPEC_VERSION = Constants.PACKAGE_SPECIFICATION_VERSION;
  final String specVersionStr = (String) he.getAttributes().remove(SPEC_VERSION);
  if (specVersionStr != null) {
    this.version = new Version(specVersionStr);
    if (versionStr != null && !this.version.equals(new Version(versionStr))) {
      throw new IllegalArgumentException("Both " + Constants.VERSION_ATTRIBUTE +
                                         " and " + SPEC_VERSION  +
                                         " are specified, and differs");
    }
  } else if (versionStr != null) {
    this.version = new Version(versionStr);
  } else {
    this.version = Version.emptyVersion;
  }
  if (he.getAttributes().containsKey(Constants.BUNDLE_VERSION_ATTRIBUTE)) {
    throw new IllegalArgumentException("Export definition illegally contains attribute, " +
                                       Constants.BUNDLE_VERSION_ATTRIBUTE);
  }
  if (he.getAttributes().containsKey(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE)) {
    throw new IllegalArgumentException("Export definition illegally contains attribute, " +
                                       Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
  }
  this.attributes = Collections.unmodifiableMap(he.getAttributes());
}
 
Example 7
Source File: ImportPkg.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Create an import package entry from manifest parser data.
 *
 * @param name the name of the package to be imported.
 * @param he the parsed import package statement.
 * @param b back link to the bundle revision owning this import declaration.
 * @param dynamic Set to true if this is a dynamic import package declaration.
 */
ImportPkg(final String name, final HeaderEntry he, final BundlePackages b,
          boolean dynamic)
{
  this.bpkgs = b;
  this.name = name;
  if (name.startsWith("java.")) {
    throw new IllegalArgumentException("You can not import a java.* package");
  }
  final Map<String, String> dirs = he.getDirectives();
  final String res = dirs.get(Constants.RESOLUTION_DIRECTIVE);
  if (dynamic) {
    if (res != null) {
      throw new IllegalArgumentException("Directives not supported for "
                                         + "Dynamic-Import, found "
                                         + Constants.RESOLUTION_DIRECTIVE
                                         + ":=" +res);
    }
    this.resolution = RESOLUTION_DYNAMIC;
  } else {
    if (res != null) {
      if (Constants.RESOLUTION_OPTIONAL.equals(res)) {
        this.resolution = Constants.RESOLUTION_OPTIONAL;
      } else if (Constants.RESOLUTION_MANDATORY.equals(res)) {
        this.resolution = Constants.RESOLUTION_MANDATORY;
      } else {
        throw new IllegalArgumentException("Directive " + Constants.RESOLUTION_DIRECTIVE +
                                           ", unexpected value: " + res);
      }
    } else {
      this.resolution = Constants.RESOLUTION_MANDATORY;
    }
  }
  this.bundleSymbolicName = (String) he.getAttributes()
      .remove(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
  final String versionStr = (String) he.getAttributes()
      .remove(Constants.VERSION_ATTRIBUTE);
  final String specVersionStr = (String) he.getAttributes()
      .remove(PACKAGE_SPECIFICATION_VERSION);
  if (specVersionStr != null) {
    this.packageRange = new VersionRange(specVersionStr);
    if (versionStr != null && !this.packageRange.equals(new VersionRange(versionStr))) {
      throw new IllegalArgumentException("Both " + Constants.VERSION_ATTRIBUTE +
                                         " and " + PACKAGE_SPECIFICATION_VERSION +
                                         " are specified, but differs");
    }
  } else if (versionStr != null) {
    this.packageRange = new VersionRange(versionStr);
  } else {
    this.packageRange = null;
  }
  final String rangeStr = (String) he.getAttributes()
      .remove(Constants.BUNDLE_VERSION_ATTRIBUTE);
  if (rangeStr != null) {
    this.bundleRange = new VersionRange(rangeStr);
  } else {
    this.bundleRange = null;
  }
  this.attributes = Collections.unmodifiableMap(he.getAttributes());
  final Filter filter = toFilter();
  if (null!=filter) {
    dirs.put(Constants.FILTER_DIRECTIVE, filter.toString());
  }
  this.directives = Collections.unmodifiableMap(dirs);
  this.parent = null;
}
 
Example 8
Source File: ExportPackage.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
@Override
public String getVersionAttribute() {
    return Constants.VERSION_ATTRIBUTE;
}
 
Example 9
Source File: ImportPackage.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
@Override
public String getVersionAttribute() {
    return Constants.VERSION_ATTRIBUTE;
}