本文整理汇总了Java中org.osgi.framework.Version.emptyVersion方法的典型用法代码示例。如果您正苦于以下问题:Java Version.emptyVersion方法的具体用法?Java Version.emptyVersion怎么用?Java Version.emptyVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.framework.Version
的用法示例。
在下文中一共展示了Version.emptyVersion方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVersion
import org.osgi.framework.Version; //导入方法依赖的package包/类
private static Version getVersion(Dictionary headers) {
if (headers != null) {
Object header = headers.get(Constants.BUNDLE_VERSION);
if (header instanceof String) {
return Version.parseVersion((String) header);
}
}
return Version.emptyVersion;
}
示例2: hasImport
import org.osgi.framework.Version; //导入方法依赖的package包/类
/**
* Get the version of a package import from a bundle.
*
* @param bundle
* @param packageName
* @return
*/
private static Version hasImport(Bundle bundle, String packageName) {
Dictionary dict = bundle.getHeaders();
// Check imports
String imports = (String) dict.get(Constants.IMPORT_PACKAGE);
Version v = getVersion(imports, packageName);
if (v != null) {
return v;
}
// Check for dynamic imports
String dynimports = (String) dict.get(Constants.DYNAMICIMPORT_PACKAGE);
if (dynimports != null) {
for (StringTokenizer strok = new StringTokenizer(dynimports, COMMA); strok.hasMoreTokens();) {
StringTokenizer parts = new StringTokenizer(strok.nextToken(), SEMI_COLON);
String pkg = parts.nextToken().trim();
if (pkg.endsWith(".*") && packageName.startsWith(pkg.substring(0, pkg.length() - 2)) || pkg.equals("*")) {
Version version = Version.emptyVersion;
for (; parts.hasMoreTokens();) {
String modifier = parts.nextToken().trim();
if (modifier.startsWith("version")) {
version = Version.parseVersion(modifier.substring(modifier.indexOf(EQUALS) + 1).trim());
}
}
return version;
}
}
}
return null;
}
示例3: createEvent
import org.osgi.framework.Version; //导入方法依赖的package包/类
private Event createEvent(Map<String, Object> props, String type) {
String topic = "org/osgi/service/remoteserviceadmin/" + type;
props.put("bundle", bctx.getBundle());
props.put("bundle.id", bctx.getBundle().getBundleId());
props.put("bundle.symbolicname", bctx.getBundle().getSymbolicName());
String version = (String)bctx.getBundle().getHeaders().get("Bundle-Version");
Version v = version != null ? new Version(version) : Version.emptyVersion;
setIfNotNull(props, "bundle.version", v);
return new Event(topic, props);
}
示例4: LogServiceImpl
import org.osgi.framework.Version; //导入方法依赖的package包/类
/**
* Creates a new instance of LogServiceImpl.
*
* @param bundle The bundle to create a new LogService for.
*/
public LogServiceImpl(Bundle bundle) {
String name = bundle.getSymbolicName();
Version version = bundle.getVersion();
if (version == null) {
version = Version.emptyVersion;
}
delegate = LoggerFactory.getLogger(name + '.' + version);
}
示例5: getVersion
import org.osgi.framework.Version; //导入方法依赖的package包/类
/**
* Get the version of a package name.
*
* @param stmt
* @param packageName
* @return
*/
private static Version getVersion(String stmt, String packageName) {
if (stmt != null) {
String[] pkgs = splitIntoPackages(stmt);
for (int packageIndex = 0; packageIndex < pkgs.length; packageIndex++) {
String pkgToken = pkgs[packageIndex].trim();
String pkg = null;
Version version = null;
int firstDirectiveIndex = pkgToken.indexOf(SEMI_COLON);
if (firstDirectiveIndex > -1) {
pkg = pkgToken.substring(0, firstDirectiveIndex);
}
else {
pkg = pkgToken;
version = Version.emptyVersion;
}
// check for version only if we have a match
if (pkg.equals(packageName)) {
// no version determined, find one
if (version == null) {
String[] directiveTokens = pkgToken.substring(firstDirectiveIndex + 1).split(SEMI_COLON);
for (int directiveTokenIndex = 0; directiveTokenIndex < directiveTokens.length; directiveTokenIndex++) {
String directive = directiveTokens[directiveTokenIndex].trim();
// found it
if (directive.startsWith(Constants.VERSION_ATTRIBUTE)) {
String value = directive.substring(directive.indexOf(EQUALS) + 1).trim();
boolean lowEqualTo = value.startsWith("\"[");
boolean lowGreaterThen = value.startsWith("\"(");
if (lowEqualTo || lowGreaterThen) {
boolean highEqualTo = value.endsWith("]\"");
boolean highLessThen = value.endsWith(")\"");
// remove brackets
value = value.substring(2, value.length() - 2);
int commaIndex = value.indexOf(COMMA);
// TODO: currently, only the left side is considered
Version left = Version.parseVersion(value.substring(0, commaIndex));
Version right = Version.parseVersion(value.substring(commaIndex + 1));
return left;
}
// check quotes
if (value.startsWith("\"")) {
return Version.parseVersion(value.substring(1, value.length() - 1));
}
return Version.parseVersion(value);
}
}
if (version == null) {
version = Version.emptyVersion;
}
}
return version;
}
}
}
return null;
}
示例6: getBundleVersion
import org.osgi.framework.Version; //导入方法依赖的package包/类
public static Version getBundleVersion(Bundle bundle) {
Dictionary<?, ?> headers = bundle.getHeaders();
String version = (String)headers.get(Constants.BUNDLE_VERSION);
return (version != null) ? Version.parseVersion(version) : Version.emptyVersion;
}
示例7: getBundleVersion
import org.osgi.framework.Version; //导入方法依赖的package包/类
public static Version getBundleVersion(Bundle bundle) {
Dictionary<?, ?> headers = bundle.getHeaders();
String version = (String) headers.get(Constants.BUNDLE_VERSION);
return (version != null) ? Version.parseVersion(version) : Version.emptyVersion;
}
示例8: Invalid
import org.osgi.framework.Version; //导入方法依赖的package包/类
public Invalid ( final Path path, final Throwable e )
{
this.path = path;
this.error = e;
this.description = new AddonDescription ( "unknwown", Version.emptyVersion, "n/a" );
}