private void ReadObject(IlObjectInputStream stream) { /*ObjectInputStream.GetField fields = stream.ReadFields(); * groupingUsed = fields.Get("groupingUsed", true); //$NON-NLS-1$ * parseIntegerOnly = fields.Get("parseIntegerOnly", false); //$NON-NLS-1$ * if (fields.Get("serialVersionOnStream", 0) == 0) { //$NON-NLS-1$ * maximumFractionDigits = fields.Get("maxFractionDigits", (byte) 3); //$NON-NLS-1$ * maximumIntegerDigits = fields.Get("maxIntegerDigits", (byte) 40); //$NON-NLS-1$ * minimumFractionDigits = fields.Get("minFractionDigits", (byte) 0); //$NON-NLS-1$ * minimumIntegerDigits = fields.Get("minIntegerDigits", (byte) 1); //$NON-NLS-1$ * } else { * maximumFractionDigits = fields.Get("maximumFractionDigits", 3); //$NON-NLS-1$ * maximumIntegerDigits = fields.Get("maximumIntegerDigits", 40); //$NON-NLS-1$ * minimumFractionDigits = fields.Get("minimumFractionDigits", 0); //$NON-NLS-1$ * minimumIntegerDigits = fields.Get("minimumIntegerDigits", 1); //$NON-NLS-1$ * } * if (minimumIntegerDigits > maximumIntegerDigits || minimumFractionDigits > maximumFractionDigits) { || // text.00=min digits greater than max digits || throw new IOException("text.00"); //$NON-NLS-1$ ||} ||if (minimumIntegerDigits < 0 || maximumIntegerDigits < 0 || minimumFractionDigits < 0 || maximumFractionDigits < 0) { || // text.01=min or max digits negative || throw new IOException("text.01"); //$NON-NLS-1$ ||}*/ }
private void ReadObject(IlObjectInputStream stream) { /*ObjectInputStream.GetField fields = stream.ReadFields(); * argumentNumbers = (int[]) fields.Get("argumentNumbers", null); //$NON-NLS-1$ * formats = (Format[]) fields.Get("formats", null); //$NON-NLS-1$ * locale = (CultureInfo) fields.Get("locale", null); //$NON-NLS-1$ * maxOffset = fields.Get("maxOffset", 0); //$NON-NLS-1$ * int[] offsets = (int[]) fields.Get("offsets", null); //$NON-NLS-1$ * String pattern = (String) fields.Get("pattern", null); //$NON-NLS-1$ * int length; * if (maxOffset < 0) { * length = (pattern.Length > 0) ? 1 : 0; * } else { * length = maxOffset + ((offsets[maxOffset] == pattern.Length) ? 1 : 2); + } + strings = new String[length]; + int last = 0; + for (int i = 0; i <= maxOffset; i++) { + strings[i] = pattern.Substring(last,(offsets[i])-(last)); + last = offsets[i]; + } + if (maxOffset + 1 < strings.Length) { + strings[strings.Length - 1] = pattern.Substring(last,(pattern.Length)-(last)); + }*/ }
private void ReadObject(IlObjectInputStream stream) { /*ObjectInputStream.GetField fields = stream.ReadFields(); * patternChars = new char[10]; * currencySymbol = (String) fields.Get("currencySymbol", ""); //$NON-NLS-1$ //$NON-NLS-2$ * SetDecimalSeparator(fields.Get("decimalSeparator", '.')); //$NON-NLS-1$ * SetDigit(fields.Get("digit", '#')); //$NON-NLS-1$ * SetGroupingSeparator(fields.Get("groupingSeparator", ',')); //$NON-NLS-1$ * infinity = (String) fields.Get("infinity", ""); //$NON-NLS-1$ //$NON-NLS-2$ * intlCurrencySymbol = (String) fields.Get("intlCurrencySymbol", ""); //$NON-NLS-1$ //$NON-NLS-2$ * SetMinusSign(fields.Get("minusSign", '-')); //$NON-NLS-1$ * NaN = (String) fields.Get("NaN", ""); //$NON-NLS-1$ //$NON-NLS-2$ * SetPatternSeparator(fields.Get("patternSeparator", ';')); //$NON-NLS-1$ * SetPercent(fields.Get("percent", '%')); //$NON-NLS-1$ * SetPerMill(fields.Get("perMill", '\u2030')); //$NON-NLS-1$ * SetZeroDigit(fields.Get("zeroDigit", '0')); //$NON-NLS-1$ * locale = (CultureInfo) fields.Get("locale", null); //$NON-NLS-1$ * if (fields.Get("serialVersionOnStream", 0) == 0) { //$NON-NLS-1$ * SetMonetaryDecimalSeparator(this.NumberDecimalSeparator[0]); * SetExponential('E'); * } else { * SetMonetaryDecimalSeparator(fields.Get("monetarySeparator", '.')); //$NON-NLS-1$ * SetExponential(fields.Get("exponential", 'E')); //$NON-NLS-1$ * * } * try { * currency = System.Collections.Currency.GetInstance(intlCurrencySymbol); * } catch (ArgumentException e) { * currency = null; * }*/ }
/// <summary> /// Override readObject. /// </summary> /// private void ReadObject(IlObjectInputStream stream) { stream.DefaultReadObject(); /* set up the transient caches... */ astro = new CalendarAstronomer(); winterSolsticeCache = new CalendarCache(); newYearCache = new CalendarCache(); }
/// <summary> /// Read the default serializable fields, then if /// <c>serialVersionOnStream</c> is less than 1, initialize /// <c>monetarySeparator</c> to be the same as /// <c>decimalSeparator</c> and <c>exponential</c> to be 'E'. /// Finally, set serialVersionOnStream back to the maximum allowed value so /// that default serialization will work properly if this object is streamed /// out again. /// </summary> /// private void ReadObject(IlObjectInputStream stream) { // TODO: it looks to me {dlf} that the serialization code was never // updated // to handle the actual/valid ulocale fields. stream.DefaultReadObject(); // /CLOVER:OFF // we don't have data for these old serialized forms any more if (serialVersionOnStream < 1) { // Didn't have monetarySeparator or exponential field; // use defaults. monetarySeparator = decimalSeparator; exponential = 'E'; } if (serialVersionOnStream < 2) { padEscape = IBM.ICU.Text.DecimalFormat.PATTERN_PAD_ESCAPE; plusSign = IBM.ICU.Text.DecimalFormat.PATTERN_PLUS_SIGN; exponentSeparator = exponential.ToString(); // Although we read the exponential field on stream to create the // exponentSeparator, we don't do the reverse, since scientific // notation isn't supported by the old classes, even though the // symbol is there. } // /CLOVER:ON if (serialVersionOnStream < 3) { // Resurrected objects from old streams will have no // locale. There is no 100% fix for this. A // 90% fix is to construct a mapping of data back to // locale, perhaps a hash of all our members. This is // expensive and doesn't seem worth it. requestedLocale = Locale.GetDefault(); } if (serialVersionOnStream < 4) { // use same default behavior as for versions with no Locale ulocale = IBM.ICU.Util.ULocale.ForLocale(requestedLocale); } if (serialVersionOnStream < 5) { // use the same one for groupingSeparator monetaryGroupingSeparator = groupingSeparator; } serialVersionOnStream = currentSerialVersion; // recreate currency = IBM.ICU.Util.Currency.GetInstance(intlCurrencySymbol); }
private void ReadObject(IlObjectInputStream stream) { /*ObjectInputStream.GetField fields = stream.ReadFields(); * int version = fields.Get("serialVersionOnStream", 0); //$NON-NLS-1$ * DateTime date; * if (version > 0) { * date = (DateTime) fields.Get("defaultCenturyStart", DateTime.Now); //$NON-NLS-1$ * } else { * date = DateTime.Now; * } * Set2DigitYearStart(date); * formatData = (DateFormatSymbols) fields.Get("formatData", null); //$NON-NLS-1$ * pattern = (String) fields.Get("pattern", ""); //$NON-NLS-1$ //$NON-NLS-2$*/ }
public void Test_RIHarmony_compatible() { IlObjectInputStream i = null; try { NumberFormatInfo symbols = NumberFormatInfo.GetInstance(ILOG.J2CsMapping.Util.Culture.CultureInfoHelper.FRANCE); i = new IlObjectInputStream( ILOG.J2CsMapping.IO.IOUtility.GetResourceAsStream(GetType().Assembly, "/serialization/java/text/DecimalFormatSymbols.ser")); NumberFormatInfo symbolsD = (NumberFormatInfo)i .ReadObject(); Junit.Framework.Assert.AssertEquals(symbols, symbolsD); } finally { try { if (i != null) { ((Stream)i).Close(); } } catch (Exception e) { // ignore } } }
private void CheckSerialization(IBM.ICU.Text.MessageFormat format) { try { MemoryStream ba = new MemoryStream(); IlObjectOutputStream xout = new IlObjectOutputStream(ba); xout.WriteObject(format); ((Stream)xout).Close(); IlObjectInputStream ins0 = new IlObjectInputStream( new MemoryStream(ba.ToArray())); IBM.ICU.Text.MessageFormat read = (IBM.ICU.Text.MessageFormat)ins0.ReadObject(); NUnit.Framework.Assert.IsTrue(format.Equals(read), "Not equal: " + format.ToPattern()); } catch (IOException e) { NUnit.Framework.Assert.Fail("Format: " + format.ToPattern() + " caused IOException: " + e); } catch (TypeLoadException e_0) { NUnit.Framework.Assert.Fail("Format: " + format.ToPattern() + " caused ClassNotFoundException: " + e_0); } }
public void Test_serialization() { NumberFormatInfo symbols = NumberFormatInfo.GetInstance(ILOG.J2CsMapping.Util.Culture.CultureInfoHelper.FRANCE); Currency currency = symbols.GetCurrency(); Junit.Framework.Assert.AssertNotNull(currency); // serialize MemoryStream byteOStream = new MemoryStream(); IlObjectOutputStream objectOStream = new IlObjectOutputStream(byteOStream); objectOStream.WriteObject(symbols); // and deserialize IlObjectInputStream objectIStream = new IlObjectInputStream( new MemoryStream(byteOStream.ToArray())); NumberFormatInfo symbolsD = (NumberFormatInfo)objectIStream .ReadObject(); // The associated currency will not persist currency = symbolsD.GetCurrency(); Junit.Framework.Assert.AssertNotNull(currency); }
private void ReadObject(IlObjectInputStream stream) { stream.DefaultReadObject(); // re-allocate the work buffer decimalBuf = new char[20]; }
/// <summary> /// Reads serialized fields following serialized forms specified by Java /// specification. /// </summary> /// /// <param name="stream">the input stream to read serialized bytes</param> /// <exception cref="IOException">if some I/O error occurs</exception> /// <exception cref="ClassNotFoundException">if some class of serialized objects or fields cannot be found</exception> /* @SuppressWarnings("nls")*/ private void ReadObject(IlObjectInputStream stream) { /* * ObjectInputStream.GetField fields = stream.ReadFields(); * String positivePrefix = (String) fields.Get("positivePrefix", ""); * String positiveSuffix = (String) fields.Get("positiveSuffix", ""); * String negativePrefix = (String) fields.Get("negativePrefix", "-"); * String negativeSuffix = (String) fields.Get("negativeSuffix", ""); * * String posPrefixPattern = (String) fields.Get("posPrefixPattern", ""); * String posSuffixPattern = (String) fields.Get("posSuffixPattern", ""); * String negPrefixPattern = (String) fields.Get("negPrefixPattern", "-"); * String negSuffixPattern = (String) fields.Get("negSuffixPattern", ""); * * int multiplier = fields.Get("multiplier", 1); * byte groupingSize = fields.Get("groupingSize", (byte) 3); * bool decimalSeparatorAlwaysShown = fields.Get( * "decimalSeparatorAlwaysShown", false); * bool parseBigDecimal_0 = fields.Get("parseBigDecimal", false); * symbols = (NumberFormatInfo) fields.Get("symbols", null); * * bool useExponentialNotation = fields.Get("useExponentialNotation", * false); * byte minExponentDigits = fields.Get("minExponentDigits", (byte) 0); * * int maximumIntegerDigits = fields.Get("maximumIntegerDigits", 309); * int minimumIntegerDigits = fields.Get("minimumIntegerDigits", 309); * int maximumFractionDigits = fields.Get("maximumFractionDigits", 340); * int minimumFractionDigits = fields.Get("minimumFractionDigits", 340); * this.serialVersionOnStream = fields.Get("serialVersionOnStream", 0); * * CultureInfo locale = (CultureInfo) ILOG.J2CsMapping.Text.IlFormat.GetInternalField("locale", symbols); * dform = new Com.Ibm.Icu.Text.DecimalFormat("", * new Com.Ibm.Icu.Text.DecimalFormatSymbols(locale)); * SetInternalField("useExponentialNotation", dform, * useExponentialNotation); * SetInternalField("minExponentDigits", dform, * (byte )(minExponentDigits)); * dform.SetPositivePrefix(positivePrefix); * dform.SetPositiveSuffix(positiveSuffix); * dform.SetNegativePrefix(negativePrefix); * dform.SetNegativeSuffix(negativeSuffix); * SetInternalField("posPrefixPattern", dform, posPrefixPattern); * SetInternalField("posSuffixPattern", dform, posSuffixPattern); * SetInternalField("negPrefixPattern", dform, negPrefixPattern); * SetInternalField("negSuffixPattern", dform, negSuffixPattern); * dform.SetMultiplier(multiplier); * dform.SetGroupingSize(groupingSize); * dform.SetDecimalSeparatorAlwaysShown(decimalSeparatorAlwaysShown); * dform.SetMinimumIntegerDigits(minimumIntegerDigits); * dform.SetMaximumIntegerDigits(maximumIntegerDigits); * dform.SetMinimumFractionDigits(minimumFractionDigits); * dform.SetMaximumFractionDigits(maximumFractionDigits); * this.SetParseBigDecimal(parseBigDecimal_0); * * if (serialVersionOnStream < 3) { * SetMaximumIntegerDigits(base.GetMaximumIntegerDigits()); * SetMinimumIntegerDigits(base.GetMinimumIntegerDigits()); * SetMaximumFractionDigits(base.GetMaximumFractionDigits()); * SetMinimumFractionDigits(base.GetMinimumFractionDigits()); * } * if (serialVersionOnStream < 1) { * this.SetInternalField("useExponentialNotation", dform, * false); * } * serialVersionOnStream = 3;*/ }