Ejemplo n.º 1
0
        /// <summary>
        /// Reads the state from the stream.
        /// </summary>
        /// <param name="in">  the input stream, not null </param>
        /// <returns> the created object, not null </returns>
        /// <exception cref="IOException"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static ZoneRules readExternal(java.io.DataInput in) throws java.io.IOException, ClassNotFoundException
        internal static ZoneRules ReadExternal(DataInput @in)
        {
            int stdSize = @in.ReadInt();

            long[] stdTrans = (stdSize == 0) ? EMPTY_LONG_ARRAY : new long[stdSize];
            for (int i = 0; i < stdSize; i++)
            {
                stdTrans[i] = Ser.ReadEpochSec(@in);
            }
            ZoneOffset[] stdOffsets = new ZoneOffset[stdSize + 1];
            for (int i = 0; i < stdOffsets.Length; i++)
            {
                stdOffsets[i] = Ser.ReadOffset(@in);
            }
            int savSize = @in.ReadInt();

            long[] savTrans = (savSize == 0) ? EMPTY_LONG_ARRAY : new long[savSize];
            for (int i = 0; i < savSize; i++)
            {
                savTrans[i] = Ser.ReadEpochSec(@in);
            }
            ZoneOffset[] savOffsets = new ZoneOffset[savSize + 1];
            for (int i = 0; i < savOffsets.Length; i++)
            {
                savOffsets[i] = Ser.ReadOffset(@in);
            }
            int ruleSize = @in.ReadByte();

            ZoneOffsetTransitionRule[] rules = (ruleSize == 0) ? EMPTY_LASTRULES : new ZoneOffsetTransitionRule[ruleSize];
            for (int i = 0; i < ruleSize; i++)
            {
                rules[i] = ZoneOffsetTransitionRule.ReadExternal(@in);
            }
            return(new ZoneRules(stdTrans, stdOffsets, savTrans, savOffsets, rules));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes the state to the stream.
        /// </summary>
        /// <param name="out">  the output stream, not null </param>
        /// <exception cref="IOException"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: void writeExternal(java.io.DataOutput out) throws java.io.IOException
        internal void WriteExternal(DataOutput @out)
        {
            @out.WriteInt(StandardTransitions.Length);
            foreach (long trans in StandardTransitions)
            {
                Ser.WriteEpochSec(trans, @out);
            }
            foreach (ZoneOffset offset in StandardOffsets)
            {
                Ser.WriteOffset(offset, @out);
            }
            @out.WriteInt(SavingsInstantTransitions.Length);
            foreach (long trans in SavingsInstantTransitions)
            {
                Ser.WriteEpochSec(trans, @out);
            }
            foreach (ZoneOffset offset in WallOffsets)
            {
                Ser.WriteOffset(offset, @out);
            }
            @out.WriteByte(LastRules.Length);
            foreach (ZoneOffsetTransitionRule rule in LastRules)
            {
                rule.WriteExternal(@out);
            }
        }
Ejemplo n.º 3
0
        protected internal override ZoneRules ProvideRules(String zoneId, bool forCaching)
        {
            // forCaching flag is ignored because this is not a dynamic provider
            Object obj = RegionToRules[zoneId];

            if (obj == null)
            {
                throw new ZoneRulesException("Unknown time-zone ID: " + zoneId);
            }
            try
            {
                if (obj is sbyte[])
                {
                    sbyte[]         bytes = (sbyte[])obj;
                    DataInputStream dis   = new DataInputStream(new ByteArrayInputStream(bytes));
                    obj = Ser.Read(dis);
                    RegionToRules[zoneId] = obj;
                }
                return((ZoneRules)obj);
            }
            catch (Exception ex)
            {
                throw new ZoneRulesException("Invalid binary time-zone data: TZDB:" + zoneId + ", version: " + VersionId, ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads the state from the stream.
        /// </summary>
        /// <param name="in">  the input stream, not null </param>
        /// <returns> the created object, not null </returns>
        /// <exception cref="IOException"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static ZoneOffsetTransition readExternal(java.io.DataInput in) throws java.io.IOException
        internal static ZoneOffsetTransition ReadExternal(DataInput @in)
        {
            long       epochSecond = Ser.ReadEpochSec(@in);
            ZoneOffset before      = Ser.ReadOffset(@in);
            ZoneOffset after       = Ser.ReadOffset(@in);

            if (before.Equals(after))
            {
                throw new IllegalArgumentException("Offsets must not be equal");
            }
            return(new ZoneOffsetTransition(epochSecond, before, after));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Writes the state to the stream.
        /// </summary>
        /// <param name="out">  the output stream, not null </param>
        /// <exception cref="IOException"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: void writeExternal(java.io.DataOutput out) throws java.io.IOException
        internal void WriteExternal(DataOutput @out)
        {
            Ser.WriteEpochSec(ToEpochSecond(), @out);
            Ser.WriteOffset(OffsetBefore_Renamed, @out);
            Ser.WriteOffset(OffsetAfter_Renamed, @out);
        }