Input:
public static void main(String... args) {
		Params params = new Params();
		JCommander jc = new JCommander(params);
		try {
			jc.parse(args);
		} catch (ParameterException t) {
			usage(jc, t);
		}
		File sourceFolder = new File(params.sourceFolder);
		File destinationFolder = new File(params.outputFolder);
		File[] markdownFiles = sourceFolder.listFiles(new FilenameFilter() {
			@Override
			public boolean accept(File dir, String name) {
				return name.toLowerCase().endsWith(".mkd");
			}
		});
		Arrays.sort(markdownFiles);
		Map<String, String> aliasMap = new HashMap<String, String>();
		for (String alias : params.aliases) {
			String[] values = alias.split("=");
			aliasMap.put(values[0], values[1]);
		}
		System.out.println(MessageFormat.format("Generating site from {0} Markdown Docs in {1} ",
				markdownFiles.length, sourceFolder.getAbsolutePath()));
		String linkPattern = "{1}";
		StringBuilder sb = new StringBuilder();
		for (File file : markdownFiles) {
			String documentName = getDocumentName(file);
			if (!params.skips.contains(documentName)) {
				String displayName = documentName;
				if (aliasMap.containsKey(documentName)) {
					displayName = aliasMap.get(documentName);
				}
				String fileName = documentName + ".html";
				sb.append(MessageFormat.format(linkPattern, fileName, displayName));
				sb.append(" | ");
			}
		}
		sb.setLength(sb.length() - 3);
		sb.trimToSize();
		String htmlHeader = FileUtils.readContent(new File(params.pageHeader), "\n");
		String htmlAdSnippet = null;
		if (!StringUtils.isEmpty(params.adSnippet)) {
			File snippet = new File(params.adSnippet);
			if (snippet.exists()) {
				htmlAdSnippet = FileUtils.readContent(snippet, "\n");
			}
		}
		String htmlFooter = FileUtils.readContent(new File(params.pageFooter), "\n");
		String links = sb.toString();
		String header = MessageFormat.format(htmlHeader, Constants.FULL_NAME, links);
		if (!StringUtils.isEmpty(params.analyticsSnippet)) {
			File snippet = new File(params.analyticsSnippet);
			if (snippet.exists()) {
				String htmlSnippet = FileUtils.readContent(snippet, "\n");
				header = header.replace("", htmlSnippet);
			}
		}
		final String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		final String footer = MessageFormat.format(htmlFooter, "generated " + date);
		for (File file : markdownFiles) {
			try {
				String documentName = getDocumentName(file);
				if (!params.skips.contains(documentName)) {
					String fileName = documentName + ".html";
					System.out.println(MessageFormat.format("  {0} => {1}", file.getName(),
							fileName));
					InputStreamReader reader = new InputStreamReader(new FileInputStream(file),
							Charset.forName("UTF-8"));
					String content = MarkdownUtils.transformMarkdown(reader);
					for (String token : params.substitutions) {
						String[] kv = token.split("=");
						content = content.replace(kv[0], kv[1]);
					}
					for (String alias : params.properties) {
						String[] kv = alias.split("=");
						String loadedContent = generatePropertiesContent(new File(kv[1]));
						content = content.replace(kv[0], loadedContent);
					}
					for (String alias : params.loads) {
						String[] kv = alias.split("=");
						String loadedContent = FileUtils.readContent(new File(kv[1]), "\n");
						loadedContent = StringUtils.escapeForHtml(loadedContent, false);
						loadedContent = StringUtils.breakLinesForHtml(loadedContent);
						content = content.replace(kv[0], loadedContent);
					}
					OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(
							new File(destinationFolder, fileName)), Charset.forName("UTF-8"));
					writer.write(header);
					if (!StringUtils.isEmpty(htmlAdSnippet)) {
						writer.write(htmlAdSnippet);
					}
					writer.write(content);
					writer.write(footer);
					reader.close();
					writer.close();
				}
			} catch (Throwable t) {
				System.err.println("Failed to transform " + file.getName());
				t.printStackTrace();
			}
		}
	}

Output:
	public static void main(String... args) {
		Params params = new Params();
		JCommander jc = new JCommander(params);
		try {
			jc.parse(args);
		} catch (ParameterException t) {
			usage(jc, t);
		}
		File sourceFolder = new File(params.sourceFolder);
		File destinationFolder = new File(params.outputFolder);
		File[] markdownFiles = sourceFolder.listFiles(new FilenameFilter() {
			@Override
			public boolean accept(File dir, String name) {
				return name.toLowerCase().endsWith(".mkd");
			}
		});
		Arrays.sort(markdownFiles);
		Map<String, String> aliasMap = new HashMap<String, String>();
		for (String alias : params.aliases) {
			String[] values = alias.split("=");
			aliasMap.put(values[0], values[1]);
		}
		System.out.println(MessageFormat.format("Generating site from {0} Markdown Docs in {1} ",
				markdownFiles.length, sourceFolder.getAbsolutePath()));
		String linkPattern = "<a href=''{0}''>{1}</a>";
		StringBuilder sb = new StringBuilder();
		for (File file : markdownFiles) {
			String documentName = getDocumentName(file);
			if (!params.skips.contains(documentName)) {
				String displayName = documentName;
				if (aliasMap.containsKey(documentName)) {
					displayName = aliasMap.get(documentName);
				} else {
					displayName = displayName.replace('_', ' ');
				}
				String fileName = documentName + ".html";
				sb.append(MessageFormat.format(linkPattern, fileName, displayName));
				sb.append(" | ");
			}
		}
		sb.setLength(sb.length() - 3);
		sb.trimToSize();
		String htmlHeader = FileUtils.readContent(new File(params.pageHeader), "\n");
		String htmlAdSnippet = null;
		if (!StringUtils.isEmpty(params.adSnippet)) {
			File snippet = new File(params.adSnippet);
			if (snippet.exists()) {
				htmlAdSnippet = FileUtils.readContent(snippet, "\n");
			}
		}
		String htmlFooter = FileUtils.readContent(new File(params.pageFooter), "\n");
		String links = sb.toString();
		String header = MessageFormat.format(htmlHeader, Constants.FULL_NAME, links);
		if (!StringUtils.isEmpty(params.analyticsSnippet)) {
			File snippet = new File(params.analyticsSnippet);
			if (snippet.exists()) {
				String htmlSnippet = FileUtils.readContent(snippet, "\n");
				header = header.replace("<!-- ANALYTICS -->", htmlSnippet);
			}
		}
		final String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		final String footer = MessageFormat.format(htmlFooter, "generated " + date);
		for (File file : markdownFiles) {
			try {
				String documentName = getDocumentName(file);
				if (!params.skips.contains(documentName)) {
					String fileName = documentName + ".html";
					System.out.println(MessageFormat.format("  {0} => {1}", file.getName(),
							fileName));
					InputStreamReader reader = new InputStreamReader(new FileInputStream(file),
							Charset.forName("UTF-8"));
					String content = MarkdownUtils.transformMarkdown(reader);
					for (String token : params.substitutions) {
						String[] kv = token.split("=");
						content = content.replace(kv[0], kv[1]);
					}
					for (String alias : params.properties) {
						String[] kv = alias.split("=");
						String loadedContent = generatePropertiesContent(new File(kv[1]));
						content = content.replace(kv[0], loadedContent);
					}
					for (String alias : params.loads) {
						String[] kv = alias.split("=");
						String loadedContent = FileUtils.readContent(new File(kv[1]), "\n");
						loadedContent = StringUtils.escapeForHtml(loadedContent, false);
						loadedContent = StringUtils.breakLinesForHtml(loadedContent);
						content = content.replace(kv[0], loadedContent);
					}
					OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(
							new File(destinationFolder, fileName)), Charset.forName("UTF-8"));
					writer.write(header);
					if (!StringUtils.isEmpty(htmlAdSnippet)) {
						writer.write(htmlAdSnippet);
					}
					writer.write(content);
					writer.write(footer);
					reader.close();
					writer.close();
				}
			} catch (Throwable t) {
				System.err.println("Failed to transform " + file.getName());
				t.printStackTrace();
			}
		}
	}


