// Path: src/com/googlecode/yatspec/parsing/JavaSource.java
// public class JavaSource implements Value<String> {
//     private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)";
//     private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)";
//     private final String value;
// 
//     public JavaSource(String value) {
//         this.value = value;
//     }
// 
//     @Override
//     public String value() {
//         return value;
//     }
// 
//     public JavaSource replace(final List<String> oldValues, final List<String> newValues) {
//         String result = value();
//         for (int i = 0; i < oldValues.size(); i++) {
//             String header = oldValues.get(i);
//             String value = newValues.get(i);
//             result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2");
//         }
//         return new JavaSource(result);
//     }
// 
//     private static String displayValue(String value) {
//         if (value.matches("[A-Z0-9]*")) {
//             return value;
//         }
//         return "\"" + value + "\"";
//     }
// 
//     @Override
//     public String toString() {
//         return value();
//     }
// }
// 
// Path: src/com/googlecode/yatspec/rendering/Renderer.java
// public interface Renderer<T> {
//     String render(T t) throws Exception;
// }
// 
// Path: src/com/googlecode/yatspec/rendering/html/JavaSourceRenderer.java
// public static Sequence<String> lines(final String sourceCode) {
//     return sequence(sourceCode.split(lineSeparator()));
// }


import com.googlecode.totallylazy.Callable1;
import com.googlecode.totallylazy.Predicate;
import com.googlecode.totallylazy.Sequence;
import com.googlecode.totallylazy.regex.Regex;
import com.googlecode.yatspec.parsing.JavaSource;
import com.googlecode.yatspec.rendering.Renderer;
import static com.googlecode.totallylazy.Predicates.not;
import static com.googlecode.totallylazy.Strings.EMPTY;
import static com.googlecode.yatspec.rendering.html.JavaSourceRenderer.lines;
import static java.lang.System.lineSeparator;
package com.googlecode.yatspec.rendering.wiki;



public class JavaSourceRenderer implements Renderer<JavaSource> {
    @Override
    public String render(JavaSource javaSource) throws Exception {
        return removeBlankLines(removeIndentation(javaSource.value()));
    }

    private String removeBlankLines(String value) {
        return value.replaceAll("^\\s+|\\s+$", EMPTY);
    }

    private String removeIndentation(String value) {
        Sequence<String> lines = lines(value);
// Path: src/com/googlecode/yatspec/parsing/JavaSource.java
// public class JavaSource implements Value<String> {
//     private static final String COMMA_OR_OPENING_BRACKET = "(\\s*[\\(\\,\"]\\s*)";
//     private static final String COMMA_OR_CLOSING_BRACKET = "(\\s*[\\,\\)\"]\\s*)";
//     private final String value;
// 
//     public JavaSource(String value) {
//         this.value = value;
//     }
// 
//     @Override
//     public String value() {
//         return value;
//     }
// 
//     public JavaSource replace(final List<String> oldValues, final List<String> newValues) {
//         String result = value();
//         for (int i = 0; i < oldValues.size(); i++) {
//             String header = oldValues.get(i);
//             String value = newValues.get(i);
//             result = result.replaceAll(COMMA_OR_OPENING_BRACKET + header + COMMA_OR_CLOSING_BRACKET, "$1" + displayValue(value) + "$2");
//         }
//         return new JavaSource(result);
//     }
// 
//     private static String displayValue(String value) {
//         if (value.matches("[A-Z0-9]*")) {
//             return value;
//         }
//         return "\"" + value + "\"";
//     }
// 
//     @Override
//     public String toString() {
//         return value();
//     }
// }
// 
// Path: src/com/googlecode/yatspec/rendering/Renderer.java
// public interface Renderer<T> {
//     String render(T t) throws Exception;
// }
// 
// Path: src/com/googlecode/yatspec/rendering/html/JavaSourceRenderer.java
// public static Sequence<String> lines(final String sourceCode) {
//     return sequence(sourceCode.split(lineSeparator()));
// }


// Path: src/com/googlecode/yatspec/rendering/wiki/JavaSourceRenderer.java
import com.googlecode.totallylazy.Callable1;
import com.googlecode.totallylazy.Predicate;
import com.googlecode.totallylazy.Sequence;
import com.googlecode.totallylazy.regex.Regex;
import com.googlecode.yatspec.parsing.JavaSource;
import com.googlecode.yatspec.rendering.Renderer;
import static com.googlecode.totallylazy.Predicates.not;
import static com.googlecode.totallylazy.Strings.EMPTY;
import static com.googlecode.yatspec.rendering.html.JavaSourceRenderer.lines;
import static java.lang.System.lineSeparator;

package com.googlecode.yatspec.rendering.wiki;



public class JavaSourceRenderer implements Renderer<JavaSource> {
    @Override
    public String render(JavaSource javaSource) throws Exception {
        return removeBlankLines(removeIndentation(javaSource.value()));
    }

    private String removeBlankLines(String value) {
        return value.replaceAll("^\\s+|\\s+$", EMPTY);
    }

    private String removeIndentation(String value) {
        Sequence<String> lines = lines(value);
        String indentation = lines.