Package org.apache.sshd.common.util
Class NumberUtils
- java.lang.Object
-
- org.apache.sshd.common.util.NumberUtils
-
public final class NumberUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.List<java.lang.Class<?>>
NUMERIC_PRIMITIVE_CLASSES
AList
of all theClass
types used to represent the primitive numerical values
-
Constructor Summary
Constructors Modifier Constructor Description private
NumberUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.lang.Integer>
asList(int... values)
static int
diffOffset(byte[] a1, int startPos1, byte[] a2, int startPos2, int len)
static byte[]
emptyIfNull(byte[] a)
static int
getNextPowerOf2(int value)
static int
hashCode(byte... values)
static int
hashCode(byte[] a, int offset, int len)
static int
hashCode(int... values)
static int
hashCode(long... values)
static boolean
isEmpty(byte[] a)
static boolean
isEmpty(int[] a)
static boolean
isEmpty(long[] a)
static boolean
isIntegerNumber(java.lang.CharSequence cs)
Checks if optional sign and all others are '0'-'9'static boolean
isNumericClass(java.lang.Class<?> clazz)
static java.lang.String
join(char separator, boolean unsigned, byte... values)
static java.lang.String
join(char separator, int... values)
static java.lang.String
join(char separator, long... values)
static java.lang.String
join(java.lang.CharSequence separator, boolean unsigned, byte... values)
static java.lang.String
join(java.lang.CharSequence separator, int... values)
static java.lang.String
join(java.lang.CharSequence separator, long... values)
static int
length(byte... a)
static int
length(int... a)
static int
length(long... a)
static java.lang.Integer
toInteger(java.lang.Number n)
Converts aNumber
into anInteger
if not already such
-
-
-
Method Detail
-
getNextPowerOf2
public static int getNextPowerOf2(int value)
- Parameters:
value
- The original (non-negative) value- 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
-
hashCode
public static int hashCode(long... values)
-
hashCode
public static int hashCode(int... values)
-
hashCode
public static int hashCode(byte... values)
-
hashCode
public static int hashCode(byte[] a, int offset, int len)
-
diffOffset
public static int diffOffset(byte[] a1, int startPos1, byte[] a2, int startPos2, int len)
-
isNumericClass
public static boolean isNumericClass(java.lang.Class<?> clazz)
- Parameters:
clazz
- TheClass
to examine - ignored ifnull
- Returns:
- If the class is a
Number
or one of the primitive numerical types - See Also:
NUMERIC_PRIMITIVE_CLASSES
-
toInteger
public static java.lang.Integer toInteger(java.lang.Number n)
Converts aNumber
into anInteger
if not already such- Parameters:
n
- TheNumber
- ignored ifnull
- Returns:
- The equivalent
Integer
value
-
join
public static java.lang.String join(java.lang.CharSequence separator, long... values)
-
join
public static java.lang.String join(char separator, long... values)
-
join
public static java.lang.String join(java.lang.CharSequence separator, boolean unsigned, byte... values)
-
join
public static java.lang.String join(char separator, boolean unsigned, byte... values)
-
join
public static java.lang.String join(java.lang.CharSequence separator, int... values)
-
join
public static java.lang.String join(char separator, int... values)
-
emptyIfNull
public static byte[] emptyIfNull(byte[] a)
-
isEmpty
public static boolean isEmpty(byte[] a)
-
isEmpty
public static boolean isEmpty(int[] a)
-
isEmpty
public static boolean isEmpty(long[] a)
-
length
public static int length(byte... a)
-
length
public static int length(int... a)
-
length
public static int length(long... a)
-
asList
public static java.util.List<java.lang.Integer> asList(int... values)
-
isIntegerNumber
public static boolean isIntegerNumber(java.lang.CharSequence cs)
Checks if optional sign and all others are '0'-'9'- Parameters:
cs
- TheCharSequence
to check- Returns:
true
if valid integer number
-
-