當前位置: 首頁>>代碼示例>>Java>>正文


Java Version.parseVersion方法代碼示例

本文整理匯總了Java中org.osgi.framework.Version.parseVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java Version.parseVersion方法的具體用法?Java Version.parseVersion怎麽用?Java Version.parseVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.osgi.framework.Version的用法示例。


在下文中一共展示了Version.parseVersion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isValid

import org.osgi.framework.Version; //導入方法依賴的package包/類
@Override
public boolean isValid ( final String value, final ConstraintValidatorContext context )
{
    if ( value == null )
    {
        return true;
    }
    if ( value.isEmpty () )
    {
        return true;
    }

    try
    {
        Version.parseVersion ( value );
        return true;
    }
    catch ( final Exception e )
    {
        return false;
    }
}
 
開發者ID:eclipse,項目名稱:packagedrone,代碼行數:23,代碼來源:VersionStringValidator.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: runTest

import org.osgi.framework.Version; //導入方法依賴的package包/類
private void runTest(Map<String, Bundle> installed, DataInputStream input, DataOutputStream output) throws Exception {
   	String symbolicName = input.readUTF();
	Version version = Version.parseVersion(input.readUTF());
	String testClass = input.readUTF();
	String testName = input.readUTF();
	
	Bundle testBundle = getTestBundle(installed, input, output, symbolicName, version);
	
	Class<?> testClazz = testBundle.loadClass(testClass);
	
	Result result = new JUnitCore().run(Request.method(testClazz, testName));
	
	if(result.wasSuccessful()) {
		output.writeUTF(SUCCESS);
	} else {
		Failure failure = result.getFailures().get(0);
		output.writeUTF(FAIL);
		output.writeUTF(failure.getMessage());
	}
	
	output.flush();
}
 
開發者ID:osgi,項目名稱:osgi.security-tests,代碼行數:23,代碼來源:TestServer.java

示例4: 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;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:11,代碼來源:MockBundle.java

示例5: setUp

