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


Java Version.equals方法代碼示例

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


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

示例1: rebuildProjectIfPluginVersionChanged

import org.osgi.framework.Version; //導入方法依賴的package包/類
private static void rebuildProjectIfPluginVersionChanged(IProject project) {
  // We're only worried about GWT projects
  if (GWTNature.isGWTProject(project.getProject())) {
    // Find the last plugin version that know the project was built with
    Version lastForcedRebuildAt = GdtPreferences.getVersionForLastForcedRebuild(project);
    Version currentPluginVersion = GdtPlugin.getVersion();

    if (!lastForcedRebuildAt.equals(currentPluginVersion)) {
      GdtPreferences.setVersionForLastForcedRebuild(project, currentPluginVersion);

      BuilderUtilities.scheduleRebuild(project);
      CorePluginLog.logInfo("Scheduled rebuild of project " + project.getName()
          + " because of plugin update (current version: " + currentPluginVersion.toString() + ")");
    }
  }
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:17,代碼來源:GdtPlugin.java

示例2: loadBundleFromLocal

import org.osgi.framework.Version; //導入方法依賴的package包/類
public static Bundle loadBundleFromLocal(BundleContext bc,String name, Version version, boolean loadIfNecessary, Bundle defaultValue) {
name=name.trim();
  	Bundle[] bundles = bc.getBundles();
  	for(Bundle b:bundles){
  		if(name.equalsIgnoreCase(b.getSymbolicName())) {
  			if(version==null || version.equals(b.getVersion())) {
  				return b;
  			}
  		}
  	}
  	if(!loadIfNecessary) return defaultValue;
  	
  	// is it in jar directory but not loaded
  	
  	CFMLEngine engine = ConfigWebUtil.getEngine(ThreadLocalPageContext.getConfig());
CFMLEngineFactory factory = engine.getCFMLEngineFactory();
BundleFile bf = _getBundleFile(factory, name, version, null);
if(bf!=null) {
	try {
		return _loadBundle(bc, bf.getFile());
	} 
	catch (Exception e) {}
}

  	return defaultValue;
  }
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:27,代碼來源:OSGiUtil.java

示例3: getBundleLoaded

import org.osgi.framework.Version; //導入方法依賴的package包/類
public static Bundle getBundleLoaded(BundleContext bc,String name, Version version, Bundle defaultValue) {
name=name.trim();

  	Bundle[] bundles = bc.getBundles();
  	for(Bundle b:bundles){
  		if(name.equalsIgnoreCase(b.getSymbolicName())) {
  			if(version==null || version.equals(b.getVersion())) {
  				return b;
  			}
  		}
  	}
  	return defaultValue;
  }
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:14,代碼來源:OSGiUtil.java

示例4: _cleanBundles

import org.osgi.framework.Version; //導入方法依賴的package包/類
private static void _cleanBundles(BundleDefinition[] candiatesToRemove, String name, Version version) {
	BundleDefinition bd;
	for(int i=0;i<candiatesToRemove.length;i++){
		bd=candiatesToRemove[i];
		
		if(bd!=null && name.equalsIgnoreCase(bd.getName())) {
			if(version==null) {
				if(bd.getVersion()==null) candiatesToRemove[i]=null; // remove that from array
			}
			else if(bd.getVersion()!=null && version.equals(bd.getVersion())) {
				candiatesToRemove[i]=null; // remove that from array
			}
		}
	}
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:16,代碼來源:XMLConfigAdmin.java

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

示例6: debugClassLoading

import org.osgi.framework.Version; //導入方法依賴的package包/類
/**
 * Tries (through a best-guess attempt) to figure out why a given class
 * could not be found. This method will search the given bundle and its
 * classpath to determine the reason for which the class cannot be loaded.
 * 
 * <p/> This method tries to be effective especially when the dealing with
 * {@link NoClassDefFoundError} caused by failure of loading transitive
 * classes (such as getting a NCDFE when loading <code>foo.A</code>
 * because <code>bar.B</code> cannot be found).
 * 
 * @param bundle the bundle to search for (and which should do the loading)
 * @param className the name of the class that failed to be loaded in dot
 * format (i.e. java.lang.Thread)
 * @param rootClassName the name of the class that triggered the loading
 * (i.e. java.lang.Runnable)
 */
public static void debugClassLoading(Bundle bundle, String className, String rootClassName) {
	boolean trace = log.isTraceEnabled();
	if (!trace)
		return;

	Dictionary dict = bundle.getHeaders();
	String bname = dict.get(Constants.BUNDLE_NAME) + "(" + dict.get(Constants.BUNDLE_SYMBOLICNAME) + ")";
	if (trace)
		log.trace("Could not find class [" + className + "] required by [" + bname + "] scanning available bundles");

	BundleContext context = OsgiBundleUtils.getBundleContext(bundle);
	int pkgIndex = className.lastIndexOf('.');
	// Reject global packages
	if (pkgIndex < 0) {
		if (trace)
			log.trace("Class is not in a package, its unlikely that this will work");
		return;
	}
	
	String packageName = className.substring(0, pkgIndex);

	Version iversion = hasImport(bundle, packageName);
	if (iversion != null && context != null) {
		if (trace)
			log.trace("Class is correctly imported as version [" + iversion + "], checking providing bundles");
		Bundle[] bundles = context.getBundles();
		for (int i = 0; i < bundles.length; i++) {
			if (bundles[i].getBundleId() != bundle.getBundleId()) {
				Version exported = checkBundleForClass(bundles[i], className, iversion);
				// Everything looks ok, but is the root bundle importing the
				// dependent class also?
				if (exported != null && exported.equals(iversion) && rootClassName != null) {
					for (int j = 0; j < bundles.length; j++) {
						Version rootexport = hasExport(bundles[j], rootClassName.substring(0,
							rootClassName.lastIndexOf('.')));
						if (rootexport != null) {
							// TODO -- this is very rough, check the bundle
							// classpath also.
							Version rootimport = hasImport(bundles[j], packageName);
							if (rootimport == null || !rootimport.equals(iversion)) {
								if (trace)
									log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundles[j])
											+ "] exports [" + rootClassName + "] as version [" + rootexport
											+ "] but does not import dependent package [" + packageName
											+ "] at version [" + iversion + "]");
							}
						}
					}
				}
			}
		}
	}
	if (hasExport(bundle, packageName) != null) {
		if (trace)
			log.trace("Class is exported, checking this bundle");
		checkBundleForClass(bundle, className, iversion);
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:75,代碼來源:DebugUtils.java

示例7: checkBundleForClass

import org.osgi.framework.Version; //導入方法依賴的package包/類
private static Version checkBundleForClass(Bundle bundle, String name, Version iversion) {
	String packageName = name.substring(0, name.lastIndexOf('.'));
	Version hasExport = hasExport(bundle, packageName);

	// log.info("Examining Bundle [" + bundle.getBundleId() + ": " + bname +
	// "]");
	// Check for version matching
	if (hasExport != null && !hasExport.equals(iversion)) {
		log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] exports [" + packageName
				+ "] as version [" + hasExport + "] but version [" + iversion + "] was required");
		return hasExport;
	}
	// Do more detailed checks
	String cname = name.substring(packageName.length() + 1) + ".class";
	Enumeration e = bundle.findEntries("/" + packageName.replace('.', '/'), cname, false);
	if (e == null) {
		if (hasExport != null) {
			URL url = checkBundleJarsForClass(bundle, name);
			if (url != null) {
				log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains [" + cname
						+ "] in embedded jar [" + url.toString() + "] but exports the package");
			}
			else {
				log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] does not contain ["
						+ cname + "] but exports the package");
			}
		}

		String root = "/";
		String fileName = packageName;
		if (packageName.lastIndexOf(".") >= 0) {
			root = root + packageName.substring(0, packageName.lastIndexOf(".")).replace('.', '/');
			fileName = packageName.substring(packageName.lastIndexOf(".") + 1).replace('.', '/');
		}
		Enumeration pe = bundle.findEntries(root, fileName, false);
		if (pe != null) {
			if (hasExport != null) {
				log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains package ["
						+ packageName + "] and exports it");
			}
			else {
				log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains package ["
						+ packageName + "] but does not export it");
			}

		}
	}
	// Found the resource, check that it is exported.
	else {
		if (hasExport != null) {
			log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains resource [" + cname
					+ "] and it is correctly exported as version [" + hasExport + "]");
			Class<?> c = null;
			try {
				c = bundle.loadClass(name);
			}
			catch (ClassNotFoundException e1) {
				// Ignored
			}
			log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] loadClass [" + cname
					+ "] returns [" + c + "]");
		}
		else {
			log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "] contains resource [" + cname
					+ "] but its package is not exported");
		}
	}
	return hasExport;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:70,代碼來源:DebugUtils.java

