Java Code Examples for org.codehaus.groovy.runtime.StringGroovyMethods

The following examples show how to use org.codehaus.groovy.runtime.StringGroovyMethods. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: native-samples   Source File: SourceCopyTask.java    License: Apache License 2.0 6 votes vote down vote up
public void doCopyDir(String templateDirName, String srcName, String targetDir, Action<TemplateDirectory> dirAction) {
    String srcFileName = templateDirName + "/" + srcName;
    File srcDir = getTemplatesDir().dir(srcFileName).get().getAsFile();
    if (!srcDir.isDirectory() || srcDir.list().length == 0) {
        return;

    }

    final TemplateDirectory dirDetails = new TemplateDirectory(srcName);
    dirAction.execute(dirDetails);
    File destDir = getSampleDir().dir(targetDir + "/" + dirDetails.getTargetDirName()).get().getAsFile();
    copy(srcDir, destDir, dirDetails.getLineFilter(), dirDetails.getRecursive());
    if (dirDetails.getRecursive()) {
        return;

    }

    Arrays.stream(srcDir.listFiles()).forEach(f -> {
        if (f.isDirectory() && !f.getName().equals(".gradle")) {
            doCopyDir(templateDirName, StringGroovyMethods.asBoolean(srcName) ? srcName + "/" + f.getName() : f.getName(), targetDir, dirAction);
        }
    });
}
 
Example 2
Source Project: groovy   Source File: GroovyDocToolTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testAbstractMethods() throws Exception {
    final String base = "org/codehaus/groovy/tools/groovydoc/testfiles";
    htmlTool.add(Arrays.asList(
        base + "/GroovyClassWithMultipleInterfaces.groovy",
        base + "/JavaClassWithDiamond.java"
    ));

    final MockOutputTool output = new MockOutputTool();
    htmlTool.renderToOutput(output, MOCK_DIR);

    final String groovydoc = output.getText(MOCK_DIR + "/" + base + "/GroovyClassWithMultipleInterfaces.html");
    final String javadoc = StringGroovyMethods.normalize(output.getText(MOCK_DIR + "/" + base + "/JavaClassWithDiamond.html"));

    final Pattern methodSummary = Pattern.compile("<code>(public&nbsp;)?abstract&nbsp;void</code>");
    final Pattern methodDetails = Pattern.compile("<h4>(public&nbsp;)?abstract&nbsp;void <strong>link</strong>");

    assertTrue("The Groovy method summary should contain 'abstract'", methodSummary.matcher(groovydoc).find());
    assertTrue("The Java method summary should contain 'abstract'", methodSummary.matcher(javadoc).find());
    assertTrue("The Groovy method details should contain 'abstract'", methodDetails.matcher(groovydoc).find());
    assertTrue("The Java method details should contain 'abstract'", methodDetails.matcher(javadoc).find());
}
 
