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

at.spardat.enterprise.fmt.ABcdFmt Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

// @(#) $Id: ABcdFmt.java 2093 2007-11-28 14:23:36Z s3460 $
package at.spardat.enterprise.fmt;

import java.util.*;
import at.spardat.enterprise.util.*;

/**
 * A IFmt class capable of formatting and parsing numbers. It's tailored towards the class ABcd and
 * expoits its internal string representation. Therefore, the internal string representation is
 * the canonic one of an ABcd object. 

*/ public abstract class ABcdFmt extends IFmt { /** * Factory method that returns an internationalization capable instance of ABcdFmt. * * @param maxBeforeC max number of digits before the comma or -1 if unrestricted. Must not be zero. * @param maxAfterC max number of digits after the comma or -1 if unrestricted * @param style may be DEFAULT, SUPPRESS_ZERO, MANDATORY, NO_THOUS_SEPS, THOUS_SEPS or NO_NEG. Either NO_THOUS_SEPS or THOUS_SEPS may be specified. * @param l the Locale. Must not be null. * @return A newly created IFmt object. */ public static ABcdFmt getInstance (int maxBeforeC, int maxAfterC, int style, Locale locale) { return new ABcdFmtDefault (maxBeforeC, maxAfterC, style, locale); } /** * Factory method that returns an internationalization capable instance of ABcdFmt, where * upper and lower limits for the accepted value are provided. * * @param maxBeforeC max number of digits before the comma or -1 if unrestricted. Must not be zero. * @param maxAfterC max number of digits after the comma or -1 if unrestricted * @param style may be DEFAULT, SUPPRESS_ZERO, MANDATORY, NO_THOUS_SEPS, THOUS_SEPS or NO_NEG. Either NO_THOUS_SEPS or THOUS_SEPS may be specified. * @param minVal values less than this value are not accepted. * @param maxVal values greater than this value are not accepted. * @param l the Locale. Must not be null. * @return A newly created IFmt object. */ public static ABcdFmt getInstance (int maxBeforeC, int maxAfterC, int style, double minVal, double maxVal, Locale locale) { return new ABcdFmtRange (maxBeforeC, maxAfterC, style, minVal, maxVal, locale); } /** * Factory method that returns an instance of ABcdFmt that is specified using a format-string * as defined in java.text.DecimalFormat. * * @param pattern format string accoring to java.text.DecimalFormat * @param style may be MANDATORY * @param locale the Locale. Must not be null. * @return A newly created ABcdFmt. */ public static ABcdFmt getInstance (String pattern, int maxBeforeC, int maxAfterC, int style, Locale locale) { return new ABcdFmtPattern (pattern, maxBeforeC, maxAfterC, style, locale); } /** * @see at.spardat.enterprise.fmt.IFmt#mayBeAppliedTo(byte) */ public boolean mayBeAppliedTo (byte type) { return type == Types.T_BCD; } // only to be called by subclasses protected ABcdFmt () { } /** * The default is formatting without thousands separation characters, as is used with numbers. */ public static final int NO_THOUS_SEPS = IFmt.LAST_STYLE*2; /** * THOUS_SEPS is the style to enforce the usage of thousands separation characters. */ public static final int THOUS_SEPS = NO_THOUS_SEPS*2; /** * NO_NEG is specified if negative numbers are not allowed. */ public static final int NO_NEG = THOUS_SEPS*2; /** * Specifies that an excess number of places after the decimal separator should not be treated * as error in parse. The value should be rounded to the right number of decimal places * before and afterwards be assigned.

* * The default is to be strict, i.e., not to allow excess number of digits after the comma. */ public static final int ROUND_FRACTION = NO_NEG*2; /** * Defines that a value of zero should be displayed as empty string on the UI and, vice versa, * that an empty string on the UI should be mapped to a zero numeric value. */ public static final int SUPPRESS_ZERO = ROUND_FRACTION * 2; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy