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


Java IJarEntryResource.isFile方法代码示例

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


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

示例1: traverse

import org.eclipse.jdt.core.IJarEntryResource; //导入方法依赖的package包/类
protected T traverse(IJarEntryResource jarEntry, boolean stopOnFirstResult, TraversalState state) {
	T result = null;
	if (jarEntry.isFile()) {
		result = handle(jarEntry, state);
	} else {
		state.push(jarEntry);
		IJarEntryResource[] children = jarEntry.getChildren();
		for (IJarEntryResource child : children) {
			result = traverse(child, stopOnFirstResult, state);
			if (stopOnFirstResult && result!=null)
				return result;
		}
		state.pop();
	}
	return result;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:17,代码来源:PackageFragmentRootWalker.java

示例2: getDialectDefinitions

import org.eclipse.jdt.core.IJarEntryResource; //导入方法依赖的package包/类
/**
 * <p>
 * Scan the current project's dependencies looking for XML file (ending with
 * "Dialect.xml").
 * <p>
 * The return list contains JarEntryResource that will be read by the
 * ProcessorCache.
 * 
 * @return List<IJarEntryResource> A list of XML files corresponding to the
 *         definitions of Thymeleaf dialects that exist in the current's
 *         project dependencies.
 * @throws JavaModelException
 * @throws CoreException
 */
private List<IJarEntryResource> getDialectDefinitions() throws JavaModelException, CoreException {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

	List<IJarEntryResource> resources = new ArrayList<IJarEntryResource>();
	
	IProject[] projects = root.getProjects();

	// Each project of the workspace is processed
	for (IProject project : projects) {

		System.out.println("project name: " + project.getName());
		
		// Only Java project are scanned
		// TODO Is that filter really necessary ?
		if (project.isNatureEnabled("org.eclipse.jdt.core.javanature")) {
			
			IJavaProject javaProject = JavaCore.create(project);
			IPackageFragment[] packages = javaProject.getPackageFragments();
			
			for(IPackageFragment packageFragment : packages){
				
				// No need to iterated over java classes, just resources
				for(Object ob : packageFragment.getNonJavaResources()){

					IJarEntryResource jarEntry = (IJarEntryResource) ob;

					// Resources are filtered by their suffix
					if(jarEntry.isFile() && jarEntry.getName().endsWith("Dialect.xml")){
						resources.add(jarEntry);
					}
				}
			}
		}
	}
	
	return resources;
}
 
开发者ID:tduchateau,项目名称:thymeleaf-eclipse-plugin,代码行数:52,代码来源:ThymeleafPlugin.java

示例3: findJarFile

import org.eclipse.jdt.core.IJarEntryResource; //导入方法依赖的package包/类
private JarEntryFile findJarFile(JarEntryDirectory directory, String path) {
  for (IJarEntryResource children : directory.getChildren()) {
    if (children.isFile() && children.getFullPath().toOSString().equals(path)) {
      return (JarEntryFile) children;
    }
    if (!children.isFile()) {
      JarEntryFile file = findJarFile((JarEntryDirectory) children, path);
      if (file != null) {
        return file;
      }
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:JavaNavigation.java

示例4: test

import org.eclipse.jdt.core.IJarEntryResource; //导入方法依赖的package包/类
@Override
public boolean test(IJarEntryResource jarEntryResource) {
	return jarEntryResource.isFile()
			&& (StrutsXmlConstants.STRUTS_DEFAULT_FILE_NAME
					.equals(jarEntryResource.getName()) || StrutsXmlConstants.STRUTS_PLUGIN_FILE_NAME
					.equals(jarEntryResource.getName()));
}
 
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:8,代码来源:ProjectUtil.java

示例5: createEditorInput

import org.eclipse.jdt.core.IJarEntryResource; //导入方法依赖的package包/类
private JarEntryEditorInput createEditorInput(String[] pathSegments, Object[] children) {
	int depth= pathSegments.length;
	segments: for (int i= 0; i < depth; i++) {
		String name= pathSegments[i];
		for (int j= 0; j < children.length; j++) {
			Object child= children[j];
			if (child instanceof IJarEntryResource) {
				IJarEntryResource jarEntryResource= (IJarEntryResource) child;
				if (name.equals(jarEntryResource.getName())) {
					boolean isFile= jarEntryResource.isFile();
					if (isFile) {
						if (i == depth - 1) {
							return new JarEntryEditorInput(jarEntryResource);
						} else {
							return null; // got a file for a directory name
						}
					} else {
						children= jarEntryResource.getChildren();
						continue segments;
					}
				}
			}
		}
		return null; // no child found on this level
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:JarEntryEditorInputFactory.java

示例6: searchRecursively

import org.eclipse.jdt.core.IJarEntryResource; //导入方法依赖的package包/类
private TapestryFile searchRecursively(IJarEntryResource parent, String path, String[] segments, int segmentIndex)
{
    if (pathEquals(parent, path))
    {
        return Activator.getDefault()
                .getTapestryContextFactory()
                .createTapestryContext(parent)
                .getInitialFile();
    }
    
    if (segmentIndex >= segments.length)
    {
        return null;
    }
    
    if (parent.isFile())
    {
        return null;
    }
    
    for (IJarEntryResource child : parent.getChildren())
    {
        if (StringUtils.equals(segments[segmentIndex], child.getName()))
        {
            return searchRecursively(child, path, segments, segmentIndex + 1);
        }
    }
    
    return null;
}
 
开发者ID:anjlab,项目名称:eclipse-tapestry5-plugin,代码行数:31,代码来源:JarFileLookup.java

示例7: resolveFileOnPackageFragment

import org.eclipse.jdt.core.IJarEntryResource; //导入方法依赖的package包/类
/**
 * Returns the given file or JAR entry if it is on the given package fragment. The file can be a Java file, class
 * file, or a non-Java resource.
 * <p>
 * This method returns null for .java files or .class files inside JARs.
 *
 * @param fileName
 *          the file name
 * @param pckgFragment
 *          the package fragment to search
 * @return the file as an IResource or IJarEntryResource, or null
 * @throws JavaModelException
 */
public static IStorage resolveFileOnPackageFragment(String fileName, IPackageFragment pckgFragment)
    throws JavaModelException {

  boolean isJavaFile = JavaCore.isJavaLikeFileName(fileName);
  boolean isClassFile = ResourceUtils.endsWith(fileName, ".class");

  // Check the non-Java resources first
  Object[] nonJavaResources = pckgFragment.getNonJavaResources();
  for (Object nonJavaResource : nonJavaResources) {
    if (nonJavaResource instanceof IFile) {
      IFile file = (IFile) nonJavaResource;
      String resFileName = file.getName();

      if (ResourceUtils.areFilenamesEqual(resFileName, fileName)) {
        // Java source files that have been excluded from the build path
        // show up as non-Java resources, but we'll ignore them since
        // they're not available on the classpath.
        if (!JavaCore.isJavaLikeFileName(resFileName)) {
          return file;
        } else {
          return null;
        }
      }
    }

    // JAR resources are not IResource's, so we need to handle them
    // differently
    if (nonJavaResource instanceof IJarEntryResource) {
      IJarEntryResource jarEntry = (IJarEntryResource) nonJavaResource;
      if (jarEntry.isFile() && ResourceUtils.areFilenamesEqual(jarEntry.getName(), fileName)) {
        return jarEntry;
      }
    }
  }

  // If we're looking for a .java or .class file, we can use the regular
  // Java Model methods.

  if (isJavaFile) {
    ICompilationUnit cu = pckgFragment.getCompilationUnit(fileName);
    if (cu.exists()) {
      return (IFile) cu.getCorrespondingResource();
    }
  }

  if (isClassFile) {
    IClassFile cf = pckgFragment.getClassFile(fileName);
    if (cf.exists()) {
      return (IFile) cf.getCorrespondingResource();
    }
  }

  return null;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:68,代码来源:ClasspathResourceUtilities.java

示例8: isModuleXml

import org.eclipse.jdt.core.IJarEntryResource; //导入方法依赖的package包/类
/**
 * Returns whether a JAR resource is a module XML.
 *
 * @param jarResource the JAR resource to check
 * @return <code>true</code> if the resource is a module XML, and <code>false</code> otherwise
 */
public static boolean isModuleXml(IJarEntryResource jarResource) {
  return (jarResource.isFile() && jarResource.getName().endsWith(FILE_EXTENSION));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:10,代码来源:ModuleUtils.java


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