2
0

ObjectInputStream.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 ObjectInputStream : System.IO.Stream, ObjectInput
  32. {
  33. readonly ObjectInput _javaObjectInput;
  34. public ObjectInputStream (ObjectInput stream)
  35. {
  36. _javaObjectInput = stream;
  37. }
  38. public override bool CanRead
  39. {
  40. get
  41. {
  42. return true;
  43. }
  44. }
  45. public override bool CanWrite
  46. {
  47. get
  48. {
  49. return false;
  50. }
  51. }
  52. public override bool CanSeek
  53. {
  54. get
  55. {
  56. return true;
  57. }
  58. }
  59. public override long Length
  60. {
  61. get
  62. {
  63. throw new NotSupportedException ();
  64. }
  65. }
  66. public override long Position
  67. {
  68. get
  69. {
  70. throw new NotSupportedException ();
  71. }
  72. set
  73. {
  74. throw new NotSupportedException ();
  75. }
  76. }
  77. public override void Flush ()
  78. {
  79. throw new NotSupportedException ();
  80. }
  81. public override long Seek (long offset, System.IO.SeekOrigin origin)
  82. {
  83. if (origin == System.IO.SeekOrigin.Current)
  84. return _javaObjectInput.skip (offset);
  85. throw new NotSupportedException ();
  86. }
  87. public override void SetLength (long value)
  88. {
  89. throw new NotSupportedException ();
  90. }
  91. public override int Read (byte [] buffer, int offset, int count)
  92. {
  93. int rv = _javaObjectInput.read (vmw.common.TypeUtils.ToSByteArray (buffer), offset, count);
  94. return rv > 0 ? rv : 0;
  95. }
  96. public override void Write (byte [] buffer, int offset, int count)
  97. {
  98. throw new NotSupportedException ();
  99. }
  100. public override int ReadByte ()
  101. {
  102. return _javaObjectInput.read ();
  103. }
  104. public override void Close ()
  105. {
  106. _javaObjectInput.close ();
  107. }
  108. #region ObjectInput Members
  109. public int available ()
  110. {
  111. return _javaObjectInput.available ();
  112. }
  113. public void close ()
  114. {
  115. _javaObjectInput.close ();
  116. }
  117. public int read (sbyte [] __p1, int __p2, int __p3)
  118. {
  119. return _javaObjectInput.read (__p1, __p2, __p3);
  120. }
  121. public int read (sbyte [] __p1)
  122. {
  123. return _javaObjectInput.read (__p1);
  124. }
  125. public int read ()
  126. {
  127. return _javaObjectInput.read ();
  128. }
  129. public object readObject ()
  130. {
  131. return _javaObjectInput.readObject ();
  132. }
  133. public long skip (long __p1)
  134. {
  135. return _javaObjectInput.skip (__p1);
  136. }
  137. #endregion
  138. #region DataInput Members
  139. public bool readBoolean ()
  140. {
  141. return _javaObjectInput.readBoolean ();
  142. }
  143. public sbyte readByte ()
  144. {
  145. return _javaObjectInput.readByte ();
  146. }
  147. public char readChar ()
  148. {
  149. return _javaObjectInput.readChar ();
  150. }
  151. public double readDouble ()
  152. {
  153. return _javaObjectInput.readDouble ();
  154. }
  155. public float readFloat ()
  156. {
  157. return _javaObjectInput.readFloat ();
  158. }
  159. public void readFully (sbyte [] __p1, int __p2, int __p3)
  160. {
  161. _javaObjectInput.readFully (__p1, __p2, __p3);
  162. }
  163. public void readFully (sbyte [] __p1)
  164. {
  165. _javaObjectInput.readFully (__p1);
  166. }
  167. public int readInt ()
  168. {
  169. return _javaObjectInput.readInt ();
  170. }
  171. public string readLine ()
  172. {
  173. return _javaObjectInput.readLine ();
  174. }
  175. public long readLong ()
  176. {
  177. return _javaObjectInput.readLong ();
  178. }
  179. public short readShort ()
  180. {
  181. return _javaObjectInput.readShort ();
  182. }
  183. public string readUTF ()
  184. {
  185. return _javaObjectInput.readUTF ();
  186. }
  187. public int readUnsignedByte ()
  188. {
  189. return _javaObjectInput.readUnsignedByte ();
  190. }
  191. public int readUnsignedShort ()
  192. {
  193. return _javaObjectInput.readUnsignedShort ();
  194. }
  195. public int skipBytes (int __p1)
  196. {
  197. return _javaObjectInput.skipBytes (__p1);
  198. }
  199. #endregion
  200. }
  201. }