Example usage for org.eclipse.jdt.core IJarEntryResource getChildren

List of usage examples for org.eclipse.jdt.core IJarEntryResource getChildren

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJarEntryResource getChildren.

Prototype

IJarEntryResource[] getChildren();

Source Link

Document

Returns the list of children of this jar entry resource.

Usage

From source file:ca.ecliptical.pde.ds.search.DescriptorQueryParticipant.java

License:Open Source License

private IJarEntryResource[] findMatchingJarEntries(IJarEntryResource resource, Filter filter) {
    ArrayList<IJarEntryResource> results = new ArrayList<IJarEntryResource>();
    for (IJarEntryResource child : resource.getChildren()) {
        if (child.isFile() && filter.matches(Collections.singletonMap("filename", child.getName()))) { //$NON-NLS-1$
            results.add(child);//w  ww . ja  va 2 s  .  c  o m
        }
    }

    return results.toArray(new IJarEntryResource[results.size()]);
}

From source file:ca.ecliptical.pde.ds.search.DescriptorQueryParticipant.java

License:Open Source License

private IJarEntryResource findJarEntry(IJarEntryResource resource, IPath path) {
    if (!resource.getName().equals(path.segment(0)))
        return null;

    if (path.segmentCount() == 1)
        return resource;

    if (resource.isFile())
        return null;

    for (IJarEntryResource child : resource.getChildren()) {
        IJarEntryResource result = findJarEntry(child, path.removeFirstSegments(1));
        if (result != null)
            return result;
    }/*from w  w  w  . j a  v a2  s .  c  o  m*/

    return null;
}

From source file:com.cisco.yangide.core.YangJarFileEntryResource.java

License:Open Source License

private Object resolveParent(IJarEntryResource parent, IPath path) {
    if (path.segmentCount() > 0) {
        for (IJarEntryResource element : parent.getChildren()) {
            if (path.segment(0).equals(element.getName())) {
                return resolveParent(element, path.removeFirstSegments(1));
            }/*from  w w w .j a v  a 2  s.c o  m*/
        }
    }
    return parent.getParent();
}

From source file:com.codenvy.ide.ext.java.server.JavaNavigation.java

License:Open Source License

private Object[] findJarDirectoryChildren(JarEntryDirectory directory, String path) {
    String directoryPath = directory.getFullPath().toOSString();
    if (directoryPath.equals(path)) {
        return directory.getChildren();
    }//from  ww  w. j  ava  2s.c  om
    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;
}

From source file:it.unibz.instasearch.indexing.WorkspaceIndexerJDT.java

License:Open Source License

/**
 * @param indexWriter/*from w  w w.j a  v a  2 s. co  m*/
 * @param jar 
 * @param resources
 * @param monitor
 * @throws IOException 
 * @throws CoreException 
 */
private void indexNonJavaResources(IndexWriter indexWriter, IPackageFragmentRoot jar,
        IJarEntryResource[] resources, IProgressMonitor monitor) throws Exception {

    String jarName = getJarName(jar);
    String projectPath = getProjectPath(jar);

    for (IJarEntryResource resource : resources) {
        if (monitor.isCanceled())
            return;

        if (resource.isFile()) {
            if (isIndexable(resource))
                indexStorageWithRetry(indexWriter, resource, projectPath, IResource.NULL_STAMP, jarName);
        } else {
            indexNonJavaResources(indexWriter, jar, resource.getChildren(), monitor);
        }
    }

}

From source file:it.unibz.instasearch.indexing.WorkspaceIndexerJDT.java

License:Open Source License

/**
 * @param doc/*from  ww  w .j av a 2 s  .c om*/
 * @return
 * @throws JavaModelException 
 */
