Class PublicationTemplate

java.lang.Object
atessera.templ.PublicationTemplate

public final class PublicationTemplate extends Object
Velocity template for generating LaTeX source of a complete publication.

This class populates the publication.vm template with metadata (title, authors, date, etc.) and content sections, producing a compilable LaTeX document. The template is designed to be compiled with PdfLatex.

Typical usage:


 PublicationTemplate t = new PublicationTemplate(factory);
 t.setHeader(publicationContent);
 t.setAbstract(abstractText);
 t.setSections(sections);
 t.setBiblio(bibliography);
 List<String> latexSource = t.renderToStringList();
 
See Also:
  • Constructor Details

    • PublicationTemplate

      public PublicationTemplate(EngineFactory engineFactory)
      Constructs a new publication template.
      Parameters:
      engineFactory - the factory for obtaining a Velocity engine; must not be null
      Throws:
      org.apache.velocity.exception.ResourceNotFoundException - if publication.vm cannot be loaded
  • Method Details

    • setHeader

      public void setHeader(PublicationContent publ)
      Sets the publication metadata from a PublicationContent object.

      Populates template variables: TITLE, TITLE_CAP, SUBTITLE, AUTHORS, BOOK_TYPE, TITLE_PAGE_TOP_NOTE, TITLE_PAGE_BOTTOM_NOTE, DATE, LOCATION, TOC_BEGIN, and TOC_END.

      Parameters:
      publ - the publication metadata; must not be null
    • setSections

      public PublicationTemplate setSections(List<PublicationTemplate.Section> sections)
      Sets the content sections of the publication.
      Parameters:
      sections - the list of sections; must not be null
      Returns:
      this template (for fluent chaining)
    • setAbstract

      public PublicationTemplate setAbstract(String abs)
      Sets the abstract text of the publication.
      Parameters:
      abs - the abstract text (may be null)
      Returns:
      this template (for fluent chaining)
    • setBiblio

      public PublicationTemplate setBiblio(List<Map.Entry<String,String>> biblio)
      Sets the bibliography entries.
      Parameters:
      biblio - a list of key-value pairs where keys are citation keys and values are the formatted bibliography text; must not be null
      Returns:
      this template (for fluent chaining)
    • render

      public void render(Writer wr)
      Merges the context into the template and writes the result to the given writer.
      Parameters:
      wr - the writer to receive the rendered output; must not be null
    • renderToStringList

      public List<String> renderToStringList()
      Renders the template and returns the result split into lines.
      Returns:
      the rendered output as a list of lines (trailing empty lines are preserved)