// -*- c++ -*- /* * Jakelib2 - General purpose C++ library * Copyright (C) 2001 Florian Wolff (florian@donuz.de) * * This library 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. * * This library 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 this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: DecimalFormatSyms.jlc,v 1.12 2003/09/27 08:10:28 florian Exp $ */ #include "jakelib2.h" #include "jakelib2/io/Serializable.h" #include "jakelib2/text/DecimalFormatSyms.h" using namespace jakelib::lang; using namespace jakelib::text; using namespace jakelib::util; JAKELIB_IMPLEMENT_CLASS("jakelib.text.DecimalFormatSyms", DecimalFormatSyms, Object); /*****************************************************************************\ * DecimalFormatSyms | *****************************************************************************/ DecimalFormatSyms::DecimalFormatSyms(Locale * loc) { init(loc); } DecimalFormatSyms::DecimalFormatSyms() { Locale *loc = Locale::getDefault(); init(loc); } /*****************************************************************************\ * init | *****************************************************************************/ void DecimalFormatSyms::init(Locale * loc) { String* language = loc->getLanguage(); digit = '#'; if (language->equals(`"de"`) || language->equals(`"fr"`)) { currencySymbol = `"EUR"`; decimalSeparator = ','; exponential = 'E'; groupingSeparator = '.'; infinity = `"\u221e"`; intlCurrencySymbol = `"EUR"`; monetarySeparator = ','; minusSign = '-'; NaN = `"\ufffd"`; patternSeparator = ';'; percent = '%'; perMill = 0x2030; zeroDigit = '0'; } else { currencySymbol = `"$"`; decimalSeparator = '.'; exponential = 'E'; groupingSeparator = ','; infinity = `"\u221e"`; intlCurrencySymbol = `"$"`; monetarySeparator = '.'; minusSign = '-'; NaN = `"\ufffd"`; patternSeparator = ';'; percent = '%'; perMill = 0x2030; zeroDigit = '0'; } } /*****************************************************************************\ * equals | *****************************************************************************/ jboolean DecimalFormatSyms::equals(jakelib::lang::Object * obj) { if (!(obj->instanceOf(`"jakelib.text.DecimalFormatSyms"`))) return false; DecimalFormatSyms *dfs = (DecimalFormatSyms *) obj; return (currencySymbol->equals(dfs->currencySymbol) && decimalSeparator == dfs->decimalSeparator && digit == dfs->digit && exponential == dfs->exponential && groupingSeparator == dfs->groupingSeparator && infinity->equals(dfs->infinity) && intlCurrencySymbol->equals(dfs->intlCurrencySymbol) && minusSign == dfs->minusSign && monetarySeparator == dfs->monetarySeparator && NaN->equals(dfs->NaN) && patternSeparator == dfs->patternSeparator && percent == dfs->percent && perMill == dfs->perMill && zeroDigit == dfs->zeroDigit); } /*****************************************************************************\ * getCurrencySymbol | *****************************************************************************/ jakelib::lang::String * DecimalFormatSyms::getCurrencySymbol() { return currencySymbol; } /*****************************************************************************\ * getDecimalSeparator | *****************************************************************************/ jchar DecimalFormatSyms::getDecimalSeparator() { return decimalSeparator; } /*****************************************************************************\ * getDigit | *****************************************************************************/ jchar DecimalFormatSyms::getDigit() { return digit; } /*****************************************************************************\ * getExponential | *****************************************************************************/ jchar DecimalFormatSyms::getExponential() { return exponential; } /*****************************************************************************\ * getGroupingSeparator | *****************************************************************************/ jchar DecimalFormatSyms::getGroupingSeparator() { return groupingSeparator; } /*****************************************************************************\ * getInfinity | *****************************************************************************/ jakelib::lang::String * DecimalFormatSyms::getInfinity() { return infinity; } /*****************************************************************************\ * getInternationalCurrencySymbol | *****************************************************************************/ jakelib::lang::String * DecimalFormatSyms::getInternationalCurrencySymbol() { return intlCurrencySymbol; } /*****************************************************************************\ * getMinusSign | *****************************************************************************/ jchar DecimalFormatSyms::getMinusSign() { return minusSign; } /*****************************************************************************\ * getGroupingSeparator | *****************************************************************************/ jchar DecimalFormatSyms::getMonetaryDecimalSeparator() { return monetarySeparator; } /*****************************************************************************\ * getNaN | *****************************************************************************/ jakelib::lang::String * DecimalFormatSyms::getNaN() { return NaN; } /*****************************************************************************\ * getPatternSeparator | *****************************************************************************/ jchar DecimalFormatSyms::getPatternSeparator() { return patternSeparator; } /*****************************************************************************\ * getPercent | *****************************************************************************/ jchar DecimalFormatSyms::getPercent() { return percent; } /*****************************************************************************\ * getPerMill | *****************************************************************************/ jchar DecimalFormatSyms::getPerMill() { return perMill; } /*****************************************************************************\ * getZeroDigit | *****************************************************************************/ jchar DecimalFormatSyms::getZeroDigit() { return zeroDigit; } /*****************************************************************************\ * hashCode | *****************************************************************************/ jint DecimalFormatSyms::hashCode() { return (zeroDigit << 16) + (groupingSeparator << 8) + decimalSeparator; } /*****************************************************************************\ * setCurrencySymbol | *****************************************************************************/ void DecimalFormatSyms::setCurrencySymbol(jakelib::lang::String * currency) { currencySymbol = currency; } /*****************************************************************************\ * setDecimalSeparator | *****************************************************************************/ void DecimalFormatSyms::setDecimalSeparator(jchar decimalSep) { decimalSeparator = decimalSep; } /*****************************************************************************\ * setDigit | *****************************************************************************/ void DecimalFormatSyms::setDigit(jchar digit) { this->digit = digit; } /*****************************************************************************\ * setExponential | *****************************************************************************/ void DecimalFormatSyms::setExponential(jchar exp) { exponential = exp; } /*****************************************************************************\ * setGroupingSeparator | *****************************************************************************/ void DecimalFormatSyms::setGroupingSeparator(jchar groupSep) { groupingSeparator = groupSep; } /*****************************************************************************\ * setInfinity | *****************************************************************************/ void DecimalFormatSyms::setInfinity(jakelib::lang::String * infinity) { this->infinity = infinity; } /*****************************************************************************\ * setInternationalCurrencySymbol | *****************************************************************************/ void DecimalFormatSyms::setInternationalCurrencySymbol(jakelib::lang::String * currency) { intlCurrencySymbol = currency; } /*****************************************************************************\ * setMinusSign | *****************************************************************************/ void DecimalFormatSyms::setMinusSign(jchar minusSign) { this->minusSign = minusSign; } /*****************************************************************************\ * setMonetaryDecimalSeparator | *****************************************************************************/ void DecimalFormatSyms::setMonetaryDecimalSeparator(jchar decimalSep) { monetarySeparator = decimalSep; } /*****************************************************************************\ * setNaN | *****************************************************************************/ void DecimalFormatSyms::setNaN(jakelib::lang::String * nan) { NaN = nan; } /*****************************************************************************\ * setPatternSeparator | *****************************************************************************/ void DecimalFormatSyms::setPatternSeparator(jchar patternSep) { patternSeparator = patternSep; } /*****************************************************************************\ * setPercent | *****************************************************************************/ void DecimalFormatSyms::setPercent(jchar percent) { this->percent = percent; } /*****************************************************************************\ * setPerMill | *****************************************************************************/ void DecimalFormatSyms::setPerMill(jchar perMill) { this->perMill = perMill; } /*****************************************************************************\ * setZeroDigit | *****************************************************************************/ void DecimalFormatSyms::setZeroDigit(jchar zeroDigit) { this->zeroDigit = zeroDigit; }