类 DataTypeUtil
- java.lang.Object
-
- org.meteoinfo.ndarray.util.DataTypeUtil
-
public class DataTypeUtil extends java.lang.Object- 作者:
- Yaqiang Wang
-
-
构造器概要
构造器 构造器 说明 DataTypeUtil()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static byte[]bigToLittle(byte[] bytes)Convert BigEndian to LittleEndianstatic intbyte2Int(byte b)Convert byte to int - byte in Java is signedstatic doublebytes2Double(byte[] b, java.nio.ByteOrder byteOrder)Byte array convert to doublestatic floatbytes2Float(byte[] b, java.nio.ByteOrder byteOrder)Byte array convert to floatstatic intbytes2Int(byte[] bytes)Byte array convert to integerstatic intbytes2Int(byte[] bytes, java.nio.ByteOrder byteOrder)Byte array convert to integerstatic intbytes2Int3(byte[] bytes)Byte array (3 bytes) convert to integerstatic java.lang.Longbytes2Long(byte[] bytes, java.nio.ByteOrder byteOrder)Byte array convert to long integerstatic shortbytes2Short(byte[] bytes, java.nio.ByteOrder byteOrder)Byte array convert to short integerstatic char[]convertByteToChar(byte[] byteArray)static char[]convertByteToCharUTF(byte[] byteArray)static byte[]convertCharToByte(char[] from)static byte[]convertCharToByteUTF(char[] from)static java.lang.ObjectconvertStringTo(java.lang.String vStr, DataType dataType, java.lang.String dateFormat)Convert input string data to current data typestatic java.lang.ObjectconvertTo(java.lang.Object value, DataType dataType, java.lang.String dateFormat)Convert input data to current data typestatic DataTypedetectDataType(java.util.List<java.lang.String> valuesList, int n, java.time.format.DateTimeFormatter dtFormatter)Detect data typestatic DataTypedetectDataType(java.util.List<java.lang.String> valuesList, java.time.format.DateTimeFormatter dtFormatter)Detect data typestatic java.lang.StringdoubleToString(double v)Double to stringstatic byte[]float2Bytes(float f, java.nio.ByteOrder byteOrder)Convert float to byte arraystatic DataTypegetDataType(java.lang.String format)Get data typestatic java.lang.StringgetDateFormat(java.lang.String format)Get date format stringstatic booleanisBoolean(java.lang.String s)Check a string is boolean or notstatic booleanisDouble(java.lang.String s)Check a string is double or notstatic booleanisFloat(java.lang.String s)Check a string is float or notstatic booleanisInteger(java.lang.String s)Check a string is integer or notstatic booleanisLocalDate(java.lang.String s, java.time.format.DateTimeFormatter dateTimeFormatter)Check a string is local date or notstatic booleanisLocalDateTime(java.lang.String s, java.time.format.DateTimeFormatter formatter)Check a string is local date time or notstatic booleanisLocalTime(java.lang.String s, java.time.format.DateTimeFormatter formatter)Check a string is local time or notstatic byte[]littleToBig(byte[] bytes)Convert LittleEndian to BigEndianstatic java.lang.StringremoveTail0(java.lang.String str)Remove last zero charsstatic java.lang.StringremoveTailingZeros(java.lang.String s)Remove tail zerostatic java.lang.ObjectresizeArray(java.lang.Object oldArray, int newSize)Resize arraystatic double[][]resizeArray2D(double[][] oldArray, int newSize)Resize double 2d arraystatic byte[]toByte_bak1(java.util.BitSet bits)static byte[]toByteArray(java.util.BitSet bits)static byte[]toByteArray_bak(java.util.BitSet bitSet)static byte[]toBytes(float f)Convert float to byte arraystatic byte[]toBytes(int i)Convert int to byte array.static byte[]toLittleBytes(float f)Convert float to byte arraystatic byte[]toLittleBytes(int i)Convert int to byte array - LittleEndianstatic byte[]toUint2Int(int i)Convert int to 2 byte array.static byte[]toUint3Int(int i)Convert int to 3 byte array.static byte[]toUintNInt(int i, int n)Convert int to N byte array.
-
-
-
方法详细资料
-
convertByteToCharUTF
public static char[] convertByteToCharUTF(byte[] byteArray)
-
convertCharToByteUTF
public static byte[] convertCharToByteUTF(char[] from)
-
convertByteToChar
public static char[] convertByteToChar(byte[] byteArray)
-
convertCharToByte
public static byte[] convertCharToByte(char[] from)
-
bytes2Float
public static float bytes2Float(byte[] b, java.nio.ByteOrder byteOrder)Byte array convert to float- 参数:
b- Byte arraybyteOrder- Byte order- 返回:
- Float value
-
bytes2Double
public static double bytes2Double(byte[] b, java.nio.ByteOrder byteOrder)Byte array convert to double- 参数:
b- Byte arraybyteOrder- Byte order- 返回:
- Double value
-
bytes2Int
public static int bytes2Int(byte[] bytes, java.nio.ByteOrder byteOrder)Byte array convert to integer- 参数:
bytes- Byte arraybyteOrder- Byte order- 返回:
- Integer value
-
bytes2Short
public static short bytes2Short(byte[] bytes, java.nio.ByteOrder byteOrder)Byte array convert to short integer- 参数:
bytes- Byte arraybyteOrder- Byte order- 返回:
- Short integer value
-
bytes2Long
public static java.lang.Long bytes2Long(byte[] bytes, java.nio.ByteOrder byteOrder)Byte array convert to long integer- 参数:
bytes- Byte arraybyteOrder- Byte order- 返回:
- Long integer value
-
bytes2Int
public static int bytes2Int(byte[] bytes)
Byte array convert to integer- 参数:
bytes- byte array- 返回:
- Integer value
-
bytes2Int3
public static int bytes2Int3(byte[] bytes)
Byte array (3 bytes) convert to integer- 参数:
bytes- Byte array- 返回:
- Integer value
-
byte2Int
public static int byte2Int(byte b)
Convert byte to int - byte in Java is signed- 参数:
b- Input byte- 返回:
- Output integer
-
littleToBig
public static byte[] littleToBig(byte[] bytes)
Convert LittleEndian to BigEndian- 参数:
bytes- Input LittleEndian byte array- 返回:
- Output BigEndian byte array
-
bigToLittle
public static byte[] bigToLittle(byte[] bytes)
Convert BigEndian to LittleEndian- 参数:
bytes- Input BigEndian byte array- 返回:
- Output LittleEndian byte array
-
toBytes
public static byte[] toBytes(int i)
Convert int to byte array.- 参数:
i- Int value- 返回:
- Byte array
-
toUint3Int
public static byte[] toUint3Int(int i)
Convert int to 3 byte array.- 参数:
i- Int value- 返回:
- Byte array
-
toUint2Int
public static byte[] toUint2Int(int i)
Convert int to 2 byte array.- 参数:
i- Int value- 返回:
- Byte array
-
toUintNInt
public static byte[] toUintNInt(int i, int n)Convert int to N byte array.- 参数:
i- Int valuen- bit number- 返回:
- Byte array
-
toLittleBytes
public static byte[] toLittleBytes(int i)
Convert int to byte array - LittleEndian- 参数:
i- Int value- 返回:
- Byte array
-
toBytes
public static byte[] toBytes(float f)
Convert float to byte array- 参数:
f- Float value- 返回:
- Byte array
-
float2Bytes
public static byte[] float2Bytes(float f, java.nio.ByteOrder byteOrder)Convert float to byte array- 参数:
f- Float valuebyteOrder- ByteOrder- 返回:
- Byte array
-
toLittleBytes
public static byte[] toLittleBytes(float f)
Convert float to byte array- 参数:
f- Float array- 返回:
- Byte array
-
resizeArray
public static java.lang.Object resizeArray(java.lang.Object oldArray, int newSize)Resize array- 参数:
oldArray- Old arraynewSize- New size- 返回:
- Resized array
-
resizeArray2D
public static double[][] resizeArray2D(double[][] oldArray, int newSize)Resize double 2d array- 参数:
oldArray- Old arraynewSize- New size- 返回:
- Resized array
-
doubleToString
public static java.lang.String doubleToString(double v)
Double to string- 参数:
v- The double value- 返回:
- Result string
-
removeTailingZeros
public static java.lang.String removeTailingZeros(java.lang.String s)
Remove tail zero- 参数:
s- The string- 返回:
- Result string
-
removeTail0
public static java.lang.String removeTail0(java.lang.String str)
Remove last zero chars- 参数:
str- String- 返回:
- Result string
-
toByte_bak1
public static byte[] toByte_bak1(java.util.BitSet bits)
-
toByteArray
public static byte[] toByteArray(java.util.BitSet bits)
-
toByteArray_bak
public static byte[] toByteArray_bak(java.util.BitSet bitSet)
-
convertTo
public static java.lang.Object convertTo(java.lang.Object value, DataType dataType, java.lang.String dateFormat)Convert input data to current data type- 参数:
value- Data valuedataType- Data typedateFormat- Date format- 返回:
- Converted data
-
convertStringTo
public static java.lang.Object convertStringTo(java.lang.String vStr, DataType dataType, java.lang.String dateFormat)Convert input string data to current data type- 参数:
vStr- String valuedataType- Data typedateFormat- Date format- 返回:
- Converted data
-
getDataType
public static DataType getDataType(java.lang.String format)
Get data type- 参数:
format- Format string- 返回:
- Data type
-
getDateFormat
public static java.lang.String getDateFormat(java.lang.String format)
Get date format string- 参数:
format- Format string- 返回:
- Date format string
-
isDouble
public static boolean isDouble(java.lang.String s)
Check a string is double or not- 参数:
s- The string- 返回:
- Boolean
-
isFloat
public static boolean isFloat(java.lang.String s)
Check a string is float or not- 参数:
s- The string- 返回:
- Boolean
-
isInteger
public static boolean isInteger(java.lang.String s)
Check a string is integer or not- 参数:
s- The string- 返回:
- Boolean
-
isBoolean
public static boolean isBoolean(java.lang.String s)
Check a string is boolean or not- 参数:
s- The string- 返回:
- Boolean
-
isLocalDate
public static boolean isLocalDate(java.lang.String s, java.time.format.DateTimeFormatter dateTimeFormatter)Check a string is local date or not- 参数:
s- The stringdateTimeFormatter- DateTimeFormatter- 返回:
-
isLocalTime
public static boolean isLocalTime(java.lang.String s, java.time.format.DateTimeFormatter formatter)Check a string is local time or not- 参数:
s- The stringformatter- DateTimeFormatter- 返回:
-
isLocalDateTime
public static boolean isLocalDateTime(java.lang.String s, java.time.format.DateTimeFormatter formatter)Check a string is local date time or not- 参数:
s- The stringformatter- DateTimeFormatter- 返回:
-
detectDataType
public static DataType detectDataType(java.util.List<java.lang.String> valuesList, java.time.format.DateTimeFormatter dtFormatter)
Detect data type- 参数:
valuesList- Values listdtFormatter- DateIimeFormatter- 返回:
- Data type
-
detectDataType
public static DataType detectDataType(java.util.List<java.lang.String> valuesList, int n, java.time.format.DateTimeFormatter dtFormatter)
Detect data type- 参数:
valuesList- Values listn- Value number used for detectdtFormatter- DateIimeFormatter- 返回:
- Data type
-
-