Example 3
Source Project: groovy   Source File: XmlUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Escape the following characters {@code " ' & < >} with their XML entities, e.g.
 * {@code "bread" & "butter"} becomes {@code &quot;bread&quot; &amp; &quot;butter&quot}.
 * Notes:<ul>
 * <li>Supports only the five basic XML entities (gt, lt, quot, amp, apos)</li>
 * <li>Does not escape control characters</li>
 * <li>Does not support DTDs or external entities</li>
 * <li>Does not treat surrogate pairs specially</li>
 * <li>Does not perform Unicode validation on its input</li>
 * </ul>
 *
 * @param orig the original String
 * @return A new string in which all characters that require escaping
 *         have been replaced with the corresponding XML entities.
 * @see #escapeControlCharacters(String)
 */
public static String escapeXml(String orig) {
    return StringGroovyMethods.collectReplacements(orig, new Closure<String>(null) {
        public String doCall(Character arg) {
            switch (arg) {
                case '&':
                    return "&amp;";
                case '<':
                    return "&lt;";
                case '>':
                    return "&gt;";
                case '"':
                    return "&quot;";
                case '\'':
                    return "&apos;";
            }
            return null;
        }
    });
}
 
Example 4
Source Project: groovy   Source File: StringUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static String replaceStandardEscapes(String text) {
	if (!text.contains(BACKSLASH)) {
		return text;
	}

	String result = StringGroovyMethods.replaceAll((CharSequence) text, STANDARD_ESCAPES_PATTERN, new Closure<Void>(null, null) {
		Object doCall(String _0, String _1, String _2) {
			if (isLengthOdd(_1)) {
				return _0;
			}

			Character character = STANDARD_ESCAPES.get(_2.charAt(0));
			return _1 + (character != null ? character : _2);
		}
	});

	return replace(result,"\\\\", "\\");
}
 
Example 5
Source Project: groovy   Source File: StringUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static String replaceLineEscape(String text) {
	if (!text.contains(BACKSLASH)) {
		return text;
	}

	text = StringGroovyMethods.replaceAll((CharSequence) text, LINE_ESCAPE_PATTERN, new Closure<Void>(null, null) {
		Object doCall(String _0, String _1) {
			if (isLengthOdd(_1)) {
				return _0;
			}

			return _1;
		}
	});

	return text;
}
 
Example 6
Source Project: groovy   Source File: BaseDuration.java    License: Apache License 2.0 6 votes vote down vote up
public String toString() {
    List buffer = new ArrayList();

    if (this.years != 0) buffer.add(this.years + " years");
    if (this.months != 0) buffer.add(this.months + " months");
    if (this.days != 0) buffer.add(this.days + " days");
    if (this.hours != 0) buffer.add(this.hours + " hours");
    if (this.minutes != 0) buffer.add(this.minutes + " minutes");

    if (this.seconds != 0 || this.millis != 0) {
        int norm_millis = this.millis % 1000;
        int norm_seconds = this.seconds + DefaultGroovyMethods.intdiv(this.millis - norm_millis, 1000).intValue();
        CharSequence millisToPad = "" + Math.abs(norm_millis);
        buffer.add((norm_seconds == 0 ? (norm_millis < 0 ? "-0" : "0") : norm_seconds) + "." + StringGroovyMethods.padLeft(millisToPad, 3, "0") + " seconds");
    }

    if (!buffer.isEmpty()) {
        return DefaultGroovyMethods.join(buffer.iterator(), ", ");
    } else {
        return "0";
    }
}
 
Example 7
Source Project: native-samples   Source File: ReleasePlugin.java    License: Apache License 2.0 5 votes vote down vote up
public void apply(final Project project) {
    project.getPluginManager().apply("swiftpm-export");
    project.getTasks().register("release", task -> {
        // Generate the Swift PM manifest prior to commit
        task.dependsOn(project.getTasks().named("generateSwiftPmManifest"));
        task.doLast(it -> {
            // Commit and tag changes
            project.exec(execSpec -> {
                execSpec.commandLine("git", "add", "Package.swift");
            });
            project.exec(execSpec -> {
                execSpec.commandLine("git", "commit", "-a", "-m", "version " + project.getVersion());
            });
            project.exec(execSpec -> {
                execSpec.commandLine("git", "tag", project.getVersion());
            });

            // Increment the version in the build script, for next release
            Pattern versionPattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d)");
            Matcher matcher = versionPattern.matcher(project.getVersion().toString());
            if (!matcher.matches()) {
                throw new GradleException("Could not parse project version \'" + project.getVersion() + "\'");
            }

            String newVersion = matcher.group(1) + "." + ((StringGroovyMethods.asType(matcher.group(2), Integer.class)) + 1) + ".0";
            String buildFileText = readFileAsString(project.getBuildFile());
            String updatedText = buildFileText.replaceAll("version\\s*=\\s*\'" + String.valueOf(project.getVersion()) + "\'", "version = \'" + newVersion + "\'");
            if (updatedText.equals(buildFileText)) {
                throw new GradleException("Could not update version in " + project.getBuildFile().getName());
            }

            writeFile(project.getBuildFile(), updatedText);
        });
    });
}
 
