if (styleSheetCode == null) {
if (this.styleSheetCode == null) {
	private void preprocess( Device device ) {		System.out.println("preprocessing for device [" +  device.getIdentifier() + "]." );		try {			int numberOfChangedFiles = 0;			String targetDir = this.buildSetting.getWorkDir().getAbsolutePath() 				+ File.separatorChar + device.getVendorName() 				+ File.separatorChar + device.getName();			device.setBaseDir( targetDir );			targetDir += File.separatorChar + "source";			device.setSourceDir(targetDir);			// initialise the preprocessor:			this.preprocessor.setTargetDir( targetDir );			this.preprocessor.setSymbols( device.getFeatures() );			this.preprocessor.setVariables( device.getCapabilities() );			// 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.usesPolishGui()								  && device.supportsPolishGui();			this.preprocessor.setUsePolishGui(usePolishGui);			long lastCssModification = 0;			StyleSheet cssStyleSheet = null;			if (usePolishGui) {				cssStyleSheet = loadStyleSheet( device );				lastCssModification = cssStyleSheet.lastModified();			}			this.preprocessor.setSyleSheet( cssStyleSheet );			StringList styleSheetCode = null;			boolean usesTicker = false;			// preprocess each source file:			for (int i = 0; i < this.sourceDirs.length; i++) {				File sourceDir = this.sourceDirs[i];				this.preprocessor.addVariable( "polish.source", sourceDir.getAbsolutePath() );				TextFile[] files = this.sourceFiles[i];				//System.out.println("current source dir: " + sourceDir );				// preprocess each file in that source-dir:				for (int j = 0; j < files.length; j++) {					TextFile file = files[j];					// check if file needs to be preprocessed at all:					long sourceLastModified = file.lastModified();					File targetFile = new File( targetDir							+ File.separatorChar + file.getFileName() );					long targetLastModified = targetFile.lastModified();					// preprocess this file, but only when there can					// be changes at all - this could be when					// 1. The preprocessed file does not yet exists					// 2. The source file has been modified since the last run					// 3. The build.xml has been modified since the last run					// 4. One of the polish.css files has been modified since the last run 					// when only the CSS files have changed					boolean saveInAnyCase =  ( !targetFile.exists() )							 || ( sourceLastModified > targetLastModified )							 || ( buildXmlLastModified > targetLastModified ); 					boolean preprocess = ( saveInAnyCase )							 || ( lastCssModification > targetLastModified);					if (   preprocess ) {						// preprocess this file:						StringList sourceCode = new StringList( file.getContent() );						// generate the class-name from the file-name:						String className = file.getFileName();						if (className.endsWith(".java")) {							className = className.substring(0, className.length() - 5 );							// in a jarfile the files always have a '/' as a path-seperator:							className = TextUtil.replace(className, '/', '.' );						}						className = TextUtil.replace(className, File.separatorChar, '.' );						// set the StyleSheet.display variable in all MIDlets						if ( (this.midletClassesByName.get( className ) != null) 								&& usePolishGui) {							insertDisplaySetting( className, sourceCode );							sourceCode.reset();						}						int result = this.preprocessor.preprocess( className, sourceCode );						// only think about saving when the file should not be skipped 						// and when it is not the StyleSheet.java file:						if (file == this.styleSheetFile ) {							styleSheetCode = sourceCode;						} else  if (result != Preprocessor.SKIP_FILE) {							sourceCode.reset();							// now replace the import statements:							boolean changed = this.importConverter.processImports(usePolishGui, device.isMidp1(), sourceCode);							if (changed) {								result = Preprocessor.CHANGED;							}							// save modified file:							if ( ( saveInAnyCase ) 							  || (result == Preprocessor.CHANGED) ) 							{								// now process the getTicker() and setTicker() calls:								usesTicker = TickerConverter.convertTickerCalls(sourceCode);								//System.out.println( "preprocessed [" + className + "]." );								file.saveToDir(targetDir, sourceCode.getArray(), false );								numberOfChangedFiles++;							//} else {							//	System.out.println("not saving " + file.getFileName() );							}						//} else {						//	System.out.println("Skipping file " + file.getFileName() );						}					} // when preprocessing should be done.				} // for each file			} // for each source folder						if (usesTicker) {				//TODO rob add preprocessing symbol for J2ME Polish library,				// so that the ticker class can be removed completely			}			// 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 (styleSheetCode == null) {						// the style sheet has not been preprocessed:						styleSheetCode = new StringList( this.styleSheetFile.getContent() );						String className = "de.enough.polish.ui.StyleSheet";						this.preprocessor.preprocess( className, styleSheetCode );					}					// now insert the CSS information for this device					// into the StyleSheet.java source-code:					CssConverter cssConverter = new CssConverter();					styleSheetCode.reset();					cssConverter.convertStyleSheet(styleSheetCode, 							this.preprocessor.getStyleSheet(),							device,							this.preprocessor ); 									this.styleSheetFile.saveToDir(targetDir, styleSheetCode.getArray(), false );					numberOfChangedFiles++;				//} else {				//	System.out.println("CSSS is not new - last CSS modification == " + lastCssModification + " <= StyleSheet.java.lastModified() == " + targetFile.lastModified() );				}							}			device.setNumberOfChangedFiles( 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() );		}	}