protected IOException expect(String expect, int ch) { return error("expected " + expect + " at " + codeName(ch)); }
/** * Reads the end byte. */ @Override public void readEnd() throws IOException { int code = read(); if (code != 'z') throw error("unknown code at " + codeName(code)); }
/** * Reads the end byte. */ @Override public void readMapEnd() throws IOException { int code = read(); if (code != 'z') throw error("expected end of map ('z') at " + codeName(code)); }
/** * Reads the end byte. */ @Override public void readListEnd() throws IOException { int code = read(); if (code != 'z') throw error("expected end of list ('z') at " + codeName(code)); }
/** * Completes reading the call * <p> * <p>A successful completion will have a single value: * <p> * <pre> * z * </pre> */ public void completeValueReply() throws IOException { int tag = read(); if (tag != 'z') error("expected end of reply at " + codeName(tag)); }
/** * Completes reading the call * <p> * <p>A successful completion will have a single value: * <p> * <pre> * z * </pre> */ @Override public void completeReply() throws IOException { int tag = read(); if (tag != 'z') error("expected end of reply at " + codeName(tag)); }
/** * Completes reading the call * <p> * <p>A successful completion will have a single value: * <p> * <pre> * z * </pre> */ @Override public void completeCall() throws IOException { int tag = read(); if (tag == 'z') { } else throw error("expected end of call ('z') at " + codeName(tag) + ". Check method arguments and ensure method overloading is enabled if necessary"); }
/** * Starts reading the call * <p> * <p>A successful completion will have a single value: * <p> * <pre> * m b16 b8 method * </pre> */ @Override public String readMethod() throws IOException { int tag = read(); if (tag != 'm') throw error("expected hessian method ('m') at " + codeName(tag)); int d1 = read(); int d2 = read(); _isLastChunk = true; _chunkLength = d1 * 256 + d2; _sbuf.setLength(0); int ch; while ((ch = parseChar()) >= 0) _sbuf.append((char) ch); _method = _sbuf.toString(); return _method; }
/** * Starts reading the call * <p> * <pre> * c major minor * </pre> */ @Override public int readCall() throws IOException { int tag = read(); if (tag != 'c') throw error("expected hessian call ('c') at " + codeName(tag)); int major = read(); int minor = read(); return (major << 16) + minor; }
/** * Parses a single UTF8 character. */ private int parseUTF8Char() throws IOException { int ch = read(); if (ch < 0x80) return ch; else if ((ch & 0xe0) == 0xc0) { int ch1 = read(); int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f); return v; } else if ((ch & 0xf0) == 0xe0) { int ch1 = read(); int ch2 = read(); int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f); return v; } else throw error("bad utf-8 encoding at " + codeName(ch)); }
/** * Starts reading the reply * <p> * <p>A successful completion will have a single value: * <p> * <pre> * r * </pre> */ @Override public void startReply() throws Throwable { int tag = read(); if (tag != 'r') error("expected hessian reply at " + codeName(tag)); int major = read(); int minor = read(); tag = read(); if (tag == 'f') throw prepareFault(); else _peek = tag; }
throw error("unknown code for readObject at " + codeName(tag));
/** * Reads a reply as an object. * If the reply has a fault, throws the exception. */ @Override public Object readReply(Class expectedClass) throws Throwable { int tag = read(); if (tag != 'r') error("expected hessian reply at " + codeName(tag)); int major = read(); int minor = read(); tag = read(); if (tag == 'f') throw prepareFault(); else { _peek = tag; Object value = readObject(expectedClass); completeValueReply(); return value; } }
/** * Reads a date. * <p> * <pre> * T b64 b56 b48 b40 b32 b24 b16 b8 * </pre> */ @Override public long readUTCDate() throws IOException { int tag = read(); if (tag != 'd') throw error("expected date at " + codeName(tag)); long b64 = read(); long b56 = read(); long b48 = read(); long b40 = read(); long b32 = read(); long b24 = read(); long b16 = read(); long b8 = read(); return ((b64 << 56) + (b56 << 48) + (b48 << 40) + (b40 << 32) + (b32 << 24) + (b24 << 16) + (b16 << 8) + b8); }
/** * Reads the end byte. */ @Override public void readEnd() throws IOException { int code = read(); if (code != 'z') throw error("unknown code at " + codeName(code)); }
/** * Reads the end byte. */ @Override public void readMapEnd() throws IOException { int code = read(); if (code != 'z') throw error("expected end of map ('z') at " + codeName(code)); }
/** * Reads the end byte. */ public void readListEnd() throws IOException { int code = read(); if (code != 'z') throw error("expected end of list ('z') at " + codeName(code)); }
/** * Reads the end byte. */ public void readEnd() throws IOException { int code = read(); if (code != 'z') throw error("unknown code at " + codeName(code)); }
/** * Reads the end byte. */ @Override public void readListEnd() throws IOException { int code = read(); if (code != 'z') throw error("expected end of list ('z') at " + codeName(code)); }
/** * Reads the end byte. */ @Override public void readEnd() throws IOException { int code = read(); if (code != 'z') throw error("unknown code at " + codeName(code)); }