Example 8
Source Project: gradle-plugins   Source File: WarOverlayPlugin.java    License: MIT License 5 votes vote down vote up
private void configureOverlay(WarOverlay overlay, Callable<FileTree> warTree) {
    War warTask = overlay.getWarTask();

    String capitalizedWarTaskName = StringGroovyMethods.capitalize((CharSequence) warTask.getName());
    String capitalizedOverlayName = StringGroovyMethods.capitalize((CharSequence) overlay.getName());

    File destinationDir = new File(project.getBuildDir(), String.format("overlays/%s/%s", warTask.getName(), overlay.getName()));
    Action<CopySpec> extractOverlay = copySpec -> {
        copySpec.into(destinationDir);
        copySpec.from(warTree);
    };

    Sync extractOverlayTask = project.getTasks().create(String.format("extract%s%sOverlay", capitalizedOverlayName, capitalizedWarTaskName), Sync.class, extractOverlay);

    overlay.getWarCopySpec().from(extractOverlayTask);

    if (overlay.isEnableCompilation()) {

        if (!destinationDir.exists() || isEmpty(destinationDir)) {
            project.sync(extractOverlay);
        }

        project.getTasks().getByName(CLEAN_TASK_NAME).finalizedBy(extractOverlayTask);

        ConfigurableFileCollection classes = project.files(new File(destinationDir, "WEB-INF/classes"))
                .builtBy(extractOverlayTask);

        project.getDependencies().add(getClasspathConfigurationName(overlay), classes);

        FileTree libs = project.files(extractOverlayTask).builtBy(extractOverlayTask).getAsFileTree()
                .matching(patternFilterable -> patternFilterable.include("WEB-INF/lib/**"));

        project.getDependencies().add(getClasspathConfigurationName(overlay), libs);
    }
}
 
Example 9
Source Project: gradle-plugins   Source File: WarOverlayPlugin.java    License: MIT License 5 votes vote down vote up
private void configureOverlay(WarOverlay overlay, Callable<FileTree> warTree) {
    War warTask = overlay.getWarTask();

    String capitalizedWarTaskName = StringGroovyMethods.capitalize((CharSequence) warTask.getName());
    String capitalizedOverlayName = StringGroovyMethods.capitalize((CharSequence) overlay.getName());

    File destinationDir = new File(project.getBuildDir(), String.format("overlays/%s/%s", warTask.getName(), overlay.getName()));
    Action<CopySpec> extractOverlay = copySpec -> {
        copySpec.into(destinationDir);
        copySpec.from(warTree);
    };

    Sync extractOverlayTask = project.getTasks().create(String.format("extract%s%sOverlay", capitalizedOverlayName, capitalizedWarTaskName), Sync.class, extractOverlay);

    overlay.getWarCopySpec().from(extractOverlayTask);

    if (overlay.isEnableCompilation()) {

        if (!destinationDir.exists() || isEmpty(destinationDir)) {
            project.sync(extractOverlay);
        }

        project.getTasks().getByName(CLEAN_TASK_NAME).finalizedBy(extractOverlayTask);

        ConfigurableFileCollection classes = project.files(new File(destinationDir, "WEB-INF/classes"))
                .builtBy(extractOverlayTask);

        project.getDependencies().add(getClasspathConfigurationName(overlay), classes);

        FileTree libs = project.files(extractOverlayTask).builtBy(extractOverlayTask).getAsFileTree()
                .matching(patternFilterable -> patternFilterable.include("WEB-INF/lib/**"));

        project.getDependencies().add(getClasspathConfigurationName(overlay), libs);
    }
}
 
Example 10
Source Project: groovy   Source File: GPathResult.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a Integer object.
 *
 * @return the GPathResult, converted to a <code>Integer</code>
 */
public Integer toInteger() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toInteger((CharSequence)text());
}
 
Example 11
Source Project: groovy   Source File: GPathResult.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a Long object.
 *
 * @return the GPathResult, converted to a <code>Long</code>
 */
public Long toLong() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toLong((CharSequence)text());
}
 
Example 12
Source Project: groovy   Source File: GPathResult.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a Float object.
 *
 * @return the GPathResult, converted to a <code>Float</code>
 */
public Float toFloat() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toFloat((CharSequence)text());
}
 