Input:
    public void doResponse(Properties conProp, httpHeader requestHeader, OutputStream out, InputStream body) {
        this.connectionProperties = conProp;
        String path = null;
        try {
            String method = conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD);
            path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH);
            String argsString = conProp.getProperty(httpHeader.CONNECTION_PROP_ARGS);
            String httpVersion= conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER);
            if (path.indexOf("..") >= 0) {
                httpd.sendRespondError(conProp,out,4,403,null,"Access not allowed",null);
                return;
            }
            try {
                path = URLDecoder.decode(path, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                assert(false) : "UnsupportedEncodingException: " + e.getMessage();
            }
            String authorization = (String) requestHeader.get(httpHeader.AUTHORIZATION);
            String adminAccountBase64MD5 = switchboard.getConfig("adminAccountBase64MD5", "");
            int pos = path.lastIndexOf(".");
            if ((path.substring(0,(pos==-1)?path.length():pos)).endsWith("_p") && (adminAccountBase64MD5.length() != 0)) {
                if(sb.userDB.hasAdminRight(authorization, conProp.getProperty("CLIENTIP"), requestHeader.getHeaderCookies())){
                    serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));
                }else if(authorization != null && sb.staticAdminAuthenticated(authorization.trim().substring(6))==4){
                    serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));
                }else if (authorization == null) {
                    httpHeader headers = getDefaultHeaders(path);
                    headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
                    servletProperties tp=new servletProperties();
                    tp.put("returnto", path);
                    httpd.sendRespondError(conProp, out, 5, 401, "Wrong Authentication", "", new File("proxymsg/authfail.inc"), tp, null, headers);
                    return;
                } else {
                    String clientIP = conProp.getProperty("CLIENTIP", "unknown-host");
                    serverLog.logInfo("HTTPD", "Wrong log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");
                    Integer attempts = (Integer) serverCore.bfHost.get(clientIP);
                    if (attempts == null)
                        serverCore.bfHost.put(clientIP, new Integer(1));
                    else
                        serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));
                    httpHeader headers = getDefaultHeaders(path);
                    headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
                    httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
                    return;
                }
            }
            serverObjects args = new serverObjects();
            int argc;
            if (argsString == null) {
                int length = 0;
                if (method.equals(httpHeader.METHOD_POST)) {
                    GZIPInputStream gzipBody = null;
                    if (requestHeader.containsKey(httpHeader.CONTENT_LENGTH)) {
                        length = Integer.parseInt((String) requestHeader.get(httpHeader.CONTENT_LENGTH));
                    } else if (requestHeader.gzip()) {
                        length = -1;
                        gzipBody = new GZIPInputStream(body);
                    }
                    if ((requestHeader.containsKey(httpHeader.CONTENT_TYPE)) &&
                            (((String) requestHeader.get(httpHeader.CONTENT_TYPE)).toLowerCase().startsWith("multipart"))) {
                        HashMap files = httpd.parseMultipart(requestHeader, args, (gzipBody!=null)?gzipBody:body, length);
                        if (files != null) {
                            Iterator fit = files.entrySet().iterator();
                            Map.Entry entry;
                            while (fit.hasNext()) {
                                entry = (Map.Entry) fit.next();
                                args.put(((String) entry.getKey()) + "$file", entry.getValue());
                            }
                        }
                        argc = Integer.parseInt((String) requestHeader.get("ARGC"));
                    } else {
                        argc = httpd.parseArgs(args, (gzipBody!=null)?gzipBody:body, length);
                    }
                } else {
                    argsString = null;
                    args = null;
                    argc = 0;
                }
            } else {
                argc = httpd.parseArgs(args, argsString);
            }
            if (argc > 0) {
                Enumeration e = args.elements();
                Object val;
                while (e.hasMoreElements()) {
                    val = e.nextElement();
                    if ((val != null) && (val instanceof String) && (((String) val).indexOf("<script") >= 0)) {
                        httpd.sendRespondError(conProp,out,4,403,null,"bad post values",null);
                        return;
                    }
                }
            }
            if (path.length() == 0) {
                httpd.sendRespondError(conProp,out,4,400,null,"Bad Request",null);
                out.flush();
                return;
            }
            File targetClass=null;
            if (!(path.startsWith("/"))) path = "/" + path;
            String localeSelection = switchboard.getConfig("htLocaleSelection","default");
            if (args != null && (args.containsKey("language")))
            {
                localeSelection = args.get("language", localeSelection);
                if (localeSelection.indexOf(".") != -1)
                    localeSelection = localeSelection.substring(0, localeSelection.indexOf("."));
            }
            File   targetFile  = getLocalizedFile(path, localeSelection);
            String targetExt   = conProp.getProperty("EXT","");
            targetClass = rewriteClassFile(new File(htDefaultPath, path));
            if (path.endsWith("/")) {
                String testpath;
                for (int i = 0; i < defaultFiles.length; i++) {
                    testpath = path + defaultFiles[i];
                    targetFile = getOverlayedFile(testpath);
                    targetClass=getOverlayedClass(testpath);
                    if (targetFile.exists()) {
                        path = testpath;
                        break;
                    }
                }
                if(targetFile == null || !targetFile.exists()){
                	String dirlistFormat = (args==null)?"html":args.get("format","html");
                    targetFile = getOverlayedFile("/htdocsdefault/dir." + dirlistFormat);
                    targetClass=getOverlayedClass("/htdocsdefault/dir." + dirlistFormat);
                    if(! (( targetFile != null && targetFile.exists()) && ( targetClass != null && targetClass.exists())) ){
                        httpd.sendRespondError(this.connectionProperties,out,3,500,"dir." + dirlistFormat + " or dir.class not found.",null,null);
                    }
                }
            }else{
                    if ( !(targetFile.exists()) && !((path.endsWith("png")||path.endsWith("gif")||path.endsWith(".stream"))&&targetClass!=null ) ){
                        targetFile = new File(htDocsPath, path);
                        targetClass = rewriteClassFile(new File(htDocsPath, path));
                    }
            }
            servletProperties tp = new servletProperties();
            Date targetDate;
            boolean nocache = false;
            if ((targetClass != null) && (path.endsWith("png"))) {
                Object img = null;
                try {
                    requestHeader.put("CLIENTIP", conProp.getProperty("CLIENTIP"));
                    requestHeader.put("PATH", path);
                    img = invokeServlet(targetClass, requestHeader, args);
                } catch (InvocationTargetException e) {
                    this.theLogger.logSevere("INTERNAL ERROR: " + e.toString() + ":" +
                    e.getMessage() +
                    " target exception at " + targetClass + ": " +
                    e.getTargetException().toString() + ":" +
                    e.getTargetException().getMessage() +
                    "; java.awt.graphicsenv='" + System.getProperty("java.awt.graphicsenv","") + "'",e);
                    targetClass = null;
                }
                if (img == null) {
                    httpd.sendRespondError(this.connectionProperties,out,3,404,"File not Found",null,null);
                } else {
                    if (img instanceof ymageMatrix) {
                        ymageMatrix yp = (ymageMatrix) img;
                        targetDate = new Date(System.currentTimeMillis());
                        nocache = true;
                        String mimeType = mimeTable.getProperty(targetExt, "text/html");
                        serverByteBuffer baos = new serverByteBuffer();
                        ImageIO.write(yp.getImage(), targetExt, baos);
                        byte[] result = baos.toByteArray();
                        baos.close();
                        baos = null;
                        httpd.sendRespondHeader(this.connectionProperties, out,
                                httpVersion, 200, null, mimeType,
                                result.length, targetDate, null, null, null,
                                null, nocache);
                        if (!method.equals(httpHeader.METHOD_HEAD)) {
                            Thread.sleep(200);
                            serverFileUtils.write(result, out);
                        }
                    }
                    if (img instanceof Image) {
                        Image i = (Image) img;
                        targetDate = new Date(System.currentTimeMillis());
                        nocache = true;
                        String mimeType = mimeTable.getProperty(targetExt, "text/html");
                        int width = i.getWidth(null); if (width < 0) width = 96;
                        int height = i.getHeight(null); if (height < 0) height = 96;
                        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                        bi.createGraphics().drawImage(i, 0, 0, width, height, null);
                        serverByteBuffer baos = new serverByteBuffer();
                        ImageIO.write(bi, targetExt, baos);
                        byte[] result = baos.toByteArray();
                        baos.close();
                        baos = null;
                        httpd.sendRespondHeader(this.connectionProperties, out,
                                httpVersion, 200, null, mimeType,
                                result.length, targetDate, null, null, null,
                                null, nocache);
                        if (!method.equals(httpHeader.METHOD_HEAD)) {
                            Thread.sleep(200);
                            serverFileUtils.write(result, out);
                        }
                    }
                }
            } else if ((targetClass != null) && (path.endsWith(".stream"))) {
                requestHeader.put("CLIENTIP", conProp.getProperty("CLIENTIP"));
                requestHeader.put("PATH", path);
                requestHeader.put("INPUTSTREAM", body);
                requestHeader.put("OUTPUTSTREAM", out);
                httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null);
                 invokeServlet(targetClass, requestHeader, args);
                this.forceConnectionClose();
                return;
            } else if ((targetFile.exists()) && (targetFile.canRead())) {
                String mimeType = mimeTable.getProperty(targetExt,"text/html");
                byte[] result;
                boolean zipContent = requestHeader.acceptGzip() && httpd.shallTransportZipped("." + conProp.getProperty("EXT",""));
                if (path.endsWith("html") ||
                        path.endsWith("xml") ||
                        path.endsWith("rss") ||
                        path.endsWith("csv") ||
                        path.endsWith("pac") ||
                        path.endsWith("src") ||
                        path.endsWith("/")) {
                    if (targetClass == null) {
                        targetDate = new Date(targetFile.lastModified());
                    } else {
                        try {
                            requestHeader.put("CLIENTIP", conProp.getProperty("CLIENTIP"));
                            requestHeader.put("PATH", path);
                            Object tmp = invokeServlet(targetClass, requestHeader, args);
                            if(tmp instanceof serverObjects){
                                tp=new servletProperties((serverObjects)tmp);
                            }else{
                                tp=(servletProperties)tmp;
                            }
                            if (tp == null) tp = new servletProperties();
                            if (tp.containsKey("AUTHENTICATE")) {
                                if (authorization != null) {
                                    String clientIP = conProp.getProperty("CLIENTIP", "unknown-host");
                                    serverLog.logInfo("HTTPD", "dynamic log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");
                                    Integer attempts = (Integer) serverCore.bfHost.get(clientIP);
                                    if (attempts == null)
                                        serverCore.bfHost.put(clientIP, new Integer(1));
                                    else
                                        serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));
                                }
                                httpHeader headers = getDefaultHeaders(path);
                                headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"" + tp.get("AUTHENTICATE", "") + "\"");
                                httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
                                return;
                            } else if (tp.containsKey("LOCATION")) {
                                String location = tp.get("LOCATION","");
                                if (location.length() == 0) location = path;
                                httpHeader headers = getDefaultHeaders(path);
                                headers.setCookieVector(tp.getOutgoingHeader().getCookieVector());
                                headers.put(httpHeader.LOCATION,location);
                                httpd.sendRespondHeader(conProp,out,httpVersion,302,headers);
                                return;
                            }
                            tp.put("version", switchboard.getConfig("version", ""));
                            tp.put("uptime", ((System.currentTimeMillis() - Long.parseLong(switchboard.getConfig("startupTime","0"))) / 1000) / 60);
                            tp.put("clientname", switchboard.getConfig("peerName", "anomic"));
                        } catch (InvocationTargetException e) {
                            if (e.getCause() instanceof InterruptedException) {
                                throw new InterruptedException(e.getCause().getMessage());
                            }
                            this.theLogger.logSevere("INTERNAL ERROR: " + e.toString() + ":" +
                                    e.getMessage() +
                                    " target exception at " + targetClass + ": " +
                                    e.getTargetException().toString() + ":" +
                                    e.getTargetException().getMessage(),e);
                            targetClass = null;
                            throw e;
                        }
                        targetDate = new Date(System.currentTimeMillis());
                        nocache = true;
                    }
                    tp.putAll(templates);
                    serverByteBuffer o = null;
                    InputStream fis = null;
                    GZIPOutputStream zippedOut = null;
                    try {
                        byte[] templateContent = null;
                        if (useTemplateCache) {
                            long fileSize = targetFile.length();
                            if (fileSize <= 512*1024) {
                                SoftReference ref = (SoftReference) templateCache.get(targetFile);
                                if (ref != null) {
                                    templateContent = (byte[]) ref.get();
                                    if (templateContent == null)
                                        templateCache.remove(targetFile);
                                }
                                if (templateContent == null) {
                                    templateContent = serverFileUtils.read(targetFile);
                                    ref = new SoftReference(templateContent);
                                    templateCache.put(targetFile,ref);
                                    if (this.theLogger.isLoggable(Level.FINEST))
                                        this.theLogger.logFinest("Cache MISS for file " + targetFile);
                                } else {
                                    if (this.theLogger.isLoggable(Level.FINEST))
                                        this.theLogger.logFinest("Cache HIT for file " + targetFile);
                                }
                                fis = new ByteArrayInputStream(templateContent);
                                templateContent = null;
                            } else {
                                fis = new BufferedInputStream(new FileInputStream(targetFile));
                            }
                        } else {
                            fis = new BufferedInputStream(new FileInputStream(targetFile));
                        }
                        String supertemplate="";
                        if(tp.containsKey("SUPERTEMPLATE")){
                            supertemplate=(String) tp.get("SUPERTEMPLATE");
                        }
                        if(!supertemplate.equals("")){
                            File pageFile=getOverlayedFile(supertemplate);
                            File pageClass=getOverlayedClass(supertemplate);
                            if(pageFile != null && pageFile.exists()){
                                BufferedReader br=new BufferedReader(new InputStreamReader(fis));
                                String line;
                                boolean inheader=false;
                                StringBuffer header=new StringBuffer();
                                StringBuffer content=new StringBuffer();
                                String content_s,header_s;
                                while((line=br.readLine())!=null){
                                    if(!inheader){
                                        if(line.startsWith("<!--HEADER")){
                                            inheader=true;
                                        }else{
                                            content.append(line);
                                        }
                                    }else{
                                        if(line.endsWith("HEADER-->")){
                                            inheader=false;
                                        }else{
                                            header.append(line);
                                        }
                                    }
                                }
                                o = new serverByteBuffer();
                                fis=new ByteArrayInputStream(content.toString().getBytes());
                                httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes());
                                content_s=o.toString();
                                o = new serverByteBuffer();
                                fis=new ByteArrayInputStream(header.toString().getBytes());
                                httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes());
                                header_s=o.toString();
                                if (pageClass != null && pageClass.exists()){
                                    Object tmp = invokeServlet(pageClass, requestHeader, args);
                                    if(tmp instanceof serverObjects){
                                        tp=new servletProperties((serverObjects)tmp);
                                    }else{
                                        tp=(servletProperties)tmp;
                                    }
                                }else
                                    tp = new servletProperties();
                                tp.put("header", header_s);
                                tp.put("page", content_s);
                                fis=new BufferedInputStream(new FileInputStream(pageFile));
                            }
                        }
                        o = new serverByteBuffer();
                        if (zipContent) zippedOut = new GZIPOutputStream(o);
                        httpTemplate.writeTemplate(fis, (zipContent) ? (OutputStream)zippedOut: (OutputStream)o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
                        if (zipContent) {
                            zippedOut.finish();
                            zippedOut.flush();
                            zippedOut.close();
                            zippedOut = null;
                        }
                        result = o.toByteArray();
                        if (this.md5Digest != null) {
                            this.md5Digest.reset();
                            this.md5Digest.update(result);
                            byte[] digest = this.md5Digest.digest();
                            StringBuffer digestString = new StringBuffer();
                            for ( int i = 0; i < digest.length; i++ )
                                digestString.append(Integer.toHexString( digest[i]&0xff));
                        }
                    } finally {
                        if (zippedOut != null) try {zippedOut.close();} catch(Exception e) {}
                        if (o != null) try {o.close(); o = null;} catch(Exception e) {}
                        if (fis != null) try {fis.close(); fis=null;} catch(Exception e) {}
                    }
                    long contentLength     = result.length;
                    String contentEncoding = (zipContent)?"gzip":null;
                    httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null, mimeType, contentLength, targetDate, null, tp.getOutgoingHeader(), contentEncoding, null, nocache);
                    if (! method.equals(httpHeader.METHOD_HEAD)) {
                        Thread.sleep(200);
                        serverFileUtils.write(result, out);
                    }
                } else {
                    int statusCode = 200;
                    int rangeStartOffset = 0;
                    httpHeader header = new httpHeader();
                    header.put(httpHeader.ACCEPT_RANGES, "bytes");
                    String targetMD5 = null;
                    File targetMd5File = new File(targetFile + ".md5");
                    try {
                        if (targetMd5File.exists()) {
                            targetMD5 = new String(serverFileUtils.read(targetMd5File));
                            pos = targetMD5.indexOf('\n');
                           if (pos >= 0) {
                               targetMD5 = targetMD5.substring(0, pos);
                           }
                           header.put(httpHeader.ETAG, targetMD5);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    if (requestHeader.containsKey(httpHeader.RANGE)) {
                        Object ifRange = requestHeader.ifRange();
                        if ((ifRange == null)||
                            (ifRange instanceof Date && targetFile.lastModified() == ((Date)ifRange).getTime()) ||
                            (ifRange instanceof String && ifRange.equals(targetMD5))) {
                            String rangeHeaderVal = ((String) requestHeader.get(httpHeader.RANGE)).trim();
                            if (rangeHeaderVal.startsWith("bytes=")) {
                                String rangesVal = rangeHeaderVal.substring("bytes=".length());
                                String[] ranges = rangesVal.split(",");
                                if ((ranges.length == 1)&&(ranges[0].endsWith("-"))) {
                                    rangeStartOffset = Integer.valueOf(ranges[0].substring(0,ranges[0].length()-1)).intValue();
                                    statusCode = 206;
                                    if (header == null) header = new httpHeader();
                                    header.put(httpHeader.CONTENT_RANGE, "bytes " + rangeStartOffset + "-" + (targetFile.length()-1) + "/" + targetFile.length());
                                }
                            }
                        }
                    }
                    targetDate = new Date(targetFile.lastModified());
                    long   contentLength    = (zipContent)?-1:targetFile.length()-rangeStartOffset;
                    String contentEncoding  = (zipContent)?"gzip":null;
                    String transferEncoding = (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1))?null:(zipContent)?"chunked":null;
                    if (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1) && zipContent) forceConnectionClose();
                    httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, statusCode, null, mimeType, contentLength, targetDate, null, header, contentEncoding, transferEncoding, nocache);
                    if (!method.equals(httpHeader.METHOD_HEAD)) {
                        httpChunkedOutputStream chunkedOut = null;
                        GZIPOutputStream zipped = null;
                        OutputStream newOut = out;
                        if (transferEncoding != null) {
                            chunkedOut = new httpChunkedOutputStream(newOut);
                            newOut = chunkedOut;
                        }
                        if (contentEncoding != null) {
                            zipped = new GZIPOutputStream(newOut);
                            newOut = zipped;
                        }
                        serverFileUtils.copyRange(targetFile,newOut,rangeStartOffset);
                        if (zipped != null) {
                            zipped.flush();
                            zipped.finish();
                        }
                        if (chunkedOut != null) {
                            chunkedOut.finish();
                        }
                    }
                }
            } else {
                httpd.sendRespondError(conProp,out,3,404,"File not Found",null,null);
                return;
            }
        } catch (Exception e) {
            try {
                int httpStatusCode = 400;
                String httpStatusText = null;
                StringBuffer errorMessage = new StringBuffer();
                Exception errorExc = null;
                String errorMsg = e.getMessage();
                if (
                        (e instanceof InterruptedException) ||
                        ((errorMsg != null) && (errorMsg.startsWith("Socket closed")) && (Thread.currentThread().isInterrupted()))
                   ) {
                    errorMessage.append("Interruption detected while processing query.");
                    httpStatusCode = 503;
                } else {
                    if ((errorMsg != null) &&
                        (
                           errorMsg.startsWith("Broken pipe") ||
                           errorMsg.startsWith("Connection reset") ||
                           errorMsg.startsWith("Software caused connection abort")
                       )) {
                        errorMessage.append("Client unexpectedly closed connection while processing query.");
                    } else if ((errorMsg != null) && (errorMsg.startsWith("Connection timed out"))) {
                        errorMessage.append("Connection timed out.");
                    } else {
                        errorMessage.append("Unexpected error while processing query.");
                        httpStatusCode = 500;
                        errorExc = e;
                    }
                }
                errorMessage.append("\nSession: ").append(Thread.currentThread().getName())
                            .append("\nQuery:   ").append(path)
                            .append("\nClient:  ").append(conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP,"unknown"))
                            .append("\nReason:  ").append(e.toString());
                if (!conProp.containsKey(httpHeader.CONNECTION_PROP_PROXY_RESPOND_HEADER)) {
                    httpd.sendRespondError(conProp,out, 4, httpStatusCode, httpStatusText, errorMessage.toString(),errorExc);
                } else {
                    this.forceConnectionClose();
                }
                if (httpStatusCode == 500) {
                    this.theLogger.logWarning(errorMessage.toString(),e);
                }
            } catch (Exception ee) {
                this.forceConnectionClose();
            }
        } finally {
            try {out.flush();}catch (Exception e) {}
            if (((String)requestHeader.get(httpHeader.CONNECTION, "close")).indexOf("keep-alive") == -1) {
                try {Thread.sleep(1000);} catch (InterruptedException e) {}
            }
        }
    }

