001/* 002 * Copyright 2004-2006 Geert Bevin <gbevin[remove] at uwyn dot com> 003 * Distributed under the terms of either: 004 * - the common development and distribution license (CDDL), v1.0; or 005 * - the GNU Lesser General Public License, v2.1 or later 006 * $Id: Renderer.java 3106 2006-03-13 17:53:50Z gbevin $ 007 */ 008package com.uwyn.jhighlight.renderer; 009 010import java.io.IOException; 011import java.io.InputStream; 012import java.io.OutputStream; 013 014/** 015 * Provides interface to render the source code highlighting. 016 * 017 * @author Geert Bevin (gbevin[remove] at uwyn dot com) 018 * @version $Revision: 3106 $ 019 * @since 1.0 020 */ 021public interface Renderer 022{ 023 /** 024 * Transforms source code that's provided through an 025 * <code>InputStream</code> to highlighted syntax and writes it back to 026 * an <code>OutputStream</code>. 027 * 028 * @param name The name of the source file. 029 * @param in The input stream that provides the source code that needs to 030 * be transformed. 031 * @param out The output stream to which to result should be written. 032 * @param encoding The encoding that will be used to read and write the 033 * text. 034 * @param fragment <code>true</code> if the result should be a fragment; 035 * or <code>false</code> if it should be a complete document 036 * @see #highlight(String, String, String, boolean) 037 * @since 1.0 038 */ 039 public void highlight(String name, InputStream in, OutputStream out, String encoding, boolean fragment) throws IOException; 040 041 /** 042 * Transforms source code that's provided through a 043 * <code>String</code> to highlighted syntax and returns it as a 044 * <code>String</code>. 045 * 046 * @param name The name of the source file. 047 * @param in The input string that provides the source code that needs to 048 * be transformed. 049 * @param encoding The encoding that will be used to read and write the 050 * text. 051 * @param fragment <code>true</code> if the result should be a fragment; 052 * or <code>false</code> if it should be a complete document 053 * @return the highlighted source code as a string 054 * @see #highlight(String, InputStream, OutputStream, String, boolean) 055 * @since 1.0 056 */ 057 public String highlight(String name, String in, String encoding, boolean fragment) throws IOException; 058}