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


Java IQueryResult.iterator方法代码示例

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


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

示例1: findUnit

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Finds the latest version of an installable unit in a repository.
 * 
 * @param spec Version specification
 * @return Installable unit or <code>null</code>.
 * @throws CoreException on failure
 */
public IInstallableUnit findUnit(IVersionedId spec) {
	String id = spec.getId();
	Version version = spec.getVersion();
	VersionRange range = VersionRange.emptyRange;
	if (version != null && !version.equals(Version.emptyVersion))
		range = new VersionRange(version, true, version, true);
	
	IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id, range);
	IQueryResult<IInstallableUnit> queryResult = getRepository().query(query, new NullProgressMonitor());
	
	Iterator<IInstallableUnit> matches = queryResult.iterator();
	// pick the newest match
	IInstallableUnit newest = null;
	while (matches.hasNext()) {
		IInstallableUnit candidate = matches.next();
		if (newest == null || (newest.getVersion().compareTo(candidate.getVersion()) < 0))
			newest = candidate;
	}
	
	return newest;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:29,代码来源:RepositoryAdapter.java

示例2: findUnit

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Returns the latest version of an installable unit in a profile.
 * 
 * @param id Installable unit identifier
 * @return Latest version found or <code>null</code>
 */
public IInstallableUnit findUnit(String id) {
	IInstallableUnit unit = null;
	if (getProfile() != null) {
		IQueryResult<IInstallableUnit> query = getProfile().query(QueryUtil.createIUQuery(id), null);
		Iterator<IInstallableUnit> iter = query.iterator();
		while (iter.hasNext()) {
			IInstallableUnit foundUnit = iter.next();
			if ((unit == null) || (unit.getVersion().compareTo(unit.getVersion()) > 0)) {
				unit = foundUnit;
			}
		}
	}
	
	return unit;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:22,代码来源:ProfileAdapter.java

示例3: queryP2Repository

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
private Iterator<IInstallableUnit> queryP2Repository(IProgressMonitor monitor, String updateURL)
		throws URISyntaxException {
	if (monitor == null) {
		monitor = new NullProgressMonitor();
	}

	SubMonitor progress = SubMonitor.convert(monitor, "", 6);
	// get all available IUs in update repository
	IMetadataRepository metadataRepo = null;
	try {
		metadataRepo = metadataRepoManager.loadRepository(new URI(updateURL), progress.newChild(1));
	} catch (ProvisionException e) {
		System.exit(1);
	}
	IQuery<IInstallableUnit> allIUQuery = QueryUtil.createIUAnyQuery();
	IQueryResult<IInstallableUnit> allIUQueryResult = metadataRepo.query(allIUQuery, progress.newChild(1));

	Iterator<IInstallableUnit> iterator = allIUQueryResult.iterator();

	if (progress.isCanceled()) {
		throw new OperationCanceledException();
	}
	return iterator;
}
 
开发者ID:wso2,项目名称:developer-studio,代码行数:25,代码来源:CheckUpdatesManager.java

示例4: filterInstallableUnits

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
private Collection<IInstallableUnit> filterInstallableUnits(String idPrefix, String idSuffix,
		IQueryResult<IInstallableUnit> queryResult, IProgressMonitor monitor) throws OperationCanceledException {
	if (monitor == null) {
		monitor = new NullProgressMonitor();
	}
	Collection<IInstallableUnit> wso2IUs = new ArrayList<IInstallableUnit>();
	Iterator<IInstallableUnit> iterator = queryResult.iterator();
	SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_24, queryResult.toSet().size());

	while (iterator.hasNext()) {
		if (progress.isCanceled()) {
			throw new OperationCanceledException();
		}
		IInstallableUnit iu = iterator.next();
		String versionedID = iu.getId();
		progress.subTask(Messages.UpdateManager_25 + versionedID);
		if (versionedID != null && versionedID.startsWith(idPrefix) && versionedID.endsWith(idSuffix)) {
			wso2IUs.add(iu);
		}
		progress.worked(1);
	}
	return wso2IUs;
}
 
开发者ID:wso2,项目名称:developer-studio,代码行数:24,代码来源:UpdateManager.java

示例5: getDownloadSize

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Mentor Graphics: Returns the download size of the mirror.
 * 
 * @return Mirror size in bytes.
 */