Output:
    public void doResponse(Properties conProp, httpHeader requestHeader, OutputStream out, InputStream body) {
        this.connectionProperties = conProp;
        String path = null;
        try {
            String method = conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD);
            path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH);
            String argsString = conProp.getProperty(httpHeader.CONNECTION_PROP_ARGS);
            String httpVersion= conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER);
            if (path.indexOf("..") >= 0) {
                httpd.sendRespondError(conProp,out,4,403,null,"Access not allowed",null);
                return;
            }
            try {
                path = URLDecoder.decode(path, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                assert(false) : "UnsupportedEncodingException: " + e.getMessage();
            }
            String authorization = (String) requestHeader.get(httpHeader.AUTHORIZATION);
            String adminAccountBase64MD5 = switchboard.getConfig("adminAccountBase64MD5", "");
            int pos = path.lastIndexOf(".");
            if ((path.substring(0,(pos==-1)?path.length():pos)).endsWith("_p") && (adminAccountBase64MD5.length() != 0)) {
                if(sb.userDB.hasAdminRight(authorization, conProp.getProperty("CLIENTIP"), requestHeader.getHeaderCookies())){
                    serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));
                }else if(authorization != null && sb.staticAdminAuthenticated(authorization.trim().substring(6))==4){
                    serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));
                }else if (authorization == null) {
                    httpHeader headers = getDefaultHeaders(path);
                    headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
                    servletProperties tp=new servletProperties();
                    tp.put("returnto", path);
                    httpd.sendRespondError(conProp, out, 5, 401, "Wrong Authentication", "", new File("proxymsg/authfail.inc"), tp, null, headers);
                    return;
                } else {
                    String clientIP = conProp.getProperty("CLIENTIP", "unknown-host");
                    serverLog.logInfo("HTTPD", "Wrong log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");
                    Integer attempts = (Integer) serverCore.bfHost.get(clientIP);
                    if (attempts == null)
                        serverCore.bfHost.put(clientIP, new Integer(1));
                    else
                        serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));
                    httpHeader headers = getDefaultHeaders(path);
                    headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
                    httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
                    return;
                }
            }
            serverObjects args = new serverObjects();
            int argc;
            if (argsString == null) {
                int length = 0;
                if (method.equals(httpHeader.METHOD_POST)) {
                    GZIPInputStream gzipBody = null;
                    if (requestHeader.containsKey(httpHeader.CONTENT_LENGTH)) {
                        length = Integer.parseInt((String) requestHeader.get(httpHeader.CONTENT_LENGTH));
                    } else if (requestHeader.gzip()) {
                        length = -1;
                        gzipBody = new GZIPInputStream(body);
                    }
                    if ((requestHeader.containsKey(httpHeader.CONTENT_TYPE)) &&
                            (((String) requestHeader.get(httpHeader.CONTENT_TYPE)).toLowerCase().startsWith("multipart"))) {
                        HashMap files = httpd.parseMultipart(requestHeader, args, (gzipBody!=null)?gzipBody:body, length);
                        if (files != null) {
                            Iterator fit = files.entrySet().iterator();
                            Map.Entry entry;
                            while (fit.hasNext()) {
                                entry = (Map.Entry) fit.next();
                                args.put(((String) entry.getKey()) + "$file", entry.getValue());
                            }
                        }
                        argc = Integer.parseInt((String) requestHeader.get("ARGC"));
                    } else {
                        argc = httpd.parseArgs(args, (gzipBody!=null)?gzipBody:body, length);
                    }
                } else {
                    argsString = null;
                    args = null;
                    argc = 0;
                }
            } else {
                argc = httpd.parseArgs(args, argsString);
            }
            if (argc > 0) {
                Enumeration e = args.elements();
                Object val;
                while (e.hasMoreElements()) {
                    val = e.nextElement();
                    if ((val != null) && (val instanceof String) && (((String) val).indexOf("<script") >= 0)) {
                        httpd.sendRespondError(conProp,out,4,403,null,"bad post values",null);
                        return;
                    }
                }
            }
            if (path.length() == 0) {
                httpd.sendRespondError(conProp,out,4,400,null,"Bad Request",null);
                out.flush();
                return;
            }
            File targetClass=null;
            if (!(path.startsWith("/"))) path = "/" + path;
            String localeSelection = switchboard.getConfig("htLocaleSelection","default");
            if (args != null && (args.containsKey("language")))
            {
                localeSelection = args.get("language", localeSelection);
                if (localeSelection.indexOf(".") != -1)
                    localeSelection = localeSelection.substring(0, localeSelection.indexOf("."));
            }
            File   targetFile  = getLocalizedFile(path, localeSelection);
            String targetExt   = conProp.getProperty("EXT","");
            targetClass = rewriteClassFile(new File(htDefaultPath, path));
            if (path.endsWith("/")) {
                String testpath;
                for (int i = 0; i < defaultFiles.length; i++) {
                    testpath = path + defaultFiles[i];
                    targetFile = getOverlayedFile(testpath);
                    targetClass=getOverlayedClass(testpath);
                    if (targetFile.exists()) {
                        path = testpath;
                        break;
                    }
                }
                if(targetFile == null || !targetFile.exists()){
                	String dirlistFormat = (args==null)?"html":args.get("format","html");
                    targetFile = getOverlayedFile("/htdocsdefault/dir." + dirlistFormat);
                    targetClass=getOverlayedClass("/htdocsdefault/dir." + dirlistFormat);
                    if(! (( targetFile != null && targetFile.exists()) && ( targetClass != null && targetClass.exists())) ){
                        httpd.sendRespondError(this.connectionProperties,out,3,500,"dir." + dirlistFormat + " or dir.class not found.",null,null);
                    }
                }
            }else{
                    if ( !(targetFile.exists()) && !((path.endsWith("png")||path.endsWith("gif")||path.endsWith(".stream"))&&targetClass!=null ) ){
                        targetFile = new File(htDocsPath, path);
                        targetClass = rewriteClassFile(new File(htDocsPath, path));
                    }
            }
            servletProperties tp = new servletProperties();
            Date targetDate;
            boolean nocache = false;
            if ((targetClass != null) && (path.endsWith("png"))) {
                Object img = null;
                try {
                    requestHeader.put("CLIENTIP", conProp.getProperty("CLIENTIP"));
                    requestHeader.put("PATH", path);
                    img = invokeServlet(targetClass, requestHeader, args);
                } catch (InvocationTargetException e) {
                    this.theLogger.logSevere("INTERNAL ERROR: " + e.toString() + ":" +
                    e.getMessage() +
                    " target exception at " + targetClass + ": " +
                    e.getTargetException().toString() + ":" +
                    e.getTargetException().getMessage() +
                    "; java.awt.graphicsenv='" + System.getProperty("java.awt.graphicsenv","") + "'",e);
                    targetClass = null;
                }
                if (img == null) {
                    httpd.sendRespondError(this.connectionProperties,out,3,404,"File not Found",null,null);
                } else {
                    if (img instanceof ymageMatrix) {
                        ymageMatrix yp = (ymageMatrix) img;
                        targetDate = new Date(System.currentTimeMillis());
                        nocache = true;
                        String mimeType = mimeTable.getProperty(targetExt, "text/html");
                        serverByteBuffer baos = new serverByteBuffer();
                        ImageIO.write(yp.getImage(), targetExt, baos);
                        byte[] result = baos.toByteArray();
                        baos.close();
                        baos = null;
                        httpd.sendRespondHeader(this.connectionProperties, out,
                                httpVersion, 200, null, mimeType,
                                result.length, targetDate, null, null, null,
                                null, nocache);
                        if (!method.equals(httpHeader.METHOD_HEAD)) {
                            Thread.sleep(200);
                            serverFileUtils.write(result, out);
                        }
                    }
                    if (img instanceof Image) {
                        Image i = (Image) img;
                        targetDate = new Date(System.currentTimeMillis());
                        nocache = true;
                        String mimeType = mimeTable.getProperty(targetExt, "text/html");
                        int width = i.getWidth(null); if (width < 0) width = 96;
                        int height = i.getHeight(null); if (height < 0) height = 96;
                        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                        bi.createGraphics().drawImage(i, 0, 0, width, height, null);
                        serverByteBuffer baos = new serverByteBuffer();
                        ImageIO.write(bi, targetExt, baos);
                        byte[] result = baos.toByteArray();
                        baos.close();
                        baos = null;
                        httpd.sendRespondHeader(this.connectionProperties, out,
                                httpVersion, 200, null, mimeType,
                                result.length, targetDate, null, null, null,
                                null, nocache);
                        if (!method.equals(httpHeader.METHOD_HEAD)) {
                            Thread.sleep(200);
                            serverFileUtils.write(result, out);
                        }
                    }
                }
            } else if ((targetClass != null) && (path.endsWith(".stream"))) {
                requestHeader.put("CLIENTIP", conProp.getProperty("CLIENTIP"));
                requestHeader.put("PATH", path);
                requestHeader.put("INPUTSTREAM", body);
                requestHeader.put("OUTPUTSTREAM", out);
                httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null);
                 invokeServlet(targetClass, requestHeader, args);
                this.forceConnectionClose();
                return;
            } else if ((targetFile.exists()) && (targetFile.canRead())) {
                String mimeType = mimeTable.getProperty(targetExt,"text/html");
                byte[] result;
                boolean zipContent = requestHeader.acceptGzip() && httpd.shallTransportZipped("." + conProp.getProperty("EXT",""));
                if (path.endsWith("html") ||
                        path.endsWith("xml") ||
                        path.endsWith("rss") ||
                        path.endsWith("csv") ||
                        path.endsWith("pac") ||
                        path.endsWith("src") ||
                        path.endsWith("/")) {
                    if (targetClass == null) {
                        targetDate = new Date(targetFile.lastModified());
                    } else {
                        try {
                            requestHeader.put("CLIENTIP", conProp.getProperty("CLIENTIP"));
                            requestHeader.put("PATH", path);
                            Object tmp = invokeServlet(targetClass, requestHeader, args);
                            if(tmp instanceof serverObjects){
                                tp=new servletProperties((serverObjects)tmp);
                            }else{
                                tp=(servletProperties)tmp;
                            }
                            if (tp == null) tp = new servletProperties();
                            if (tp.containsKey("AUTHENTICATE")) {
                                if (authorization != null) {
                                    String clientIP = conProp.getProperty("CLIENTIP", "unknown-host");
                                    serverLog.logInfo("HTTPD", "dynamic log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");
                                    Integer attempts = (Integer) serverCore.bfHost.get(clientIP);
                                    if (attempts == null)
                                        serverCore.bfHost.put(clientIP, new Integer(1));
                                    else
                                        serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));
                                }
                                httpHeader headers = getDefaultHeaders(path);
                                headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"" + tp.get("AUTHENTICATE", "") + "\"");
                                httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
                                return;
                            } else if (tp.containsKey("LOCATION")) {
                                String location = tp.get("LOCATION","");
                                if (location.length() == 0) location = path;
                                httpHeader headers = getDefaultHeaders(path);
                                headers.setCookieVector(tp.getOutgoingHeader().getCookieVector());
                                headers.put(httpHeader.LOCATION,location);
                                httpd.sendRespondHeader(conProp,out,httpVersion,302,headers);
                                return;
                            }
                            tp.put("version", switchboard.getConfig("version", ""));
                            tp.put("uptime", ((System.currentTimeMillis() - Long.parseLong(switchboard.getConfig("startupTime","0"))) / 1000) / 60);
                            tp.put("clientname", switchboard.getConfig("peerName", "anomic"));
                        } catch (InvocationTargetException e) {
                            if (e.getCause() instanceof InterruptedException) {
                                throw new InterruptedException(e.getCause().getMessage());
                            }
                            this.theLogger.logSevere("INTERNAL ERROR: " + e.toString() + ":" +
                                    e.getMessage() +
                                    " target exception at " + targetClass + ": " +
                                    e.getTargetException().toString() + ":" +
                                    e.getTargetException().getMessage(),e);
                            targetClass = null;
                            throw e;
                        }
                        targetDate = new Date(System.currentTimeMillis());
                        nocache = true;
                    }
                    tp.putAll(templates);
                    serverByteBuffer o = null;
                    InputStream fis = null;
                    GZIPOutputStream zippedOut = null;
                    try {
                        byte[] templateContent = null;
                        if (useTemplateCache) {
                            long fileSize = targetFile.length();
                            if (fileSize <= 512*1024) {
                                SoftReference ref = (SoftReference) templateCache.get(targetFile);
                                if (ref != null) {
                                    templateContent = (byte[]) ref.get();
                                    if (templateContent == null)
                                        templateCache.remove(targetFile);
                                }
                                if (templateContent == null) {
                                    templateContent = serverFileUtils.read(targetFile);
                                    ref = new SoftReference(templateContent);
                                    templateCache.put(targetFile,ref);
                                    if (this.theLogger.isLoggable(Level.FINEST))
                                        this.theLogger.logFinest("Cache MISS for file " + targetFile);
                                } else {
                                    if (this.theLogger.isLoggable(Level.FINEST))
                                        this.theLogger.logFinest("Cache HIT for file " + targetFile);
                                }
                                fis = new ByteArrayInputStream(templateContent);
                                templateContent = null;
                            } else {
                                fis = new BufferedInputStream(new FileInputStream(targetFile));
                            }
                        } else {
                            fis = new BufferedInputStream(new FileInputStream(targetFile));
                        }
                        String supertemplate="";
                        if(tp.containsKey("SUPERTEMPLATE")){
                            supertemplate=(String) tp.get("SUPERTEMPLATE");
                        }
                        if(!supertemplate.equals("")){
                            File pageFile=getOverlayedFile(supertemplate);
                            File pageClass=getOverlayedClass(supertemplate);
                            if(pageFile != null && pageFile.exists()){
                                BufferedReader br=new BufferedReader(new InputStreamReader(fis));
                                String line;
                                boolean inheader=false;
                                StringBuffer header=new StringBuffer();
                                StringBuffer content=new StringBuffer();
                                String content_s,header_s;
                                while((line=br.readLine())!=null){
                                    if(!inheader){
                                        if(line.startsWith("<!--HEADER")){
                                            inheader=true;
                                        }else{
                                            content.append(line);
                                        }
                                    }else{
                                        if(line.endsWith("HEADER-->")){
                                            inheader=false;
                                        }else{
                                            header.append(line);
                                        }
                                    }
                                }
                                o = new serverByteBuffer();
                                fis=new ByteArrayInputStream(content.toString().getBytes());
                                httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes());
                                content_s=o.toString();
                                o = new serverByteBuffer();
                                fis=new ByteArrayInputStream(header.toString().getBytes());
                                httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes());
                                header_s=o.toString();
                                if (pageClass != null && pageClass.exists()){
                                    Object tmp = invokeServlet(pageClass, requestHeader, args);
                                    if(tmp instanceof serverObjects){
                                        tp=new servletProperties((serverObjects)tmp);
                                    }else{
                                        tp=(servletProperties)tmp;
                                    }
                                }else
                                    tp = new servletProperties();
                                tp.putASIS("header", header_s);
                                tp.putASIS("page", content_s);
                                fis=new BufferedInputStream(new FileInputStream(pageFile));
                            }
                        }
                        o = new serverByteBuffer();
                        if (zipContent) zippedOut = new GZIPOutputStream(o);
                        httpTemplate.writeTemplate(fis, (zipContent) ? (OutputStream)zippedOut: (OutputStream)o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
                        if (zipContent) {
                            zippedOut.finish();
                            zippedOut.flush();
                            zippedOut.close();
                            zippedOut = null;
                        }
                        result = o.toByteArray();
                        if (this.md5Digest != null) {
                            this.md5Digest.reset();
                            this.md5Digest.update(result);
                            byte[] digest = this.md5Digest.digest();
                            StringBuffer digestString = new StringBuffer();
                            for ( int i = 0; i < digest.length; i++ )
                                digestString.append(Integer.toHexString( digest[i]&0xff));
                        }
                    } finally {
                        if (zippedOut != null) try {zippedOut.close();} catch(Exception e) {}
                        if (o != null) try {o.close(); o = null;} catch(Exception e) {}
                        if (fis != null) try {fis.close(); fis=null;} catch(Exception e) {}
                    }
                    long contentLength     = result.length;
                    String contentEncoding = (zipContent)?"gzip":null;
                    httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null, mimeType, contentLength, targetDate, null, tp.getOutgoingHeader(), contentEncoding, null, nocache);
                    if (! method.equals(httpHeader.METHOD_HEAD)) {
                        Thread.sleep(200);
                        serverFileUtils.write(result, out);
                    }
                } else {
                    int statusCode = 200;
                    int rangeStartOffset = 0;
                    httpHeader header = new httpHeader();
                    header.put(httpHeader.ACCEPT_RANGES, "bytes");
                    String targetMD5 = null;
                    File targetMd5File = new File(targetFile + ".md5");
                    try {
                        if (targetMd5File.exists()) {
                            targetMD5 = new String(serverFileUtils.read(targetMd5File));
                            pos = targetMD5.indexOf('\n');
                           if (pos >= 0) {
                               targetMD5 = targetMD5.substring(0, pos);
                           }
                           header.put(httpHeader.ETAG, targetMD5);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    if (requestHeader.containsKey(httpHeader.RANGE)) {
                        Object ifRange = requestHeader.ifRange();
                        if ((ifRange == null)||
                            (ifRange instanceof Date && targetFile.lastModified() == ((Date)ifRange).getTime()) ||
                            (ifRange instanceof String && ifRange.equals(targetMD5))) {
                            String rangeHeaderVal = ((String) requestHeader.get(httpHeader.RANGE)).trim();
                            if (rangeHeaderVal.startsWith("bytes=")) {
                                String rangesVal = rangeHeaderVal.substring("bytes=".length());
                                String[] ranges = rangesVal.split(",");
                                if ((ranges.length == 1)&&(ranges[0].endsWith("-"))) {
                                    rangeStartOffset = Integer.valueOf(ranges[0].substring(0,ranges[0].length()-1)).intValue();
                                    statusCode = 206;
                                    if (header == null) header = new httpHeader();
                                    header.put(httpHeader.CONTENT_RANGE, "bytes " + rangeStartOffset + "-" + (targetFile.length()-1) + "/" + targetFile.length());
                                }
                            }
                        }
                    }
                    targetDate = new Date(targetFile.lastModified());
                    long   contentLength    = (zipContent)?-1:targetFile.length()-rangeStartOffset;
                    String contentEncoding  = (zipContent)?"gzip":null;
                    String transferEncoding = (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1))?null:(zipContent)?"chunked":null;
                    if (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1) && zipContent) forceConnectionClose();
                    httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, statusCode, null, mimeType, contentLength, targetDate, null, header, contentEncoding, transferEncoding, nocache);
                    if (!method.equals(httpHeader.METHOD_HEAD)) {
                        httpChunkedOutputStream chunkedOut = null;
                        GZIPOutputStream zipped = null;
                        OutputStream newOut = out;
                        if (transferEncoding != null) {
                            chunkedOut = new httpChunkedOutputStream(newOut);
                            newOut = chunkedOut;
                        }
                        if (contentEncoding != null) {
                            zipped = new GZIPOutputStream(newOut);
                            newOut = zipped;
                        }
                        serverFileUtils.copyRange(targetFile,newOut,rangeStartOffset);
                        if (zipped != null) {
                            zipped.flush();
                            zipped.finish();
                        }
                        if (chunkedOut != null) {
                            chunkedOut.finish();
                        }
                    }
                }
            } else {
                httpd.sendRespondError(conProp,out,3,404,"File not Found",null,null);
                return;
            }
        } catch (Exception e) {
            try {
                int httpStatusCode = 400;
                String httpStatusText = null;
                StringBuffer errorMessage = new StringBuffer();
                Exception errorExc = null;
                String errorMsg = e.getMessage();
                if (
                        (e instanceof InterruptedException) ||
                        ((errorMsg != null) && (errorMsg.startsWith("Socket closed")) && (Thread.currentThread().isInterrupted()))
                   ) {
                    errorMessage.append("Interruption detected while processing query.");
                    httpStatusCode = 503;
                } else {
                    if ((errorMsg != null) &&
                        (
                           errorMsg.startsWith("Broken pipe") ||
                           errorMsg.startsWith("Connection reset") ||
                           errorMsg.startsWith("Software caused connection abort")
                       )) {
                        errorMessage.append("Client unexpectedly closed connection while processing query.");
                    } else if ((errorMsg != null) && (errorMsg.startsWith("Connection timed out"))) {
                        errorMessage.append("Connection timed out.");
                    } else {
                        errorMessage.append("Unexpected error while processing query.");
                        httpStatusCode = 500;
                        errorExc = e;
                    }
                }
                errorMessage.append("\nSession: ").append(Thread.currentThread().getName())
                            .append("\nQuery:   ").append(path)
                            .append("\nClient:  ").append(conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP,"unknown"))
                            .append("\nReason:  ").append(e.toString());
                if (!conProp.containsKey(httpHeader.CONNECTION_PROP_PROXY_RESPOND_HEADER)) {
                    httpd.sendRespondError(conProp,out, 4, httpStatusCode, httpStatusText, errorMessage.toString(),errorExc);
                } else {
                    this.forceConnectionClose();
                }
                if (httpStatusCode == 500) {
                    this.theLogger.logWarning(errorMessage.toString(),e);
                }
            } catch (Exception ee) {
                this.forceConnectionClose();
            }
        } finally {
            try {out.flush();}catch (Exception e) {}
            if (((String)requestHeader.get(httpHeader.CONNECTION, "close")).indexOf("keep-alive") == -1) {
                try {Thread.sleep(1000);} catch (InterruptedException e) {}
            }
        }
    }


