this.dynamicScreenSizeDirs = (File[]) dynamicScreenSizeDirsList.toArray( new File[dynamicScreenSizeDirsList.size()] ); this.dynamicScreenSizeMatchers = (SizeMatcher[]) dynamicScreenSizeMatchersList.toArray( new SizeMatcher[dynamicScreenSizeMatchersList.size()] );  this.dynamicCanvasSizeDirs = (File[]) dynamicCanvasSizeDirsList.toArray( new File[dynamicCanvasSizeDirsList.size()] ); this.dynamicCanvasSizeMatchers = (SizeMatcher[]) dynamicCanvasSizeMatchersList.toArray( new SizeMatcher[dynamicCanvasSizeMatchersList.size()] );  this.dynamicFullCanvasSizeDirs = (File[]) dynamicFullCanvasSizeDirsList.toArray( new File[dynamicFullCanvasSizeDirsList.size()] ); this.dynamicFullCanvasSizeMatchers = (SizeMatcher[]) dynamicFullCanvasSizeMatchersList.toArray( new SizeMatcher[dynamicFullCanvasSizeMatchersList.size()] );
	public ResourceManager(ResourceSetting setting,				ExtensionManager manager,				Environment environment ) 	{		super();		this.filterZeroLengthFiles = setting.filterZeroLengthFiles();		this.resourceSetting = setting;		this.extensionManager = manager;		this.environment = environment;		this.project = environment.getProject();		this.booleanEvaluator = environment.getBooleanEvaluator();		this.resourceDirsByDevice = new HashMap();		ArrayList dynamicScreenSizeDirsList = new ArrayList();		ArrayList dynamicScreenSizeMatchersList = new ArrayList();		ArrayList dynamicCanvasSizeDirsList = new ArrayList();		ArrayList dynamicCanvasSizeMatchersList = new ArrayList();		ArrayList dynamicFullCanvasSizeDirsList = new ArrayList();		ArrayList dynamicFullCanvasSizeMatchersList = new ArrayList();		File[] resDirs = setting.getRootDirectories(environment);		this.resourceDirectories = resDirs;		for (int i = 0; i < resDirs.length; i++) {			File resDir = resDirs[i];			if (!resDir.exists()) {				System.err.println("Warning: the resources-directory [" + resDir.getAbsolutePath() + "] did not exist, J2ME Polish created it automatically now.");				resDir.mkdir();			} else if (!resDir.isDirectory()) {				throw new BuildException("The resources-directory [" + resDir.getAbsolutePath() + "] is not a directory. Please adjust either your \"resources\"-attribute of the <build>-element or the \"dir\"-attribute of the <resources>-element.");			}			// getting all dynamic ScreenSize-directories:			// getting all dynamic CanvasSize-directories:			// getting all dynamic FullCanvasSize-directories:			File[] resDirFiles = resDir.listFiles();			Arrays.sort( resDirFiles );			for (int j = 0; j < resDirFiles.length; j++) {				File file = resDirFiles[j];				if (file.isDirectory() ) {					String name = file.getName();					if (name.startsWith("ScreenSize.") 							&& ( (name.indexOf('+') != -1) || (name.indexOf('-') != -1)) )  					{						dynamicScreenSizeDirsList.add( file );						String requirement = name.substring( "ScreenSize.".length() );						SizeMatcher sizeMatcher = new SizeMatcher( requirement );						dynamicScreenSizeMatchersList.add( sizeMatcher );					} 					else if (name.startsWith("CanvasSize.")							&& ( (name.indexOf('+') != -1) || (name.indexOf('-') != -1)) )  					{						dynamicCanvasSizeDirsList.add( file );						String requirement = name.substring( "CanvasSize.".length() );						SizeMatcher sizeMatcher = new SizeMatcher( requirement );						dynamicCanvasSizeMatchersList.add( sizeMatcher );					}					else if (name.startsWith("FullCanvasSize.") 							&& ( (name.indexOf('+') != -1) || (name.indexOf('-') != -1)) )  					{						dynamicScreenSizeDirsList.add( file );						String requirement = name.substring( "FullCanvasSize.".length() );						SizeMatcher sizeMatcher = new SizeMatcher( requirement );						dynamicScreenSizeMatchersList.add( sizeMatcher );					}				}			}					}				this.dynamicScreenSizeDirs = (File[]) dynamicScreenSizeDirsList.toArray( new File[dynamicScreenSizeDirsList.size()] );		this.dynamicScreenSizeMatchers = (SizeMatcher[]) dynamicScreenSizeMatchersList.toArray( new SizeMatcher[dynamicScreenSizeMatchersList.size()] );		this.dynamicCanvasSizeDirs = (File[]) dynamicCanvasSizeDirsList.toArray( new File[dynamicCanvasSizeDirsList.size()] );		this.dynamicCanvasSizeMatchers = (SizeMatcher[]) dynamicCanvasSizeMatchersList.toArray( new SizeMatcher[dynamicCanvasSizeMatchersList.size()] );		this.dynamicFullCanvasSizeDirs = (File[]) dynamicFullCanvasSizeDirsList.toArray( new File[dynamicFullCanvasSizeDirsList.size()] );		this.dynamicFullCanvasSizeMatchers = (SizeMatcher[]) dynamicFullCanvasSizeMatchersList.toArray( new SizeMatcher[dynamicFullCanvasSizeMatchersList.size()] );		// get localization setting:		this.localizationSetting = this.resourceSetting.getLocalizationSetting();				// creates resources-filter:		this.resourceFilter = new ResourceFilter( setting.getExcludes(), DEFAULT_EXCLUDES, setting.useDefaultExcludes() );		if (this.localizationSetting != null) {			String messagesFileName = this.localizationSetting.getMessagesFileName() ;			this.resourceFilter.addExclude( messagesFileName );			// add filters for messages_de.txt etc! 			int splitPos = messagesFileName.lastIndexOf('.');			String start = null;			String end = null;			if (splitPos != -1) {				start = messagesFileName.substring(0, splitPos) + "_";				end = messagesFileName.substring(splitPos);			}			LocaleSetting[] locales = this.localizationSetting.getSupportedLocales( environment  );			for (int i = 0; i < locales.length; i++) {				Locale locale = locales[i].getLocale();				if (splitPos != -1) {					this.resourceFilter.addExclude( start + locale.toString() + end );					//System.out.println("excluding [" + start + locale.toString() + end + "]");				} else {					this.resourceFilter.addExclude(messagesFileName + locale.toString() );				}				if (locale.getCountry().length() > 0) {					// okay, this locale has also a country defined,					// so we need to look at the language-resources as well:					if (splitPos != -1) {						this.resourceFilter.addExclude( start + locale.getLanguage() + end );						//System.out.println("excluding [" + start + locale.getLanguage() + end + "]");					} else {						this.resourceFilter.addExclude(messagesFileName + locale.getLanguage() );					}				}			}		}	}