當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。