Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/nio/ByteOrder.java
38829 views
/*1* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.nio;262728/**29* A typesafe enumeration for byte orders.30*31* @author Mark Reinhold32* @author JSR-51 Expert Group33* @since 1.434*/3536public final class ByteOrder {3738private String name;3940private ByteOrder(String name) {41this.name = name;42}4344/**45* Constant denoting big-endian byte order. In this order, the bytes of a46* multibyte value are ordered from most significant to least significant.47*/48public static final ByteOrder BIG_ENDIAN49= new ByteOrder("BIG_ENDIAN");5051/**52* Constant denoting little-endian byte order. In this order, the bytes of53* a multibyte value are ordered from least significant to most54* significant.55*/56public static final ByteOrder LITTLE_ENDIAN57= new ByteOrder("LITTLE_ENDIAN");5859/**60* Retrieves the native byte order of the underlying platform.61*62* <p> This method is defined so that performance-sensitive Java code can63* allocate direct buffers with the same byte order as the hardware.64* Native code libraries are often more efficient when such buffers are65* used. </p>66*67* @return The native byte order of the hardware upon which this Java68* virtual machine is running69*/70public static ByteOrder nativeOrder() {71return Bits.byteOrder();72}7374/**75* Constructs a string describing this object.76*77* <p> This method returns the string <tt>"BIG_ENDIAN"</tt> for {@link78* #BIG_ENDIAN} and <tt>"LITTLE_ENDIAN"</tt> for {@link #LITTLE_ENDIAN}.79* </p>80*81* @return The specified string82*/83public String toString() {84return name;85}8687}888990