/******************************************************************* Copyright (c) 2001-2010 Apprisant Technologies Inc. All rights reserved. Apprisant Technologies permits non-exclusive royalty free use, copying and modification of this demo program source code for the purposes of evaluating the Apprisant Toolkit or building applications that use it. This software and documentation is provided "AS IS". APPRISANT TECHNOLOGIES DISCLAIMS ANY REPRESENTATIONS AND WARRANTIES, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS OF THIS PRODUCT FOR ANY PARTICULAR PURPOSE. APPRISANT TECHNOLOGIES SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY ANY PARTY, INCLUDING LOST PROFITS, ARISING FROM THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ITS DERIVATIONS. ********************************************************************/ package oilfield; import java.text.NumberFormat; import apprisant.diagram.env.AGConverter; import apprisant.diagram.ConversionException; public class Converters { /** Converter to format the 'completed' data value to percent. */ public static class Percent implements AGConverter { NumberFormat formatter; public Percent() { formatter = NumberFormat.getPercentInstance(); } public Object getAsObject (String text) throws ConversionException { throw new ConversionException(); } public String getAsString (Object obj) throws ConversionException { if (obj instanceof Double) return formatter.format((Double) obj); else throw new ConversionException(); } } /** Converter to format the 'cost' data value as currency. */ public static class Currency implements AGConverter { NumberFormat formatter; public Currency() { formatter = NumberFormat.getCurrencyInstance(); } public Object getAsObject (String text) throws ConversionException { throw new ConversionException(); } public String getAsString (Object obj) throws ConversionException { if (obj instanceof Double) return formatter.format((Double) obj); else throw new ConversionException(); } } }