Ejemplo n.º 1
0
        protected void SaveStateInClient(FacesContext facesContext, StateManager.SerializedView serializedView)
        {
            //UIViewRoot uiViewRoot = facesContext.getViewRoot ();
            ////save state in response (client-side: full state; server-side: sequence)
            //RenderKit renderKit = RenderKitFactory.getRenderKit (facesContext, uiViewRoot.getRenderKitId ());
            //// not us.
            //renderKit.getResponseStateManager ().writeState (facesContext, serializedView);

            java.io.ByteArrayOutputStream bytearrayoutputstream = new java.io.ByteArrayOutputStream();
            java.io.ObjectOutputStream    objectoutputstream    = new java.io.ObjectOutputStream(bytearrayoutputstream);

            //ignore tree structure
            //objectoutputstream.writeObject (serializedView.getStructure ());
            objectoutputstream.writeObject(serializedView.getState());
            objectoutputstream.close();
            bytearrayoutputstream.close();

            string s =
                @"<div>
	<input type=""hidden"" name="""     + VIEWSTATE + "\" id=\"" + VIEWSTATE + "\" value=\"" +
                Convert.ToBase64String((byte [])vmw.common.TypeUtils.ToByteArray(bytearrayoutputstream.toByteArray())) + @""" />
</div>";

            facesContext.getResponseWriter().write(s);
        }
Ejemplo n.º 2
0
 public virtual void testSerializePolyline()
 {
     try
     {
         java.io.ByteArrayOutputStream   streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream      oo        = new java.io.ObjectOutputStream(streamOut);
         com.esri.core.geometry.Polyline pt        = new com.esri.core.geometry.Polyline();
         pt.startPath(10, 10);
         pt.lineTo(100, 100);
         pt.lineTo(200, 100);
         oo.writeObject(pt);
         java.io.ByteArrayInputStream streamIn = new java.io.ByteArrayInputStream(streamOut
                                                                                  .toByteArray());
         java.io.ObjectInputStream       ii    = new java.io.ObjectInputStream(streamIn);
         com.esri.core.geometry.Polyline ptRes = (com.esri.core.geometry.Polyline)ii.readObject
                                                     ();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt));
     }
     catch (System.Exception)
     {
         fail("Polyline serialization failure");
     }
     // try
     // {
     // FileOutputStream streamOut = new FileOutputStream(m_thisDirectory +
     // "savedPolyline.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 = Sharpen.Runtime.getClassForType(typeof(com.esri.core.geometry.TestSerialization
                                                                        )).getResourceAsStream("savedPolyline.txt");
         java.io.ObjectInputStream       ii    = new java.io.ObjectInputStream(s);
         com.esri.core.geometry.Polyline ptRes = (com.esri.core.geometry.Polyline)ii.readObject
                                                     ();
         NUnit.Framework.Assert.IsTrue(ptRes != null);
     }
     catch (System.Exception)
     {
         fail("Polyline serialization failure");
     }
 }
Ejemplo n.º 3
0
 public virtual void testSerializeMultiPoint()
 {
     try
     {
         java.io.ByteArrayOutputStream     streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream        oo        = new java.io.ObjectOutputStream(streamOut);
         com.esri.core.geometry.MultiPoint pt        = new com.esri.core.geometry.MultiPoint();
         pt.add(10, 30);
         pt.add(120, 40);
         oo.writeObject(pt);
         java.io.ByteArrayInputStream streamIn = new java.io.ByteArrayInputStream(streamOut
                                                                                  .toByteArray());
         java.io.ObjectInputStream         ii    = new java.io.ObjectInputStream(streamIn);
         com.esri.core.geometry.MultiPoint ptRes = (com.esri.core.geometry.MultiPoint)ii.readObject
                                                       ();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt));
     }
     catch (System.Exception)
     {
         fail("MultiPoint serialization failure");
     }
     // try
     // {
     // FileOutputStream streamOut = new FileOutputStream(m_thisDirectory +
     // "savedMultiPoint.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 = Sharpen.Runtime.getClassForType(typeof(com.esri.core.geometry.TestSerialization
                                                                        )).getResourceAsStream("savedMultiPoint.txt");
         java.io.ObjectInputStream         ii    = new java.io.ObjectInputStream(s);
         com.esri.core.geometry.MultiPoint ptRes = (com.esri.core.geometry.MultiPoint)ii.readObject
                                                       ();
         NUnit.Framework.Assert.IsTrue(ptRes.getPoint(1).getY() == 40);
     }
     catch (System.Exception)
     {
         fail("MultiPoint serialization failure");
     }
 }
