private List<Object> parse(byte[] bytes, List<byte[]> subrs, List<Object> sequence) throws IOException DataInput input = new DataInput(bytes); while (input.hasRemaining()) int b0 = input.readUnsignedByte(); if (b0 == CALLSUBR) else if (b0 == TWO_BYTE && input.peekUnsignedByte(0) == CALLOTHERSUBR) input.readByte(); while (input.peekUnsignedByte(0) == TWO_BYTE && input.peekUnsignedByte(1) == POP) input.readByte(); // B0_POP input.readByte(); // B1_POP sequence.add(results.pop());
/** * Peeks one single unsigned byte from the buffer. * @return the unsigned byte as int * @throws IOException if an error occurs during reading */ public int peekUnsignedByte(int offset) throws IOException { int b = peek(offset); if (b < 0) { throw new EOFException(); } return b; }
/** * Read one single int (4 bytes) from the buffer. * @return the int value * @throws IOException if an error occurs during reading */ public int readInt() throws IOException { int b1 = read(); int b2 = read(); int b3 = read(); int b4 = read(); if ((b1 | b2 | b3 | b4) < 0) { throw new EOFException(); } return b1 << 24 | b2 << 16 | b3 << 8 | b4; }
private Integer readNumber(DataInput input, int b0) throws IOException { if (b0 >= 32 && b0 <= 246) { return b0 - 139; } else if (b0 >= 247 && b0 <= 250) { int b1 = input.readUnsignedByte(); return (b0 - 247) * 256 + b1 + 108; } else if (b0 >= 251 && b0 <= 254) { int b1 = input.readUnsignedByte(); return -(b0 - 251) * 256 - b1 - 108; } else if (b0 == 255) { return input.readInt(); } else { throw new IllegalArgumentException(); } } }
return (int) input.readShort(); int b1 = input.readUnsignedByte(); int b1 = input.readUnsignedByte(); short value = input.readShort(); double fraction = input.readUnsignedShort() / 65535d; return value + fraction;
sequence = new ArrayList<>(); DataInput input = new DataInput(bytes); boolean localSubroutineIndexProvided = localSubrIndex != null && localSubrIndex.length > 0; boolean globalSubroutineIndexProvided = globalSubrIndex != null && globalSubrIndex.length > 0; while (input.hasRemaining()) int b0 = input.readUnsignedByte(); if (b0 == 10 && localSubroutineIndexProvided)
private CharStringCommand readCommand(DataInput input, int b0) throws IOException { if (b0 == 12) { int b1 = input.readUnsignedByte(); return new CharStringCommand(b0, b1); } return new CharStringCommand(b0); }
/** * Read one single short value from the buffer. * @return the short value * @throws IOException if an error occurs during reading */ public short readShort() throws IOException { return (short) readUnsignedShort(); }
return (int) input.readShort(); int b1 = input.readUnsignedByte(); int b1 = input.readUnsignedByte(); short value = input.readShort(); double fraction = input.readUnsignedShort() / 65535d; return value + fraction;
sequence = new ArrayList<>(); DataInput input = new DataInput(bytes); boolean localSubroutineIndexProvided = localSubrIndex != null && localSubrIndex.length > 0; boolean globalSubroutineIndexProvided = globalSubrIndex != null && globalSubrIndex.length > 0; while (input.hasRemaining()) int b0 = input.readUnsignedByte(); if (b0 == 10 && localSubroutineIndexProvided)
private Integer readNumber(DataInput input, int b0) throws IOException { if (b0 >= 32 && b0 <= 246) { return b0 - 139; } else if (b0 >= 247 && b0 <= 250) { int b1 = input.readUnsignedByte(); return (b0 - 247) * 256 + b1 + 108; } else if (b0 >= 251 && b0 <= 254) { int b1 = input.readUnsignedByte(); return -(b0 - 251) * 256 - b1 - 108; } else if (b0 == 255) { return input.readInt(); } else { throw new IllegalArgumentException(); } } }
private CharStringCommand readCommand(int b0, DataInput input) throws IOException { if (b0 == 1 || b0 == 18) { hstemCount += peekNumbers().size() / 2; } else if (b0 == 3 || b0 == 19 || b0 == 20 || b0 == 23) { vstemCount += peekNumbers().size() / 2; } // End if if (b0 == 12) { int b1 = input.readUnsignedByte(); return new CharStringCommand(b0, b1); } else if (b0 == 19 || b0 == 20) { int[] value = new int[1 + getMaskLength()]; value[0] = b0; for (int i = 1; i < value.length; i++) { value[i] = input.readUnsignedByte(); } return new CharStringCommand(value); } return new CharStringCommand(b0); }
/** * Read one single short value from the buffer. * @return the short value * @throws IOException if an error occurs during reading */ public short readShort() throws IOException { return (short) readUnsignedShort(); }
private List<Object> parse(byte[] bytes, List<byte[]> subrs, List<Object> sequence) throws IOException DataInput input = new DataInput(bytes); while (input.hasRemaining()) int b0 = input.readUnsignedByte(); if (b0 == CALLSUBR) else if (b0 == TWO_BYTE && input.peekUnsignedByte(0) == CALLOTHERSUBR) input.readByte(); while (input.peekUnsignedByte(0) == TWO_BYTE && input.peekUnsignedByte(1) == POP) input.readByte(); // B0_POP input.readByte(); // B1_POP sequence.add(results.pop());
return (int) input.readShort(); int b1 = input.readUnsignedByte(); int b1 = input.readUnsignedByte(); short value = input.readShort(); double fraction = input.readUnsignedShort() / 65535d; return value + fraction;
sequence = new ArrayList<Object>(); DataInput input = new DataInput(bytes); boolean localSubroutineIndexProvided = localSubrIndex != null && localSubrIndex.length > 0; boolean globalSubroutineIndexProvided = globalSubrIndex != null && globalSubrIndex.length > 0; while (input.hasRemaining()) int b0 = input.readUnsignedByte(); if (b0 == 10 && localSubroutineIndexProvided)
private Integer readNumber(DataInput input, int b0) throws IOException { if (b0 >= 32 && b0 <= 246) { return b0 - 139; } else if (b0 >= 247 && b0 <= 250) { int b1 = input.readUnsignedByte(); return (b0 - 247) * 256 + b1 + 108; } else if (b0 >= 251 && b0 <= 254) { int b1 = input.readUnsignedByte(); return -(b0 - 251) * 256 - b1 - 108; } else if (b0 == 255) { return input.readInt(); } else { throw new IllegalArgumentException(); } } }
/** * Read one single unsigned short (2 bytes) value from the buffer. * @return the unsigned short value as int * @throws IOException if an error occurs during reading */ public int readUnsignedShort() throws IOException { int b1 = read(); int b2 = read(); if ((b1 | b2) < 0) { throw new EOFException(); } return b1 << 8 | b2; }
private CharStringCommand readCommand(DataInput input, int b0) throws IOException { if (b0 == 12) { int b1 = input.readUnsignedByte(); return new CharStringCommand(b0, b1); } return new CharStringCommand(b0); }
/** * Read one single short value from the buffer. * @return the short value * @throws IOException if an error occurs during reading */ public short readShort() throws IOException { return (short) readUnsignedShort(); }