Package org.greenrobot.essentials
Class PrimitiveArrayUtils
- java.lang.Object
-
- org.greenrobot.essentials.PrimitiveArrayUtils
-
- Direct Known Subclasses:
PrimitiveArrayUtils.SafeImpl,PrimitiveArrayUtils.UnsafeImpl
public abstract class PrimitiveArrayUtils extends java.lang.ObjectRetrieves int and long values from byte arrays. By default it uses a "safe" implementation (plain Java). By callinginitUnsafeInstance(), you can switch to sun.misc.Unsafe (deprecated) for fast access.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPrimitiveArrayUtils.SafeImplprivate static classPrimitiveArrayUtils.UnsafeImpl
-
Field Summary
Fields Modifier and Type Field Description private static PrimitiveArrayUtilsinstanceSafeprivate static PrimitiveArrayUtilsinstanceUnsafe
-
Constructor Summary
Constructors Constructor Description PrimitiveArrayUtils()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static PrimitiveArrayUtilsgetInstance()static PrimitiveArrayUtilsgetInstanceSafe()abstract intgetIntBE(byte[] bytes, int index)abstract intgetIntLE(byte[] bytes, int index)abstract intgetIntLE(char[] chars, int index)abstract longgetLongBE(byte[] bytes, int index)abstract longgetLongLE(byte[] bytes, int index)static booleaninitUnsafeInstance()If sun.misc.Unsafe is available, this will init the static instance with a fast implementation.
-
-
-
Field Detail
-
instanceUnsafe
private static volatile PrimitiveArrayUtils instanceUnsafe
-
instanceSafe
private static final PrimitiveArrayUtils instanceSafe
-
-
Method Detail
-
getInstance
public static PrimitiveArrayUtils getInstance()
-
initUnsafeInstance
public static boolean initUnsafeInstance()
If sun.misc.Unsafe is available, this will init the static instance with a fast implementation.- Returns:
- true if an unsafe implementation is available - future calls to
getInstance()will return it.
-
getInstanceSafe
public static PrimitiveArrayUtils getInstanceSafe()
-
getIntLE
public abstract int getIntLE(byte[] bytes, int index)
-
getIntBE
public abstract int getIntBE(byte[] bytes, int index)
-
getLongLE
public abstract long getLongLE(byte[] bytes, int index)
-
getLongBE
public abstract long getLongBE(byte[] bytes, int index)
-
getIntLE
public abstract int getIntLE(char[] chars, int index)
-
-