当前位置: 首页>>代码示例>>Java>>正文


Java ByteBuffer.getLong方法代码示例

本文整理汇总了Java中java.nio.ByteBuffer.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuffer.getLong方法的具体用法?Java ByteBuffer.getLong怎么用?Java ByteBuffer.getLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.getLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tableHashCode

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public long tableHashCode(int tableId) {
    try {
        m_data.clear();
        m_data.putInt(Commands.TableHashCode.m_id);
        m_data.putInt(tableId);

        m_data.flip();
        m_connection.write();

        m_connection.readStatusByte();
        ByteBuffer hashCode = ByteBuffer.allocate(8);
        while (hashCode.hasRemaining()) {
            int read = m_connection.m_socketChannel.read(hashCode);
            if (read <= 0) {
                throw new EOFException();
            }
        }
        hashCode.flip();
        return hashCode.getLong();
    } catch (final IOException e) {
        System.out.println("Exception: " + e.getMessage());
        throw new RuntimeException(e);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:26,代码来源:ExecutionEngineIPC.java

示例2: ChmItsfHeader

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public ChmItsfHeader(ByteBuffer bb) throws IOException {
    String signature = ByteBufferHelper.parseString(bb, 4, "ASCII");
    if (!signature.equals("ITSF")) {
        throw new IOException("Unexpected ITSF header signature.");
    }
    try {
        int version = bb.getInt();
        ByteBufferHelper.skip(bb, 12);
        langId = bb.getInt();
        ByteBufferHelper.skip(bb, 48);
        dirOffset = bb.getLong();
        long dirLen = bb.getLong();
        if (version >= 3) {
            dataOffset = bb.getLong();
        } else {
            dataOffset = dirOffset + dirLen;
        }
    } catch (Exception e) {
        throw new IOException("Failed to parse ITSF header", e);
    }
}
 
开发者ID:chimenchen,项目名称:jchmlib,代码行数:22,代码来源:ChmItsfHeader.java

示例3: AdvancedPaymentEscrowCreation

import java.nio.ByteBuffer; //导入方法依赖的package包/类
AdvancedPaymentEscrowCreation(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
	super(buffer, transactionVersion);
	this.amountNQT = buffer.getLong();
	this.deadline = buffer.getInt();
	this.deadlineAction = Escrow.byteToDecision(buffer.get());
	this.requiredSigners = buffer.get();
	byte totalSigners = buffer.get();
	if(totalSigners > 10 || totalSigners <= 0) {
		throw new NxtException.NotValidException("Invalid number of signers listed on create escrow transaction");
	}
	for(int i = 0; i < totalSigners; i++) {
		if(!this.signers.add(buffer.getLong())) {
			throw new NxtException.NotValidException("Duplicate signer on escrow creation");
		}
	}
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:Attachment.java

示例4: deserialize

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public IPacket deserialize(byte[] data, int offset, int length)
        throws PacketParsingException {
    ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
    
    controllerId = bb.getLong();
    sequenceId = bb.getInt();
    bb.get(this.srcMac, 0, 6);
    bb.get(this.dstMac, 0, 6);
    this.srcSwDpid = bb.getLong();
    this.srcPortNo = bb.getInt();
    
    if (bb.hasRemaining()) {
    	this.payload = new Data();
     this.payload = payload.deserialize(data, bb.position(), bb.limit() - bb.position());
     this.payload.setParent(this);
    }
    
    return this;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:21,代码来源:BSNPROBE.java

示例5: Mp4MvhdBox

import java.nio.ByteBuffer; //导入方法依赖的package包/类
/**
 * @param header     header info
 * @param dataBuffer data of box (doesnt include header data)
 */
public Mp4MvhdBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
{
    this.header = header;
    dataBuffer.order(ByteOrder.BIG_ENDIAN);
    byte version = dataBuffer.get(VERSION_FLAG_POS);

    if (version == LONG_FORMAT)
    {
        timeScale = dataBuffer.getInt(TIMESCALE_LONG_POS);
        timeLength = dataBuffer.getLong(DURATION_LONG_POS);

    }
    else
    {
        timeScale = dataBuffer.getInt(TIMESCALE_SHORT_POS);
        timeLength = Utils.u(dataBuffer.getInt(DURATION_SHORT_POS));
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:23,代码来源:Mp4MvhdBox.java

示例6: ElfSymbol

import java.nio.ByteBuffer; //导入方法依赖的package包/类
ElfSymbol(ElfReader reader, ElfStringTable strtab, int offset) {
    ByteBuffer buf = reader.buf;
    this.reader = reader;
    this.strtab = strtab;
    this.nameIndex = buf.getInt(offset);

    if (reader.elf64) {
        this.info = buf.get(offset + 4) & 0xff;
        this.other = buf.get(offset + 5);
        this.sectionIndex = buf.getShort(offset + 6) & 0xffff;
        this.value = buf.getLong(offset + 8);
        this.size = buf.getInt(offset + 16);
    } else {
        this.value = buf.getInt(offset + 4) & 0xffffffffL;
        this.size = buf.getInt(offset + 8) & 0xffffffffL;
        this.info = buf.get(offset + 12) & 0xff;
        this.other = buf.get(offset + 13);
        this.sectionIndex = buf.getShort(offset + 14) & 0xffff;
    }
}
 
开发者ID:Maschell,项目名称:nn_nex_logging_and_research,代码行数:21,代码来源:ElfSymbol.java

示例7: HFileBlock

import java.nio.ByteBuffer; //导入方法依赖的package包/类
/**
 * Creates a block from an existing buffer starting with a header. Rewinds
 * and takes ownership of the buffer. By definition of rewind, ignores the
 * buffer position, but if you slice the buffer beforehand, it will rewind
 * to that point. The reason this has a minorNumber and not a majorNumber is
 * because majorNumbers indicate the format of a HFile whereas minorNumbers
 * indicate the format inside a HFileBlock.
 */
HFileBlock(ByteBuffer b, boolean usesHBaseChecksum) throws IOException {
  b.rewind();
  blockType = BlockType.read(b);
  onDiskSizeWithoutHeader = b.getInt(Header.ON_DISK_SIZE_WITHOUT_HEADER_INDEX);
  uncompressedSizeWithoutHeader = b.getInt(Header.UNCOMPRESSED_SIZE_WITHOUT_HEADER_INDEX);
  prevBlockOffset = b.getLong(Header.PREV_BLOCK_OFFSET_INDEX);
  HFileContextBuilder contextBuilder = new HFileContextBuilder();
  contextBuilder.withHBaseCheckSum(usesHBaseChecksum);
  if (usesHBaseChecksum) {
    contextBuilder.withChecksumType(ChecksumType.codeToType(b.get(Header.CHECKSUM_TYPE_INDEX)));
    contextBuilder.withBytesPerCheckSum(b.getInt(Header.BYTES_PER_CHECKSUM_INDEX));
    this.onDiskDataSizeWithHeader = b.getInt(Header.ON_DISK_DATA_SIZE_WITH_HEADER_INDEX);
  } else {
    contextBuilder.withChecksumType(ChecksumType.NULL);
    contextBuilder.withBytesPerCheckSum(0);
    this.onDiskDataSizeWithHeader = onDiskSizeWithoutHeader +
                                     HConstants.HFILEBLOCK_HEADER_SIZE_NO_CHECKSUM;
  }
  this.fileContext = contextBuilder.build();
  buf = b;
  buf.rewind();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:HFileBlock.java

示例8: ElfSection

import java.nio.ByteBuffer; //导入方法依赖的package包/类
ElfSection(ElfReader reader, int offset) {
    ByteBuffer buf = reader.buf;
    this.reader = reader;
    this.nameIndex = buf.getInt(offset);
    this.type = buf.getInt(offset + 4);

    if (reader.elf64) {
        this.flags = buf.getLong(offset + 8);
        this.address = buf.getLong(offset + 16);
        this.offset = buf.getLong(offset + 24);
        this.size = buf.getLong(offset + 32);
        this.linkIndex = buf.getInt(offset + 40);
        this.info = buf.getInt(offset + 44);
        this.align = buf.getLong(offset + 48);
        this.entrySize = buf.getLong(offset + 56);
    } else {
        this.flags = buf.getInt(offset + 8) & 0xffffffffL;
        this.address = buf.getInt(offset + 12) & 0xffffffffL;
        this.offset = buf.getInt(offset + 16) & 0xffffffffL;
        this.size = buf.getInt(offset + 20) & 0xffffffffL;
        this.linkIndex = buf.getInt(offset + 24);
        this.info = buf.getInt(offset + 28);
        this.align = buf.getInt(offset + 32);
        this.entrySize = buf.getInt(offset + 36);
    }
}
 
开发者ID:Maschell,项目名称:nn_nex_logging_and_research,代码行数:27,代码来源:ElfSection.java

示例9: getPrimitiveArray

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public PrimitiveObject[] getPrimitiveArray( final byte[] buffer , final int start , final int length ) throws IOException{
  int size = length / Long.BYTES;
  PrimitiveObject[] result = new PrimitiveObject[size];
  ByteBuffer wrapBuffer = ByteBuffer.wrap( buffer , start , length );
  for( int i = 0 ; i < size ; i++ ){
    result[i] = new LongObj( wrapBuffer.getLong() );
  }
  return result;
}
 
开发者ID:yahoojapan,项目名称:multiple-dimension-spread,代码行数:11,代码来源:OptimizeDumpLongColumnBinaryMaker.java

示例10: getLong

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static long getLong(byte[] b){
	ByteBuffer buffer = ByteBuffer.allocate(8);
	buffer.order(ByteOrder.LITTLE_ENDIAN);
	buffer.position(0);
	buffer.put(b);
	return buffer.getLong(0);
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:8,代码来源:AT_API_Helper.java

示例11: unalignedReadSnippet

import java.nio.ByteBuffer; //导入方法依赖的package包/类
Ret unalignedReadSnippet(byte[] arg) {
    ByteBuffer buffer = ByteBuffer.wrap(arg).order(byteOrder);

    Ret ret = new Ret();
    ret.byteValue = buffer.get();
    ret.shortValue = buffer.getShort();
    ret.intValue = buffer.getInt();
    ret.longValue = buffer.getLong();
    ret.doubleValue = buffer.getDouble();
    ret.floatValue = buffer.getFloat();

    return ret;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ByteBufferTest.java

示例12: alignedReadSnippet

import java.nio.ByteBuffer; //导入方法依赖的package包/类
Ret alignedReadSnippet(byte[] arg) {
    ByteBuffer buffer = makeDirect(arg, byteOrder);

    Ret ret = new Ret();
    ret.byteValue = buffer.get();
    ret.byteValue += buffer.get();
    ret.shortValue = buffer.getShort();
    ret.intValue = buffer.getInt();
    ret.longValue = buffer.getLong();
    ret.doubleValue = buffer.getDouble();
    ret.floatValue = buffer.getFloat();

    return ret;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:DirectByteBufferTest.java

示例13: decodeData

import java.nio.ByteBuffer; //导入方法依赖的package包/类
@Override
public void decodeData(ByteBuffer buffer, int length) {
	data = buffer.getLong();
	addDataLength(length);
}
 
开发者ID:mustafabayar,项目名称:EasyDiameter,代码行数:6,代码来源:Integer64AVP.java

示例14: byteArrayToUUID

import java.nio.ByteBuffer; //导入方法依赖的package包/类
public static UUID byteArrayToUUID(byte[] bytes) {
    ByteBuffer bb = ByteBuffer.wrap(bytes);
    long firstLong = bb.getLong();
    long secondLong = bb.getLong();
    return new UUID(firstLong, secondLong);
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:7,代码来源:TransactionXid.java

示例15: bytesToLong

import java.nio.ByteBuffer; //导入方法依赖的package包/类
protected long bytesToLong(byte[] bytes) {
    ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
    buffer.put(bytes);
    buffer.flip(); 
    return buffer.getLong();
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:7,代码来源:AbstractEnvironmentManager.java


注:本文中的java.nio.ByteBuffer.getLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。