public long getDownloadSize() {
	long size = 0;
	
	Iterator<IArtifactKey> keys = null;
	if (keysToMirror != null) {
		keys = keysToMirror.iterator();
	}
	else {
		IQueryResult<IArtifactKey> result = source.query(ArtifactKeyQuery.ALL_KEYS, null);
		keys = result.iterator();
	}

	while (keys.hasNext()) {
		IArtifactKey key = keys.next();
		IArtifactDescriptor[] descriptors = source.getArtifactDescriptors(key);
		
		for (int j = 0; j < descriptors.length; j++) {
			String downloadSize = descriptors[j].getProperty(IArtifactDescriptor.DOWNLOAD_SIZE);
			if (downloadSize != null) {
				size += Long.parseLong(downloadSize);
			}
		}
	}
	
	return size;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:32,代码来源:InstallerMirroring.java

示例6: findMemberUnits

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Finds all required members for an installable unit.
 * 
 * @param parent Parent installable unit
 * @param members Filled with the member installable units
 */
public void findMemberUnits(IInstallableUnit parent, List<IInstallableUnit> members) {
	members.clear();
	// Expression to get required IU's.  This expression matches the expression used in
	// QueryUtil.matchesRequirementsExpression to get category IU members.
	IExpression matchesRequirementsExpression = ExpressionUtil.parse("$0.exists(r | this ~= r)");
	IQuery<IInstallableUnit> query = QueryUtil.createMatchQuery(matchesRequirementsExpression, 
			parent.getRequirements());
	IQueryResult<IInstallableUnit> result = getRepository().query(query, null);
	Iterator<IInstallableUnit> iter = result.iterator();
	while (iter.hasNext()) {
		members.add(iter.next());
	}
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:20,代码来源:RepositoryAdapter.java

示例7: findUnits

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Returns installable units from a profile.
 * 
 * @param versions Versions for installable units
 * @return Installable units
 */
public IInstallableUnit[] findUnits(IVersionedId[] versions) {
	ArrayList<IInstallableUnit> units = new ArrayList<IInstallableUnit>();
	
	for (IVersionedId version : versions) {
		IQueryResult<IInstallableUnit> query = getProfile().query(QueryUtil.createIUQuery(version), null);
		Iterator<IInstallableUnit> iter = query.iterator();
		while (iter.hasNext()) {
			units.add(iter.next());
		}
	}
	
	return units.toArray(new IInstallableUnit[units.size()]);
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:20,代码来源:ProfileAdapter.java

示例8: findUnit

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Finds the latest version of an installable unit in local repositories.
 * 
 * @param spec Version specification
 * @return Installable unit or <code>null</code>.
 * @throws CoreException on failure
 */
public IInstallableUnit findUnit(IVersionedId spec) throws CoreException {
	String id = spec.getId();
	if (id == null) {
		Installer.fail(InstallMessages.Error_NoId);
	}
	Version version = spec.getVersion();
	VersionRange range = VersionRange.emptyRange;
	if (version != null && !version.equals(Version.emptyVersion))
		range = new VersionRange(version, true, version, true);
	
	URI[] locations = manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_LOCAL);
	List<IMetadataRepository> queryables = new ArrayList<IMetadataRepository>(locations.length);
	for (URI location : locations) {
		queryables.add(getManager().loadRepository(location, new NullProgressMonitor()));
	}

	IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id, range);
	IQueryable<IInstallableUnit> compoundQueryable = QueryUtil.compoundQueryable(queryables);
	IQueryResult<IInstallableUnit> queryResult = compoundQueryable.query(query, new NullProgressMonitor());
	
	Iterator<IInstallableUnit> matches = queryResult.iterator();
	// pick the newest match
	IInstallableUnit newest = null;
	while (matches.hasNext()) {
		IInstallableUnit candidate = matches.next();
		if (newest == null || (newest.getVersion().compareTo(candidate.getVersion()) < 0))
			newest = candidate;
	}

	return newest;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:39,代码来源:RepositoryManagerAdapter.java

示例9: findMemberUnits

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Returns all required members for an installable unit.
 * 
 * @param unit Unit
 * @param members Required members
 */
public void findMemberUnits(IInstallableUnit unit, List<IInstallableUnit> members) {
	members.clear();
	// Expression to get required IU's.  This expression matches the expression used in
	// QueryUtil.matchesRequirementsExpression to get category IU members.
	IExpression matchesRequirementsExpression = ExpressionUtil.parse("$0.exists(r | this ~= r)");
	IQuery<IInstallableUnit> query = QueryUtil.createMatchQuery(matchesRequirementsExpression, 
			unit.getRequirements());
	IQueryResult<IInstallableUnit> result = getManager().query(query, null);
	Iterator<IInstallableUnit> iter = result.iterator();
	while (iter.hasNext()) {
		members.add(iter.next());
	}
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:20,代码来源:RepositoryManagerAdapter.java

示例10: getExistingRequiredRootIUs

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Checks the requirements of a specified IU and returns any that are already installed as a root IU.
 * 
 * @param unit IU to check for requirements.
 * @param requiredRoots Filled with root IU's that are required by the IU.
 */
private void getExistingRequiredRootIUs(IInstallableUnit unit, ArrayList<IInstallableUnit> requiredRoots) {
	try {
		// Get requirements for the IU
		IQueryResult<IInstallableUnit> requirements = getMetadataRepositoryManager().query(new RequiredIUsQuery(unit), new NullProgressMonitor());
		Iterator<IInstallableUnit> iter = requirements.iterator();
		ProfileAdapter profileAdapter = new ProfileAdapter(getInstallProfile());
		RepositoryManagerAdapter repositoryAdapter = new RepositoryManagerAdapter(getMetadataRepositoryManager());
		while (iter.hasNext()) {
			IInstallableUnit required = iter.next();
			// Check if the required IU is already present in the profile
			IInstallableUnit existingRequired = profileAdapter.findUnit(required.getId());
			if (existingRequired != null) {
				// See if the required IU is present in the repository
				IInstallableUnit installingUnit = repositoryAdapter.findUnit(new VersionedId(existingRequired.getId(), Version.emptyVersion));
				if ((installingUnit != null) && !requiredRoots.contains(installingUnit)) {
					// Is the required IU a root
					String root = getInstallProfile().getInstallableUnitProperties(existingRequired).get(IProfile.PROP_PROFILE_ROOT_IU);
					boolean newerVersion = (required.getVersion().compareTo(existingRequired.getVersion()) > 0);
					
					// If the required IU is an existing root then add it
					if (Boolean.TRUE.toString().equals(root) && newerVersion) {
						if (!requiredRoots.contains(existingRequired)) {
							requiredRoots.add(existingRequired);
							getExistingRequiredRootIUs(required, requiredRoots);
						}
					}
				}
			}
		}
	}
	catch (Exception e) {
		Installer.log(e);
	}
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:41,代码来源:RepositoryManager.java

示例11: queryIuName

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Returns the name for an installable unit.
 * 
 * @param id IU identifier.
 * @return IU name or <code>null</code> if the IU is not found.
 */
public String queryIuName(String id) {
	IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id);
	IQueryResult<IInstallableUnit> result = getMetadataRepositoryManager().query(query, null);
	Iterator<IInstallableUnit> iter = result.iterator();
	while (iter.hasNext()) {
		IInstallableUnit unit = iter.next();
		return unit.getProperty(IInstallableUnit.PROP_NAME, null);
	}
	
	return null;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:18,代码来源:RepositoryManager.java

示例12: getMirroring

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * This method is overridden to use a special InstallerMirroring class instead of the normal P2 Mirroring class
 * so that progress reporting can be provided and so the operation can be cancelled.
 * 
 * @see org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication#getMirroring
 */
@Override
protected Mirroring getMirroring(IQueryable<IInstallableUnit> slice, IProgressMonitor monitor) {
	// Obtain ArtifactKeys from IUs
	IQueryResult<IInstallableUnit> ius = slice.query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
	boolean iusSpecified = !ius.isEmpty(); // call before ius.iterator() to avoid bug 420318
	ArrayList<IArtifactKey> keys = new ArrayList<IArtifactKey>();
	for (Iterator<IInstallableUnit> iterator = ius.iterator(); iterator.hasNext();) {
		IInstallableUnit iu = iterator.next();
		keys.addAll(iu.getArtifacts());
	}

	InstallerMirroring mirror = new InstallerMirroring(getCompositeArtifactRepository(), destinationArtifactRepository, true/*raw*/,
			getProgressMonitor(), getProgressText());
	mirror.setCompare(false);
	mirror.setComparatorId(null);
	mirror.setBaseline(null);
	mirror.setValidate(true);
	mirror.setCompareExclusions(null);
	mirror.setTransport((Transport) agent.getService(Transport.SERVICE_NAME));
	mirror.setIncludePacked(true);

	// If IUs have been specified then only they should be mirrored, otherwise mirror everything.
	if (iusSpecified)
		mirror.setArtifactKeys(keys.toArray(new IArtifactKey[keys.size()]));

	return mirror;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:34,代码来源:InstallerMirrorApplication.java

示例13: validateMirror

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
private IStatus validateMirror(boolean verbose) {
	MultiStatus status = new MultiStatus(Activator.ID, 0, Messages.Mirroring_ValidationError, null);

	// The keys that were mirrored in this session
	Iterator<IArtifactKey> keys = null;
	if (keysToMirror != null) {
		keys = keysToMirror.iterator();
	} else {
		IQueryResult<IArtifactKey> result = source.query(ArtifactKeyQuery.ALL_KEYS, null);
		keys = result.iterator();
	}
	while (keys.hasNext()) {
		IArtifactKey artifactKey = keys.next();
		IArtifactDescriptor[] srcDescriptors = source.getArtifactDescriptors(artifactKey);
		IArtifactDescriptor[] destDescriptors = destination.getArtifactDescriptors(artifactKey);

		Arrays.sort(srcDescriptors, new ArtifactDescriptorComparator());
		Arrays.sort(destDescriptors, new ArtifactDescriptorComparator());

		int src = 0;
		int dest = 0;
		while (src < srcDescriptors.length && dest < destDescriptors.length) {
			if (!destDescriptors[dest].equals(srcDescriptors[src])) {
				if (destDescriptors[dest].toString().compareTo((srcDescriptors[src].toString())) > 0) {
					// Missing an artifact
					if (verbose)
						System.out.println(NLS.bind(Messages.Mirroring_missingDescriptor, srcDescriptors[src]));
					status.add(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Mirroring_missingDescriptor, srcDescriptors[src++])));
				} else {
					// Its okay if there are extra descriptors in the destination
					dest++;
				}
			} else {
				// check properties for differences
				Map<String, String> destMap = destDescriptors[dest].getProperties();
				Map<String, String> srcProperties = null;
				if (baseline != null) {
					IArtifactDescriptor baselineDescriptor = getBaselineDescriptor(destDescriptors[dest]);
					if (baselineDescriptor != null)
						srcProperties = baselineDescriptor.getProperties();
				}
				// Baseline not set, or could not find descriptor so we'll use the source descriptor
				if (srcProperties == null)
					srcProperties = srcDescriptors[src].getProperties();

				// Cycle through properties of the originating descriptor & compare
				for (String key : srcProperties.keySet()) {
					if (!srcProperties.get(key).equals(destMap.get(key))) {
						if (verbose)
							System.out.println(NLS.bind(Messages.Mirroring_differentDescriptorProperty, new Object[] {destDescriptors[dest], key, srcProperties.get(key), destMap.get(key)}));
						status.add(new Status(IStatus.WARNING, Activator.ID, NLS.bind(Messages.Mirroring_differentDescriptorProperty, new Object[] {destDescriptors[dest], key, srcProperties.get(key), destMap.get(key)})));
					}
				}
				src++;
				dest++;
			}
		}

		// If there are still source descriptors they're missing from the destination repository 
		while (src < srcDescriptors.length) {
			if (verbose)
				System.out.println(NLS.bind(Messages.Mirroring_missingDescriptor, srcDescriptors[src]));
			status.add(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Mirroring_missingDescriptor, srcDescriptors[src++])));
		}
	}

	return status;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:69,代码来源:InstallerMirroring.java

示例14: addInstallComponent

import org.eclipse.equinox.p2.query.IQueryResult; //导入方法依赖的package包/类
/**
 * Adds a new install component for an installable unit.  If the installable
 * unit is a category, it's member units will also be added.
 * 
 * @param unit Installable unit
 * @param parentGroup Parent component or <code>null</code>
 * @return Added components or <code>null</code> if the component has already been added
 * @throws ProvisionException on failure
 */
private List<IInstallComponent> addInstallComponent(IInstallableUnit unit, InstallComponent parentGroup) throws ProvisionException {
	IInstallComponent existingComponent = getInstallComponent(unit.getId());
	ArrayList<IInstallComponent> addedComponents = new ArrayList<IInstallComponent>();
	InstallComponent component = null;

	// Category IU
	boolean isCategory = isCategoryIu(unit);
	
	// If there is an existing component for the unit
	if (existingComponent != null) {
		// If category, add to existing component
		if (isCategory)
			component = (InstallComponent)existingComponent;
		// Else do not allow duplicates units
		else 
			return null;
	}
	// Create component
	if (component == null) {
		component = new InstallComponent(unit);
	}
	
	// If category unit, add members
	if (isCategory) {
		IQuery<IInstallableUnit> categoryQuery = QueryUtil.createIUCategoryMemberQuery(unit);
		IQueryResult<IInstallableUnit> query = getMetadataRepositoryManager().query(categoryQuery, null);
		Iterator<IInstallableUnit> iter = query.iterator();
		while (iter.hasNext()) {
			IInstallableUnit categoryMemberUnit = iter.next();
			List<IInstallComponent> members = addInstallComponent(categoryMemberUnit, component);
			if (members != null) {
				addedComponents.addAll(members);
			}
		}
	}
	
	// Add component
	if (existingComponent == null) {
		if (parentGroup != null) {
			parentGroup.addComponent(component);
		}

		// Set component parent
		component.setParent(parentGroup);
		// Add component
		components.add(component);
		addedComponents.add(component);
	}
	
	return addedComponents;
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:61,代码来源:RepositoryManager.java


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