Package com.esotericsoftware.kryo.util
Class Util
- java.lang.Object
-
- com.esotericsoftware.kryo.util.Util
-
public class Util extends Object
A few utility methods, mostly for private use.- Author:
- Nathan Sweet
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
isAndroid
static int
maxArraySize
static boolean
unsafe
True if Unsafe is available.
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
canonicalName(Class type)
Returns the class formatted as a string.static String
className(Class type)
Returns the class formatted as a string.static String
classNames(Class[] types)
Returns the classes formatted as a string.static int
getDimensionCount(Class arrayClass)
Returns the number of dimensions of an array.static Class
getElementClass(Class arrayClass)
Returns the base element type of an n-dimensional array class.static Class
getPrimitiveClass(Class type)
Returns the primitive class for a primitive wrapper class.static Class
getWrapperClass(Class type)
Returns the primitive wrapper class for a primitive class, or the specified class if it is not primitive.static boolean
isAscii(String value)
static boolean
isAssignableTo(Class<?> from, Class<?> to)
static boolean
isClassAvailable(String className)
static boolean
isEnum(Class type)
static boolean
isUnsafeAvailable()
static boolean
isWrapperClass(Class type)
static void
log(String message, Object object, int position)
Logs a message about an object.static <T extends SerializerFactory>
TnewFactory(Class<T> factoryClass, Class<? extends Serializer> serializerClass)
static String
pos(int position)
static String
simpleName(Class type, Generics.GenericType genericType)
static String
simpleName(Type type)
static String
string(Object object)
Returns the object formatted as a string.
-
-
-
Field Detail
-
isAndroid
public static final boolean isAndroid
-
unsafe
public static final boolean unsafe
True if Unsafe is available. Unsafe can be disabled by setting the system property "kryo.unsafe" to "false".
-
maxArraySize
public static final int maxArraySize
- See Also:
- Constant Field Values
-
-
Method Detail
-
isUnsafeAvailable
public static boolean isUnsafeAvailable()
-
isClassAvailable
public static boolean isClassAvailable(String className)
-
getWrapperClass
public static Class getWrapperClass(Class type)
Returns the primitive wrapper class for a primitive class, or the specified class if it is not primitive.
-
getPrimitiveClass
public static Class getPrimitiveClass(Class type)
Returns the primitive class for a primitive wrapper class. Otherwise returns the type parameter.- Parameters:
type
- Must be a wrapper class.
-
isWrapperClass
public static boolean isWrapperClass(Class type)
-
isEnum
public static boolean isEnum(Class type)
-
log
public static void log(String message, Object object, int position)
Logs a message about an object. The log level and the string format of the object depend on the object type.
-
pos
public static String pos(int position)
-
string
public static String string(Object object)
Returns the object formatted as a string. The format depends on the object's type and whetherObject.toString()
has been overridden.
-
className
public static String className(Class type)
Returns the class formatted as a string. The format varies depending on the type.
-
classNames
public static String classNames(Class[] types)
Returns the classes formatted as a string. The format varies depending on the type.
-
canonicalName
public static String canonicalName(Class type)
Returns the class formatted as a string. If the class has a canonical name, the canonical name is returned, otherwise it returns the result ofclassName(Class)
-
simpleName
public static String simpleName(Class type, Generics.GenericType genericType)
-
getDimensionCount
public static int getDimensionCount(Class arrayClass)
Returns the number of dimensions of an array.
-
getElementClass
public static Class getElementClass(Class arrayClass)
Returns the base element type of an n-dimensional array class.
-
isAscii
public static boolean isAscii(String value)
-
newFactory
public static <T extends SerializerFactory> T newFactory(Class<T> factoryClass, Class<? extends Serializer> serializerClass)
- Parameters:
factoryClass
- Must have a constructor that takes a serializer class, or a zero argument constructor.serializerClass
- May be null if the factory already knows the serializer class to create.
-
-