Input:
	public static void doActiveUpdate(final Context context, Boolean useGPS) {
		Log.d(DEBUG_TAG, "force active location update");
		if (locationListener == null) {
			Log.d(DEBUG_TAG, "set up new LocationListener");
			locationListener = new LocationListener() {
				public void onLocationChanged(Location location) {
					Log.d(DEBUG_TAG, "locationListener: location changed. disabling myself");
					LocationManager locationManager = (LocationManager) context
							.getSystemService(Context.LOCATION_SERVICE);
					try {
						Thread.sleep(4000);
					} catch (InterruptedException e) {
					}
					locationManager.removeUpdates(locationListener);
					locationListener = null;
				}
				public void onProviderDisabled(String provider) {
				}
				public void onProviderEnabled(String provider) {
				}
				public void onStatusChanged(String provider, int status,
						Bundle extras) {
				}
			};
			LocationManager locationManager = (LocationManager) context
					.getSystemService(Context.LOCATION_SERVICE);
			SharedPreferences SP = PreferenceManager
					.getDefaultSharedPreferences(context);
			if (SP.getBoolean("activeupdate", false) && useGPS) {
				if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
					Log.d(DEBUG_TAG, "GPS disabled, requesting network location update");
					Toast.makeText(
							context,
							context.getResources().getString(
									R.string.msg_gpsdisabled),
							Toast.LENGTH_SHORT).show();
					locationManager.requestLocationUpdates(
							LocationManager.NETWORK_PROVIDER, 0, 0,
							locationListener);
				} else {
					Log.d(DEBUG_TAG, "requesting GPS location update");
					locationManager.requestLocationUpdates(
							LocationManager.GPS_PROVIDER, 0, 0,
							locationListener);
				}
			} else {
				Log.d(DEBUG_TAG, "Active lookup disabled, requesting network location update");
				locationManager.requestLocationUpdates(
						LocationManager.NETWORK_PROVIDER, 0, 0,
						locationListener);
			}
			AlarmManager alarmManager = (AlarmManager) context
					.getSystemService(Context.ALARM_SERVICE);
			Intent i = new Intent(context, LocationReceiver.class);
			i.putExtra("de.h3ndrik.openlocation.cancelgps", "true");
			PendingIntent pendingIntent = PendingIntent
					.getBroadcast(context, 0, i,
							PendingIntent.FLAG_UPDATE_CURRENT);
			alarmManager.set(AlarmManager.RTC_WAKEUP,
					System.currentTimeMillis() + 16000,
					pendingIntent);
			Log.d(DEBUG_TAG, "cancelUpdates alarm set");
		}
		else {
			Log.d(DEBUG_TAG, "conflicting locationListener, skipping");
		}
	}

