public boolean processImports( boolean usePolishGui, boolean isMidp1, StringList sourceCode, Device device, Preprocessor preprocessor ) { boolean usePolishGameApi = false; boolean supportsSiemensColorGameApi = false; if (preprocessor != null) { usePolishGameApi = "true".equals(preprocessor.getVariable("polish.usePolishGameApi")); supportsSiemensColorGameApi = preprocessor.hasSymbol("polish.api.siemens-color-game-api"); } HashMap translations; if (usePolishGui) { if (isMidp1 || usePolishGameApi ) { if (supportsSiemensColorGameApi) { translations = this.siemensColorGameApiToPolish; } else { translations = this.midp1ToPolish; } } else { translations = this.midp2ToPolish; } } else { if (isMidp1 || usePolishGameApi ) { if (supportsSiemensColorGameApi) { translations = this.polishToSiemensColorGameApi; } else { translations = this.polishToMidp1; } } else { translations = this.polishToMidp2; } } translations = addDynamicTranslations( translations, usePolishGui, isMidp1, device, preprocessor );  boolean changed = false; while (sourceCode.next()) { String line = sourceCode.getCurrent().trim(); if (line.startsWith("import ")) { String importContent = line.substring( 7, line.length() -1 ).trim(); if ( usePolishGui ) { if (!changed) { sourceCode.setCurrent( line + " import de.enough.polish.ui.StyleSheet;"); changed = true; }  String replacement = (String) translations.get(importContent); if ( replacement != null) { changed = true; sourceCode.setCurrent("import " + replacement + ";"); } else if ("javax.microedition.lcdui.*".equals( importContent) ) {  changed = true;  if (isMidp1) { sourceCode.setCurrent( this.completeMidp1 ); } else { sourceCode.setCurrent( this.completeMidp2 ); } } } else {  String replacement = (String) translations.get(importContent); if ( replacement != null) { changed = true; sourceCode.setCurrent("import " + replacement + ";"); } }  } else if (line.startsWith("public class ")) { break; } else if (line.startsWith("protected class ")) { break; } else if (line.startsWith("class ")) { break; } else if (line.startsWith("public interface ")) { break; } else if (line.startsWith("protected interface ")) { break; } else if (line.startsWith("interface ")) { break; } } return changed;
protected boolean processImports( boolean usePolishGui, boolean isMidp1, StringList sourceCode ) { return processImports(usePolishGui, isMidp1, sourceCode, null, null );
	public boolean processImports( boolean usePolishGui, boolean isMidp1, StringList sourceCode, Device device, Preprocessor preprocessor ) {		boolean usePolishGameApi = false;		boolean supportsSiemensColorGameApi = false;		if (preprocessor != null) {			usePolishGameApi = "true".equals(preprocessor.getVariable("polish.usePolishGameApi"));			supportsSiemensColorGameApi = preprocessor.hasSymbol("polish.api.siemens-color-game-api");		}		HashMap translations;		if (usePolishGui) {			if (isMidp1 || usePolishGameApi ) {				if (supportsSiemensColorGameApi) {					translations = this.siemensColorGameApiToPolish;				} else {					translations = this.midp1ToPolish;				}			} else {				translations = this.midp2ToPolish;			}		} else {			if (isMidp1 || usePolishGameApi ) {				if (supportsSiemensColorGameApi) {					translations = this.polishToSiemensColorGameApi;				} else {					translations = this.polishToMidp1;				}			} else {				translations = this.polishToMidp2;			}		}		translations = addDynamicTranslations( translations, usePolishGui, isMidp1, device, preprocessor );		// go through the code and search for import statements:		boolean changed = false;		while (sourceCode.next()) {			String line = sourceCode.getCurrent().trim();			if (line.startsWith("import ")) {				String importContent = line.substring( 7, line.length() -1 ).trim();				if ( usePolishGui ) {					if (!changed) {						sourceCode.setCurrent( line + " import de.enough.polish.ui.StyleSheet;");						changed = true;					}					// translate import statements from javax.microedition.lcdui to polish:					String replacement = (String) translations.get(importContent);					if ( replacement != null) {						changed = true;						sourceCode.setCurrent("import " + replacement + ";");					} else if ("javax.microedition.lcdui.*".equals( importContent) ) {						// check for the javax.microedition.lcdui.* import:						changed = true;						// insert replacement:						if (isMidp1) {							sourceCode.setCurrent( this.completeMidp1 );						} else {							sourceCode.setCurrent( this.completeMidp2 );						}					}				} else {					// translate import statements from polish to javax.microedition.lcdui:					String replacement = (String) translations.get(importContent);					if ( replacement != null) {						changed = true;						sourceCode.setCurrent("import " + replacement + ";");					}				}							} else if (line.startsWith("public class ")) {				break;			} else if (line.startsWith("protected class ")) {				break;			} else if (line.startsWith("class ")) {				break;			} else if (line.startsWith("public interface ")) {				break;			} else if (line.startsWith("protected interface ")) {				break;			} else if (line.startsWith("interface ")) {				break;			}		}		return changed;	}