Top Fields Constructors Methods
org.apache.sshd.common.util

public final Class NumberUtils

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .Collections, .List

Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
public static final List<Class<?>>
NUMERIC_PRIMITIVE_CLASSES

A List of all the Class types used to represent the primitive numerical values

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static List<Integer>
asList(int... values)

public static int
diffOffset(byte[] a1, int startPos1, byte[] a2, int startPos2, int len)

public static byte[]
emptyIfNull(byte[] a)

public static int

Returns:

The closest positive power of 2 that is greater or equal to the value. If none can be found then returns the original value
getNextPowerOf2
(int
The original (non-negative) value
value
)

public static int
hashCode(long... values)

public static int
hashCode(int... values)

public static int
hashCode(byte... values)

public static int
hashCode(byte[] a, int offset, int len)

public static boolean
isEmpty(byte[] a)

public static boolean
isEmpty(int[] a)

public static boolean
isEmpty(long[] a)

public static boolean

Returns:

true if valid integer number
isIntegerNumber
(CharSequence
The CharSequence to check
cs
)

Checks if optional sign and all others are '0'-'9'

public static boolean

Returns:

If the class is a Number or one of the primitive numerical types
isNumericClass
(Class<?>
The Class to examine - ignored if null
clazz
)

public static String
join(CharSequence separator, long... values)

public static String
join(char separator, long... values)

public static String
join(CharSequence separator, boolean unsigned, byte... values)

public static String
join(char separator, boolean unsigned, byte... values)

public static String
join(CharSequence separator, int... values)

public static String
join(char separator, int... values)

public static int
length(byte... a)

public static int
length(int... a)

public static int
length(long... a)

public static Integer

Returns:

The equivalent Integer value
toInteger
(Number
The Number - ignored if null
n
)

Converts a Number into an Integer if not already such

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NUMERIC_PRIMITIVE_CLASSESback to summary
public static final List<Class<?>> NUMERIC_PRIMITIVE_CLASSES

A List of all the Class types used to represent the primitive numerical values

Constructor Detail

NumberUtilsback to summary
private NumberUtils()

Method Detail

asListback to summary
public static List<Integer> asList(int... values)
diffOffsetback to summary
public static int diffOffset(byte[] a1, int startPos1, byte[] a2, int startPos2, int len)
emptyIfNullback to summary
public static byte[] emptyIfNull(byte[] a)
getNextPowerOf2back to summary
public static int getNextPowerOf2(int value)
Parameters
value:int

The original (non-negative) value

Returns:int

The closest positive power of 2 that is greater or equal to the value. If none can be found then returns the original value

hashCodeback to summary
public static int hashCode(long... values)
hashCodeback to summary
public static int hashCode(int... values)
hashCodeback to summary
public static int hashCode(byte... values)
hashCodeback to summary
public static int hashCode(byte[] a, int offset, int len)
isEmptyback to summary
public static boolean isEmpty(byte[] a)
isEmptyback to summary
public static boolean isEmpty(int[] a)
isEmptyback to summary
public static boolean isEmpty(long[] a)
isIntegerNumberback to summary
public static boolean isIntegerNumber(CharSequence cs)

Checks if optional sign and all others are '0'-'9'

Parameters
cs:CharSequence

The CharSequence to check

Returns:boolean

true if valid integer number

isNumericClassback to summary
public static boolean isNumericClass(Class<?> clazz)
Parameters
clazz:Class<?>

The Class to examine - ignored if null

Returns:boolean

If the class is a Number or one of the primitive numerical types

See Also
NUMERIC_PRIMITIVE_CLASSES
joinback to summary
public static String join(CharSequence separator, long... values)
joinback to summary
public static String join(char separator, long... values)
joinback to summary
public static String join(CharSequence separator, boolean unsigned, byte... values)
joinback to summary
public static String join(char separator, boolean unsigned, byte... values)
joinback to summary
public static String join(CharSequence separator, int... values)
joinback to summary
public static String join(char separator, int... values)
lengthback to summary
public static int length(byte... a)
lengthback to summary
public static int length(int... a)
lengthback to summary
public static int length(long... a)
toIntegerback to summary
public static Integer toInteger(Number n)

Converts a Number into an Integer if not already such

Parameters
n:Number

The Number - ignored if null

Returns:Integer

The equivalent Integer value