if (device.hasFeature(name) || this.booleanEvaluator.evaluate(name, "resourceassembling", 0) || (name.endsWith(".0x0") && device.getCapability(name.substring(0, name.length() - ".0x0".length()) ) == null ) ) {  dirs.add( file );
try { if (name.startsWith("ScreenSize.") && ( (name.indexOf('+') != -1) || (name.indexOf('-') != -1)) ) { String deviceSize = device.getCapability("polish.ScreenSize"); if (deviceSize != null) { String requirement = name.substring( "ScreenSize.".length() ); SizeMatcher sizeMatcher = new SizeMatcher( requirement ); if (sizeMatcher.matches(deviceSize)) { dirs.add( file ); } } } else if (name.startsWith("CanvasSize.") && ( (name.indexOf('+') != -1) || (name.indexOf('-') != -1)) ) { String deviceSize = device.getCapability("polish.CanvasSize"); if (deviceSize != null) { String requirement = name.substring( "CanvasSize.".length() ); SizeMatcher sizeMatcher = new SizeMatcher( requirement ); if (sizeMatcher.matches(deviceSize)) { dirs.add( file ); } } } else if (name.startsWith("FullCanvasSize.") && ( (name.indexOf('+') != -1) || (name.indexOf('-') != -1)) ) { String deviceSize = device.getCapability("polish.FullCanvasSize"); if (deviceSize != null) { String requirement = name.substring( "FullCanvasSize.".length() ); SizeMatcher sizeMatcher = new SizeMatcher( requirement ); if (sizeMatcher.matches(deviceSize)) { dirs.add( file ); } } } else if (device.hasFeature(name) || this.booleanEvaluator.evaluate(name, "resourceassembling", 0) || (name.endsWith(".0x0") && device.getCapability(name.substring(0, name.length() - ".0x0".length()) ) == null ) ) {  dirs.add( file ); } } catch (BuildException e) { System.out.println("WARNING: unable to add resource folder [" + file.getAbsolutePath() + "]: " + e.getMessage() );
	private File[] getResourceDirs(Device device, Locale locale) {		String key = device.getIdentifier();		if (locale != null) {			key += locale.toString();		}		File[] directories = (File[]) this.resourceDirsByDevice.get( key );		if (directories != null) {			return directories;		}		ArrayList dirs = new ArrayList();		for (int j = 0; j < this.resourceDirectories.length; j++) {			File resourcesDir = this.resourceDirectories[j];			// first dir is the general resources dir:			dirs.add( resourcesDir );			//String resourcePath = resourcesDir.getAbsolutePath() + File.separator;			// then the vendor specific resources:			File resourceDir = new File( resourcesDir, device.getVendorName() );			if (resourceDir.exists()) {				dirs.add( resourceDir );			}			// now add all dynamic ScreenSize-directories:			String screenSize = device.getCapability("polish.ScreenSize");			if (screenSize != null) {				for (int i = 0; i < this.dynamicScreenSizeDirs.length; i++ ) {					SizeMatcher matcher = this.dynamicScreenSizeMatchers[i];					if (matcher.matches(screenSize)) {						resourceDir = this.dynamicScreenSizeDirs[i];						dirs.add( resourceDir );					}				}			}			// now add all dynamic CanvasSize-directories:			String canvasSize = device.getCapability("polish.CanvasSize");			if (canvasSize != null) {				for (int i = 0; i < this.dynamicCanvasSizeDirs.length; i++ ) {					SizeMatcher matcher = this.dynamicCanvasSizeMatchers[i];					if (matcher.matches(canvasSize)) {						resourceDir = this.dynamicCanvasSizeDirs[i];						dirs.add( resourceDir );					}				}			}			// now add all dynamic FullCanvasSize-directories:			String fullCanvasSize = device.getCapability("polish.FullCanvasSize");			if (fullCanvasSize != null) {				for (int i = 0; i < this.dynamicFullCanvasSizeDirs.length; i++ ) {					SizeMatcher matcher = this.dynamicFullCanvasSizeMatchers[i];					if (matcher.matches(fullCanvasSize)) {						resourceDir = this.dynamicFullCanvasSizeDirs[i];						dirs.add( resourceDir );					}				}			}			// now add all group resource-directories:			String[] groups = device.getGroupNames();			for (int i = 0; i < groups.length; i++) {				String group = groups[i];				resourceDir = new File( resourcesDir,  group );				if (resourceDir.exists()) {					dirs.add( resourceDir );				}			}						// now add any directories that use specific capabilities or contain preprocessing statements etc:			File[] files = resourcesDir.listFiles();			for (int i = 0; i < files.length; i++) {				File file = files[i];				if (file.isDirectory() && !dirs.contains(file)) {					// The slash can be a protected character:					String name = StringUtil.replace(file.getName(), "%2f", "/");					//System.out.println("Considering dir "+ name);					if (device.hasFeature(name) 						|| this.booleanEvaluator.evaluate(name, "resourceassembling", 0)						|| (name.endsWith(".0x0")							&& device.getCapability(name.substring(0, name.length() - ".0x0".length()) ) == null ) )					{						//System.out.println("Adding capability or preprocessing dir " + file.getAbsolutePath() );						dirs.add( file );					}				}			}						// The last possible resource directory is the directory for the specific device:			resourceDir = new File( resourcesDir, device.getVendorName() 								+ File.separatorChar + device.getName() );			if (resourceDir.exists()) {				dirs.add( resourceDir );			}								}		if (locale != null) {			// now add all locale-specific directories:			ArrayList localizedDirs = new ArrayList( dirs.size() * 2 );			String languageDirName = null;			String localeDirName = locale.toString();			if (locale.getCountry().length() > 0) {				languageDirName = locale.getLanguage();			}			directories = (File[]) dirs.toArray( new File[ dirs.size() ]);			for (int i = 0; i < directories.length; i++) {				File resourceDir = directories[i];				localizedDirs.add( resourceDir );				//resourcePath = resourceDir.getAbsolutePath() + File.separator;				if (languageDirName != null) {					File localizedResourceDir = new File( resourceDir, languageDirName );					if (localizedResourceDir.exists()) {						localizedDirs.add( localizedResourceDir );					}				}				File localizedResourceDir = new File( resourceDir, localeDirName );				if (localizedResourceDir.exists()) {					localizedDirs.add( localizedResourceDir );				}							}			dirs = localizedDirs;		}		directories = (File[]) dirs.toArray( new File[ dirs.size() ]);		this.resourceDirsByDevice.put( key, directories );		return directories;	}