Search in sources :

Example 1 with IndexingSink

use of org.apache.maven.doxia.index.IndexingSink in project maven-plugins by apache.

the class PdfMojo method getGeneratedDocumentTitle.

/**
     * Parse a generated Doxia file and returns its title.
     *
     * @param f not null
     * @return the xdoc file title or null if an error occurs.
     * @throws IOException if any
     * @since 1.1
     */
private String getGeneratedDocumentTitle(final File f) throws IOException {
    final IndexEntry entry = new IndexEntry("index");
    final IndexingSink titleSink = new IndexingSink(entry);
    Reader reader = null;
    try {
        reader = ReaderFactory.newXmlReader(f);
        doxia.parse(reader, f.getParentFile().getName(), titleSink);
        reader.close();
        reader = null;
    } catch (ParseException e) {
        getLog().error("ParseException: " + e.getMessage());
        getLog().debug(e);
        return null;
    } catch (ParserNotFoundException e) {
        getLog().error("ParserNotFoundException: " + e.getMessage());
        getLog().debug(e);
        return null;
    } finally {
        IOUtil.close(reader);
    }
    return titleSink.getTitle();
}
Also used : IndexingSink(org.apache.maven.doxia.index.IndexingSink) ParserNotFoundException(org.apache.maven.doxia.parser.manager.ParserNotFoundException) IndexEntry(org.apache.maven.doxia.index.IndexEntry) XmlStreamReader(org.apache.commons.io.input.XmlStreamReader) Reader(java.io.Reader) DecorationXpp3Reader(org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader) StringReader(java.io.StringReader) ParseException(org.apache.maven.doxia.parser.ParseException)

Aggregations

Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 XmlStreamReader (org.apache.commons.io.input.XmlStreamReader)1 IndexEntry (org.apache.maven.doxia.index.IndexEntry)1 IndexingSink (org.apache.maven.doxia.index.IndexingSink)1 ParseException (org.apache.maven.doxia.parser.ParseException)1 ParserNotFoundException (org.apache.maven.doxia.parser.manager.ParserNotFoundException)1 DecorationXpp3Reader (org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader)1