/** * Reads a null * <p> * <pre> * N * </pre> */ @Override public void readNull() throws IOException { int tag = read(); switch (tag) { case 'N': return; default: throw expect("null", tag); } }
/** * Reads a fault. */ private HashMap readFault() throws IOException { HashMap map = new HashMap(); int code = read(); for (; code > 0 && code != 'z'; code = read()) { _peek = code; Object key = readObject(); Object value = readObject(); if (key != null && value != null) map.put(key, value); } if (code != 'z') throw expect("fault", code); return map; }
/** * Reads a byte array * <p> * <pre> * B b16 b8 data value * </pre> */ @Override public byte[] readBytes() throws IOException { int tag = read(); switch (tag) { case 'N': return null; case 'B': case 'b': _isLastChunk = tag == 'B'; _chunkLength = (read() << 8) + read(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); int data; while ((data = parseByte()) >= 0) bos.write(data); return bos.toByteArray(); default: throw expect("bytes", tag); } }
throw expect("string", tag);
/** * Reads an XML node. * <p> * <pre> * S b16 b8 string value * </pre> */ @Override public org.w3c.dom.Node readNode() throws IOException { int tag = read(); switch (tag) { case 'N': return null; case 'S': case 's': case 'X': case 'x': _isLastChunk = tag == 'S' || tag == 'X'; _chunkLength = (read() << 8) + read(); throw error("Can't handle string in this context"); default: throw expect("string", tag); } }
/** * Reads an integer * <p> * <pre> * I b32 b24 b16 b8 * </pre> */ @Override public int readInt() throws IOException { int tag = read(); switch (tag) { case 'T': return 1; case 'F': return 0; case 'I': return parseInt(); case 'L': return (int) parseLong(); case 'D': return (int) parseDouble(); default: throw expect("int", tag); } }
throw expect("inputStream", tag);
/** * Reads a long * <p> * <pre> * L b64 b56 b48 b40 b32 b24 b16 b8 * </pre> */ @Override public long readLong() throws IOException { int tag = read(); switch (tag) { case 'T': return 1; case 'F': return 0; case 'I': return parseInt(); case 'L': return parseLong(); case 'D': return (long) parseDouble(); default: throw expect("long", tag); } }
/** * Reads a double * <p> * <pre> * D b64 b56 b48 b40 b32 b24 b16 b8 * </pre> */ @Override public double readDouble() throws IOException { int tag = read(); switch (tag) { case 'T': return 1; case 'F': return 0; case 'I': return parseInt(); case 'L': return (double) parseLong(); case 'D': return parseDouble(); default: throw expect("long", tag); } }
/** * Reads a boolean * <p> * <pre> * T * F * </pre> */ @Override public boolean readBoolean() throws IOException { int tag = read(); switch (tag) { case 'T': return true; case 'F': return false; case 'I': return parseInt() == 0; case 'L': return parseLong() == 0; case 'D': return parseDouble() == 0.0; case 'N': return false; default: throw expect("boolean", tag); } }
throw expect("byte[]", code);
/** * Reads a character from the underlying stream. */ private int parseChar() throws IOException { while (_chunkLength <= 0) { if (_isLastChunk) return -1; int code = read(); switch (code) { case 's': case 'x': _isLastChunk = false; _chunkLength = (read() << 8) + read(); break; case 'S': case 'X': _isLastChunk = true; _chunkLength = (read() << 8) + read(); break; default: throw expect("string", code); } } _chunkLength--; return parseUTF8Char(); }
/** * Reads a byte from the underlying stream. */ private int parseByte() throws IOException { while (_chunkLength <= 0) { if (_isLastChunk) { return -1; } int code = read(); switch (code) { case 'b': _isLastChunk = false; _chunkLength = (read() << 8) + read(); break; case 'B': _isLastChunk = true; _chunkLength = (read() << 8) + read(); break; default: throw expect("byte[]", code); } } _chunkLength--; return read(); }
/** * Reads a null * <p> * <pre> * N * </pre> */ @Override public void readNull() throws IOException { int tag = read(); switch (tag) { case 'N': return; default: throw expect("null", tag); } }
/** * Reads a null * * <pre> * N * </pre> */ public void readNull() throws IOException { int tag = read(); switch (tag) { case 'N': return; default: throw expect("null", tag); } }
/** * Reads a null * <p> * <pre> * N * </pre> */ @Override public void readNull() throws IOException { int tag = read(); switch (tag) { case 'N': return; default: throw expect("null", tag); } }
/** * Reads a null * * <pre> * N * </pre> */ public void readNull() throws IOException { int tag = read(); switch (tag) { case 'N': return; default: throw expect("null", tag); } }
/** * Reads a fault. */ private HashMap readFault() throws IOException { HashMap map = new HashMap(); int code = read(); for (; code > 0 && code != 'z'; code = read()) { _peek = code; Object key = readObject(); Object value = readObject(); if (key != null && value != null) map.put(key, value); } if (code != 'z') throw expect("fault", code); return map; }
/** * Reads a fault. */ private HashMap readFault() throws IOException { HashMap map = new HashMap(); int code = read(); for (; code > 0 && code != 'z'; code = read()) { _peek = code; Object key = readObject(); Object value = readObject(); if (key != null && value != null) map.put(key, value); } if (code != 'z') throw expect("fault", code); return map; }
/** * Reads a fault. */ private HashMap readFault() throws IOException { HashMap map = new HashMap(); int code = read(); for (; code > 0 && code != 'z'; code = read()) { _peek = code; Object key = readObject(); Object value = readObject(); if (key != null && value != null) map.put(key, value); } if (code != 'z') throw expect("fault", code); return map; }