Example 13
Source Project: groovy   Source File: GPathResult.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a Double object.
 *
 * @return the GPathResult, converted to a <code>Double</code>
 */
public Double toDouble() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toDouble((CharSequence)text());
}
 
Example 14
Source Project: groovy   Source File: GPathResult.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a BigDecimal object.
 *
 * @return the GPathResult, converted to a <code>BigDecimal</code>
 */
public BigDecimal toBigDecimal() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toBigDecimal((CharSequence)text());
}
 
Example 15
Source Project: groovy   Source File: GPathResult.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a BigInteger object.
 *
 * @return the GPathResult, converted to a <code>BigInteger</code>
 */
public BigInteger toBigInteger() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toBigInteger((CharSequence)text());
}
 
Example 16
Source Project: groovy   Source File: StringUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String replaceHexEscapes(String text) {
	if (!text.contains(BACKSLASH)) {
		return text;
	}

	return StringGroovyMethods.replaceAll((CharSequence) text, HEX_ESCAPES_PATTERN, new Closure<Void>(null, null) {
		Object doCall(String _0, String _1, String _2) {
			if (isLengthOdd(_1)) {
				return _0;
			}

			return _1 + new String(Character.toChars(Integer.parseInt(_2, 16)));
		}
	});
}
 
Example 17
Source Project: groovy   Source File: StringUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String replaceOctalEscapes(String text) {
	if (!text.contains(BACKSLASH)) {
		return text;
	}

	return StringGroovyMethods.replaceAll((CharSequence) text, OCTAL_ESCAPES_PATTERN, new Closure<Void>(null, null) {
		Object doCall(String _0, String _1, String _2) {
			if (isLengthOdd(_1)) {
				return _0;
			}

			return _1 + new String(Character.toChars(Integer.parseInt(_2, 8)));
		}
	});
}
 
Example 18
Source Project: groovy   Source File: ConsoleTextEditor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    // starting position in document
    int start = textEditor.viewToModel(getViewport().getViewPosition());
    // end position in document
    int end = textEditor.viewToModel(new Point(10,
            getViewport().getViewPosition().y +
                    (int) textEditor.getVisibleRect().getHeight())
    );

    // translate offsets to lines
    Document doc = textEditor.getDocument();
    int startline = doc.getDefaultRootElement().getElementIndex(start) + 1;
    int endline = doc.getDefaultRootElement().getElementIndex(end) + 1;
    Font f = textEditor.getFont();
    int fontHeight = g.getFontMetrics(f).getHeight();
    int fontDesc = g.getFontMetrics(f).getDescent();
    int startingY = -1;

    try {
        startingY = textEditor.modelToView(start).y + fontHeight - fontDesc;
    } catch (BadLocationException e1) {
        System.err.println(e1.getMessage());
    }
    g.setFont(f);
    for (int line = startline, y = startingY; line <= endline; y += fontHeight, line++) {
        String lineNumber = StringGroovyMethods.padLeft((CharSequence)Integer.toString(line), 4, " ");
        g.drawString(lineNumber, 0, y);
    }
}
 
Example 19
Source Project: groovy   Source File: SortableASTTransformation.java    License: Apache License 2.0 5 votes vote down vote up
private static void createComparatorFor(ClassNode classNode, PropertyNode property, boolean reversed) {
    String propName = StringGroovyMethods.capitalize((CharSequence) property.getName());
    String className = classNode.getName() + "$" + propName + "Comparator";
    ClassNode superClass = makeClassSafeWithGenerics(AbstractComparator.class, classNode);
    InnerClassNode cmpClass = new InnerClassNode(classNode, className, ACC_PRIVATE | ACC_STATIC, superClass);
    addGeneratedInnerClass(classNode, cmpClass);

    addGeneratedMethod(cmpClass,
            "compare",
            ACC_PUBLIC,
            ClassHelper.int_TYPE,
            params(param(newClass(classNode), ARG0), param(newClass(classNode), ARG1)),
            ClassNode.EMPTY_ARRAY,
            createCompareMethodBody(property, reversed)
    );

    String fieldName = "this$" + propName + "Comparator";
    // private final Comparator this$<property>Comparator = new <type>$<property>Comparator();
    FieldNode cmpField = classNode.addField(
            fieldName,
            ACC_STATIC | ACC_FINAL | ACC_PRIVATE | ACC_SYNTHETIC,
            COMPARATOR_TYPE,
            ctorX(cmpClass));

    addGeneratedMethod(classNode,
            "comparatorBy" + propName,
            ACC_PUBLIC | ACC_STATIC,
            COMPARATOR_TYPE,
            Parameter.EMPTY_ARRAY,
            ClassNode.EMPTY_ARRAY,
            returnS(fieldX(cmpField))
    );
}
 
