org.integratedmodelling.api.metadata.IReport Maven / Gradle / Ivy
The newest version!
/*******************************************************************************
* Copyright (C) 2007, 2015:
*
* - Ferdinando Villa
* - integratedmodelling.org
* - any other authors listed in @author annotations
*
* All rights reserved. This file is part of the k.LAB software suite,
* meant to enable modular, collaborative, integrated
* development of interoperable data and model components. For
* details, see http://integratedmodelling.org.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Affero General Public License
* Version 3 or any later version.
*
* This program is distributed in the hope that it will be useful,
* but without any warranty; without even the implied warranty of
* merchantability or fitness for a particular purpose. See the
* Affero General Public License for more details.
*
* You should have received a copy of the Affero General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* The license is also available at: https://www.gnu.org/licenses/agpl.html
*******************************************************************************/
package org.integratedmodelling.api.metadata;
/**
* Simple interface to incrementally build a report in Markdown and compile it to HTML or
* text. Used during model contextualization; models can write to it using the monitor.
* There is a report per IContext, retrievable through REST in json, html or other
* formats.
*
* @author Ferd
*
*/
public interface IReport {
void setTitle(String title);
String getTitle();
/**
* Level of current section, starting at 0. Levels are created by adding sections
* using the API.
*
* @return
*/
int getLevel();
/**
* Write string directly to report.
*
* @param markdown
*/
void write(String markdown);
/**
* Add a link - either to an anchor created by {@link #getAnchor()} or
* {@link IReport#addAttachment(Object)} or to a passed URL.
*
* @param markdown
*/
void writeLink(String markdown, String anchorOrUrl);
/**
* Write string followed by newline.
*
* @param markdown
*/
void writeln(String markdown);
/**
* Add or retrieve section, get object to use to define section attributes. Equivalent
* to {@link #section(section, this)}. Does not insert the section - you need to call
* {@link #insert(IReport)} or {@link #insert(IReport, String)} for it to show up in
* the final report.
*
* @param section
* @param title
*/
IReport section(String section);
/**
* Create a new page for a multi-page report.
*
* @return
*/
IReport newPage();
/**
* Add or retrieve section to given other.
*
* @param section
* @param addTo
* @return
*/
IReport section(String section, IReport addTo);
/**
* Insert another report without creating a new section. The report's text will appear
* at this point in the text. Further changes to the report will change the text after
* the call.
*
* @param report
*/
void insert(IReport report);
/**
* Append another report to a section, creating it if necessary. All subsections in
* the report become subsection of the passed one. The section will appear at this
* point in the text. Further changes to the inserted report will change the text
* after the call.
*
*
* @param report
* @param sectionName
*/
void insert(IReport report, String section);
/**
* Return the html correspondent to the report so far.
*
* @return
*/
String asHTML();
/**
* Turn the report into ASCII text and return it.
*
* @return
*/
String asText();
/**
* Attach object to report. Return the anchor to insert in the text if wanted.
*
*/
String addAttachment(Object o);
/**
* Insert an anchor to this point in the text and return it.
* @return
*/
String getAnchor();
}