2
0

ObjectOutputStream.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. //
  2. // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
  3. //
  4. // Authors:
  5. // Vladimir Krasnov <[email protected]>
  6. // Konstantin Triger <[email protected]>
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. using System;
  28. using java.io;
  29. namespace Mainsoft.Web.Hosting
  30. {
  31. public sealed class ObjectOutputStream : System.IO.Stream, ObjectOutput
  32. {
  33. readonly ObjectOutput _javaObjectOutput;
  34. public ObjectOutputStream (ObjectOutput stream)
  35. {
  36. _javaObjectOutput = stream;
  37. }
  38. public override bool CanRead
  39. {
  40. get
  41. {
  42. return false;
  43. }
  44. }
  45. public override bool CanSeek
  46. {
  47. get
  48. {
  49. return false;
  50. }
  51. }
  52. public override bool CanWrite
  53. {
  54. get
  55. {
  56. return true;
  57. }
  58. }
  59. public override void Close ()
  60. {
  61. _javaObjectOutput.close ();
  62. }
  63. public override void Flush ()
  64. {
  65. _javaObjectOutput.flush ();
  66. }
  67. public override long Length
  68. {
  69. get
  70. {
  71. throw new NotSupportedException ();
  72. }
  73. }
  74. public override long Position
  75. {
  76. get
  77. {
  78. throw new NotSupportedException ();
  79. }
  80. set
  81. {
  82. throw new NotSupportedException ();
  83. }
  84. }
  85. public override long Seek (long offset, System.IO.SeekOrigin origin)
  86. {
  87. throw new NotSupportedException ();
  88. }
  89. public override void SetLength (long value)
  90. {
  91. throw new NotSupportedException ();
  92. }
  93. public override int Read (byte [] buffer, int offset, int count)
  94. {
  95. throw new NotSupportedException ();
  96. }
  97. public override void Write (byte [] buffer, int offset, int count)
  98. {
  99. _javaObjectOutput.write (vmw.common.TypeUtils.ToSByteArray (buffer), offset, count);
  100. }
  101. public override void WriteByte (byte value)
  102. {
  103. _javaObjectOutput.write (value);
  104. }
  105. public ObjectOutput NativeStream
  106. {
  107. get { return _javaObjectOutput; }
  108. }
  109. #region ObjectOutput Members
  110. public void close ()
  111. {
  112. _javaObjectOutput.close ();
  113. }
  114. public void flush ()
  115. {
  116. _javaObjectOutput.flush ();
  117. }
  118. public void write (sbyte [] __p1, int __p2, int __p3)
  119. {
  120. _javaObjectOutput.write (__p1, __p2, __p3);
  121. }
  122. public void write (sbyte [] __p1)
  123. {
  124. _javaObjectOutput.write (__p1);
  125. }
  126. public void write (int __p1)
  127. {
  128. _javaObjectOutput.write (__p1);
  129. }
  130. public void writeObject (object __p1)
  131. {
  132. _javaObjectOutput.writeObject (__p1);
  133. }
  134. #endregion
  135. #region DataOutput Members
  136. public void writeBoolean (bool __p1)
  137. {
  138. _javaObjectOutput.writeBoolean (__p1);
  139. }
  140. public void writeByte (int __p1)
  141. {
  142. _javaObjectOutput.writeByte (__p1);
  143. }
  144. public void writeBytes (string __p1)
  145. {
  146. _javaObjectOutput.writeBytes (__p1);
  147. }
  148. public void writeChar (int __p1)
  149. {
  150. _javaObjectOutput.writeChar (__p1);
  151. }
  152. public void writeChars (string __p1)
  153. {
  154. _javaObjectOutput.writeChars (__p1);
  155. }
  156. public void writeDouble (double __p1)
  157. {
  158. _javaObjectOutput.writeDouble (__p1);
  159. }
  160. public void writeFloat (float __p1)
  161. {
  162. _javaObjectOutput.writeFloat (__p1);
  163. }
  164. public void writeInt (int __p1)
  165. {
  166. _javaObjectOutput.writeInt (__p1);
  167. }
  168. public void writeLong (long __p1)
  169. {
  170. _javaObjectOutput.writeLong (__p1);
  171. }
  172. public void writeShort (int __p1)
  173. {
  174. _javaObjectOutput.writeShort (__p1);
  175. }
  176. public void writeUTF (string __p1)
  177. {
  178. _javaObjectOutput.writeUTF (__p1);
  179. }
  180. #endregion
  181. }
  182. }