1 /* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package java.nio; 18 19 //import org.apache.harmony.luni.platform.Platform; 20 21 /** Defines byte order constants. 22 * 23 * @since Android 1.0 */ 24 public final class ByteOrder { 25 26 /** This constant represents big endian. 27 * 28 * @since Android 1.0 */ 29 public static final ByteOrder BIG_ENDIAN = new ByteOrder("BIG_ENDIAN"); //$NON-NLS-1$ 30 31 /** This constant represents little endian. 32 * 33 * @since Android 1.0 */ 34 public static final ByteOrder LITTLE_ENDIAN = new ByteOrder("LITTLE_ENDIAN"); //$NON-NLS-1$ 35 36 private static final ByteOrder NATIVE_ORDER; 37 38 static { 39 // if (Platform.getMemorySystem().isLittleEndian()) { 40 NATIVE_ORDER = LITTLE_ENDIAN; 41 // } else { 42 // NATIVE_ORDER = BIG_ENDIAN; 43 // } 44 } 45 46 /** Returns the current platform byte order. 47 * 48 * @return the byte order object, which is either LITTLE_ENDIAN or BIG_ENDIAN. 49 * @since Android 1.0 */ nativeOrder()50 public static ByteOrder nativeOrder () { 51 return NATIVE_ORDER; 52 } 53 54 private final String name; 55 ByteOrder(String name)56 private ByteOrder (String name) { 57 super(); 58 this.name = name; 59 } 60 61 /** Returns a string that describes this object. 62 * 63 * @return "BIG_ENDIAN" for {@link #BIG_ENDIAN ByteOrder.BIG_ENDIAN} objects, "LITTLE_ENDIAN" for {@link #LITTLE_ENDIAN 64 * ByteOrder.LITTLE_ENDIAN} objects. 65 * @since Android 1.0 */ toString()66 public String toString () { 67 return name; 68 } 69 } 70