UErrorCode &status)
: rules(rules), parent(parent) {
data.populate(locale, nsName, compactStyle, compactType, status);
- if (U_FAILURE(status)) { return; }
if (buildReference != nullptr) {
// Safe code path
precomputeAllModifiers(*buildReference, status);
}
void CompactHandler::precomputeAllModifiers(MutablePatternModifier &buildReference, UErrorCode &status) {
+ if (U_FAILURE(status)) { return; }
+
// Initial capacity of 12 for 0K, 00K, 000K, ...M, ...B, and ...T
UVector allPatterns(12, status);
if (U_FAILURE(status)) { return; }
// C++ Note: Use unsafePatternInfo for proper lifecycle.
ParsedPatternInfo &patternInfo = const_cast<CompactHandler *>(this)->unsafePatternInfo;
PatternParser::parseToPatternInfo(UnicodeString(patternString), patternInfo, status);
- dynamic_cast<MutablePatternModifier *>(const_cast<Modifier *>(micros.modMiddle))->setPatternInfo(
- &patternInfo);
+ static_cast<MutablePatternModifier*>(const_cast<Modifier*>(micros.modMiddle))
+ ->setPatternInfo(&patternInfo);
numDigits = patternInfo.positive.integerTotal;
}
DecimalQuantity::DecimalQuantity() {
setBcdToZero();
+ flags = 0;
}
DecimalQuantity::~DecimalQuantity() {
}
}
- void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) override {
+ void put(const char *key, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) U_OVERRIDE {
ResourceTable pluralsTable = value.getTable(status);
if (U_FAILURE(status)) { return; }
for (int i = 0; pluralsTable.getKeyAndValue(i, key, value); ++i) {
}
}
-SimpleModifier::SimpleModifier() : fStrong(false), fPrefixLength(0), fSuffixLength(0) {
+SimpleModifier::SimpleModifier()
+ : fField(UNUM_FIELD_COUNT), fStrong(false), fPrefixLength(0), fSuffixLength(0) {
}
int32_t SimpleModifier::apply(NumberStringBuilder &output, int leftIndex, int rightIndex,
UnicodeString toUnicodeString() const U_OVERRIDE;
private:
- // Modifier details
+ // Modifier details (initialized in constructor)
const bool fStrong;
- // Pattern details
+ // Pattern details (initialized in setPatternInfo and setPatternAttributes)
const AffixPatternProvider *patternInfo;
UNumberSignDisplay signDisplay;
bool perMilleReplacesPercent;
- // Symbol details
+ // Symbol details (initialized in setSymbols)
const DecimalFormatSymbols *symbols;
UNumberUnitWidth unitWidth;
char16_t currencyCode[4];
const PluralRules *rules;
- // Number details
+ // Number details (initialized in setNumberProperties)
bool isNegative;
StandardPlural::Form plural;
- // QuantityChain details
+ // QuantityChain details (initialized in addToChain)
const MicroPropsGenerator *parent;
- // Transient CharSequence fields
+ // Transient CharSequence fields (initialized in enterCharSequenceMode)
bool inCharSequenceMode = false;
int32_t fFlags;
int32_t fLength;
return properties;
}
-void PatternParser::parseToExistingProperties(const UnicodeString& pattern, DecimalFormatProperties properties,
+void PatternParser::parseToExistingProperties(const UnicodeString& pattern, DecimalFormatProperties& properties,
IgnoreRounding ignoreRounding, UErrorCode &status) {
parseToExistingPropertiesImpl(pattern, properties, ignoreRounding, status);
}
}
void PatternParser::patternInfoToProperties(DecimalFormatProperties &properties,
- ParsedPatternInfo patternInfo,
+ ParsedPatternInfo& patternInfo,
IgnoreRounding _ignoreRounding, UErrorCode &status) {
// Translate from PatternParseResult to Properties.
// Note that most data from "negative" is ignored per the specification of DecimalFormat.
* @throws IllegalArgumentException
* If there was a syntax error in the pattern string.
*/
- static void parseToExistingProperties(const UnicodeString& pattern, DecimalFormatProperties properties,
+ static void parseToExistingProperties(const UnicodeString& pattern, DecimalFormatProperties& properties,
IgnoreRounding ignoreRounding, UErrorCode &status);
private:
/** Finalizes the temporary data stored in the ParsedPatternInfo to the Properties. */
static void
- patternInfoToProperties(DecimalFormatProperties &properties, ParsedPatternInfo patternInfo,
+ patternInfoToProperties(DecimalFormatProperties &properties, ParsedPatternInfo& patternInfo,
IgnoreRounding _ignoreRounding, UErrorCode &status);
};
@Override
public boolean equals(Object _other) {
+ if (_other == null) return false;
+ if (this == _other) return true;
+ if (!(_other instanceof MacroProps)) return false;
MacroProps other = (MacroProps) _other;
return Utility.equals(notation, other.notation)
&& Utility.equals(unit, other.unit)
import java.math.BigDecimal;
-public class MultiplierImpl implements MicroPropsGenerator, Cloneable {
+public class MultiplierImpl implements MicroPropsGenerator {
final int magnitudeMultiplier;
final BigDecimal bigDecimalMultiplier;
final MicroPropsGenerator parent;
/** Creates a modifier that uses the SimpleFormatter string formats. */
public SimpleModifier(String compiledPattern, Field field, boolean strong) {
- this.compiledPattern = (compiledPattern == null) ? "\u0001\u0000" : compiledPattern;
+ assert compiledPattern != null;
+ this.compiledPattern = compiledPattern;
this.field = field;
this.strong = strong;
"\uD801\uDCA0", "\uD801\uDCA1", "\uD801\uDCA2", "\uD801\uDCA3", "\uD801\uDCA4",
"\uD801\uDCA5", "\uD801\uDCA6", "\uD801\uDCA7", "\uD801\uDCA8", "\uD801\uDCA9"
};
- final String[] differentDigitStrings = {"0", "b", "3", "d", "5", "f", "7", "h", "9", "j"};
+ final String[] differentDigitStrings = {"0", "b", "3", "d", "5", "ff", "7", "h", "9", "j"};
DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ENGLISH);