FileDocCategorySizeDatePackage
JavaResourceFilter.javaAPI DocAndroid 1.5 API3714Wed May 06 22:41:10 BST 2009com.android.jarutils

JavaResourceFilter

public class JavaResourceFilter extends Object implements com.android.jarutils.SignedJarBuilder.IZipEntryFilter
A basic implementation of {@link IZipEntryFilter} to filter out anything that is not a java resource.

Fields Summary
Constructors Summary
Methods Summary
public booleancheckEntry(java.lang.String name)

        // split the path into segments.
        String[] segments = name.split("/");

        // empty path? skip to next entry.
        if (segments.length == 0) {
            return false;
        }

        // Check each folders to make sure they should be included.
        // Folders like CVS, .svn, etc.. should already have been excluded from the
        // jar file, but we need to exclude some other folder (like /META-INF) so
        // we check anyway.
        for (int i = 0 ; i < segments.length - 1; i++) {
            if (checkFolderForPackaging(segments[i]) == false) {
                return false;
            }
        }

        // get the file name from the path
        String fileName = segments[segments.length-1];
        
        return checkFileForPackaging(fileName);
    
public static booleancheckFileForPackaging(java.lang.String fileName)
Checks a file to make sure it should be packaged as standard resources.

param
fileName the name of the file (including extension)
return
true if the file should be packaged as standard java resources.

        String[] fileSegments = fileName.split("\\.");
        String fileExt = "";
        if (fileSegments.length > 1) {
            fileExt = fileSegments[fileSegments.length-1];
        }

        return checkFileForPackaging(fileName, fileExt);
    
public static booleancheckFileForPackaging(java.lang.String fileName, java.lang.String extension)
Checks a file to make sure it should be packaged as standard resources.

param
fileName the name of the file (including extension)
param
extension the extension of the file (excluding '.')
return
true if the file should be packaged as standard java resources.

        return "aidl".equalsIgnoreCase(extension) == false &&
            "java".equalsIgnoreCase(extension) == false &&
            "class".equalsIgnoreCase(extension) == false &&
            "package.html".equalsIgnoreCase(fileName) == false &&
            "overview.html".equalsIgnoreCase(fileName) == false &&
            ".cvsignore".equalsIgnoreCase(fileName) == false &&
            ".DS_Store".equals(fileName) == false && 
            fileName.charAt(fileName.length()-1) != '~";
    
public static booleancheckFolderForPackaging(java.lang.String folderName)
Checks whether a folder and its content is valid for packaging into the .apk as standard Java resource.

param
folderName the name of the folder.

        return folderName.equals("CVS") == false &&
            folderName.equals(".svn") == false &&
            folderName.equals("SCCS") == false &&
            folderName.equals("META-INF") == false &&
            folderName.startsWith("_") == false;