001package org.apache.maven.doxia;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.maven.doxia.parser.ParseException;
023import org.apache.maven.doxia.parser.Parser;
024import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
025import org.apache.maven.doxia.sink.Sink;
026
027import java.io.Reader;
028
029/**
030 * Basic interface of the Doxia framework.
031 *
032 * @author Jason van Zyl
033 * @since 1.0
034 */
035public interface Doxia
036{
037    /** The Plexus lookup role. */
038    String ROLE = Doxia.class.getName();
039
040    /**
041     * Parses the given source model using a parser with given id,
042     * and emits Doxia events into the given sink.
043     *
044     * @param source not null reader that provides the source document
045     * @param parserId identifier for the parser to use
046     * @param sink a sink that consumes the Doxia events
047     * @throws ParserNotFoundException if no parser could be found for the given id
048     * @throws ParseException if the model could not be parsed
049     */
050    void parse( Reader source, String parserId, Sink sink )
051        throws ParserNotFoundException, ParseException;
052
053    /**
054     * Parses the given source model using a parser with given id,
055     * and emits Doxia events into the given sink.
056     *
057     * @param source not null reader that provides the source document
058     * @param parserId identifier for the parser to use
059     * @param sink a sink that consumes the Doxia events
060     * @param reference string containing the reference to the source (e.g. filename)
061     * @throws ParserNotFoundException if no parser could be found for the given id
062     * @throws ParseException if the model could not be parsed
063     */
064    void parse( Reader source, String parserId, Sink sink, String reference )
065        throws ParserNotFoundException, ParseException;
066
067    /**
068     * Return a parser for the given <code>parserId</code>.
069     *
070     * @param parserId identifier for the parser to use
071     * @return the parser identified by parserId
072     * @throws ParserNotFoundException if no parser could be found for the given id
073     */
074    Parser getParser( String parserId )
075        throws ParserNotFoundException;
076}