001/*
002 * CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE
003 * CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT.
004 * PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY
005 * DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THE
006 * AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE"
007 * BUTTON AT THE BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency
008 * API ("Specification") Copyright (c) 2012-2013, Credit Suisse All rights
009 * reserved.
010 */
011package org.javamoney.moneta.format.internal;
012
013import java.io.IOException;
014import java.text.ParseException;
015
016import javax.money.MonetaryAmount;
017import javax.money.format.MonetaryParseException;
018
019/**
020 * Abstraction for a token that is part of a token stream, used for formatting
021 * and parsing.
022 * 
023 * @author Anatole Tresch
024 */
025public interface FormatToken {
026        /**
027         * Parse the context, based on the given {@link ParseContext}.
028         * 
029         * @param context
030         *            the current {@link ParseContext}.
031         * @throws ParseException
032         *             if parsing fails.
033         */
034        public void parse(ParseContext context) throws MonetaryParseException;
035
036        /**
037         * Formats the given {@link MonetaryAmount} to an {@link Appendable}.
038         * @param appendable the {@link Appendable}, not {@code null}.
039         * @param amount the {@link MonetaryAmount} to be formatted, not {@code null}.
040         * @throws IOException thrown by the {@link Appendable} on appending.
041         */
042        public void print(Appendable appendable, MonetaryAmount amount)
043                        throws IOException;
044
045}