Output:
	public static void doActiveUpdate(final Context context, Boolean useGPS) {
		Log.d(DEBUG_TAG, "force active location update");
		if (locationListener == null) {
			Log.d(DEBUG_TAG, "set up new LocationListener");
			locationListener = new LocationListener() {
				public void onLocationChanged(Location location) {
					Log.d(DEBUG_TAG, "locationListener: location changed. disabling myself");
					LocationManager locationManager = (LocationManager) context
							.getSystemService(Context.LOCATION_SERVICE);
					try {
						Thread.sleep(4000);
					} catch (InterruptedException e) {
					}
					locationManager.removeUpdates(this);
					locationListener = null;
				}
				public void onProviderDisabled(String provider) {
				}
				public void onProviderEnabled(String provider) {
				}
				public void onStatusChanged(String provider, int status,
						Bundle extras) {
				}
			};
			LocationManager locationManager = (LocationManager) context
					.getSystemService(Context.LOCATION_SERVICE);
			SharedPreferences SP = PreferenceManager
					.getDefaultSharedPreferences(context);
			if (SP.getBoolean("activeupdate", false) && useGPS) {
				if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
					Log.d(DEBUG_TAG, "GPS disabled, requesting network location update");
					Toast.makeText(
							context,
							context.getResources().getString(
									R.string.msg_gpsdisabled),
							Toast.LENGTH_SHORT).show();
					locationManager.requestLocationUpdates(
							LocationManager.NETWORK_PROVIDER, 0, 0,
							locationListener);
				} else {
					Log.d(DEBUG_TAG, "requesting GPS location update");
					locationManager.requestLocationUpdates(
							LocationManager.GPS_PROVIDER, 0, 0,
							locationListener);
				}
			} else {
				Log.d(DEBUG_TAG, "Active lookup disabled, requesting network location update");
				locationManager.requestLocationUpdates(
						LocationManager.NETWORK_PROVIDER, 0, 0,
						locationListener);
			}
			AlarmManager alarmManager = (AlarmManager) context
					.getSystemService(Context.ALARM_SERVICE);
			Intent i = new Intent(context, LocationReceiver.class);
			i.putExtra("de.h3ndrik.openlocation.cancelgps", "true");
			PendingIntent pendingIntent = PendingIntent
					.getBroadcast(context, 0, i,
							PendingIntent.FLAG_UPDATE_CURRENT);
			alarmManager.set(AlarmManager.RTC_WAKEUP,
					System.currentTimeMillis() + 16000,
					pendingIntent);
			Log.d(DEBUG_TAG, "cancelUpdates alarm set");
		}
		else {
			Log.d(DEBUG_TAG, "conflicting locationListener, skipping");
		}
	}


Input:
	protected void doExecute(IProgressMonitor monitor) throws ExecutionException {
		super.doExecute(monitor);
		List modelsToImport = (List) model.getProperty(IEARComponentImportDataModelProperties.HANDLED_PROJECT_MODELS_LIST);
		try {
			IDataModel importModel = null;
			List allModels = (List) model.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST);
			List componentToAdd = new ArrayList();
			Map componentToURIMap = new HashMap();
			for (int i = 0; i < allModels.size(); i++) {
				importModel = (IDataModel) allModels.get(i);
				if (modelsToImport.contains(importModel)) {
					String archiveUri = ((Archive) importModel.getProperty(IEARComponentImportDataModelProperties.FILE)).getURI();
					importModel.setProperty(IJ2EEComponentImportDataModelProperties.CLOSE_ARCHIVE_ON_DISPOSE, Boolean.FALSE);
					IDataModel compCreationModel = importModel.getNestedModel("IJ2EEArtifactImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION");
					compCreationModel.setProperty(IJ2EEFacetProjectCreationDataModelProperties.MODULE_URI, archiveUri);
					try {
						importModel.getDefaultOperation().execute(monitor, info);
					} catch (ExecutionException e) {
						Logger.getLogger().logError(e);
					}
					IVirtualComponent component = (IVirtualComponent) importModel.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT);
					componentToAdd.add(component);
					componentToURIMap.put(component, archiveUri);
				}
			}
			if (componentToAdd.size() > 0) {
				IDataModel addComponentsDM = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider());
				addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, virtualComponent);
				addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, componentToAdd);
				addComponentsDM.setProperty(IAddComponentToEnterpriseApplicationDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, componentToURIMap);
				addComponentsDM.getDefaultOperation().execute(monitor, info);
			}
			try {
				fixupClasspaths(modelsToImport, virtualComponent);
			} catch (JavaModelException e) {
				Logger.getLogger().logError(e);
			}
		} finally {
			if (null != artifactEdit) {
				artifactEdit.dispose();
				artifactEdit = null;
			}
			resetDisposeImportModels();
		}
	}

Output:
	protected void doExecute(IProgressMonitor monitor) throws ExecutionException {
		super.doExecute(monitor);
		List modelsToImport = (List) model.getProperty(IEARComponentImportDataModelProperties.HANDLED_PROJECT_MODELS_LIST);
		try {
			IDataModel importModel = null;
			List allModels = (List) model.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST);
			List componentToAdd = new ArrayList();
			Map componentToURIMap = new HashMap();
			for (int i = 0; i < allModels.size(); i++) {
				importModel = (IDataModel) allModels.get(i);
				if (modelsToImport.contains(importModel)) {
					String archiveUri = ((Archive) importModel.getProperty(IEARComponentImportDataModelProperties.FILE)).getURI();
					importModel.setProperty(IJ2EEComponentImportDataModelProperties.CLOSE_ARCHIVE_ON_DISPOSE, Boolean.FALSE);
					IDataModel compCreationModel = importModel.getNestedModel("IJ2EEArtifactImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION");
					if (compCreationModel.isProperty(IJ2EEFacetProjectCreationDataModelProperties.MODULE_URI))
						compCreationModel.setProperty(IJ2EEFacetProjectCreationDataModelProperties.MODULE_URI, archiveUri);
					try {
						importModel.getDefaultOperation().execute(monitor, info);
					} catch (ExecutionException e) {
						Logger.getLogger().logError(e);
					}
					IVirtualComponent component = (IVirtualComponent) importModel.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT);
					componentToAdd.add(component);
					componentToURIMap.put(component, archiveUri);
				}
			}
			if (componentToAdd.size() > 0) {
				IDataModel addComponentsDM = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider());
				addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, virtualComponent);
				addComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, componentToAdd);
				addComponentsDM.setProperty(IAddComponentToEnterpriseApplicationDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, componentToURIMap);
				addComponentsDM.getDefaultOperation().execute(monitor, info);
			}
			try {
				fixupClasspaths(modelsToImport, virtualComponent);
			} catch (JavaModelException e) {
				Logger.getLogger().logError(e);
			}
		} finally {
			if (null != artifactEdit) {
				artifactEdit.dispose();
				artifactEdit = null;
			}
			resetDisposeImportModels();
		}
	}


Input:
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Can't vanish if not a player!");
            return true;
        }
        if (args.length == 0) {
            boolean vanishing = true;
            String bit;
            if (this.vanished.contains(sender.getName())) {
                vanishing = false;
                this.vanished.remove(sender.getName());
                bit = "unvanished";
            } else {
                this.vanished.add(sender.getName());
                bit = "vanished";
            }
            final Player player = (Player) sender;
            for (final Player plr : this.getServer().getOnlinePlayers()) {
                if (vanishing && !plr.hasPermission(this.vanishPerm)) {
                    plr.hidePlayer(player);
                } else if (!vanishing && plr.canSee(player)) {
                    plr.showPlayer(player);
                }
            }
            this.getServer().broadcast(ChatColor.AQUA + player.getName() + " has " + bit, this.vanishPerm);
        } else if (args[0].equalsIgnoreCase("list")) {
            final StringBuilder list = new StringBuilder();
            list.append(ChatColor.AQUA);
            list.append("Vanished (");
            list.append(this.vanished.size());
            list.append("): ");
            for (final String name : this.vanished) {
                list.append(name);
                list.append(" ,");
            }
            list.setLength(list.length() - 2);
            sender.sendMessage(list.toString());
        }
        return true;
    }

Output:
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Can't vanish if not a player!");
            return true;
        }
        if (args.length == 0) {
            boolean vanishing = true;
            String bit;
            if (this.vanished.contains(sender.getName())) {
                vanishing = false;
                this.vanished.remove(sender.getName());
                bit = "unvanished";
            } else {
                this.vanished.add(sender.getName());
                bit = "vanished";
            }
            final Player player = (Player) sender;
            for (final Player plr : this.getServer().getOnlinePlayers()) {
                if (vanishing && !plr.hasPermission(this.vanishPerm)) {
                    plr.hidePlayer(player);
                } else if (!vanishing && !plr.canSee(player)) {
                    plr.showPlayer(player);
                }
            }
            this.getServer().broadcast(ChatColor.AQUA + player.getName() + " has " + bit, this.vanishPerm);
        } else if (args[0].equalsIgnoreCase("list")) {
            final StringBuilder list = new StringBuilder();
            list.append(ChatColor.AQUA);
            list.append("Vanished (");
            list.append(this.vanished.size());
            list.append("): ");
            for (final String name : this.vanished) {
                list.append(name);
                list.append(", ");
            }
            list.setLength(list.length() - 2);
            sender.sendMessage(list.toString());
        }
        return true;
    }


Input:
	public Event(){
		this.id = UUID.randomUUID().toString().toLowerCase();
	}

Output:
	public Event(){
		this.id = UUID.randomUUID().toString();
	}


Input:
	public MenuManager getSubMenuManager(TaskListView view, ITaskListElement selection) {
		final ITaskListElement selectedElement = selection;
		final TaskListView taskListView = view;
		final MenuManager subMenuManager = new MenuManager(LABEL_REMINDER);
		if (selectedElement instanceof ITask) {
			task = (ITask) selectedElement;
		} else if (selectedElement instanceof AbstractQueryHit) {
			if (((AbstractQueryHit) selectedElement).getCorrespondingTask() != null) {
				task = ((AbstractQueryHit) selectedElement).getCorrespondingTask();
			}
		}
		Action action = new Action() {
			@Override
			public void run() {
				Calendar reminderCalendar = GregorianCalendar.getInstance();
				MylarTaskListPlugin.getTaskListManager().setScheduledToday(reminderCalendar);
				MylarTaskListPlugin.getTaskListManager().setReminder(task, reminderCalendar.getTime());
			}
		};
		action.setText(LABEL_TODAY);
		action.setEnabled(canSchedule());
		subMenuManager.add(action);
		if (MylarTaskListPlugin.getTaskListManager().isReminderToday(task)) {
			action.setChecked(true);
		}
		subMenuManager.add(new Separator());
		final int today = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
		boolean reachedEndOfWeek = false;
		for (int i = today+1; i <= 8 && !reachedEndOfWeek; i++) {
			final int day = i;
			action = new Action() {
				@Override
				public void run() {
					Calendar reminderCalendar = GregorianCalendar.getInstance();
					int dueIn = day-today;
					MylarTaskListPlugin.getTaskListManager().setSecheduledIn(reminderCalendar, dueIn);
					MylarTaskListPlugin.getTaskListManager().setReminder(task, reminderCalendar.getTime());
				}
			};
			getDayLabel(i, action);
			int tasksCheduledOn = task.getReminderDate().getDay();
			if (MylarTaskListPlugin.getTaskListManager().isReminderThisWeek(task)) {
				if (tasksCheduledOn+1 == day) {
					action.setChecked(true);
				} else if (tasksCheduledOn ==0 && day == 8) {
					action.setChecked(true);
				}
			}
			action.setEnabled(canSchedule());
			subMenuManager.add(action);
		}
		subMenuManager.add(new Separator());
		action = new Action() {
			@Override
			public void run() {
				MylarTaskListPlugin.getTaskListManager().setReminder(task,
						MylarTaskListPlugin.getTaskListManager().getActivityNextWeek().getStart().getTime());
			}
		};
		action.setText(LABEL_NEXT_WEEK);
		action.setEnabled(canSchedule());
		if (MylarTaskListPlugin.getTaskListManager().isReminderAfterThisWeek(task) &&
			!MylarTaskListPlugin.getTaskListManager().isReminderLater(task)) {
			action.setChecked(true);
		}
		subMenuManager.add(action);
		action = new Action() {
			@Override
			public void run() {
				MylarTaskListPlugin.getTaskListManager().setReminder(task,
						MylarTaskListPlugin.getTaskListManager().getActivityFuture().getStart().getTime());
			}
		};
		action.setText(LABEL_FUTURE);
		action.setEnabled(canSchedule());
		if (MylarTaskListPlugin.getTaskListManager().isReminderLater(task)) {
			action.setChecked(true);
		}
		subMenuManager.add(action);
		subMenuManager.add(new Separator());
		action = new Action() {
			@Override
			public void run() {
				Calendar theCalendar = GregorianCalendar.getInstance();
				if(task.getReminderDate() != null) {
					theCalendar.setTime(task.getReminderDate());
				}
				DateSelectionDialog reminderDialog = new DateSelectionDialog(taskListView.getSite().getShell(), theCalendar, ReminderCellEditor.REMINDER_DIALOG_TITLE);
				int result = reminderDialog.open();
				if (result == Window.OK) {
					MylarTaskListPlugin.getTaskListManager().setReminder(task, reminderDialog.getDate());
				}
			}
		};
		action.setText(LABEL_CALENDAR);
		action.setEnabled(canSchedule());
		subMenuManager.add(action);
		action = new Action() {
			@Override
			public void run() {
				MylarTaskListPlugin.getTaskListManager().setReminder(task, null);
			}
		};
		action.setText(LABEL_CLEAR);
		action.setEnabled(task != null);
		subMenuManager.add(action);
		return subMenuManager;
	}