Example 20
Source Project: groovy   Source File: DefaultTypeTransformation.java    License: Apache License 2.0 5 votes vote down vote up
public static Collection asCollection(Object value) {
    if (value == null) {
        return Collections.EMPTY_LIST;
    } else if (value instanceof Collection) {
        return (Collection) value;
    } else if (value instanceof Map) {
        Map map = (Map) value;
        return map.entrySet();
    } else if (value.getClass().isArray()) {
        return arrayAsCollection(value);
    } else if (value instanceof MethodClosure) {
        MethodClosure method = (MethodClosure) value;
        IteratorClosureAdapter adapter = new IteratorClosureAdapter(method.getDelegate());
        method.call(adapter);
        return adapter.asList();
    } else if (value instanceof String || value instanceof GString) {
        return StringGroovyMethods.toList((CharSequence) value);
    } else if (value instanceof File) {
        try {
            return ResourceGroovyMethods.readLines((File) value);
        } catch (IOException e) {
            throw new GroovyRuntimeException("Error reading file: " + value, e);
        }
    } else if (value instanceof Class && ((Class) value).isEnum()) {
        Object[] values = (Object[]) InvokerHelper.invokeMethod(value, "values", EMPTY_OBJECT_ARRAY);
        return Arrays.asList(values);
    } else {
        // let's assume it's a collection of 1
        return Collections.singletonList(value);
    }
}
 
Example 21
Source Project: groovy   Source File: GroovyMain.java    License: Apache License 2.0 5 votes vote down vote up
private List<String> getConfigScripts() {
    List<String> scripts = new ArrayList<String>();

    if (this.configscript != null) {
        scripts.add(this.configscript);
    }

    String configScripts = System.getProperty("groovy.starter.configscripts", null);

    if (configScripts != null && !configScripts.isEmpty()) {
        scripts.addAll(StringGroovyMethods.tokenize(configScripts, ','));
    }

    return scripts;
}
 
Example 22
Source Project: groovy   Source File: ConfigObject.java    License: Apache License 2.0 5 votes vote down vote up
private static void writeValue(String key, String space, String prefix, Object value, BufferedWriter out) throws IOException {
//        key = key.indexOf('.') > -1 ? InvokerHelper.inspect(key) : key;
        boolean isKeyword = KEYWORDS.contains(key);
        key = isKeyword ? InvokerHelper.inspect(key) : key;

        if (!StringGroovyMethods.asBoolean(prefix) && isKeyword) prefix = "this.";
        out.append(space).append(prefix).append(key).append('=').append(InvokerHelper.inspect(value));
        out.newLine();
    }
 
Example 23
Source Project: groovy   Source File: Node.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a Integer object.
 *
 * @return the GPathResult, converted to a <code>Integer</code>
 */
public Integer toInteger() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toInteger((CharSequence)text());
}
 
Example 24
Source Project: groovy   Source File: Node.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a Long object.
 *
 * @return the GPathResult, converted to a <code>Long</code>
 */
public Long toLong() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toLong((CharSequence)text());
}
 
Example 25
Source Project: groovy   Source File: Node.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a Float object.
 *
 * @return the GPathResult, converted to a <code>Float</code>
 */
public Float toFloat() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toFloat((CharSequence)text());
}
 
Example 26
Source Project: groovy   Source File: Node.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a Double object.
 *
 * @return the GPathResult, converted to a <code>Double</code>
 */