示例8: _eq

import org.osgi.framework.Version; //導入方法依賴的package包/類
private boolean _eq(String lName, Version lVersion, String rName, Version rVersion) {
	if(!lName.equals(rName)) return false;
	if(lVersion==null) return rVersion==null;
	return lVersion.equals(rVersion);
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:6,代碼來源:Admin.java

示例9: changeVersionTo

import org.osgi.framework.Version; //導入方法依賴的package包/類
public void changeVersionTo(Version version, Password password, IdentificationWeb id) throws PageException {
	checkWriteAccess();
   	
   	ConfigServerImpl cs=(ConfigServerImpl) ConfigImpl.getConfigServer(config,password);
   	
   	try {
       	CFMLEngineFactory factory = cs.getCFMLEngine().getCFMLEngineFactory();
       	cleanUp(factory);
       	// do we have the core file?
       	final File patchDir = factory.getPatchDirectory();
   		File localPath=new File(version.toString()+".lco");
       	
   		if(!localPath.isFile()) {
   			localPath=null;
   			Version v;
   			final File[] patches = patchDir.listFiles(new ExtensionFilter(new String[] { ".lco" }));
       		for (final File patch : patches) {
       			v=CFMLEngineFactory.toVersion(patch.getName(),null);
       			// not a valid file get deleted
       			if(v==null){
       				patch.delete();
       			}
       			else {
        			if(v.equals(version)) { // match!
        				localPath=patch;
        			}
        			// delete newer files
        			else if(OSGiUtil.isNewerThan(v,version)) {
        				patch.delete();
        			}
       			}
   			}
   		}
       	
   		// download patch
       	if(localPath==null) {
       		
       		downloadCore(factory, version, id);
       	}
       	
       	
       	
       	
       	factory.restart(password);
       } 
       catch (Exception e) {
           throw Caster.toPageException(e);
       }
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:50,代碼來源:XMLConfigAdmin.java


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