All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.daisy.pipeline.braille.common.BrailleTranslator Maven / Gradle / Ivy

There is a newer version: 5.0.2
Show newest version
package org.daisy.pipeline.braille.common;

import org.daisy.dotify.api.translator.BrailleTranslatorResult;
import org.daisy.pipeline.braille.css.CSSStyledText;

public interface BrailleTranslator extends Transform {

	/**
	 * Return a new {@link BrailleTranslator} that uses the given {@link Hyphenator} to perform
	 * hyphenation.
	 *
	 * The returned object should be selectable based on its identifier from the same {@link
	 * BrailleTranslatorProvider} that provided this {@link BrailleTranslator}.
	 */
	public BrailleTranslator withHyphenator(Hyphenator hyphenator) throws UnsupportedOperationException;
	
	public FromStyledTextToBraille fromStyledTextToBraille() throws UnsupportedOperationException;
	
	public LineBreakingFromStyledText lineBreakingFromStyledText() throws UnsupportedOperationException;
	
	/* ------------------------- */
	/* fromStyledTextToBraille() */
	/* ------------------------- */
	
	public interface FromStyledTextToBraille {
		
		default public Iterable transform(Iterable styledText) throws TransformationException {
			return transform(styledText, 0, -1);
		}
		
		public Iterable transform(Iterable styledText, int from, int to) throws TransformationException;
	}
	
	/* ---------------------------- */
	/* lineBreakingFromStyledText() */
	/* ---------------------------- */
	
	public interface LineBreakingFromStyledText {
		
		/**
		 * Transform a sequence of {@link CSSStyledText} to braille, in the form of a {@link
		 * LineIterator}, which is an interface for laying out text into lines.
		 */
		default public LineIterator transform(Iterable styledText) throws TransformationException {
			return transform(styledText, 0, -1);
		}
		
		/**
		 * Transform the part of the input sequence between index from (included) and
		 * index to (not included). If to is a negative number it means
		 * transform up until the last segment.
		 */
		public LineIterator transform(Iterable styledTextWithContext, int from, int to) throws TransformationException;
	}
	
	/* ------------ */
	/* LineIterator */
	/* ------------ */
	
	public interface LineIterator extends BrailleTranslatorResult {
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy