/*private static readonly ObjectStreamField[] serialPersistentFields = { * new ObjectStreamField("groupingUsed", typeof(Boolean)), //$NON-NLS-1$ * new ObjectStreamField("maxFractionDigits", typeof(Byte)), //$NON-NLS-1$ * new ObjectStreamField("maximumFractionDigits", typeof(Int32)), //$NON-NLS-1$ * new ObjectStreamField("maximumIntegerDigits", typeof(Int32)), //$NON-NLS-1$ * new ObjectStreamField("maxIntegerDigits", typeof(Byte)), //$NON-NLS-1$ * new ObjectStreamField("minFractionDigits", typeof(Byte)), //$NON-NLS-1$ * new ObjectStreamField("minimumFractionDigits", typeof(Int32)), //$NON-NLS-1$ * new ObjectStreamField("minimumIntegerDigits", typeof(Int32)), //$NON-NLS-1$ * new ObjectStreamField("minIntegerDigits", typeof(Byte)), //$NON-NLS-1$ * new ObjectStreamField("parseIntegerOnly", typeof(Boolean)), //$NON-NLS-1$ * new ObjectStreamField("serialVersionOnStream", typeof(Int32)), }; //$NON-NLS-1$*/ private void WriteObject(IlObjectOutputStream stream) { /*ObjectOutputStream.PutField fields = stream.PutFields(); * fields.Put("groupingUsed", groupingUsed); //$NON-NLS-1$ * fields.Put( * "maxFractionDigits", //$NON-NLS-1$ * (maximumFractionDigits < Byte.MaxValue) ? (byte) maximumFractionDigits * : Byte.MaxValue); * fields.Put("maximumFractionDigits", maximumFractionDigits); //$NON-NLS-1$ * fields.Put("maximumIntegerDigits", maximumIntegerDigits); //$NON-NLS-1$ * fields.Put( * "maxIntegerDigits", //$NON-NLS-1$ * (maximumIntegerDigits < Byte.MaxValue) ? (byte) maximumIntegerDigits * : Byte.MaxValue); * fields.Put( * "minFractionDigits", //$NON-NLS-1$ * (minimumFractionDigits < Byte.MaxValue) ? (byte) minimumFractionDigits * : Byte.MaxValue); * fields.Put("minimumFractionDigits", minimumFractionDigits); //$NON-NLS-1$ * fields.Put("minimumIntegerDigits", minimumIntegerDigits); //$NON-NLS-1$ * fields.Put( * "minIntegerDigits", //$NON-NLS-1$ * (minimumIntegerDigits < Byte.MaxValue) ? (byte) minimumIntegerDigits * : Byte.MaxValue); * fields.Put("parseIntegerOnly", parseIntegerOnly); //$NON-NLS-1$ * fields.Put("serialVersionOnStream", 1); //$NON-NLS-1$ * stream.WriteFields();*/ }
/*private static readonly ObjectStreamField[] serialPersistentFields = { * new ObjectStreamField("defaultCenturyStart", typeof(DateTime)), //$NON-NLS-1$ * new ObjectStreamField("formatData", typeof(DateFormatSymbols)), //$NON-NLS-1$ * new ObjectStreamField("pattern", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("serialVersionOnStream", typeof(Int32)), }; //$NON-NLS-1$*/ private void WriteObject(IlObjectOutputStream stream) { /*ObjectOutputStream.PutField fields = stream.PutFields(); * fields.Put("defaultCenturyStart", defaultCenturyStart); //$NON-NLS-1$ * fields.Put("formatData", formatData); //$NON-NLS-1$ * fields.Put("pattern", pattern); //$NON-NLS-1$ * fields.Put("serialVersionOnStream", 1); //$NON-NLS-1$ * stream.WriteFields();*/ }
/*private static readonly ObjectStreamField[] serialPersistentFields = { * new ObjectStreamField("currencySymbol", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("decimalSeparator", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("digit", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("exponential", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("groupingSeparator", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("infinity", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("intlCurrencySymbol", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("minusSign", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("monetarySeparator", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("NaN", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("patternSeparator", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("percent", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("perMill", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("serialVersionOnStream", typeof(Int32)), //$NON-NLS-1$ * new ObjectStreamField("zeroDigit", typeof(Char)), //$NON-NLS-1$ * new ObjectStreamField("locale", typeof(CultureInfo)), }; //$NON-NLS-1$*/ private void WriteObject(IlObjectOutputStream stream) { /*ObjectOutputStream.PutField fields = stream.PutFields(); * fields.Put("currencySymbol", currencySymbol); //$NON-NLS-1$ * fields.Put("decimalSeparator", this.NumberDecimalSeparator[0]); //$NON-NLS-1$ * fields.Put("digit", GetDigit()); //$NON-NLS-1$ * fields.Put("exponential", GetExponential()); //$NON-NLS-1$ * fields.Put("groupingSeparator", this.NumberGroupSeparator[0]); //$NON-NLS-1$ * fields.Put("infinity", infinity); //$NON-NLS-1$ * fields.Put("intlCurrencySymbol", intlCurrencySymbol); //$NON-NLS-1$ * fields.Put("minusSign", GetMinusSign()); //$NON-NLS-1$ * fields.Put("monetarySeparator", GetMonetaryDecimalSeparator()); //$NON-NLS-1$ * fields.Put("NaN", NaN); //$NON-NLS-1$ * fields.Put("patternSeparator", GetPatternSeparator()); //$NON-NLS-1$ * fields.Put("percent", GetPercent()); //$NON-NLS-1$ * fields.Put("perMill", GetPerMill()); //$NON-NLS-1$ * fields.Put("serialVersionOnStream", 1); //$NON-NLS-1$ * fields.Put("zeroDigit", GetZeroDigit()); //$NON-NLS-1$ * fields.Put("locale", locale); //$NON-NLS-1$ * stream.WriteFields();*/ }
// the fields list to be serialized /*private static readonly ObjectStreamField[] serialPersistentFields = { * new ObjectStreamField("positivePrefix", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("positiveSuffix", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("negativePrefix", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("negativeSuffix", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("posPrefixPattern", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("posSuffixPattern", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("negPrefixPattern", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("negSuffixPattern", typeof(String)), //$NON-NLS-1$ * new ObjectStreamField("multiplier", typeof(int)), //$NON-NLS-1$ * new ObjectStreamField("groupingSize", typeof(byte)), //$NON-NLS-1$ * new ObjectStreamField("decimalSeparatorAlwaysShown", typeof(bool)), //$NON-NLS-1$ * new ObjectStreamField("parseBigDecimal", typeof(bool)), //$NON-NLS-1$ * new ObjectStreamField("symbols", typeof(NumberFormatInfo)), //$NON-NLS-1$ * new ObjectStreamField("useExponentialNotation", typeof(bool)), //$NON-NLS-1$ * new ObjectStreamField("minExponentDigits", typeof(byte)), //$NON-NLS-1$ * new ObjectStreamField("maximumIntegerDigits", typeof(int)), //$NON-NLS-1$ * new ObjectStreamField("minimumIntegerDigits", typeof(int)), //$NON-NLS-1$ * new ObjectStreamField("maximumFractionDigits", typeof(int)), //$NON-NLS-1$ * new ObjectStreamField("minimumFractionDigits", typeof(int)), //$NON-NLS-1$ * new ObjectStreamField("serialVersionOnStream", typeof(int)), }; //$NON-NLS-1$*/ /// <summary> /// Writes serialized fields following serialized forms specified by Java /// specification. /// </summary> /// /// <param name="stream">the output stream to write serialized bytes</param> /// <exception cref="IOException">if some I/O error occurs</exception> /// <exception cref="ClassNotFoundException"></exception> /* @SuppressWarnings("nls")*/ private void WriteObject(IlObjectOutputStream stream) { /*ObjectOutputStream.PutField fields = stream.PutFields(); * fields.Put("positivePrefix", dform.GetPositivePrefix()); * fields.Put("positiveSuffix", dform.GetPositiveSuffix()); * fields.Put("negativePrefix", dform.GetNegativePrefix()); * fields.Put("negativeSuffix", dform.GetNegativeSuffix()); * String posPrefixPattern = (String) ILOG.J2CsMapping.Text.IlFormat.GetInternalField( * "posPrefixPattern", dform); * fields.Put("posPrefixPattern", posPrefixPattern); * String posSuffixPattern = (String) ILOG.J2CsMapping.Text.IlFormat.GetInternalField( * "posSuffixPattern", dform); * fields.Put("posSuffixPattern", posSuffixPattern); * String negPrefixPattern = (String) ILOG.J2CsMapping.Text.IlFormat.GetInternalField( * "negPrefixPattern", dform); * fields.Put("negPrefixPattern", negPrefixPattern); * String negSuffixPattern = (String) ILOG.J2CsMapping.Text.IlFormat.GetInternalField( * "negSuffixPattern", dform); * fields.Put("negSuffixPattern", negSuffixPattern); * fields.Put("multiplier", dform.GetMultiplier()); * fields.Put("groupingSize", (byte) dform.GetGroupingSize()); * fields.Put("decimalSeparatorAlwaysShown", * dform.IsDecimalSeparatorAlwaysShown()); * fields.Put("parseBigDecimal", parseBigDecimal); * fields.Put("symbols", symbols); * bool useExponentialNotation = (bool)(((Boolean) ILOG.J2CsMapping.Text.IlFormat.GetInternalField( * "useExponentialNotation", dform))); * fields.Put("useExponentialNotation", useExponentialNotation); * byte minExponentDigits = ((Byte) ILOG.J2CsMapping.Text.IlFormat.GetInternalField( * "minExponentDigits", dform)); * fields.Put("minExponentDigits", minExponentDigits); * fields.Put("maximumIntegerDigits", dform.GetMaximumIntegerDigits()); * fields.Put("minimumIntegerDigits", dform.GetMinimumIntegerDigits()); * fields.Put("maximumFractionDigits", dform.GetMaximumFractionDigits()); * fields.Put("minimumFractionDigits", dform.GetMinimumFractionDigits()); * fields.Put("serialVersionOnStream", CURRENT_SERIAL_VERTION); * stream.WriteFields();*/ }
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 static readonly ObjectStreamField[] serialPersistentFields = { * new ObjectStreamField("argumentNumbers", typeof(int[])), //$NON-NLS-1$ * new ObjectStreamField("formats", typeof(Format[])), //$NON-NLS-1$ * new ObjectStreamField("locale", typeof(CultureInfo)), //$NON-NLS-1$ * new ObjectStreamField("maxOffset", typeof(Int32)), //$NON-NLS-1$ * new ObjectStreamField("offsets", typeof(int[])), //$NON-NLS-1$ * new ObjectStreamField("pattern", typeof(String)), }; //$NON-NLS-1$*/ private void WriteObject(IlObjectOutputStream stream) { /*ObjectOutputStream.PutField fields = stream.PutFields(); * fields.Put("argumentNumbers", argumentNumbers); //$NON-NLS-1$ * Format[] compatibleFormats = formats; * fields.Put("formats", compatibleFormats); //$NON-NLS-1$ * fields.Put("locale", locale); //$NON-NLS-1$ * fields.Put("maxOffset", maxOffset); //$NON-NLS-1$ * int offset = 0; * int offsetsLength = maxOffset + 1; * int[] offsets = new int[offsetsLength]; * StringBuilder pattern = new StringBuilder(); * for (int i = 0; i <= maxOffset; i++) { * offset += strings[i].Length; * offsets[i] = offset; * pattern.Append(strings[i]); * } * if (maxOffset + 1 < strings.Length) { * pattern.Append(strings[maxOffset + 1]); * } * fields.Put("offsets", offsets); //$NON-NLS-1$ * fields.Put("pattern", pattern.ToString()); //$NON-NLS-1$ * stream.WriteFields();*/ }