this.styleSheetCode = new StringList( this.styleSheetFile.getContent() );
this.styleSheetCode = new StringList( this.styleSheetSourceFile.getContent() );
	private void preprocess( Device device, Locale locale ) {		System.out.println("preprocessing for device [" +  device.getIdentifier() + "]." );		try {			this.numberOfChangedFiles = 0;			String targetDir = this.buildSetting.getWorkDir().getAbsolutePath() 				+ File.separatorChar + device.getVendorName() 				+ File.separatorChar + device.getName();			if (locale != null) {				targetDir += File.separatorChar + locale.toString();			}			device.setBaseDir( targetDir );			targetDir += File.separatorChar + "source";			device.setSourceDir(targetDir);			// initialise the preprocessor:			this.preprocessor.setTargetDir( targetDir );			// set variables and symbols:			this.preprocessor.setSymbols( device.getFeatures() );			this.preprocessor.setVariables( device.getCapabilities() );			this.preprocessor.addVariable( "polish.identifier", device.getIdentifier() );			this.preprocessor.addVariable( "polish.name", device.getName() );			this.preprocessor.addVariable( "polish.vendor", device.getVendorName() );			this.preprocessor.addVariable( "polish.version", this.infoSetting.getVersion() );			long lastLocaleModification = 0;			// set localization-variables:			if (locale != null) {				this.preprocessor.addVariable("polish.locale", locale.toString() );				this.preprocessor.addVariable("polish.language", locale.getLanguage() );				this.preprocessor.addVariable("polish.country", locale.getCountry() );								// load localized messages, this also sets localized variables automatically:				TranslationManager translationManager = this.resourceManager.getTranslationManager(device, locale, this.preprocessor.getVariables() );				this.translationPreprocessor.setTranslationManager( translationManager );				lastLocaleModification = translationManager.getLastModificationTime();			}			// set info-variables:			String jarName = this.infoSetting.getJarName();			jarName = PropertyUtil.writeProperties(jarName, this.preprocessor.getVariables());			this.preprocessor.addVariable( "polish.jarName", jarName );			String jadName = jarName.substring(0, jarName.lastIndexOf('.') ) + ".jad";			this.preprocessor.addVariable( "polish.jadName", jadName );						// set conditional variables:			if (this.conditionalVariables != null) {				// add variables which fulfill the conditions: 				BooleanEvaluator evaluator = this.preprocessor.getBooleanEvaluator();				for (int i = 0; i < this.conditionalVariables.length; i++) {					Variable var = this.conditionalVariables[i];					if (var.isConditionFulfilled( evaluator, this.project )) {						this.preprocessor.addVariable(var.getName(), var.getValue() );					}				}			}			// get the last modfication time of the build.xml file			// so that it can be checked whether there are any changes at all:			File buildXml = new File( this.project.getBaseDir().getAbsolutePath() 						+ File.separatorChar + "build.xml" );			long buildXmlLastModified = buildXml.lastModified();			// check if the polish gui is used at all:			boolean usePolishGui = this.buildSetting.usePolishGui()								  && device.supportsPolishGui();			this.preprocessor.setUsePolishGui(usePolishGui);			long lastCssModification = lastLocaleModification;			StyleSheet cssStyleSheet = null;			if (usePolishGui) {				cssStyleSheet = this.resourceManager.loadStyleSheet( this.styleSheet, device, locale );				if (cssStyleSheet.lastModified() > lastLocaleModification) {					lastCssModification = cssStyleSheet.lastModified();				}			}			this.preprocessor.setSyleSheet( cssStyleSheet, device );			this.preprocessor.notifyDevice(device, usePolishGui);			// preprocess each source file:			for (int i = 0; i < this.sourceDirs.length; i++) {				File sourceDir = this.sourceDirs[i];				TextFile[] files = this.sourceFiles[i];				processSourceDir(sourceDir, files, device, usePolishGui, targetDir, buildXmlLastModified, lastCssModification, false);			} // for each source folder			this.preprocessor.notifyPolishPackageStart();			// now process the J2ME package files:			processSourceDir(this.polishSourceDir, this.polishSourceFiles, device, usePolishGui, targetDir, buildXmlLastModified, lastCssModification, true);			// notify preprocessor about the end of preprocessing:			this.preprocessor.notifyDeviceEnd( device, usePolishGui );									// now all files have been preprocessed.			// Now the StyleSheet.java file needs to be written,			// but only when the polish GUI should be used:			if (usePolishGui) {				// check if the CSS declarations have changed since the last run:				File targetFile = new File( targetDir + File.separatorChar + this.styleSheetFile.getFileName() );								boolean cssIsNew = (!targetFile.exists())					|| ( lastCssModification > targetFile.lastModified() )					|| ( buildXmlLastModified > targetFile.lastModified() );				if (cssIsNew) {					//System.out.println("CSS is new and the style sheet will be generated.");					if (this.styleSheetCode == null) {						// the style sheet has not been preprocessed:						this.styleSheetCode = new StringList( this.styleSheetFile.getContent() );						String className = "de.enough.polish.ui.StyleSheet";						this.preprocessor.preprocess( className, this.styleSheetCode );					}					// now insert the CSS information for this device					// into the StyleSheet.java source-code:					CssConverter cssConverter = new CssConverter( this.cssAttributesManager );					this.styleSheetCode.reset();					cssConverter.convertStyleSheet(this.styleSheetCode, 							this.preprocessor.getStyleSheet(),							device,							this.preprocessor ); 									this.styleSheetFile.saveToDir(targetDir, this.styleSheetCode.getArray(), false );					this.numberOfChangedFiles++;				//} else {				//	System.out.println("CSSS is not new - last CSS modification == " + lastCssModification + " <= StyleSheet.java.lastModified() == " + targetFile.lastModified() );				}							}			device.setNumberOfChangedFiles( this.numberOfChangedFiles );		} catch (FileNotFoundException e) {			e.printStackTrace();			throw new BuildException( e.getMessage() );		} catch (IOException e) {			e.printStackTrace();			throw new BuildException( e.getMessage() );		} catch (BuildException e) {			e.printStackTrace();			throw new BuildException( e.getMessage() );		}	}