private IStorage getNonJavaResource(SearchResultDoc doc) throws JavaModelException {

    IWorkspaceRoot workspaceRoot = InstaSearchPlugin.getWorkspaceRoot();
    IJavaModel javaModel = JavaCore.create(workspaceRoot);

    String javaProjectName = doc.getProject().segment(0);
    IJavaProject javaProj = javaModel.getJavaProject(javaProjectName);

    if (!javaProj.isOpen())
        javaProj.open(new NullProgressMonitor());

    javaModel.refreshExternalArchives(new IJavaElement[] { javaProj }, new NullProgressMonitor());

    String jarName = doc.getJarName();

    IPackageFragmentRoot[] roots = javaProj.getPackageFragmentRoots();
    IPackageFragmentRoot jar = null;

    for (IPackageFragmentRoot root : roots) {
        if (root.isArchive() && root.getSourceAttachmentPath() != null) {

            String name = root.getElementName();
            if (name.equals(jarName)) {
                jar = root;
                break;
            }
        }
    }

    if (jar == null)
        return null;

    String filePath = doc.getFilePath();
    IPath path = new Path(filePath);

    IJarEntryResource res = null;
    for (String segment : path.segments()) {
        if (res == null)
            res = findJarEntry(jar, segment);
        else
            res = findJarEntry(res.getChildren(), segment);
    }

    return res;
}

From source file:net.officefloor.eclipse.classpath.ClasspathUtil.java

License:Open Source License

/**
 * Obtains the children of the {@link IJarEntryResource}.
 * //www. ja v a  2s  .c  o m
 * @param jarEntryResource
 *            {@link IJarEntryResource}.
 * @return Children.
 */
public static Object[] getChildren(IJarEntryResource jarEntryResource) {
    return jarEntryResource.getChildren();
}

From source file:org.dev.toos.constcode.model.ConstModel.java

License:Apache License

/**Jar*/
private void iterateIJarEntryResource(IJarEntryResource atElement, final String resourceName,
        Map<String, Object> findRes) throws CoreException {
    if (atElement.getFullPath().toString().endsWith(resourceName) == true) {
        //System.out.println(atElement.getFullPath().toString());
        JarPackageFragmentRoot root = (JarPackageFragmentRoot) atElement.getPackageFragmentRoot();
        String name = root.getJar().getName();
        findRes.put(name, atElement);//from   ww w  .  jav a 2s .c  o m
    }
    IJarEntryResource[] resourcesItem = atElement.getChildren();
    if (resourcesItem != null)
        for (IJarEntryResource element : resourcesItem)
            iterateItem(element, resourceName, findRes);
}

From source file:org.eclipse.jst.jsf.core.jsfappconfig.AnnotationPackageFragmentRoot.java

License:Open Source License

private final boolean isFacesArchive(IPath rootPath) {
    if (webInfLibPath.isPrefixOf(rootPath)) {

        Object[] nonJavaResources;
        try {/*from   ww  w . ja v  a  2s  .  c o  m*/
            nonJavaResources = root.getNonJavaResources();
            if (nonJavaResources != null) {
                for (Object nonJavaResource : nonJavaResources) {
                    if (nonJavaResource instanceof IJarEntryResource) {
                        IJarEntryResource jarEntry = (IJarEntryResource) nonJavaResource;
                        if (!jarEntry.isFile()) {
                            String entryName = jarEntry.getName();
                            if ("META-INF".equals(entryName)) { //$NON-NLS-1$
                                IJarEntryResource[] metaInfContents = jarEntry.getChildren();
                                for (IJarEntryResource resource : metaInfContents) {
                                    if (resource.isFile() && "faces-config.xml".equals(resource.getName())) { //$NON-NLS-1$
                                        return true;
                                    }
                                }
                            } else if (entryName != null && jarEntry.getName().charAt(0) == '.') {
                                return hasDotFacesConfigFile(jarEntry);
                            }
                        }
                    }
                }
            }
        } catch (JavaModelException e) {
            return false;
        }
    }
    return false;
}

From source file:org.eclipse.jst.jsf.core.jsfappconfig.AnnotationPackageFragmentRoot.java

License:Open Source License

private final boolean hasDotFacesConfigFile(IJarEntryResource jarEntry) {
    IJarEntryResource[] contents = jarEntry.getChildren();
    for (IJarEntryResource resource : contents) {
        if (resource.isFile()) {
            if (".faces-config.xml".equals(resource.getName())) { //$NON-NLS-1$
                return true;
            }/*from   w  w w .  j  a v  a  2s. c  om*/
        } else {
            if (hasDotFacesConfigFile(resource)) {
                return true;
            }
        }
    }
    return false;
}