1 48 49 package com.caucho.hessian.io; 50 51 import java.io.IOException ; 52 import java.io.OutputStream ; 53 54 67 abstract public class AbstractHessianOutput { 68 protected SerializerFactory _serializerFactory; 70 71 74 public void setSerializerFactory(SerializerFactory factory) 75 { 76 _serializerFactory = factory; 77 } 78 79 82 public SerializerFactory getSerializerFactory() 83 { 84 return _serializerFactory; 85 } 86 87 90 protected final SerializerFactory findSerializerFactory() 91 { 92 SerializerFactory factory = _serializerFactory; 93 94 if (factory == null) 95 _serializerFactory = factory = new SerializerFactory(); 96 97 return factory; 98 } 99 100 103 public void init(OutputStream os) 104 { 105 } 106 107 110 public void call(String method, Object []args) 111 throws IOException 112 { 113 startCall(method); 114 115 if (args != null) { 116 for (int i = 0; i < args.length; i++) 117 writeObject(args[i]); 118 } 119 120 completeCall(); 121 } 122 123 132 abstract public void startCall() 133 throws IOException ; 134 135 145 abstract public void startCall(String method) 146 throws IOException ; 147 148 155 abstract public void writeHeader(String name) 156 throws IOException ; 157 158 167 abstract public void writeMethod(String method) 168 throws IOException ; 169 170 177 abstract public void completeCall() 178 throws IOException ; 179 180 191 abstract public void writeBoolean(boolean value) 192 throws IOException ; 193 194 204 abstract public void writeInt(int value) 205 throws IOException ; 206 207 217 abstract public void writeLong(long value) 218 throws IOException ; 219 220 230 abstract public void writeDouble(double value) 231 throws IOException ; 232 233 242 abstract public void writeUTCDate(long time) 243 throws IOException ; 244 245 255 abstract public void writeNull() 256 throws IOException ; 257 258 274 abstract public void writeString(String value) 275 throws IOException ; 276 277 293 abstract public void writeString(char []buffer, int offset, int length) 294 throws IOException ; 295 296 312 abstract public void writeBytes(byte []buffer) 313 throws IOException ; 314 330 abstract public void writeBytes(byte []buffer, int offset, int length) 331 throws IOException ; 332 333 336 abstract public void writeByteBufferStart() 337 throws IOException ; 338 339 348 abstract public void writeByteBufferPart(byte []buffer, 349 int offset, 350 int length) 351 throws IOException ; 352 353 362 abstract public void writeByteBufferEnd(byte []buffer, 363 int offset, 364 int length) 365 throws IOException ; 366 367 376 abstract public void writeRef(int value) 377 throws IOException ; 378 379 382 abstract public boolean removeRef(Object obj) 383 throws IOException ; 384 385 388 abstract public boolean replaceRef(Object oldRef, Object newRef) 389 throws IOException ; 390 391 404 abstract public boolean addRef(Object object) 405 throws IOException ; 406 407 410 abstract public void writeObject(Object object) 411 throws IOException ; 412 413 428 abstract public boolean writeListBegin(int length, String type) 429 throws IOException ; 430 431 434 abstract public void writeListEnd() 435 throws IOException ; 436 437 446 abstract public void writeMapBegin(String type) 447 throws IOException ; 448 449 452 abstract public void writeMapEnd() 453 throws IOException ; 454 455 468 public int writeObjectBegin(String type) 469 throws IOException 470 { 471 writeMapBegin(type); 472 473 return -1; 474 } 475 476 479 public void writeClassFieldLength(int len) 480 throws IOException 481 { 482 } 483 484 487 public void writeObjectEnd() 488 throws IOException 489 { 490 } 491 492 500 abstract public void writeRemote(String type, String url) 501 throws IOException ; 502 503 public void startReply() 504 throws IOException 505 { 506 } 507 508 public void completeReply() 509 throws IOException 510 { 511 } 512 513 public void writeFault(String code, String message, Object detail) 514 throws IOException 515 { 516 } 517 518 public void flush() 519 throws IOException 520 { 521 } 522 523 public void close() 524 throws IOException 525 { 526 } 527 } 528 | Popular Tags |