import org.osgi.framework.Version; //導入方法依賴的package包/類
protected void setUp() throws Exception {
	props = new Properties();
	bundle = new MockBundle(props);

	min = Version.parseVersion("1.2");
	max = Version.parseVersion("1.3");
	version = Version.parseVersion("1.2.5");
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:9,代碼來源:ConfigUtilsVersioningTest.java

示例6: 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;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:36,代碼來源:DebugUtils.java

示例7: getTLAToolsClasspath

import org.osgi.framework.Version; //導入方法依賴的package包/類
/**
   * Returns the classpath entry of the tla2tool.jar (the TLA tools) 
   */
  public static IPath getTLAToolsClasspath() {
  	Bundle bundle = null;
  	
  	// find the tlatools bundle among all installed bundles
  	// (this code assumes tlatools has a bundle shape "dir")
Bundle[] bundles = Activator.getDefault().getBundle()
		.getBundleContext().getBundles();
      for (int i = 0; i < bundles.length; i++) {
	Bundle aBundle = bundles[i];
	if ("org.lamport.tlatools".equals(aBundle.getSymbolicName())) {
		// OSGi supports multiple bundles with the same symbolic name, but
		// different versions. This e.g. occurs after a Toolbox update
		// before the old bundle version gets purged from the
		// installation directory.
		// Without this explicitly version check, the Toolbox
		// might accidentally use an old tla version which leads to
		// undefined behavior.
		// @see Bug #285 in general/bugzilla/index.html
		Version otherVersion = bundle != null ? bundle.getVersion()
				: Version.parseVersion("0.0.0");
		if (aBundle.getVersion().compareTo(otherVersion) > 0) {
			bundle = aBundle;
		}
	}
}
      if (bundle == null)
          return null;

      URL local = null;
      try
      {
          local = FileLocator.toFileURL(bundle.getEntry("/")); //$NON-NLS-1$
      } catch (IOException e)
      {
          return null;
      }
      String fullPath = new File(local.getPath()).getAbsolutePath();
      return Path.fromOSString(fullPath);
  }
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:43,代碼來源:ToolboxHandle.java

示例8: addManifest

import org.osgi.framework.Version; //導入方法依賴的package包/類
/** Adds a manifest to the catalog. */
private void addManifest(List<SwtPlatform> supported, Manifest parsed, File plugin) {
	// parse out the name (looking out for the ";singleton=true" names
	String name = parsed.getMainAttributes().getValue(BUNDLE_NAME);
	int splitIdx = name.indexOf(';');
	if (splitIdx > 0) {
		name = name.substring(0, splitIdx);
	}

	// parse out the platform filter (if any)
	// if it doesn't match an OS that we support, throw it out
	String platformFilter = parsed.getMainAttributes().getValue(ECLIPSE_PLATFORM_FILTER);
	if (platformFilter != null) {
		Filter filter = new Filter(platformFilter.replace(" ", ""));
		boolean isSupportedOS = supported.stream().anyMatch(Errors.rethrow().wrapPredicate(platform -> filter.matchMap(platform.platformProperties())));
		if (!isSupportedOS) {
			unsupportedPlatform.add(name);
			return;
		}
	}

	// parse out the version
	String versionRaw = parsed.getMainAttributes().getValue(BUNDLE_VERSION);
	Version version = Version.parseVersion(versionRaw);
	availableVersions.put(name, version);
	toFile.put(name, version, plugin);
}
 
開發者ID:diffplug,項目名稱:goomph,代碼行數:28,代碼來源:PluginCatalog.java

示例9: createWithIdVersionUpdatesite

import org.osgi.framework.Version; //導入方法依賴的package包/類
/** Creates a custom eclipse release (use an official release, e.g. `EclipseRelease.R_4_5_2` whenever possible). */
public static EclipseRelease createWithIdVersionUpdatesite(String id, String version, String updateSite) {
	EclipseRelease official = officialReleaseMaybe(id);
	if (official != null) {
		throw new IllegalArgumentException("User-generated version cannot conflict with built-in " + id + ", change the ID or use EclipseRelease.forVersion(" + id + ")");
	}
	return new EclipseRelease(
			Objects.requireNonNull(id),
			Version.parseVersion(version),
			Objects.requireNonNull(updateSite));
}
 
開發者ID:diffplug,項目名稱:goomph,代碼行數:12,代碼來源:EclipseRelease.java

示例10: PluginImpl

import org.osgi.framework.Version; //導入方法依賴的package包/類
public PluginImpl(PluginManagerImpl pluginManager, File file, PluginInfo pluginInfo) {
	this.pluginManager = pluginManager;
	this.file = file;
	id = pluginInfo.getId();
	name = pluginInfo.getName();
	description = pluginInfo.getDescription();
	organization = pluginInfo.getOrganization();
	version = Version.parseVersion(pluginInfo.getVersion());
}
 
開發者ID:apache,項目名稱:incubator-taverna-osgi,代碼行數:10,代碼來源:PluginImpl.java

示例11: checkVersion

import org.osgi.framework.Version; //導入方法依賴的package包/類
/**
 * Checks whether the given version is properly formatted. Passing null or empty {@code String} as {@code value}
 * will NOT result in adding {@code TaskError} to the {@code error}.
 *
 * @param errors  the collection of errors that acts as the result of validation, not null
 * @param objectName  the object name
 * @param field  the field name
 * @param value  the value to be checked
 */
protected static void checkVersion(Set<TaskError> errors, String objectName, String field, String value) {
    try {
        Version.parseVersion(value);
    } catch (RuntimeException e) {
        LOGGER.error("An exception occurred during validation of field - {}, objectName - {}, value - {}",
            field, objectName, value);
        errors.add(new TaskError(VERSION, field, objectName));
    }
}
 
開發者ID:motech,項目名稱:motech,代碼行數:19,代碼來源:GeneralValidator.java

示例12: sendBundle

import org.osgi.framework.Version; //導入方法依賴的package包/類
private void sendBundle(DataInput dataInput, DataOutputStream dataOutput)
		throws IOException {
	String symbolicName = dataInput.readUTF();
	Version version = Version.parseVersion(dataInput.readUTF());

	String location = null;

	for (Bundle b : ctx.getBundles()) {
		if (b.getSymbolicName().equals(symbolicName) && b.getVersion().equals(version)) {
			location = b.getLocation();
			break;
		}
	}

	if (location == null) {
		throw new IllegalArgumentException(
				"No bundle exists with name " + symbolicName + " and version " + version);
	} else if (location.startsWith("reference:")) {
		//Equinox is unkind, and reference: urls are not readable :(
		//Remove reference: and it should be a normal file URL
		location = location.substring(10);
	}

	File f = new File(URI.create(location));

	try (InputStream is = new FileInputStream(f)) {
		dataOutput.writeUTF(BUNDLE);
		dataOutput.writeUTF(symbolicName);
		dataOutput.writeUTF(version.toString());
		dataOutput.writeInt((int) f.length());

		byte[] buffer = new byte[4096];
		int i;

		while ((i = is.read(buffer, 0, buffer.length)) != -1) {
			dataOutput.write(buffer, 0, i);
		}
		dataOutput.flush();
	}
}
 
開發者ID:osgi,項目名稱:osgi.security-tests,代碼行數:41,代碼來源:OSGiSecurityTestRunner.java

示例13: isVersion

import org.osgi.framework.Version; //導入方法依賴的package包/類
public boolean isVersion(String v){
	try {
		Version version = Version.parseVersion(v);
		return true;
	} catch(Exception e){
		return false;
	}
}
 
開發者ID:ibcn-cloudlet,項目名稱:dianne,代碼行數:9,代碼來源:DianneDownload.java

示例14: toVersion

import org.osgi.framework.Version; //導入方法依賴的package包/類
/**
 * cast a lucee string version to a int version
 * 
 * @param version
 * @return int version
 */
public static Version toVersion(String version, final Version defaultValue) {
	// remove extension if there is any
	final int rIndex = version.lastIndexOf(".lco");
	if (rIndex != -1)
		version = version.substring(0, rIndex);

	try {
		return Version.parseVersion(version);
	} catch (final IllegalArgumentException iae) {
		return defaultValue;
	}
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:19,代碼來源:CFMLEngineFactorySupport.java

示例15: 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


注:本文中的org.osgi.framework.Version.parseVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。