public Double toDouble() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toDouble((CharSequence)text());
}
 
Example 27
Source Project: groovy   Source File: Node.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a BigDecimal object.
 *
 * @return the GPathResult, converted to a <code>BigDecimal</code>
 */
public BigDecimal toBigDecimal() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toBigDecimal((CharSequence)text());
}
 
Example 28
Source Project: groovy   Source File: Node.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Converts the text of this GPathResult to a BigInteger object.
 *
 * @return the GPathResult, converted to a <code>BigInteger</code>
 */
public BigInteger toBigInteger() {
    if(textIsEmptyOrNull()){
        return null;
    }
    return StringGroovyMethods.toBigInteger((CharSequence)text());
}
 
Example 29
Source Project: groovy   Source File: SimpleGroovyAnnotationRef.java    License: Apache License 2.0 4 votes vote down vote up
public SimpleGroovyAnnotationRef(String name, String desc) {
    this.name = name;
    final String params = StringGroovyMethods.minus(desc, "@" + name);
    this.desc = "()".equals(params) ? "" : params;
}
 
Example 30
Source Project: groovy   Source File: GroovyDocToolTest.java    License: Apache License 2.0 4 votes vote down vote up
public void testLinksToSamePackage() throws Exception {
    final String base = "org/codehaus/groovy/tools/groovydoc/testfiles";
    htmlTool.add(Arrays.asList(
            base + "/GroovyInterface1.groovy",
            base + "/JavaClassWithDiamond.java"
    ));

    final MockOutputTool output = new MockOutputTool();
    htmlTool.renderToOutput(output, MOCK_DIR);

    final String groovydoc = output.getText(MOCK_DIR + "/" + base + "/GroovyInterface1.html");
    final String javadoc = StringGroovyMethods.normalize(output.getText(MOCK_DIR + "/" + base + "/JavaClassWithDiamond.html"));

    final Matcher groovyClassComment = Pattern.compile(Pattern.quote(
            "<p> <a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/JavaClassWithDiamond.html#link()' title='Java'>Java</a> " +
                    "<DL><DT><B>See Also:</B></DT>" +
                    "<DD><a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/JavaClassWithDiamond.html' title='JavaClassWithDiamond'>JavaClassWithDiamond</a></DD>" +
                    "</DL></p>"
    )).matcher(groovydoc);
    final Matcher groovyMethodComment = Pattern.compile(Pattern.quote(
            "<p> <a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/JavaClassWithDiamond.html#link()' title='Java link'>Java link</a> " +
                    "<DL><DT><B>See Also:</B></DT>" +
                    "<DD><a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/JavaClassWithDiamond.html#link()' title='JavaClassWithDiamond.link'>JavaClassWithDiamond.link</a></DD>" +
                    "</DL></p>"
    )).matcher(groovydoc);
    final Matcher javaClassComment = Pattern.compile(Pattern.quote(
            "<p> <a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/GroovyInterface1.html#link()' title='Groovy link'>Groovy link</a>\n" +
                    "  <DL><DT><B>See Also:</B></DT>" +
                    "<DD><a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/GroovyInterface1.html' title='GroovyInterface1'>GroovyInterface1</a></DD>" +
                    "</DL></p>"
    )).matcher(javadoc);
    final Matcher javaMethodComment = Pattern.compile(Pattern.quote(
            "<p> <a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/GroovyInterface1.html#link()' title='Groovy link'>Groovy link</a>\n" +
                    "      <DL><DT><B>See Also:</B></DT>" +
                    "<DD><a href='../../../../../../org/codehaus/groovy/tools/groovydoc/testfiles/GroovyInterface1.html#link()' title='GroovyInterface1.link'>GroovyInterface1.link</a></DD>" +
                    "</DL></p>"
    )).matcher(javadoc);

    assertTrue("The Groovy class comment should contain links", groovyClassComment.find());
    assertTrue("The Groovy method comment should contain links", groovyMethodComment.find());
    assertTrue("The Java class comment should contain links", javaClassComment.find());
    assertTrue("The Java method comment should contain links", javaMethodComment.find());
}