Output:
	public MenuManager getSubMenuManager(TaskListView view, ITaskListElement selection) {
		final ITaskListElement selectedElement = selection;
		final TaskListView taskListView = view;
		final MenuManager subMenuManager = new MenuManager(LABEL_REMINDER);
		if (selectedElement instanceof ITask) {
			task = (ITask) selectedElement;
		} else if (selectedElement instanceof AbstractQueryHit) {
			if (((AbstractQueryHit) selectedElement).getCorrespondingTask() != null) {
				task = ((AbstractQueryHit) selectedElement).getCorrespondingTask();
			}
		}
		Action action = new Action() {
			@Override
			public void run() {
				Calendar reminderCalendar = GregorianCalendar.getInstance();
				MylarTaskListPlugin.getTaskListManager().setScheduledToday(reminderCalendar);
				MylarTaskListPlugin.getTaskListManager().setReminder(task, reminderCalendar.getTime());
			}
		};
		action.setText(LABEL_TODAY);
		action.setEnabled(canSchedule());
		subMenuManager.add(action);
		if (MylarTaskListPlugin.getTaskListManager().isReminderToday(task)) {
			action.setChecked(true);
		}
		subMenuManager.add(new Separator());
		final int today = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
		boolean reachedEndOfWeek = false;
		for (int i = today+1; i <= 8 && !reachedEndOfWeek; i++) {
			final int day = i;
			action = new Action() {
				@Override
				public void run() {
					Calendar reminderCalendar = GregorianCalendar.getInstance();
					int dueIn = day-today;
					MylarTaskListPlugin.getTaskListManager().setSecheduledIn(reminderCalendar, dueIn);
					MylarTaskListPlugin.getTaskListManager().setReminder(task, reminderCalendar.getTime());
				}
			};
			getDayLabel(i, action);
			if (task != null) {
				int tasksCheduledOn = task.getReminderDate().getDay();
				if (MylarTaskListPlugin.getTaskListManager().isReminderThisWeek(task)) {
					if (tasksCheduledOn+1 == day) {
						action.setChecked(true);
					} else if (tasksCheduledOn ==0 && day == 8) {
						action.setChecked(true);
					}
				}
			}
			action.setEnabled(canSchedule());
			subMenuManager.add(action);
		}
		subMenuManager.add(new Separator());
		action = new Action() {
			@Override
			public void run() {
				MylarTaskListPlugin.getTaskListManager().setReminder(task,
						MylarTaskListPlugin.getTaskListManager().getActivityNextWeek().getStart().getTime());
			}
		};
		action.setText(LABEL_NEXT_WEEK);
		action.setEnabled(canSchedule());
		if (MylarTaskListPlugin.getTaskListManager().isReminderAfterThisWeek(task) &&
			!MylarTaskListPlugin.getTaskListManager().isReminderLater(task)) {
			action.setChecked(true);
		}
		subMenuManager.add(action);
		action = new Action() {
			@Override
			public void run() {
				MylarTaskListPlugin.getTaskListManager().setReminder(task,
						MylarTaskListPlugin.getTaskListManager().getActivityFuture().getStart().getTime());
			}
		};
		action.setText(LABEL_FUTURE);
		action.setEnabled(canSchedule());
		if (MylarTaskListPlugin.getTaskListManager().isReminderLater(task)) {
			action.setChecked(true);
		}
		subMenuManager.add(action);
		subMenuManager.add(new Separator());
		action = new Action() {
			@Override
			public void run() {
				Calendar theCalendar = GregorianCalendar.getInstance();
				if(task.getReminderDate() != null) {
					theCalendar.setTime(task.getReminderDate());
				}
				DateSelectionDialog reminderDialog = new DateSelectionDialog(taskListView.getSite().getShell(), theCalendar, ReminderCellEditor.REMINDER_DIALOG_TITLE);
				int result = reminderDialog.open();
				if (result == Window.OK) {
					MylarTaskListPlugin.getTaskListManager().setReminder(task, reminderDialog.getDate());
				}
			}
		};
		action.setText(LABEL_CALENDAR);
		action.setEnabled(canSchedule());
		subMenuManager.add(action);
		action = new Action() {
			@Override
			public void run() {
				MylarTaskListPlugin.getTaskListManager().setReminder(task, null);
			}
		};
		action.setText(LABEL_CLEAR);
		action.setEnabled(task != null);
		subMenuManager.add(action);
		return subMenuManager;
	}


Input:
    public void addJourney(final Place start, final Place end, final List<String> activities) {
        final List<JourneyStep> steps = JourneyUtil.getSteps(activities);
        final Collection<Journey> journeys = findJourneys(start, end);
        for (Journey journey : journeys) {
            if (journey.getSteps() == steps.size()) {
                final List<JourneyStep> theirSteps = getSteps(journey);
                if (theirSteps.equals(steps)) {
                    updateJourneyStatement.bindLong(1, journey.getId());
                    updateJourneyStatement.execute();
                    return;
                }
            }
        }
        insertJourneyStatement.bindLong(1, start.getId());
        insertJourneyStatement.bindLong(2, end.getId());
        insertJourneyStatement.bindLong(3, steps.size());
        final long id = insertJourneyStatement.executeInsert();
        long next = 0;
        for (int i = steps.size() - 1; i >= 0; i--) {
            final JourneyStep step = steps.get(i);
            insertJourneyStepStatement.bindString(1, step.getActivity());
            insertJourneyStepStatement.bindLong(2, step.getRepetitions());
            insertJourneyStepStatement.bindLong(3, id);
            insertJourneyStepStatement.bindLong(4, next);
            next = insertJourneyStepStatement.executeInsert();
        }
    }

Output:
    public void addJourney(final Place start, final Place end, final List<String> activities) {
        final List<JourneyStep> steps = JourneyUtil.getSteps(activities);
        final Collection<Journey> journeys = findJourneys(start, end);
        for (Journey journey : journeys) {
            if (journey.getSteps() == steps.size()) {
                final List<JourneyStep> theirSteps = getSteps(journey);
                if (JourneyUtil.isCompatible(steps, theirSteps)) {
                    updateJourneyStatement.bindLong(1, journey.getId());
                    updateJourneyStatement.execute();
                    return;
                }
            }
        }
        insertJourneyStatement.bindLong(1, start.getId());
        insertJourneyStatement.bindLong(2, end.getId());
        insertJourneyStatement.bindLong(3, steps.size());
        final long id = insertJourneyStatement.executeInsert();
        long next = 0;
        for (int i = steps.size() - 1; i >= 0; i--) {
            final JourneyStep step = steps.get(i);
            insertJourneyStepStatement.bindString(1, step.getActivity());
            insertJourneyStepStatement.bindLong(2, step.getRepetitions());
            insertJourneyStepStatement.bindLong(3, id);
            insertJourneyStepStatement.bindLong(4, next);
            next = insertJourneyStepStatement.executeInsert();
        }
    }


Input:
   protected Stats executeMySQLImpl() {
      String readQuery = "SELECT name FROM ReadWriteTest WHERE id = 1";
      String writeUpdate = "UPDATE users SET name = '%s' WHERE id = 1";
      List<Long> readAfterWriteTimes = new ArrayList<Long>(TIMES);
      List<Long> writeAfterReadTimes = new ArrayList<Long>(TIMES);
      Statement statement = null;
      ResultSet results = null;
      try {
         statement = conn.createStatement();
         long time = System.currentTimeMillis();
         for (int i = 0; i < TIMES; i++) {
            results = statement.executeQuery(readQuery);
            if (i != 0) {
               readAfterWriteTimes.add(System.currentTimeMillis() - time);
            }
            time = System.currentTimeMillis();
            statement.executeUpdate(String.format(writeUpdate, randomStrings[i]));
            writeAfterReadTimes.add(System.currentTimeMillis() - time);
            time = System.currentTimeMillis();
         }
      } catch (Exception ex) {
         System.err.println("Error getting read/write times.");
         ex.printStackTrace(System.err);
      } finally {
         try {
            if (results != null) {
               results.close();
               results = null;
            }
            if (statement != null) {
               statement.close();
               statement = null;
            }
         } catch (SQLException sqlEx) {
            System.err.println("Error Closing results.");
         }
      }
      return new ReadWriteStats(readAfterWriteTimes, writeAfterReadTimes);
   }

Output:
   protected Stats executeMySQLImpl() {
      String readQuery = "SELECT name FROM ReadWriteTest WHERE id = 1";
      String writeUpdate = "UPDATE ReadWriteTest SET name = '%s' WHERE id = 1";
      List<Long> readAfterWriteTimes = new ArrayList<Long>(TIMES);
      List<Long> writeAfterReadTimes = new ArrayList<Long>(TIMES);
      Statement statement = null;
      ResultSet results = null;
      try {
         statement = conn.createStatement();
         long time = System.currentTimeMillis();
         for (int i = 0; i < TIMES; i++) {
            results = statement.executeQuery(readQuery);
            if (i != 0) {
               readAfterWriteTimes.add(System.currentTimeMillis() - time);
            }
            time = System.currentTimeMillis();
            statement.executeUpdate(String.format(writeUpdate, randomStrings[i]));
            writeAfterReadTimes.add(System.currentTimeMillis() - time);
            time = System.currentTimeMillis();
         }
      } catch (Exception ex) {
         System.err.println("Error getting read/write times.");
         ex.printStackTrace(System.err);
      } finally {
         try {
            if (results != null) {
               results.close();
               results = null;
            }
            if (statement != null) {
               statement.close();
               statement = null;
            }
         } catch (SQLException sqlEx) {
            System.err.println("Error Closing results.");
         }
      }
      return new ReadWriteStats(readAfterWriteTimes, writeAfterReadTimes);
   }


Input:
  private long getTimeForSituation(SituationBean bean) {
    TimeRangeBean window = bean.getPublicationWindow();
    if (window != null && window.getFrom() != 0)
      return window.getFrom();
    if (CollectionsLibrary.isEmpty(bean.getConsequences())) {
      long t = Long.MAX_VALUE;
      for (SituationConsequenceBean consequence : bean.getConsequences()) {
        TimeRangeBean period = consequence.getPeriod();
        if (period != null && period.getFrom() != 0)
          t = Math.min(t, period.getFrom());
      }
      if (t != Long.MAX_VALUE)
        return t;
    }
    return bean.getCreationTime();
  }

Output:
  private long getTimeForSituation(SituationBean bean) {
    TimeRangeBean window = bean.getPublicationWindow();
    if (window != null && window.getFrom() != 0)
      return window.getFrom();
    if (! CollectionsLibrary.isEmpty(bean.getConsequences())) {
      long t = Long.MAX_VALUE;
      for (SituationConsequenceBean consequence : bean.getConsequences()) {
        TimeRangeBean period = consequence.getPeriod();
        if (period != null && period.getFrom() != 0)
          t = Math.min(t, period.getFrom());
      }
      if (t != Long.MAX_VALUE)
        return t;
    }
    return bean.getCreationTime();
  }


Input:
	public void testContributeWithBadContributorId() {
		try {
			counter.contribute(digitalCard, new UserUrl("bob", "deus.org"));
			fail("contribution with different contributor id than in the DC is possible");
		}
		catch(RuntimeException e) {
			assertEquals("ID of the contributor does not match the id in the digital card!", e.getMessage());
		}
	}

Output:
	public void testContributeWithBadContributorId() {
		try {
			counter.contributeOther(digitalCard, new UserUrl("bob", "deus.org"));
			fail("contribution with different contributor id than in the DC is possible");
		}
		catch(RuntimeException e) {
			assertEquals("ID of the contributor does not match the id in the digital card!", e.getMessage());
		}
	}