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


Java ByteOrder.LITTLE_ENDIAN属性代码示例

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


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

示例1: afterPropertiesSet

@Override
public void afterPropertiesSet() throws Exception
{
	// 初始化一些参数
	if (byteOrder == 0) {
		SystemConsts.order = ByteOrder.LITTLE_ENDIAN;
		LOG.info("当前安装小端顺序读取数据!");
	} else {
		SystemConsts.order = ByteOrder.BIG_ENDIAN;
		LOG.info("当前安装大端顺序读取数据!");
	}
	initConnections();
	start();
	//加入网关是否断电的检测
	//new CheckSocketClientThread().start();
}
 
开发者ID:yanghao0518,项目名称:cstruct-parser,代码行数:16,代码来源:SocketConnFactoryImpl.java

示例2: copyFrom

/**
 * Creates a new immutable byte sequence copying bytes from the given
 * ByteBuffer {@link ByteBuffer}. If the byte buffer order is not big-endian
 * bytes will be copied in reverse order.
 *
 * @param original a byte buffer
 * @return a new byte buffer object
 */
public static ImmutableByteSequence copyFrom(ByteBuffer original) {
    checkArgument(original != null && original.capacity() > 0,
                  "Cannot copy from an empty or null byte buffer");

    byte[] bytes = new byte[original.capacity()];

    // copy bytes from original buffer
    original.rewind();
    original.get(bytes);

    if (original.order() == ByteOrder.LITTLE_ENDIAN) {
        // FIXME: this can be improved, e.g. read bytes in reverse order from original
        reverse(bytes);
    }

    return new ImmutableByteSequence(ByteBuffer.wrap(bytes));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:ImmutableByteSequence.java

示例3: addServerStatsToSnooper

public void addServerStatsToSnooper(Snooper playerSnooper)
{
    playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
    playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
    playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
    playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
    playerSnooper.addClientStat("run_time", Long.valueOf((MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
    playerSnooper.addClientStat("current_action", this.getCurrentAction());
    playerSnooper.addClientStat("language", this.gameSettings.language == null ? "en_us" : this.gameSettings.language);
    String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
    playerSnooper.addClientStat("endianness", s);
    playerSnooper.addClientStat("subtitles", Boolean.valueOf(this.gameSettings.showSubtitles));
    playerSnooper.addClientStat("touch", this.gameSettings.touchscreen ? "touch" : "mouse");
    playerSnooper.addClientStat("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
    int i = 0;

    for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
    {
        playerSnooper.addClientStat("resource_pack[" + i++ + "]", resourcepackrepository$entry.getResourcePackName());
    }

    if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
    {
        playerSnooper.addClientStat("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:26,代码来源:Minecraft.java

示例4: writeInt

@Override
public void writeInt(int v) throws IOException {
    if (network) {
        VarInt.writeVarInt(this.stream, v);
    } else {
        if (endianness == ByteOrder.LITTLE_ENDIAN) {
            v = Integer.reverseBytes(v);
        }
        this.stream.writeInt(v);
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:11,代码来源:NBTOutputStream.java

示例5: readUnsignedVInt

public long readUnsignedVInt() throws IOException
{
    //If 9 bytes aren't available use the slow path in VIntCoding
    if (buffer.remaining() < 9)
        return VIntCoding.readUnsignedVInt(this);

    byte firstByte = buffer.get();

    //Bail out early if this is one byte, necessary or it fails later
    if (firstByte >= 0)
        return firstByte;

    int extraBytes = VIntCoding.numberOfExtraBytesToRead(firstByte);

    int position = buffer.position();
    int extraBits = extraBytes * 8;

    long retval = buffer.getLong(position);
    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
        retval = Long.reverseBytes(retval);
    buffer.position(position + extraBytes);

    // truncate the bytes we read in excess of those we needed
    retval >>>= 64 - extraBits;
    // remove the non-value bits from the first byte
    firstByte &= VIntCoding.firstByteValueMask(extraBytes);
    // shift the first byte up to its correct position
    retval |= (long) firstByte << extraBits;
    return retval;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:30,代码来源:RebufferingInputStream.java

示例6: readShort

@Override
public short readShort() throws IOException {
    short s = this.stream.readShort();
    if (endianness == ByteOrder.LITTLE_ENDIAN) {
        s = Short.reverseBytes(s);
    }
    return s;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:8,代码来源:NBTInputStream.java

示例7: writeShort

@Override
public void writeShort(int v) throws IOException {
    if (endianness == ByteOrder.LITTLE_ENDIAN) {
        v = Integer.reverseBytes(v) >> 16;
    }
    this.stream.writeShort(v);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:7,代码来源:NBTOutputStream.java

示例8: readChar

@Override
public char readChar() throws IOException {
    char c = this.stream.readChar();
    if (endianness == ByteOrder.LITTLE_ENDIAN) {
        c = Character.reverseBytes(c);
    }
    return c;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:8,代码来源:NBTInputStream.java

示例9: readUnsignedShort

@Override
public int readUnsignedShort() throws IOException {
    int s = this.stream.readUnsignedShort();
    if (endianness == ByteOrder.LITTLE_ENDIAN) {
        s = Integer.reverseBytes(s) >> 16;
    }
    return s;
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:8,代码来源:NBTInputStream.java

示例10: readInt

@Override
public int readInt() throws IOException {
    if (network) {
        return VarInt.readVarInt(this.stream);
    }
    int i = this.stream.readInt();
    if (endianness == ByteOrder.LITTLE_ENDIAN) {
        i = Integer.reverseBytes(i);
    }
    return i;
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:11,代码来源:NBTInputStream.java

示例11: putColorMultiplier

public void putColorMultiplier(float red, float green, float blue, int p_178978_4_)
{
    int i = this.getColorIndex(p_178978_4_);
    int j = -1;

    if (!this.needsUpdate)
    {
        j = this.rawIntBuffer.get(i);

        if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
        {
            int k = (int)((float)(j & 255) * red);
            int l = (int)((float)(j >> 8 & 255) * green);
            int i1 = (int)((float)(j >> 16 & 255) * blue);
            j = j & -16777216;
            j = j | i1 << 16 | l << 8 | k;
        }
        else
        {
            int j1 = (int)((float)(j >> 24 & 255) * red);
            int k1 = (int)((float)(j >> 16 & 255) * green);
            int l1 = (int)((float)(j >> 8 & 255) * blue);
            j = j & 255;
            j = j | j1 << 24 | k1 << 16 | l1 << 8;
        }
    }

    this.rawIntBuffer.put(i, j);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:WorldRenderer.java

示例12: getByteOrder

/**
 * Get the byte order for the given ByteBuffer.
 *
 * @return int - the byte order of the instrumentation buffer
 */
public static ByteOrder getByteOrder(ByteBuffer bb) {
    // save buffer state
    int position = bb.position();

    bb.position(PERFDATA_PROLOG_BYTEORDER_OFFSET);
    ByteOrder order = (bb.get() == PERFDATA_BIG_ENDIAN)
                      ? ByteOrder.BIG_ENDIAN
                      : ByteOrder.LITTLE_ENDIAN;

    // restore buffer state.
    bb.position(position);
    return order;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:AbstractPerfDataBufferPrologue.java

示例13: color

public VertexBuffer color(int red, int green, int blue, int alpha)
{
    if (this.noColor)
    {
        return this;
    }
    else
    {
        int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);

        switch (this.vertexFormatElement.getType())
        {
            case FLOAT:
                this.byteBuffer.putFloat(i, (float)red / 255.0F);
                this.byteBuffer.putFloat(i + 4, (float)green / 255.0F);
                this.byteBuffer.putFloat(i + 8, (float)blue / 255.0F);
                this.byteBuffer.putFloat(i + 12, (float)alpha / 255.0F);
                break;

            case UINT:
            case INT:
                this.byteBuffer.putFloat(i, (float)red);
                this.byteBuffer.putFloat(i + 4, (float)green);
                this.byteBuffer.putFloat(i + 8, (float)blue);
                this.byteBuffer.putFloat(i + 12, (float)alpha);
                break;

            case USHORT:
            case SHORT:
                this.byteBuffer.putShort(i, (short)red);
                this.byteBuffer.putShort(i + 2, (short)green);
                this.byteBuffer.putShort(i + 4, (short)blue);
                this.byteBuffer.putShort(i + 6, (short)alpha);
                break;

            case UBYTE:
            case BYTE:
                if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
                {
                    this.byteBuffer.put(i, (byte)red);
                    this.byteBuffer.put(i + 1, (byte)green);
                    this.byteBuffer.put(i + 2, (byte)blue);
                    this.byteBuffer.put(i + 3, (byte)alpha);
                }
                else
                {
                    this.byteBuffer.put(i, (byte)alpha);
                    this.byteBuffer.put(i + 1, (byte)blue);
                    this.byteBuffer.put(i + 2, (byte)green);
                    this.byteBuffer.put(i + 3, (byte)red);
                }
        }

        this.nextVertexFormatIndex();
        return this;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:57,代码来源:VertexBuffer.java

示例14: updateBytes

/**
 * Updates the CRC-32C checksum with the specified array of bytes.
 */
@HotSpotIntrinsicCandidate
private static int updateBytes(int crc, byte[] b, int off, int end) {

    // Do only byte reads for arrays so short they can't be aligned
    // or if bytes are stored with a larger witdh than one byte.,%
    if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) {

        // align on 8 bytes
        int alignLength
                = (8 - ((Unsafe.ARRAY_BYTE_BASE_OFFSET + off) & 0x7)) & 0x7;
        for (int alignEnd = off + alignLength; off < alignEnd; off++) {
            crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF];
        }

        if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
            crc = Integer.reverseBytes(crc);
        }

        // slicing-by-8
        for (; off < (end - Long.BYTES); off += Long.BYTES) {
            int firstHalf;
            int secondHalf;
            if (Unsafe.ADDRESS_SIZE == 4) {
                // On 32 bit platforms read two ints instead of a single 64bit long
                firstHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
                secondHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off
                                           + Integer.BYTES);
            } else {
                long value = UNSAFE.getLong(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
                if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
                    firstHalf = (int) value;
                    secondHalf = (int) (value >>> 32);
                } else { // ByteOrder.BIG_ENDIAN
                    firstHalf = (int) (value >>> 32);
                    secondHalf = (int) value;
                }
            }
            crc ^= firstHalf;
            if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
                crc = byteTable7[crc & 0xFF]
                        ^ byteTable6[(crc >>> 8) & 0xFF]
                        ^ byteTable5[(crc >>> 16) & 0xFF]
                        ^ byteTable4[crc >>> 24]
                        ^ byteTable3[secondHalf & 0xFF]
                        ^ byteTable2[(secondHalf >>> 8) & 0xFF]
                        ^ byteTable1[(secondHalf >>> 16) & 0xFF]
                        ^ byteTable0[secondHalf >>> 24];
            } else { // ByteOrder.BIG_ENDIAN
                crc = byteTable0[secondHalf & 0xFF]
                        ^ byteTable1[(secondHalf >>> 8) & 0xFF]
                        ^ byteTable2[(secondHalf >>> 16) & 0xFF]
                        ^ byteTable3[secondHalf >>> 24]
                        ^ byteTable4[crc & 0xFF]
                        ^ byteTable5[(crc >>> 8) & 0xFF]
                        ^ byteTable6[(crc >>> 16) & 0xFF]
                        ^ byteTable7[crc >>> 24];
            }
        }

        if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
            crc = Integer.reverseBytes(crc);
        }
    }

    // Tail
    for (; off < end; off++) {
        crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF];
    }

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

示例15: assertByteOrderLittleEndian

static void assertByteOrderLittleEndian(ByteBuffer buffer) {
    if (buffer.order() != ByteOrder.LITTLE_ENDIAN) {
        throw new IllegalArgumentException("ByteBuffer byte order must be little endian");
    }
}
 
开发者ID:nukc,项目名称:ApkMultiChannelPlugin,代码行数:5,代码来源:ZipUtils.java


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