private Process loadFlow() {
		loadMessages.clear();
		isLoaded = true;
//		ArrayList discoveredMapElements = new ArrayList();
//		ArrayList lines = new ArrayList();
		rootProcess = new Process(this.mappingName, -1, 0);
		discoveredMapElements.add(rootProcess);

		try {
			InputStream input;

			File file = new File(fileName);
			if (file.exists()) {
				input = new FileInputStream(file);
			} else {
				//load file from classpath
				input = getClass().getClassLoader().getResourceAsStream(fileName);
			}
/*			if(input == null)
			{
				file = new File(/ *Environment.currentApplication().getWorkingDirectory() +* / fileName);
				if(file.exists())
				{
					input = new FileInputStream(file);
				}
			}    */
			if (input == null) {
				throw new ConfigurationException("can not load flow: file '" + fileName + "' can not be found at exact location or classpath");
			}

			BufferedReader reader = new BufferedReader(new InputStreamReader(input));

//			RandomAccessFile raf;
			String line;
			int lineCount = 0;

//			raf = new RandomAccessFile(fileName, "r");

			readline:
			do {
				line = reader.readLine();
				String lineSav = line;

				if (line != null) {
					lineCount++;

					//determine the depth of the String
					int depth = 0;
					while ((line.length() > depth) && Character.isWhitespace(line.charAt(depth))) {
						if (line.charAt(depth) == '\t') {
							this.tabsUsedAsIndentation = true;
						} else if (line.charAt(depth) == ' ') {
							this.spacesUsedAsIndentation = true;
						}


						depth++;
					}

					line = line.trim();

					//save line for error messages
					lines.add(line);

					if (line.startsWith("#") || line.startsWith("//") || line.startsWith(";")) {
						//comment
						continue readline;
					}

					if (line.length() > 0) {
/*						if (getForm(line, discoveredMapElements, depth, lineCount))
						{
							continue readline;
						}*/
/*						if (getEvent(line, discoveredMapElements, depth, lineCount))
						{
							continue readline;
						}*/
						if (getTask(line, discoveredMapElements, depth, lineCount)) {
							continue readline;
						}
						if (getResult(line, discoveredMapElements, depth, lineCount)) {
							continue readline;
						}
						if (getExceptionHandler(line, discoveredMapElements, depth, lineCount)) {
							continue readline;
						}
						if (getResponseWriter(line, discoveredMapElements, depth, lineCount)) {
							continue readline;
						}
						if (getSubProcess(line, discoveredMapElements, depth, lineCount)) {
							continue readline;
						}

						//line contains rubbish
						isLoaded = false;
						reportError(loadMessages, fileName, lineCount, line, "syntax error");
					}
					//line empty
				}
			}
			while (line != null);

			input.close();

			Iterator i = discoveredMapElements.iterator();
			lineCount = 0;

			loop:
			while (i.hasNext()) {
				MapElement fe = (MapElement) i.next();
				if (fe instanceof UnparsableLine) {
					isLoaded = false;
					reportError(loadMessages, fileName, fe.getLineNr(), ((String) lines.get(fe.getLineNr() - 1)), fe.getArgument());
					continue loop;
				}
				MapElement parent = getParent(discoveredMapElements, lineCount, fe.getDepth());
				if (parent == null) {
					rootProcess.addFlowElement(fe);
					fe.setParent(rootProcess);
/*					if (fe instanceof ActionBundle)
					{
						//if a form by this name already exists, it's an error
						if (forms.containsKey(mappingName + '.' + fe.getLabel()))
						{
							isLoaded = false;
							reportError(fileName, fe.getLineNr(), ((String) lines.get(fe.getLineNr() - 1)), "multiple mapping of form");
						}
						forms.put(mappingName + '.' + fe.getLabel(), fe);
					}
					else
					{
						isLoaded = false;
						reportError(fileName, fe.getLineNr(), ((String) lines.get(fe.getLineNr() - 1)), "mvc element " + getFlowElementDescription(fe) + " must be part of another element");
					}*/
				} else {
					if (!parent.addFlowElement(fe)) {
						isLoaded = false;

						if (parent.isTerminated()) {
							reportError(loadMessages, fileName, fe.getLineNr(), ((String) lines.get(fe.getLineNr() - 1)), "unreachable statement");
						} else {
							reportError(loadMessages, fileName, fe.getLineNr(), ((String) lines.get(fe.getLineNr() - 1)), "can not add " + getFlowElementDescription(fe) + " to " + getFlowElementDescription(parent));
						}
					} else {
						fe.setParent(parent);
					}
				}

				lineCount++;
			}
			return rootProcess;
		} catch (IOException ioe) {
			System.out.println(new LogEntry(Level.CRITICAL, "", ioe));
			isLoaded = false;
			loadMessages.add("Loading of mapping '" + mappingName + "' resulted in exception with message: " + ioe.getMessage());

			return null;
		}
	}
