Package java.nio

Examples of java.nio.ByteOrder


                return this;
            }

            // Shrink and compact:
            //// Save the state.
            ByteOrder bo = order();

            //// Sanity check.
            if (remaining > newCapacity) {
                throw new IllegalStateException("The amount of the remaining bytes is greater than "
                        + "the new capacity.");
View Full Code Here


   * @param seed   The seed for the hash.
   * @return       The 32 bit murmur hash of the bytes in the buffer.
   */
  public static int hash(ByteBuffer buf, int seed) {
    // save byte order for later restoration
    ByteOrder byteOrder = buf.order();
    buf.order(ByteOrder.LITTLE_ENDIAN);

    int m = 0x5bd1e995;
    int r = 24;

View Full Code Here

  public static long hash64A(byte[] data, int offset, int length, int seed) {
    return hash64A(ByteBuffer.wrap(data, offset, length), seed);
  }

  public static long hash64A(ByteBuffer buf, int seed) {
    ByteOrder byteOrder = buf.order();
    buf.order(ByteOrder.LITTLE_ENDIAN);

    long m = 0xc6a4a7935bd1e995L;
    int r = 47;
View Full Code Here

    }

    private ImageSize determineSize(ImageInputStream in, ImageContext context)
            throws IOException, ImageException {
        in.mark();
        ByteOrder oldByteOrder = in.getByteOrder();
        try {
            ImageSize size = new ImageSize();

            // BMP uses little endian notation!
            in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
View Full Code Here

        if (!ImageUtil.hasImageInputStream(src)) {
            return null;
        }
        ImageInputStream in = ImageUtil.needImageInputStream(src);
        in.mark();
        ByteOrder originalByteOrder = in.getByteOrder();
        in.setByteOrder(ByteOrder.LITTLE_ENDIAN);
        EPSBinaryFileHeader binaryHeader = null;
        try {
            long magic = in.readUnsignedInt();
            magic &= 0xFFFFFFFFL; //Work-around for bug in Java 1.4.2
View Full Code Here

        return context.runtime.newSymbol(getMemoryIO().order().equals(ByteOrder.LITTLE_ENDIAN) ? "little" : "big");
    }

    @JRubyMethod(name = "order", required = 1)
    public final IRubyObject order(ThreadContext context, IRubyObject byte_order) {
        ByteOrder order = Util.parseByteOrder(context.runtime, byte_order);
        return new Struct(context.runtime, getMetaClass(), layout,
                getMemory().order(context.runtime, order));
    }
View Full Code Here

            return io;
        }

        static ByteOrder getByteOrderOption(ThreadContext context, IRubyObject[] args) {

            ByteOrder order = ByteOrder.nativeOrder();

            if (args.length > 3 && args[3] instanceof RubyHash) {
                RubyHash options = (RubyHash) args[3];
                IRubyObject byte_order = options.fastARef(RubySymbol.newSymbol(context.runtime, "byte_order"));
                if (byte_order instanceof RubySymbol || byte_order instanceof RubyString) {
View Full Code Here

            if (buffers[0].readable()) {
                return wrappedBuffer(buffers[0]);
            }
            break;
        default:
            ByteOrder order = null;
            final List<ChannelBuffer> components = new ArrayList<ChannelBuffer>(buffers.length);
            for (ChannelBuffer c: buffers) {
                if (c == null) {
                    break;
                }
                if (c.readable()) {
                    if (order != null) {
                        if (!order.equals(c.order())) {
                            throw new IllegalArgumentException(
                                    "inconsistent byte order");
                        }
                    } else {
                        order = c.order();
View Full Code Here

            if (buffers[0].hasRemaining()) {
                return wrappedBuffer(buffers[0]);
            }
            break;
        default:
            ByteOrder order = null;
            final List<ChannelBuffer> components = new ArrayList<ChannelBuffer>(buffers.length);
            for (ByteBuffer b: buffers) {
                if (b == null) {
                    break;
                }
                if (b.hasRemaining()) {
                    if (order != null) {
                        if (!order.equals(b.order())) {
                            throw new IllegalArgumentException(
                                    "inconsistent byte order");
                        }
                    } else {
                        order = b.order();
View Full Code Here

        long position = 0;
        int bitOffset = 0;
        int operation = 0;
        final ByteBuffer buffer = ByteBuffer.allocate(128);
        final Random random = TestUtilities.createRandomNumberGenerator("testWithRandomData");
        final ByteOrder byteOrder = random.nextBoolean() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
        final byte[] data = ChannelDataInputTest.createRandomArray(512 * 1024, random);
        final ImageInputStream r = ImageIO.createImageInputStream(new ByteArrayInputStream(data));
        final ImageInputStream t = new ChannelImageInputStream("Test data",
                     Channels.newChannel(new ByteArrayInputStream(data)), buffer, false);
        try {
View Full Code Here

TOP

Related Classes of java.nio.ByteOrder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.