net.time4j.format.ChronoPrinter Maven / Gradle / Ivy
/*
* -----------------------------------------------------------------------
* Copyright © 2013-2014 Meno Hochschild,
* -----------------------------------------------------------------------
* This file (ChronoPrinter.java) is part of project Time4J.
*
* Time4J is free software: You can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* Time4J 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
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Time4J. If not, see .
* -----------------------------------------------------------------------
*/
package net.time4j.format;
import net.time4j.engine.AttributeQuery;
import net.time4j.engine.ChronoDisplay;
import net.time4j.engine.ChronoFunction;
import java.io.IOException;
/**
* Prints a chronological entity.
*
* @param generic type of chronological entity to be formatted
* @author Meno Hochschild
* @see net.time4j.engine.ChronoEntity
*/
/*[deutsch]
* Erzeugt eine formatierte Ausgabe einer Entität.
*
* @param generic type of chronological entity to be formatted
* @author Meno Hochschild
* @see net.time4j.engine.ChronoEntity
*/
public interface ChronoPrinter {
//~ Methoden ----------------------------------------------------------
/**
* Creates a text output and writes it into given buffer.
*
* Note: Implementations have to call {@code query.apply(...)}
* at the end to return a possibly meaningful result. An example
* would be a query which produces just the identical input so
* the result of printing a {@code Moment} will be the formatted
* form of the original {@code Moment}.
*
* @param formattable chronological entity to be formatted
* @param buffer format buffer any text output will be sent to
* @param attributes control attributes
* @param query custom query returning any kind of result
* @return result of query
* @throws IllegalArgumentException if the object is not formattable
* @throws IOException if writing into buffer fails
*/
/*[deutsch]
* Erzeugt eine Textausgabe und schreibt sie in den angegebenen
* Puffer.
*
* Notiz: Implementierungen müssen schließlich
* {@code query.apply(...)} aufrufen, um ein Ergebnis
* zurückzugeben. Ein Beispiel wäre eine Abfrage, die
* einfach die identische Eingabe zurückgibt, so daß
* das Ergebnis dieser Methode angewandt auf einen {@code Moment}
* die vorformatierte Form des ursprünglichen {@code Moment}
* sein wird.
*
* @param formattable chronological entity to be formatted
* @param buffer format buffer any text output will be sent to
* @param attributes control attributes
* @param query custom query returning any kind of result
* @return result of query
* @throws IllegalArgumentException if the object is not formattable
* @throws IOException if writing into buffer fails
*/
R print(
T formattable,
Appendable buffer,
AttributeQuery attributes,
ChronoFunction query
) throws IOException;
}