All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cflint.HTMLOutput Maven / Gradle / Ivy

Go to download

A static code analysis tool for ColdFusion (in the spirit of FindBugs and Lint). With CFLint, you are able to analyze your ColdFusion code base for code violations.

There is a newer version: 1.5.0
Show newest version
package com.cflint;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;

import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;

public class HTMLOutput {

	final String htmlStyle;

	public void output(final BugList bugList, final Writer writer, final boolean showStats)
			throws IOException, TransformerException {

		// 1. Instantiate a TransformerFactory.
		final javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance();

		// 2. Use the TransformerFactory to process the stylesheet Source and
		// generate a Transformer.
		javax.xml.transform.Transformer transformer;
		// System.out.println("Using html style:" + htmlStyle);
		try {
			final InputStream is = getClass().getResourceAsStream("/findbugs/" + htmlStyle);
			transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(is));
		} catch (final TransformerConfigurationException e) {
			final InputStream is = getClass().getResourceAsStream("/" + htmlStyle);
			transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(is));
		}

		final StringWriter sw = new StringWriter();
		new XMLOutput().outputFindBugs(bugList, sw, showStats);

		// 3. Use the Transformer to transform an XML Source and send the
		// output to a Result object.
		transformer.transform(new StreamSource(new StringReader(sw.toString())),
				new javax.xml.transform.stream.StreamResult(writer));

		writer.close();
	}

	public HTMLOutput(final String htmlStyle) {
		super();
		this.htmlStyle = htmlStyle;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy