secondBytes[bi] = rawInput.getBytes()[rawInput.getAndIncreaseStreamPositionByOne()]; if (secondBytes[bi] > 0) { isImmediate = false; fractionBytes[bi] = rawInput.getBytes()[rawInput.getAndIncreaseStreamPositionByOne()]; if (bi < 7) { if (fractionBytes[bi] > 0) {
/** * Reads the types of the arguments from the byte stream. * @return a char array with the types of the arguments, * or <code>null</code>, in case of no arguments */ private CharSequence readTypes(final Input rawInput) { final String typesStr; // The next byte should be a ',', but some legacy code may omit it // in case of no arguments, refering to "OSC Messages" in: // http://opensoundcontrol.org/spec-1_0 if (rawInput.getBytes().length <= rawInput.getStreamPosition()) { typesStr = NO_ARGUMENT_TYPES; } else if (rawInput.getBytes()[rawInput.getStreamPosition()] != ',') { // XXX should we not rather fail-fast -> throw exception? typesStr = NO_ARGUMENT_TYPES; } else { rawInput.getAndIncreaseStreamPositionByOne(); typesStr = readString(rawInput); } return typesStr; }
/** * Reads an unsigned integer (32 bit) from the byte stream. * This code is copied from {@see http://darksleep.com/player/JavaAndUnsignedTypes.html}, * which is licensed under the Public Domain. * @return single precision, unsigned integer (32 bit) wrapped in a 64 bit integer (long) */ private Long readUnsignedInteger(final Input rawInput) { final int firstByte = (0x000000FF & ((int) rawInput.getBytes()[rawInput.getAndIncreaseStreamPositionByOne()])); final int secondByte = (0x000000FF & ((int) rawInput.getBytes()[rawInput.getAndIncreaseStreamPositionByOne()])); final int thirdByte = (0x000000FF & ((int) rawInput.getBytes()[rawInput.getAndIncreaseStreamPositionByOne()])); final int fourthByte = (0x000000FF & ((int) rawInput.getBytes()[rawInput.getAndIncreaseStreamPositionByOne()])); return ((long) (firstByte << 24 | secondByte << 16 | thirdByte << 8 | fourthByte)) & 0xFFFFFFFFL; }
/** * Reads a char from the byte stream. * @return a {@link Character} */ private Character readChar(final Input rawInput) { return (char) rawInput.getBytes()[rawInput.getAndIncreaseStreamPositionByOne()]; }