本文整理汇总了Java中org.eclipse.jdt.core.IJarEntryResource类的典型用法代码示例。如果您正苦于以下问题:Java IJarEntryResource类的具体用法?Java IJarEntryResource怎么用?Java IJarEntryResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IJarEntryResource类属于org.eclipse.jdt.core包,在下文中一共展示了IJarEntryResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalGetUri
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
@Override
protected URI internalGetUri(IStorage storage) {
if (!uriValidator.isPossiblyManaged(storage))
return null;
URI uri = super.internalGetUri(storage);
if (uri != null)
return uri;
if (storage instanceof IJarEntryResource) {
final IJarEntryResource storage2 = (IJarEntryResource) storage;
Map<URI, IStorage> data = getAllEntries(storage2.getPackageFragmentRoot());
for (Map.Entry<URI, IStorage> entry : data.entrySet()) {
if (entry.getValue().equals(storage2))
return entry.getKey();
}
}
return null;
}
示例2: getURI
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
/**
* @return a URI for the given jarEntry, can be <code>null</code>.
*/
public URI getURI(IPackageFragmentRoot root, IJarEntryResource jarEntry, TraversalState state) {
if (root.isArchive()) {
URI jarURI = JarEntryURIHelper.getUriForPackageFragmentRoot(root);
URI storageURI = URI.createURI(jarEntry.getFullPath().toString());
return createJarURI(root.isArchive(), jarURI, storageURI);
} else if (root instanceof ExternalPackageFragmentRoot) {
IResource resource = ((ExternalPackageFragmentRoot) root).resource();
IPath result = resource.getFullPath();
for(int i = 1; i < state.getParents().size(); i++) {
Object obj = state.getParents().get(i);
if (obj instanceof IPackageFragment) {
result = result.append(new Path(((IPackageFragment) obj).getElementName().replace('.', '/')));
} else if (obj instanceof IJarEntryResource) {
result = result.append(((IJarEntryResource) obj).getName());
}
}
result = result.append(jarEntry.getName());
return URI.createPlatformResourceURI(result.toString(), true);
} else {
throw new IllegalStateException("Unexpeced root type: " + root.getClass().getName());
}
}
示例3: getLogicalURI
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
/**
* Converts the physical URI to a logic URI based on the bundle symbolic name.
*/
protected URI getLogicalURI(URI uri, IStorage storage, TraversalState state) {
if (bundleSymbolicName != null) {
URI logicalURI = URI.createPlatformResourceURI(bundleSymbolicName, false);
List<?> parents = state.getParents();
for (int i = 1; i < parents.size(); i++) {
Object obj = parents.get(i);
if (obj instanceof IPackageFragment) {
logicalURI = logicalURI.appendSegments(((IPackageFragment) obj).getElementName().split("\\."));
} else if (obj instanceof IJarEntryResource) {
logicalURI = logicalURI.appendSegment(((IJarEntryResource) obj).getName());
} else if (obj instanceof IFolder) {
logicalURI = logicalURI.appendSegment(((IFolder) obj).getName());
}
}
return logicalURI.appendSegment(uri.lastSegment());
}
return uri;
}
示例4: traverse
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
public T traverse(IPackageFragmentRoot root, boolean stopOnFirstResult) throws JavaModelException {
T result = null;
if (root.exists()) {
Object[] resources = root.getNonJavaResources();
TraversalState state = new TraversalState(root);
for (Object object : resources) {
if (object instanceof IJarEntryResource) {
result = traverse((IJarEntryResource) object, stopOnFirstResult, state);
if (stopOnFirstResult && result != null)
return result;
}
}
IJavaElement[] children = root.getChildren();
for (IJavaElement javaElement : children) {
if (javaElement instanceof IPackageFragment) {
result = traverse((IPackageFragment) javaElement, stopOnFirstResult, state);
if (stopOnFirstResult && result != null)
return result;
}
}
}
return result;
}
示例5: getJarWithEntry
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
protected IPackageFragmentRoot getJarWithEntry(URI uri) {
Iterable<Pair<IStorage, IProject>> storages = getStorages(uri);
IPackageFragmentRoot result = null;
for (Pair<IStorage, IProject> storage2Project : storages) {
IStorage storage = storage2Project.getFirst();
if (storage instanceof IJarEntryResource) {
IPackageFragmentRoot fragmentRoot = ((IJarEntryResource) storage).getPackageFragmentRoot();
if (fragmentRoot != null) {
IJavaProject javaProject = fragmentRoot.getJavaProject();
if (isAccessibleXtextProject(javaProject.getProject()))
return fragmentRoot;
if (result != null)
result = fragmentRoot;
}
}
}
return result;
}
示例6: findJarDirectoryChildren
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
private Object[] findJarDirectoryChildren(JarEntryDirectory directory, String path) {
String directoryPath = directory.getFullPath().toOSString();
if (directoryPath.equals(path)) {
return directory.getChildren();
}
if (path.startsWith(directoryPath)) {
for (IJarEntryResource resource : directory.getChildren()) {
String childrenPath = resource.getFullPath().toOSString();
if (childrenPath.equals(path)) {
return resource.getChildren();
}
if (path.startsWith(childrenPath) && resource instanceof JarEntryDirectory) {
findJarDirectoryChildren((JarEntryDirectory) resource, path);
}
}
}
return null;
}
示例7: getText
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
@Override
public String getText(Object element) {
if (!(element instanceof IModule)) {
return super.getText(element);
}
String text = null;
IModule module = (IModule) element;
String packageName = module.getPackageName();
if (!module.isBinary()) {
ModuleFile moduleFile = (ModuleFile) module;
IFile file = moduleFile.getFile();
String modulePath = file.getFullPath().makeRelative().toString();
text = packageName + " - " + modulePath;
} else {
ModuleJarResource moduleJarResource = (ModuleJarResource) module;
IJarEntryResource jarEntryResource = moduleJarResource.getJarEntryResource();
String jarPath = jarEntryResource.getPackageFragmentRoot().getPath().makeRelative().toString();
text = packageName + " - " + jarPath;
}
return text;
}
示例8: getPathForModule
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
/**
* Helper method to return the absolute workspace path of a GWT Module.
*
* If the module file is located in a JAR, then the absolute path of the JAR
* on the file system is returned.
*/
private static IPath getPathForModule(IModule module) {
if (module == null) {
return null;
}
if (!module.isBinary()) {
ModuleFile moduleFile = (ModuleFile) module;
IFile file = moduleFile.getFile();
return file.getFullPath();
}
ModuleJarResource moduleJarResource = (ModuleJarResource) module;
IJarEntryResource jarEntryResource = moduleJarResource.getJarEntryResource();
return jarEntryResource.getPackageFragmentRoot().getPath();
}
示例9: extractManifest
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
/**
* @param packageFragmentRoot
* @throws JavaModelException
* @throws CoreException
*/
@SuppressWarnings("restriction")
private static Manifest extractManifest(IPackageFragmentRoot packageFragmentRoot) throws JavaModelException {
Manifest result = null;
final Object[] nonJavaResources = packageFragmentRoot.getNonJavaResources();
for (Object obj : nonJavaResources) {
if (obj instanceof JarEntryDirectory) {
final JarEntryDirectory jarEntryDirectory = (JarEntryDirectory) obj;
final IJarEntryResource[] jarEntryResources = jarEntryDirectory.getChildren();
for (IJarEntryResource jarEntryResource : jarEntryResources) {
if ("MANIFEST.MF".equals(jarEntryResource.getName())) {
try {
final InputStream stream = jarEntryResource.getContents();
result = new Manifest(stream);
} catch (Exception e) {
// no manifest as result
}
}
}
}
}
return result;
}
示例10: collectNonJavaResources
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
private static void collectNonJavaResources(Object[] nonJavaResources,
IPath rootPath, List<JarEntryStorage> list,
JarEntryPredicate jarEntryPredicate) {
for (Object nonJavaRes : nonJavaResources) {
if (nonJavaRes instanceof IJarEntryResource) {
IJarEntryResource jarEntry = (IJarEntryResource) nonJavaRes;
boolean addToList = jarEntryPredicate == null ? true
: jarEntryPredicate.test(jarEntry);
if (addToList) {
list.add(new JarEntryStorage(rootPath.append(jarEntry
.getFullPath()), jarEntry));
}
}
}
}
示例11: isEclipseNLSAvailable
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
private static boolean isEclipseNLSAvailable(IStorageEditorInput editorInput) {
IStorage storage;
try {
storage= editorInput.getStorage();
} catch (CoreException ex) {
return false;
}
if (!(storage instanceof IJarEntryResource))
return false;
IJavaProject javaProject= ((IJarEntryResource) storage).getPackageFragmentRoot().getJavaProject();
if (javaProject == null || !javaProject.exists())
return false;
try {
return javaProject.findType("org.eclipse.osgi.util.NLS") != null; //$NON-NLS-1$
} catch (JavaModelException e) {
return false;
}
}
示例12: getQualifiedName
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
private String getQualifiedName(Object element) throws JavaModelException {
if (element instanceof IResource)
return ((IResource)element).getFullPath().toString();
if (element instanceof IJarEntryResource)
return ((IJarEntryResource)element).getFullPath().toString();
if (element instanceof LogicalPackage)
return ((LogicalPackage)element).getElementName();
if (element instanceof IJavaProject || element instanceof IPackageFragmentRoot || element instanceof ITypeRoot) {
IResource resource= ((IJavaElement)element).getCorrespondingResource();
if (resource != null)
return getQualifiedName(resource);
}
if (element instanceof IBinding)
return BindingLabelProvider.getBindingLabel((IBinding)element, LABEL_FLAGS);
return TextProcessor.deprocess(JavaElementLabels.getTextLabel(element, LABEL_FLAGS));
}
示例13: getChildren
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
public IJarEntryResource[] getChildren() {
if (this.resource instanceof IContainer) {
IResource[] members;
try {
members = ((IContainer) this.resource).members();
} catch (CoreException e) {
Util.log(e, "Could not retrieve children of " + this.resource.getFullPath()); //$NON-NLS-1$
return NO_CHILDREN;
}
int length = members.length;
if (length == 0)
return NO_CHILDREN;
IJarEntryResource[] children = new IJarEntryResource[length];
for (int i = 0; i < length; i++) {
children[i] = new NonJavaResource(this, members[i]);
}
return children;
}
return NO_CHILDREN;
}
示例14: searchNonJavaResources
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
private TapestryFile searchNonJavaResources(IParent root, String path) throws JavaModelException
{
String[] segments = path.split("/");
if (root instanceof IPackageFragmentRoot)
{
for (Object nonJava : ((IPackageFragmentRoot) root).getNonJavaResources())
{
if (nonJava instanceof IJarEntryResource)
{
IJarEntryResource resource = (IJarEntryResource) nonJava;
if (StringUtils.equals(segments[0], resource.getName()))
{
return searchRecursively(resource, path, segments, 1);
}
}
}
}
return null;
}
示例15: initializeFromResources
import org.eclipse.jdt.core.IJarEntryResource; //导入依赖的package包/类
/**
* Initialize the processor cache from JAR resources.
*
* @param jarEntryResources A list of JAR entries describing the dialects and their
* processors to store.
* @throws CoreException
* @throws XMLException
*/
public static void initializeFromResources(List<IJarEntryResource> jarEntryResources) throws XMLException, CoreException {
XMLReader<Dialect> xmlreader = new XMLReader<Dialect>(Dialect.class);
for (IJarEntryResource jarEntry: jarEntryResources) {
// Get default file as stream
Dialect dialect = xmlreader.readXMLData(jarEntry.getContents());
// Link the processor with it's dialect
for (Processor processor: dialect.getProcessors()) {
processor.setDialect(dialect);
processors.add(processor);
}
// Ensure processors are in alphabetical order
Collections.sort(processors, new Comparator<Processor>() {
@Override
public int compare(Processor p1, Processor p2) {
return p1.getName().compareTo(p2.getName());
}
});
}
}