private Process loadFlow ( ) { loadMessages . clear ( ) ; isLoaded = true ; rootProcess = new Process ( this . mappingName , - 1 , 0 ) ; discoveredMapElements . add ( rootProcess ) ; try { InputStream input ; File file = new File ( fileName ) ; if ( file . exists ( ) ) { input = new FileInputStream ( file ) ; } else { input = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( fileName ) ; } if ( input == null ) { throw new ConfigurationException ( "can not load flow: file '" + fileName + "' can not be found at exact location or classpath" ) ; } BufferedReader reader = new BufferedReader ( new InputStreamReader ( input ) ) ; String line ; int lineCount = 0 ; readline : do { line = reader . readLine ( ) ; String lineSav = line ; if ( line != null ) { lineCount ++ ; int depth = 0 ; while ( ( line . length ( ) > depth ) && Character . isWhitespace ( line . charAt ( depth ) ) ) { if ( line . charAt ( depth ) == '\t' ) { this . tabsUsedAsIndentation = true ; } else if ( line . charAt ( depth ) == ' ' ) { this . spacesUsedAsIndentation = true ; } depth ++ ; } line = line . trim ( ) ; lines . add ( line ) ; if ( line . startsWith ( "#" ) || line . startsWith ( "//" ) || line . startsWith ( ";" ) ) { continue readline ; } if ( line . length ( ) > 0 ) { if ( getTask ( line , discoveredMapElements , depth , lineCount ) ) { continue readline ; } if ( getResult ( line , discoveredMapElements , depth , lineCount ) ) { continue readline ; } if ( getExceptionHandler ( line , discoveredMapElements , depth , lineCount ) ) { continue readline ; } if ( getResponseWriter ( line , discoveredMapElements , depth , lineCount ) ) { continue readline ; } if ( getSubProcess ( line , discoveredMapElements , depth , lineCount ) ) { continue readline ; } isLoaded = false ; reportError ( loadMessages , fileName , lineCount , line , "syntax error" ) ; } } } while ( line != null ) ; input . close ( ) ; Iterator i = discoveredMapElements . iterator ( ) ; lineCount = 0 ; loop : while ( i . hasNext ( ) ) { MapElement fe = ( MapElement ) i . next ( ) ; if ( fe instanceof UnparsableLine ) { isLoaded = false ; reportError ( loadMessages , fileName , fe . getLineNr ( ) , ( ( String ) lines . get ( fe . getLineNr ( ) - 1 ) ) , fe . getArgument ( ) ) ; continue loop ; } MapElement parent = getParent ( discoveredMapElements , lineCount , fe . getDepth ( ) ) ; if ( parent == null ) { rootProcess . addFlowElement ( fe ) ; fe . setParent ( rootProcess ) ; } else { if ( ! parent . addFlowElement ( fe ) ) { isLoaded = false ; if ( parent . isTerminated ( ) ) { reportError ( loadMessages , fileName , fe . getLineNr ( ) , ( ( String ) lines . get ( fe . getLineNr ( ) - 1 ) ) , "unreachable statement" ) ; } else { reportError ( loadMessages , fileName , fe . getLineNr ( ) , ( ( String ) lines . get ( fe . getLineNr ( ) - 1 ) ) , "can not add " + getFlowElementDescription ( fe ) + " to " + getFlowElementDescription ( parent ) ) ; } } else { fe . setParent ( parent ) ; } } lineCount ++ ; } return rootProcess ; } catch ( IOException ioe ) { System . out . println ( new LogEntry ( Level . CRITICAL , "" , ioe ) ) ; isLoaded = false ; loadMessages . add ( "Loading of mapping '" + mappingName + "' resulted in exception with message: " + ioe . getMessage ( ) ) ; return null ; } }
@return