KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > nio > ByteOrder


1 /*
2  * @(#)ByteOrder.java 1.13 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.nio;
9
10
11 /**
12  * A typesafe enumeration for byte orders.
13  *
14  * @author Mark Reinhold
15  * @author JSR-51 Expert Group
16  * @version 1.13, 03/12/19
17  * @since 1.4
18  */

19
20 public final class ByteOrder {
21
22     private String JavaDoc name;
23
24     private ByteOrder(String JavaDoc name) {
25     this.name = name;
26     }
27
28     /**
29      * Constant denoting big-endian byte order. In this order, the bytes of a
30      * multibyte value are ordered from most significant to least significant.
31      * </p>
32      */

33     public static final ByteOrder JavaDoc BIG_ENDIAN
34     = new ByteOrder JavaDoc("BIG_ENDIAN");
35
36     /**
37      * Constant denoting little-endian byte order. In this order, the bytes of
38      * a multibyte value are ordered from least significant to most
39      * significant. </p>
40      */

41     public static final ByteOrder JavaDoc LITTLE_ENDIAN
42     = new ByteOrder JavaDoc("LITTLE_ENDIAN");
43
44     /**
45      * Retrieves the native byte order of the underlying platform.
46      *
47      * <p> This method is defined so that performance-sensitive Java code can
48      * allocate direct buffers with the same byte order as the hardware.
49      * Native code libraries are often more efficient when such buffers are
50      * used. </p>
51      *
52      * @return The native byte order of the hardware upon which this Java
53      * virtual machine is running
54      */

55     public static ByteOrder JavaDoc nativeOrder() {
56     return Bits.byteOrder();
57     }
58
59     /**
60      * Constructs a string describing this object.
61      *
62      * <p> This method returns the string <tt>"BIG_ENDIAN"</tt> for {@link
63      * #BIG_ENDIAN} and <tt>"LITTLE_ENDIAN"</tt> for {@link #LITTLE_ENDIAN}.
64      * </p>
65      *
66      * @return The specified string
67      */

68     public String JavaDoc toString() {
69     return name;
70     }
71
72 }
73
Popular Tags