position() public method

public position ( ) : long
return long
コード例 #1
0
ファイル: BufferEvent.cs プロジェクト: thymen/buffer_bci
        public static int count(ByteBuffer buf)
        {
            int num = 0;
            long pos = buf.position();

            while (buf.remaining() >= 32) {
                int typeType   = buf.getInt();
                int typeNumEl  = buf.getInt();
                int valueType  = buf.getInt();
                int valueNumEl = buf.getInt();
                buf.getInt(); // sample
                buf.getInt(); // offset
                buf.getInt(); // duration
                int size = buf.getInt();
                int sizeType  = typeNumEl  * DataType.wordSize[typeType];
                int sizeValue = valueNumEl * DataType.wordSize[valueType];

                if (sizeType < 0 || sizeValue < 0 || sizeType + sizeValue > size) {
                    return -(1+num);
                }

                buf.position(buf.position() + size);
                num++;
            }
            buf.position(pos);
            return num;
        }
コード例 #2
0
ファイル: BufferEvent.cs プロジェクト: thymen/buffer_bci
        public BufferEvent(ByteBuffer buf)
        {
            wType  = new WrappedObject();
            wValue = new WrappedObject();

            wType.type   = buf.getInt();
            wType.numel  = buf.getInt();
            wValue.type  = buf.getInt();
            wValue.numel = buf.getInt();
            sample       = buf.getInt();
            offset       = buf.getInt();
            duration     = buf.getInt();
            int size = buf.getInt();

            wType.array  = DataType.getObject(wType.type, wType.numel, buf);
            if (wType.array != null) {
                wType.size = wType.numel * DataType.wordSize[wType.type];
            }

            wValue.array = DataType.getObject(wValue.type, wValue.numel, buf);
            if (wValue.array != null) {
                wValue.size = wValue.numel * DataType.wordSize[wValue.type];
            }

            size -= wType.size + wValue.size;
            if (size != 0) {
                buf.position(buf.position() + size);
            }
        }