本文整理匯總了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" );
}