Ejemplo n.º 4
0
 public virtual void testSerializeEnvelope2D()
 {
     try
     {
         java.io.ByteArrayOutputStream     streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream        oo        = new java.io.ObjectOutputStream(streamOut);
         com.esri.core.geometry.Envelope2D env       = new com.esri.core.geometry.Envelope2D(1.213948734
                                                                                             , 2.213948734, 11.213948734, 12.213948734);
         oo.writeObject(env);
         java.io.ByteArrayInputStream streamIn = new java.io.ByteArrayInputStream(streamOut
                                                                                  .toByteArray());
         java.io.ObjectInputStream         ii     = new java.io.ObjectInputStream(streamIn);
         com.esri.core.geometry.Envelope2D envRes = (com.esri.core.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 = Sharpen.Runtime.getClassForType(typeof(com.esri.core.geometry.TestSerialization
                                                                        )).getResourceAsStream("savedEnvelope2D.txt");
         java.io.ObjectInputStream         ii = new java.io.ObjectInputStream(s);
         com.esri.core.geometry.Envelope2D e  = (com.esri.core.geometry.Envelope2D)ii.readObject
                                                    ();
         NUnit.Framework.Assert.IsTrue(e != null);
         NUnit.Framework.Assert.IsTrue(e.Equals(new com.esri.core.geometry.Envelope2D(177.123
                                                                                      , 188.234, 999.122, 888.999)));
     }
     catch (System.Exception)
     {
         fail("Envelope2D serialization failure");
     }
 }
Ejemplo n.º 5
0
 public static bool writeObjectToFile(string fileName, object obj)
 {
     try
     {
         java.io.File f = new java.io.File(fileName);
         f.setWritable(true);
         java.io.FileOutputStream   fout = new java.io.FileOutputStream(f);
         java.io.ObjectOutputStream oo   = new java.io.ObjectOutputStream(fout);
         oo.writeObject(obj);
         fout.close();
         return(true);
     }
     catch (System.Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 6
0
 public virtual void testSerializeSR()
 {
     try
     {
         java.io.ByteArrayOutputStream           streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream              oo        = new java.io.ObjectOutputStream(streamOut);
         com.esri.core.geometry.SpatialReference sr        = com.esri.core.geometry.SpatialReference
                                                             .create(102100);
         oo.writeObject(sr);
         java.io.ByteArrayInputStream streamIn = new java.io.ByteArrayInputStream(streamOut
                                                                                  .toByteArray());
         java.io.ObjectInputStream ii = new java.io.ObjectInputStream(streamIn);
         com.esri.core.geometry.SpatialReference ptRes = (com.esri.core.geometry.SpatialReference
                                                          )ii.readObject();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(sr));
     }
     catch (System.Exception)
     {
         fail("Spatial Reference serialization failure");
     }
 }
Ejemplo n.º 7
0
 public virtual void testSerializeLine()
 {
     try
     {
         java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream    oo        = new java.io.ObjectOutputStream(streamOut);
         com.esri.core.geometry.Line   pt        = new com.esri.core.geometry.Line();
         pt.setStart(new com.esri.core.geometry.Point(10, 30));
         pt.setEnd(new com.esri.core.geometry.Point(120, 40));
         oo.writeObject(pt);
         java.io.ByteArrayInputStream streamIn = new java.io.ByteArrayInputStream(streamOut
                                                                                  .toByteArray());
         java.io.ObjectInputStream   ii    = new java.io.ObjectInputStream(streamIn);
         com.esri.core.geometry.Line ptRes = (com.esri.core.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");
     }
 }
Ejemplo n.º 8
0
		protected void SaveStateInClient (FacesContext facesContext, StateManager.SerializedView serializedView) {
			//UIViewRoot uiViewRoot = facesContext.getViewRoot ();
			////save state in response (client-side: full state; server-side: sequence)
			//RenderKit renderKit = RenderKitFactory.getRenderKit (facesContext, uiViewRoot.getRenderKitId ());
			//// not us.
			//renderKit.getResponseStateManager ().writeState (facesContext, serializedView);

			java.io.ByteArrayOutputStream bytearrayoutputstream = new java.io.ByteArrayOutputStream ();
			java.io.ObjectOutputStream objectoutputstream = new java.io.ObjectOutputStream (bytearrayoutputstream);

			//ignore tree structure
			//objectoutputstream.writeObject (serializedView.getStructure ());
			objectoutputstream.writeObject (serializedView.getState ());
			objectoutputstream.close ();
			bytearrayoutputstream.close ();

			string s = 
@"<div>
	<input type=""hidden"" name=""" + VIEWSTATE + "\" id=\"" + VIEWSTATE + "\" value=\"" +
				Convert.ToBase64String ((byte []) vmw.common.TypeUtils.ToByteArray (bytearrayoutputstream.toByteArray ())) + @""" />
</div>";
			facesContext.getResponseWriter ().write (s);
		}
Ejemplo n.º 9
0
 /// <summary>Writes the state of this object to the stream passed.</summary>
 /// <remarks>Writes the state of this object to the stream passed.</remarks>
 /// <param name="out">the stream to write the state to.</param>
 /// <exception cref="System.IO.IOException">if the stream throws it during the write.
 ///     </exception>
 /// <serialData>
 ///
 /// <code>int</code>
 /// - the length of this object.
 /// <code>char[]</code>
 /// - the
 /// buffer from this object, which may be larger than the length
 /// field.
 /// </serialData>
 private void writeObject(java.io.ObjectOutputStream @out)
 {
     @out.defaultWriteObject();
     @out.writeInt(Length);
     @out.writeObject(getValue());
 }