当前位置: 首页>>代码示例>>Java>>正文


Java Version.compareTo方法代码示例

本文整理汇总了Java中org.osgi.framework.Version.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java Version.compareTo方法的具体用法?Java Version.compareTo怎么用?Java Version.compareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.osgi.framework.Version的用法示例。


在下文中一共展示了Version.compareTo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isWordcloudRequiredVersionInstalled

import org.osgi.framework.Version; //导入方法依赖的package包/类
public boolean isWordcloudRequiredVersionInstalled() {
	if(!availableCommands.getNamespaces().contains("wordcloud"))
		return false;
	if(!availableCommands.getCommands("wordcloud").contains("version"))
		return false;
	
	String command = "wordcloud version";
	VersionTaskObserver observer = new VersionTaskObserver();
	
	TaskIterator taskIterator = commandTaskFactory.createTaskIterator(observer, command);
	syncTaskManager.execute(taskIterator);
	
	if(!observer.hasResult())
		return false;
	
	int major = observer.version[0];
	int minor = observer.version[1];
	int micro = observer.version[2];
	
	Version actual = new Version(major, minor, micro);
	return actual.compareTo(WORDCLOUD_MINIMUM) >= 0;
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:23,代码来源:WordCloudAdapter.java

示例2: checkForUpdates

import org.osgi.framework.Version; //导入方法依赖的package包/类
@Override
public void checkForUpdates() throws PluginException {
	boolean updatesFound = false;
	synchronized (pluginUpdates) {
		pluginUpdates.clear();
		for (PluginSite pluginSite : pluginSiteManager.getPluginSites()) {
			List<PluginVersions> plugins = pluginSiteManager.getPlugins(pluginSite);
			for (PluginVersions plugin : plugins) {
				if (installedPlugins.containsKey(plugin.getId())) {
					Plugin installedPlugin = installedPlugins.get(plugin.getId());
					if (installedPlugin.getFile().toFile().canWrite()) {
						Version latestVersion = Version.parseVersion(plugin.getLatestVersion()
								.getVersion());
						if (latestVersion.compareTo(installedPlugin.getVersion()) > 0) {
							pluginUpdates.put(plugin.getId(), plugin);
							updatesFound = true;
						}
					}
				}
			}
		}
	}
	if (updatesFound) {
		postEvent(PluginManager.UPDATES_AVAILABLE);
	}
}
 
开发者ID:apache,项目名称:incubator-taverna-osgi,代码行数:27,代码来源:PluginManagerImpl.java

示例3: supportsVersion

import org.osgi.framework.Version; //导入方法依赖的package包/类
protected boolean supportsVersion(Version ccApiVersion) {
	if (ccApiVersion == null) {
		return false;
	}
	Version supported = getSupportedV2ClientApiVersion();
	return ccApiVersion.compareTo(supported) > 0;
}
 
开发者ID:eclipse,项目名称:cft,代码行数:8,代码来源:V2CFClientProvider.java

示例4: getConfigurator

import org.osgi.framework.Version; //导入方法依赖的package包/类
@Override
public WidgetConfigurator getConfigurator(final Version persisted_version)
        throws Exception
{
    if (persisted_version.compareTo(version) < 0)
        return new LegacyWidgetConfigurator(persisted_version);
    else
        return super.getConfigurator(persisted_version);
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:10,代码来源:PolygonWidget.java

示例5: isNewOSGIAPI

import org.osgi.framework.Version; //导入方法依赖的package包/类
/**
 * The 3.10.0 version of the OSGI bundle made a lot of breaking changes to internals (that we unfortunately used).
 * 
 * @return
 */
private synchronized static boolean isNewOSGIAPI()
{
	if (fgNewAPI == null)
	{
		Bundle b = Platform.getBundle("org.eclipse.osgi"); //$NON-NLS-1$
		Version v = b.getVersion();
		fgNewAPI = v.compareTo(Version.parseVersion("3.9.100")) >= 0; //$NON-NLS-1$
	}
	return fgNewAPI;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:16,代码来源:EclipseUtil.java

示例6: matches

import org.osgi.framework.Version; //导入方法依赖的package包/类
public boolean matches(Version v) {
	if(EQ==op) return v.compareTo(version)==0;
	if(LTE==op) return v.compareTo(version)<=0;
	if(LT==op) return v.compareTo(version)<0;
	if(GTE==op) return v.compareTo(version)>=0;
	if(GT==op) return v.compareTo(version)>0;
	if(NEQ==op) return v.compareTo(version)!=0;
	return false;
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:10,代码来源:OSGiUtil.java

示例7: checkValidWorkspace

import org.osgi.framework.Version; //导入方法依赖的package包/类
/**
 * Return true if the argument directory is ok to use as a workspace and false otherwise. A version check will be
 * performed, and a confirmation box may be displayed on the argument shell if an older version is detected.
 *
 * @return true if the argument URL is ok to use as a workspace and false otherwise.
 */
private boolean checkValidWorkspace(final Shell shell, final URL url) {
	// a null url is not a valid workspace
	if (url == null) {
		return false;
	}

	if (WORKSPACE_CHECK_REFERENCE_BUNDLE_VERSION == null) {
		// no reference bundle installed, no check possible
		return true;
	}

	final Version version = readWorkspaceVersion(url);
	// if the version could not be read, then there is not any existing
	// workspace data to trample, e.g., perhaps its a new directory that
	// is just starting to be used as a workspace
	if (version == null) {
		return true;
	}

	final Version ide_version = toMajorMinorVersion(WORKSPACE_CHECK_REFERENCE_BUNDLE_VERSION);
	final Version workspace_version = toMajorMinorVersion(version);
	final int versionCompareResult = workspace_version.compareTo(ide_version);

	// equality test is required since any version difference (newer
	// or older) may result in data being trampled
	if (versionCompareResult == 0) {
		return true;
	}

	// At this point workspace has been detected to be from a version
	// other than the current ide version -- find out if the user wants
	// to use it anyhow.
	int severity;
	String title;
	String message;
	if (versionCompareResult < 0) {
		// Workspace < IDE. Update must be possible without issues,
		// so only inform user about it.
		severity = INFORMATION;
		title = IDEApplication_versionTitle_olderWorkspace;
		message = NLS.bind(IDEApplication_versionMessage_olderWorkspace, url.getFile());
	} else {
		// Workspace > IDE. It must have been opened with a newer IDE version.
		// Downgrade might be problematic, so warn user about it.
		severity = WARNING;
		title = IDEApplication_versionTitle_newerWorkspace;
		message = NLS.bind(IDEApplication_versionMessage_newerWorkspace, url.getFile());
	}

	final MessageDialog dialog = new MessageDialog(shell, title, null, message, severity,
			new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
	return dialog.open() == Window.OK;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:60,代码来源:N4JSApplication.java

示例8: matchExtenderVersionRange

import org.osgi.framework.Version; //导入方法依赖的package包/类
public static boolean matchExtenderVersionRange(Bundle bundle, String header, Version versionToMatch) {
	Assert.notNull(bundle);
	// get version range
	String range = (String) bundle.getHeaders().get(header);

	boolean trace = log.isTraceEnabled();

	// empty value = empty version = *
	if (!StringUtils.hasText(range))
		return true;

	if (trace)
		log.trace("discovered " + header + " header w/ value=" + range);

	// do we have a range or not ?
	range = StringUtils.trimWhitespace(range);

	// a range means one comma
	int commaNr = StringUtils.countOccurrencesOf(range, COMMA);

	// no comma, no intervals
	if (commaNr == 0) {
		Version version = Version.parseVersion(range);

		return versionToMatch.equals(version);
	}

	if (commaNr == 1) {

		// sanity check
		if (!((range.startsWith(LEFT_CLOSED_INTERVAL) || range.startsWith(LEFT_OPEN_INTERVAL)) && (range.endsWith(RIGHT_CLOSED_INTERVAL) || range.endsWith(RIGHT_OPEN_INTERVAL)))) {
			throw new IllegalArgumentException("range [" + range + "] is invalid");
		}

		boolean equalMin = range.startsWith(LEFT_CLOSED_INTERVAL);
		boolean equalMax = range.endsWith(RIGHT_CLOSED_INTERVAL);

		// remove interval brackets
		range = range.substring(1, range.length() - 1);

		// split the remaining string in two pieces
		String[] pieces = StringUtils.split(range, COMMA);

		if (trace)
			log.trace("discovered low/high versions : " + ObjectUtils.nullSafeToString(pieces));

		Version minVer = Version.parseVersion(pieces[0]);
		Version maxVer = Version.parseVersion(pieces[1]);

		if (trace)
			log.trace("comparing version " + versionToMatch + " w/ min=" + minVer + " and max=" + maxVer);

		boolean result = true;

		int compareMin = versionToMatch.compareTo(minVer);

		if (equalMin)
			result = (result && (compareMin >= 0));
		else
			result = (result && (compareMin > 0));

		int compareMax = versionToMatch.compareTo(maxVer);

		if (equalMax)
			result = (result && (compareMax <= 0));
		else
			result = (result && (compareMax < 0));

		return result;
	}

	// more then one comma means incorrect range

	throw new IllegalArgumentException("range [" + range + "] is invalid");
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:76,代码来源:ConfigUtils.java

示例9: getConfigFile

import org.osgi.framework.Version; //导入方法依赖的package包/类
public String getConfigFile(String version) {
	if(ConfigFile == null) {
		return null;
	}

	Version vIn = new Version(version);
	String filename = null;
	// Check for a version'ed file
	// There are multiple permutations of the file that we need to account for -:
	// * No version information
	// * Only a min version
	// * Only a max version
	// * Both min and max versions
	// Versions need to be evaluated with the max and min specifiers separately
	// i.e. the part either side of the decimal.
	// So, version 1.3 is lower than version 1.11 
	for(ZWaveDbConfigFile cfg : ConfigFile) {
		// Find a default - ie one with no version information
		if(cfg.VersionMin == null && cfg.VersionMax == null && filename == null) {
			filename = cfg.Filename;
			continue;
		}

		if(cfg.VersionMin != null) {
			Version vMin = new Version(cfg.VersionMin);
			if(vIn.compareTo(vMin) < 0) {
				continue;
			}
		}

		if(cfg.VersionMax != null) {
			Version vMax = new Version(cfg.VersionMax);

			if(vIn.compareTo(vMax) > 0) {
				continue;
			}
		}
		
		// This version matches the criterea
		return cfg.Filename;
	}

	// Otherwise return the default if there was one!
	return filename;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:46,代码来源:ZWaveDbProduct.java

示例10: isNewerThan

import org.osgi.framework.Version; //导入方法依赖的package包/类
/**
 * check left value against right value
 * 
 * @param left
 * @param right
 * @return returns if right is newer than left
 */
public static boolean isNewerThan(final Version left, final Version right) {

// major
	if(left.getMajor()>right.getMajor()) return true;
	if(left.getMajor()<right.getMajor()) return false;
	
// minor
	if(left.getMinor()>right.getMinor()) return true;
	if(left.getMinor()<right.getMinor()) return false;
	
// micro
	if(left.getMicro()>right.getMicro()) return true;
	if(left.getMicro()<right.getMicro()) return false;
	
// qualifier
	// left
	String q = left.getQualifier();
	int index=q.indexOf('-');
	String qla = index==-1?"":q.substring(index+1).trim();
	String qln=index==-1?q:q.substring(0, index);
	int ql = isEmpty(qln)?Integer.MIN_VALUE:Integer.parseInt(qln);
	
	//right
	q = right.getQualifier();
	index=q.indexOf('-');
	String qra = index==-1?"":q.substring(index+1).trim();
	String qrn=index==-1?q:q.substring(0, index);
	int qr = isEmpty(qln)?Integer.MIN_VALUE:Integer.parseInt(qrn);

	if(ql>qr) return true;
	if(ql<qr) return false;
	
	
	int qlan=qualifierAppendix2Number(qla);
	int qran=qualifierAppendix2Number(qra);
	
	if(qlan>qran) return true;
	if(qlan<qran) return false;
	
	if(qlan==QUALIFIER_APPENDIX_OTHER && qran==QUALIFIER_APPENDIX_OTHER)
		return left.compareTo(right) > 0;
	
	return false;
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:52,代码来源:Util.java

示例11: isNewerThan

import org.osgi.framework.Version; //导入方法依赖的package包/类
/**
 * check left value against right value
 * 
 * @param left
 * @param right
 * @return returns if right is newer than left
 */
public static boolean isNewerThan(final Version left, final Version right) {

// major
	if(left.getMajor()>right.getMajor()) return true;
	if(left.getMajor()<right.getMajor()) return false;
	
// minor
	if(left.getMinor()>right.getMinor()) return true;
	if(left.getMinor()<right.getMinor()) return false;
	
// micro
	if(left.getMicro()>right.getMicro()) return true;
	if(left.getMicro()<right.getMicro()) return false;
	
// qualifier
	// left
	String q = left.getQualifier();
	int index=q.indexOf('-');
	String qla = index==-1?"":q.substring(index+1).trim();
	String qln=index==-1?q:q.substring(0, index);
	int ql = StringUtil.isEmpty(qln)?Integer.MIN_VALUE:Caster.toIntValue(qln, Integer.MAX_VALUE);
	
	//right
	q = right.getQualifier();
	index=q.indexOf('-');
	String qra = index==-1?"":q.substring(index+1).trim();
	String qrn=index==-1?q:q.substring(0, index);
	int qr = StringUtil.isEmpty(qln)?Integer.MIN_VALUE:Caster.toIntValue(qrn, Integer.MAX_VALUE);

	if(ql>qr) return true;
	if(ql<qr) return false;
	
	
	int qlan=qualifierAppendix2Number(qla);
	int qran=qualifierAppendix2Number(qra);
	
	if(qlan>qran) return true;
	if(qlan<qran) return false;
	
	if(qlan==QUALIFIER_APPENDIX_OTHER && qran==QUALIFIER_APPENDIX_OTHER)
		return left.compareTo(right) > 0;
	
	return false;
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:52,代码来源:OSGiUtil.java


注:本文中的org.osgi.framework.Version.compareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。