Java ByteOrder complementingOrder(ByteOrder order)

Here you can find the source of complementingOrder(ByteOrder order)

Description

complementing Order

License

Apache License

Parameter

Parameter Description
order The ByteOrder to complement - ignored if <code>null</code>

Return

The complement (or null if no argument to complement)

Declaration

public static final ByteOrder complementingOrder(ByteOrder order) 

Method Source Code

//package com.java2s;
/*//w  w  w  . j av  a 2 s. c o m
 * Copyright 2013 Lyor Goldstein
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.nio.ByteOrder;

public class Main {
    /**
     * @return The complement of the current byte order
     * @see ByteOrder#nativeOrder()
     * @see #complementingOrder(ByteOrder)
     */
    public static final ByteOrder complementingOrder() {
        return complementingOrder(ByteOrder.nativeOrder());
    }

    /**
     * @param order The {@link ByteOrder} to complement - ignored if <code>null</code>
     * @return The complement {@link ByteOrder} (or <code>null</code> if no
     * argument to complement)
     */
    public static final ByteOrder complementingOrder(ByteOrder order) {
        if (order == null) {
            return null;
        } else if (ByteOrder.BIG_ENDIAN.equals(order)) {
            return ByteOrder.LITTLE_ENDIAN;
        } else {
            return ByteOrder.BIG_ENDIAN;
        }
    }
}

Related

  1. byteArrayToNumber(byte[] data, int index, int length, ByteOrder byteOrder)
  2. convertBytesToBigInteger(byte[] bytes, ByteOrder byteOrder, boolean isSigned)
  3. createWord(final ByteOrder aByteOrder, final int aMSB, final int aLSB)
  4. decode(final ByteOrder aExpectedByteOrder, final byte... aBytes)
  5. get24BitInt(byte b1, byte b2, byte b3, ByteOrder order)