Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: void internalWriteEntries(java.io.ObjectOutputStream s) throws java.io.IOException
        internal virtual void InternalWriteEntries(java.io.ObjectOutputStream s)
        {
            for (LinkedHashMap.Entry <K, V> e = Head; e != Map_Fields.Null; e = e.After)
            {
                s.WriteObject(e.Key_Renamed);
                s.WriteObject(e.Value_Renamed);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// <code>writeObject</code> for custom serialization.
        ///
        /// <para>This method writes this object's serialized form for this class
        /// as follows:
        ///
        /// </para>
        /// <para>The <seealso cref="RemoteRef#getRefClass(java.io.ObjectOutput) getRefClass"/>
        /// method is invoked on this object's <code>ref</code> field
        /// to obtain its external ref type name.
        /// If the value returned by <code>getRefClass</code> was
        /// a non-<code>null</code> string of length greater than zero,
        /// the <code>writeUTF</code> method is invoked on <code>out</code>
        /// with the value returned by <code>getRefClass</code>, and then
        /// the <code>writeExternal</code> method is invoked on
        /// this object's <code>ref</code> field passing <code>out</code>
        /// as the argument; otherwise,
        /// the <code>writeUTF</code> method is invoked on <code>out</code>
        /// with a zero-length string (<code>""</code>), and then
        /// the <code>writeObject</code> method is invoked on <code>out</code>
        /// passing this object's <code>ref</code> field as the argument.
        ///
        /// @serialData
        ///
        /// The serialized data for this class comprises a string (written with
        /// <code>ObjectOutput.writeUTF</code>) that is either the external
        /// ref type name of the contained <code>RemoteRef</code> instance
        /// (the <code>ref</code> field) or a zero-length string, followed by
        /// either the external form of the <code>ref</code> field as written by
        /// its <code>writeExternal</code> method if the string was of non-zero
        /// length, or the serialized form of the <code>ref</code> field as
        /// written by passing it to the serialization stream's
        /// <code>writeObject</code> if the string was of zero length.
        ///
        /// </para>
        /// <para>If this object is an instance of
        /// <seealso cref="RemoteStub"/> or <seealso cref="RemoteObjectInvocationHandler"/>
        /// that was returned from any of
        /// the <code>UnicastRemoteObject.exportObject</code> methods
        /// and custom socket factories are not used,
        /// the external ref type name is <code>"UnicastRef"</code>.
        ///
        /// If this object is an instance of
        /// <code>RemoteStub</code> or <code>RemoteObjectInvocationHandler</code>
        /// that was returned from any of
        /// the <code>UnicastRemoteObject.exportObject</code> methods
        /// and custom socket factories are used,
        /// the external ref type name is <code>"UnicastRef2"</code>.
        ///
        /// If this object is an instance of
        /// <code>RemoteStub</code> or <code>RemoteObjectInvocationHandler</code>
        /// that was returned from any of
        /// the <code>java.rmi.activation.Activatable.exportObject</code> methods,
        /// the external ref type name is <code>"ActivatableRef"</code>.
        ///
        /// If this object is an instance of
        /// <code>RemoteStub</code> or <code>RemoteObjectInvocationHandler</code>
        /// that was returned from
        /// the <code>RemoteObject.toStub</code> method (and the argument passed
        /// to <code>toStub</code> was not itself a <code>RemoteStub</code>),
        /// the external ref type name is a function of how the remote object
        /// passed to <code>toStub</code> was exported, as described above.
        ///
        /// If this object is an instance of
        /// <code>RemoteStub</code> or <code>RemoteObjectInvocationHandler</code>
        /// that was originally created via deserialization,
        /// the external ref type name is the same as that which was read
        /// when this object was deserialized.
        ///
        /// </para>
        /// <para>If this object is an instance of
        /// <code>java.rmi.server.UnicastRemoteObject</code> that does not
        /// use custom socket factories,
        /// the external ref type name is <code>"UnicastServerRef"</code>.
        ///
        /// If this object is an instance of
        /// <code>UnicastRemoteObject</code> that does
        /// use custom socket factories,
        /// the external ref type name is <code>"UnicastServerRef2"</code>.
        ///
        /// </para>
        /// <para>Following is the data that must be written by the
        /// <code>writeExternal</code> method and read by the
        /// <code>readExternal</code> method of <code>RemoteRef</code>
        /// implementation classes that correspond to the each of the
        /// defined external ref type names:
        ///
        /// </para>
        /// <para>For <code>"UnicastRef"</code>:
        ///
        /// <ul>
        ///
        /// <li>the hostname of the referenced remote object,
        /// written by <seealso cref="java.io.ObjectOutput#writeUTF(String)"/>
        ///
        /// <li>the port of the referenced remote object,
        /// written by <seealso cref="java.io.ObjectOutput#writeInt(int)"/>
        ///
        /// <li>the data written as a result of calling
        /// {link java.rmi.server.ObjID#write(java.io.ObjectOutput)}
        /// on the <code>ObjID</code> instance contained in the reference
        ///
        /// <li>the boolean value <code>false</code>,
        /// written by <seealso cref="java.io.ObjectOutput#writeBoolean(boolean)"/>
        ///
        /// </ul>
        ///
        /// </para>
        /// <para>For <code>"UnicastRef2"</code> with a
        /// <code>null</code> client socket factory:
        ///
        /// <ul>
        ///
        /// <li>the byte value <code>0x00</code>
        /// (indicating <code>null</code> client socket factory),
        /// written by <seealso cref="java.io.ObjectOutput#writeByte(int)"/>
        ///
        /// <li>the hostname of the referenced remote object,
        /// written by <seealso cref="java.io.ObjectOutput#writeUTF(String)"/>
        ///
        /// <li>the port of the referenced remote object,
        /// written by <seealso cref="java.io.ObjectOutput#writeInt(int)"/>
        ///
        /// <li>the data written as a result of calling
        /// {link java.rmi.server.ObjID#write(java.io.ObjectOutput)}
        /// on the <code>ObjID</code> instance contained in the reference
        ///
        /// <li>the boolean value <code>false</code>,
        /// written by <seealso cref="java.io.ObjectOutput#writeBoolean(boolean)"/>
        ///
        /// </ul>
        ///
        /// </para>
        /// <para>For <code>"UnicastRef2"</code> with a
        /// non-<code>null</code> client socket factory:
        ///
        /// <ul>
        ///
        /// <li>the byte value <code>0x01</code>
        /// (indicating non-<code>null</code> client socket factory),
        /// written by <seealso cref="java.io.ObjectOutput#writeByte(int)"/>
        ///
        /// <li>the hostname of the referenced remote object,
        /// written by <seealso cref="java.io.ObjectOutput#writeUTF(String)"/>
        ///
        /// <li>the port of the referenced remote object,
        /// written by <seealso cref="java.io.ObjectOutput#writeInt(int)"/>
        ///
        /// <li>a client socket factory (object of type
        /// <code>java.rmi.server.RMIClientSocketFactory</code>),
        /// written by passing it to an invocation of
        /// <code>writeObject</code> on the stream instance
        ///
        /// <li>the data written as a result of calling
        /// {link java.rmi.server.ObjID#write(java.io.ObjectOutput)}
        /// on the <code>ObjID</code> instance contained in the reference
        ///
        /// <li>the boolean value <code>false</code>,
        /// written by <seealso cref="java.io.ObjectOutput#writeBoolean(boolean)"/>
        ///
        /// </ul>
        ///
        /// </para>
        /// <para>For <code>"ActivatableRef"</code> with a
        /// <code>null</code> nested remote reference:
        ///
        /// <ul>
        ///
        /// <li>an instance of
        /// <code>java.rmi.activation.ActivationID</code>,
        /// written by passing it to an invocation of
        /// <code>writeObject</code> on the stream instance
        ///
        /// <li>a zero-length string (<code>""</code>),
        /// written by <seealso cref="java.io.ObjectOutput#writeUTF(String)"/>
        ///
        /// </ul>
        ///
        /// </para>
        /// <para>For <code>"ActivatableRef"</code> with a
        /// non-<code>null</code> nested remote reference:
        ///
        /// <ul>
        ///
        /// <li>an instance of
        /// <code>java.rmi.activation.ActivationID</code>,
        /// written by passing it to an invocation of
        /// <code>writeObject</code> on the stream instance
        ///
        /// <li>the external ref type name of the nested remote reference,
        /// which must be <code>"UnicastRef2"</code>,
        /// written by <seealso cref="java.io.ObjectOutput#writeUTF(String)"/>
        ///
        /// <li>the external form of the nested remote reference,
        /// written by invoking its <code>writeExternal</code> method
        /// with the stream instance
        /// (see the description of the external form for
        /// <code>"UnicastRef2"</code> above)
        ///
        /// </ul>
        ///
        /// </para>
        /// <para>For <code>"UnicastServerRef"</code> and
        /// <code>"UnicastServerRef2"</code>, no data is written by the
        /// <code>writeExternal</code> method or read by the
        /// <code>readExternal</code> method.
        /// </para>
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException, java.lang.ClassNotFoundException
        private void WriteObject(java.io.ObjectOutputStream @out)
        {
            if (@ref == null)
            {
                throw new java.rmi.MarshalException("Invalid remote object");
            }
            else
            {
                String refClassName = @ref.GetRefClass(@out);
                if (refClassName == null || refClassName.Length() == 0)
                {
                    /*
                     * No reference class name specified, so serialize
                     * remote reference.
                     */
                    @out.WriteUTF("");
                    @out.WriteObject(@ref);
                }
                else
                {
                    /*
                     * Built-in reference class specified, so delegate
                     * to reference to write out its external form.
                     */
                    @out.WriteUTF(refClassName);
                    @ref.WriteExternal(@out);
                }
            }
        }
 public virtual void TestSerializePolyline()
 {
     try
     {
         java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream    oo        = new java.io.ObjectOutputStream(streamOut);
         com.epl.geometry.Polyline     pt        = new com.epl.geometry.Polyline();
         pt.StartPath(10, 10);
         pt.LineTo(100, 100);
         pt.LineTo(200, 100);
         oo.WriteObject(pt);
         System.IO.BinaryWriter    streamIn = new System.IO.BinaryWriter(streamOut.ToByteArray());
         java.io.ObjectInputStream ii       = new java.io.ObjectInputStream(streamIn);
         com.epl.geometry.Polyline ptRes    = (com.epl.geometry.Polyline)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt));
     }
     catch (System.Exception)
     {
         Fail("Polyline serialization failure");
     }
     //try
     //{
     //FileOutputStream streamOut = new FileOutputStream("c:/temp/savedPolyline1.txt");
     //ObjectOutputStream oo = new ObjectOutputStream(streamOut);
     //Polyline pt = new Polyline();
     //pt.startPath(10, 10);
     //pt.lineTo(100, 100);
     //pt.lineTo(200, 100);
     //oo.writeObject(pt);
     //}
     //catch(Exception ex)
     //{
     //fail("Polyline serialization failure");
     //}
     try
     {
         java.io.InputStream       s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedPolyline.txt");
         java.io.ObjectInputStream ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.Polyline ptRes = (com.epl.geometry.Polyline)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes != null);
     }
     catch (System.Exception)
     {
         Fail("Polyline serialization failure");
     }
     try
     {
         java.io.InputStream       s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedPolyline1.txt");
         java.io.ObjectInputStream ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.Polyline ptRes = (com.epl.geometry.Polyline)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes != null);
     }
     catch (System.Exception)
     {
         Fail("Polyline serialization failure");
     }
 }
 public virtual void TestSerializeMultiPoint()
 {
     try
     {
         java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream    oo        = new java.io.ObjectOutputStream(streamOut);
         com.epl.geometry.MultiPoint   pt        = new com.epl.geometry.MultiPoint();
         pt.Add(10, 30);
         pt.Add(120, 40);
         oo.WriteObject(pt);
         System.IO.BinaryWriter      streamIn = new System.IO.BinaryWriter(streamOut.ToByteArray());
         java.io.ObjectInputStream   ii       = new java.io.ObjectInputStream(streamIn);
         com.epl.geometry.MultiPoint ptRes    = (com.epl.geometry.MultiPoint)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt));
     }
     catch (System.Exception)
     {
         Fail("MultiPoint serialization failure");
     }
     //try
     //{
     //FileOutputStream streamOut = new FileOutputStream("c:/temp/savedMultiPoint1.txt");
     //ObjectOutputStream oo = new ObjectOutputStream(streamOut);
     //MultiPoint pt = new MultiPoint();
     //pt.add(10, 30);
     //pt.add(120, 40);
     //oo.writeObject(pt);
     //}
     //catch(Exception ex)
     //{
     //fail("MultiPoint serialization failure");
     //}
     try
     {
         java.io.InputStream         s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedMultiPoint.txt");
         java.io.ObjectInputStream   ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.MultiPoint ptRes = (com.epl.geometry.MultiPoint)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.GetPoint(1).GetY() == 40);
     }
     catch (System.Exception)
     {
         Fail("MultiPoint serialization failure");
     }
     try
     {
         java.io.InputStream         s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedMultiPoint1.txt");
         java.io.ObjectInputStream   ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.MultiPoint ptRes = (com.epl.geometry.MultiPoint)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.GetPoint(1).GetY() == 40);
     }
     catch (System.Exception)
     {
         Fail("MultiPoint serialization failure");
     }
 }
 public virtual void TestSerializeEnvelope()
 {
     try
     {
         java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream    oo        = new java.io.ObjectOutputStream(streamOut);
         com.epl.geometry.Envelope     pt        = new com.epl.geometry.Envelope(10, 10, 400, 300);
         oo.WriteObject(pt);
         System.IO.BinaryWriter    streamIn = new System.IO.BinaryWriter(streamOut.ToByteArray());
         java.io.ObjectInputStream ii       = new java.io.ObjectInputStream(streamIn);
         com.epl.geometry.Envelope ptRes    = (com.epl.geometry.Envelope)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt));
     }
     catch (System.Exception)
     {
         Fail("Envelope serialization failure");
     }
     //try
     //{
     //FileOutputStream streamOut = new FileOutputStream("c:/temp/savedEnvelope1.txt");
     //ObjectOutputStream oo = new ObjectOutputStream(streamOut);
     //Envelope pt = new Envelope(10, 10, 400, 300);
     //oo.writeObject(pt);
     //}
     //catch(Exception ex)
     //{
     //fail("Envelope serialization failure");
     //}
     try
     {
         java.io.InputStream       s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedEnvelope.txt");
         java.io.ObjectInputStream ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.Envelope ptRes = (com.epl.geometry.Envelope)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.GetXMax() == 400);
     }
     catch (System.Exception)
     {
         Fail("Envelope serialization failure");
     }
     try
     {
         java.io.InputStream       s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedEnvelope1.txt");
         java.io.ObjectInputStream ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.Envelope ptRes = (com.epl.geometry.Envelope)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.GetXMax() == 400);
     }
     catch (System.Exception)
     {
         Fail("Envelope serialization failure");
     }
 }
 public virtual void TestSerializeSR()
 {
     try
     {
         java.io.ByteArrayOutputStream     streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream        oo        = new java.io.ObjectOutputStream(streamOut);
         com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(102100);
         oo.WriteObject(sr);
         System.IO.BinaryWriter            streamIn = new System.IO.BinaryWriter(streamOut.ToByteArray());
         java.io.ObjectInputStream         ii       = new java.io.ObjectInputStream(streamIn);
         com.epl.geometry.SpatialReference ptRes    = (com.epl.geometry.SpatialReference)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(sr));
     }
     catch (System.Exception)
     {
         Fail("Spatial Reference serialization failure");
     }
 }
 public virtual void TestSerializeEnvelope2D()
 {
     try
     {
         java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream    oo        = new java.io.ObjectOutputStream(streamOut);
         com.epl.geometry.Envelope2D   env       = new com.epl.geometry.Envelope2D(1.213948734, 2.213948734, 11.213948734, 12.213948734);
         oo.WriteObject(env);
         System.IO.BinaryWriter      streamIn = new System.IO.BinaryWriter(streamOut.ToByteArray());
         java.io.ObjectInputStream   ii       = new java.io.ObjectInputStream(streamIn);
         com.epl.geometry.Envelope2D envRes   = (com.epl.geometry.Envelope2D)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(envRes.Equals(env));
     }
     catch (System.Exception)
     {
         Fail("Envelope2D serialization failure");
     }
     //		try
     //		{
     //			 FileOutputStream streamOut = new FileOutputStream(
     //			 "c:/temp/savedEnvelope2D.txt");
     //			 ObjectOutputStream oo = new ObjectOutputStream(streamOut);
     //			 Envelope2D e = new Envelope2D(177.123, 188.234, 999.122, 888.999);
     //			 oo.writeObject(e);
     //		 }
     //		 catch(Exception ex)
     //		 {
     //		   fail("Envelope2D serialization failure");
     //		 }
     try
     {
         java.io.InputStream         s  = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedEnvelope2D.txt");
         java.io.ObjectInputStream   ii = new java.io.ObjectInputStream(s);
         com.epl.geometry.Envelope2D e  = (com.epl.geometry.Envelope2D)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(e != null);
         NUnit.Framework.Assert.IsTrue(e.Equals(new com.epl.geometry.Envelope2D(177.123, 188.234, 999.122, 888.999)));
     }
     catch (System.Exception)
     {
         Fail("Envelope2D serialization failure");
     }
 }
 public virtual void TestSerializeLine()
 {
     try
     {
         java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream    oo        = new java.io.ObjectOutputStream(streamOut);
         com.epl.geometry.Line         pt        = new com.epl.geometry.Line();
         pt.SetStart(new com.epl.geometry.Point(10, 30));
         pt.SetEnd(new com.epl.geometry.Point(120, 40));
         oo.WriteObject(pt);
         System.IO.BinaryWriter    streamIn = new System.IO.BinaryWriter(streamOut.ToByteArray());
         java.io.ObjectInputStream ii       = new java.io.ObjectInputStream(streamIn);
         com.epl.geometry.Line     ptRes    = (com.epl.geometry.Line)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt));
     }
     catch (System.Exception ex)
     {
         // fail("Line serialization failure");
         NUnit.Framework.Assert.AreEqual(ex.Message, "Cannot serialize this geometry");
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Writes this object out to a stream (i.e., serializes it).
        ///
        /// @serialData An initial {@code URL} is followed by an
        /// {@code int} indicating the number of certificates to follow
        /// (a value of "zero" denotes that there are no certificates associated
        /// with this object).
        /// Each certificate is written out starting with a {@code String}
        /// denoting the certificate type, followed by an
        /// {@code int} specifying the length of the certificate encoding,
        /// followed by the certificate encoding itself which is written out as an
        /// array of bytes. Finally, if any code signers are present then the array
        /// of code signers is serialized and written out too.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void writeObject(java.io.ObjectOutputStream oos) throws java.io.IOException
        private void WriteObject(java.io.ObjectOutputStream oos)
        {
            oos.DefaultWriteObject();             // location

            // Serialize the array of certs
            if (Certs == null || Certs.Length == 0)
            {
                oos.WriteInt(0);
            }
            else
            {
                // write out the total number of certs
                oos.WriteInt(Certs.Length);
                // write out each cert, including its type
                for (int i = 0; i < Certs.Length; i++)
                {
                    java.security.cert.Certificate cert = Certs[i];
                    try
                    {
                        oos.WriteUTF(cert.Type);
                        sbyte[] encoded = cert.Encoded;
                        oos.WriteInt(encoded.Length);
                        oos.Write(encoded);
                    }
                    catch (CertificateEncodingException cee)
                    {
                        throw new IOException(cee.Message);
                    }
                }
            }

            // Serialize the array of code signers (if any)
            if (Signers != null && Signers.Length > 0)
            {
                oos.WriteObject(Signers);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Save the state of the {@code StringBuilder} instance to a stream
        /// (that is, serialize it).
        ///
        /// @serialData the number of characters currently stored in the string
        ///             builder ({@code int}), followed by the characters in the
        ///             string builder ({@code char[]}).   The length of the
        ///             {@code char} array may be greater than the number of
        ///             characters currently stored in the string builder, in which
        ///             case extra characters are ignored.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
        private void WriteObject(java.io.ObjectOutputStream s)
        {
            s.DefaultWriteObject();
            s.WriteInt(Count);
            s.WriteObject(Value_Renamed);
        }