类 General
java.lang.Object
com.sh.javax.util.General
Description: 通用函数类,包括一系列有用的函数,其中大部分是静态函数。
Title:首亨软件 - CRM
-
字段概要
字段修饰符和类型字段说明protected static Stringstatic Stringprotected static longstatic Propertiesstatic Properties -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static String将用字符串表示的某一格式日期增加或者减少几天static Date在某一个时间的基础上增加或减少几天static String将用字符串表示的某一格式月份增加或者减少几个月static Date在某一个时间的基础上增加或减少几个月static Stringbyte2hex(byte[] b) 将字节数据转换成对应的二进制字符串static Stringconsume(Properties p, String key) 从属性表中获取某一属性的字符串值static intconsumeInt(Properties p, String key) 从属性表中获取某一属性代表的数值static DatastoreconvertAcrossTable2Vertic(Datastore acrossDS, int colType, String[] acrossDSColNames, String[] idValues, String vLabelColName, String vValueColName) 将横表转化成纵表,返回列名为vLabelColName、vValueColName变量指定的的数据集static DateconvertDateToSqlDate(Date date) 将java.util.Data类型转化成java.sql.Datastatic StringconvertDateToString(Date date) 将日期转化成字符串,日期的模式为"yyyy年MM月dd日"static StringconvertDateToString(Date date, String pattern) 将日期对象转换成特定模式的字符串static StringconvertDateToString(Date date, String pattern, String toZoneId) 将日期对象转换成特定模式的字符串static TimestampconvertDateToTimestamp(Date date) 将java.util.Data类型转化成java.sql.Timestampstatic StringconvertGBKToISO(String str) 将GBK编码格式的字符串转换成ISO编码字符串static StringconvertISOToGBK(String str) 将ISO编码格式的字符串转换成GBK编码字符串static StringconvertISOToUTF8(String str) static String[]convertList2StrArray(List list) 将一个链表中的数据作为字符串数组输出static StringconvertNullToDefault(String str, String defaultValue) 转换字符串,如果值为null,返回默认值static StringconvertNullToEmpty(String str) 转换字符串,如果值为null,返回""static String将字符串中有空格的地方转化成  static DateconvertSqlDateToDate(Date date) static Date将"yyyy年M月d日"格式的字符串转化成日期static DateconvertStringToDate(String str, String pattern) 将特定格式的字符串转化成日期static double将字符串转换成double值static float将字符串转换成float值static intconvertStringToInt(String str) 将字符串转换成int值static long将字符串转换成long值static short将字符串转换成short值static Timestampstatic TimestampconvertStringToTimestamp(String str, String pattern) static StringconvertWideString(String str) 替换中文字符static StringcreateRandomID(jakarta.servlet.http.HttpSession session) 根据web服务器的会话(session)生成一个唯一的IDstatic StringencodeHTML(String source) 将文本按照HTML的要进行编码protected static StringencryptMac(String mac) 通过MAC地址生成安装注册码,以防止未经授权而直接从其他地方拷贝使用该系统static intgetDateField(int field, Date today) 取得日期中的某一部分static StringgetEncryptString(String original) 利用消息摘要对字符串加密,加密是单向的static StringgetFileDigest(Class cls, String fileName) 读取一个文件的内容,并根据文件的内容生成消息摘要static StringgetLicenseByMachineCode(String machineCode) static StringgetLicenseByMachineCodeLocal(String machineCode) 64位系统使用static String获取Linux下的机器码static String获取服务器的MAC地址protected static String根据System.properties中的参数配置来获取服务器MAC地址static Stringstatic int获取系统允许的最大在线用户数static String获取当前操作系统名称. return 操作系统名称 例如:windows xp,linux 等.static StringgetSysdate(DataCenter dc) static StringgetSysdate(DataCenter dc, String format) 获取数据库的时间static Stringstatic StringgetSystemParameter(Class cls, String paraName) 从system.ini中读取某一参数的值static DategetToday()static DategetToday(int months, int days) 取得当天的时间static StringgetTodayStr(int months, int days, String pattern) 获取当天的时间字符串static StringgetTodayStr(String pattern) static String获取windows下的机器码static booleanisLinux()判断是否Linux系统static boolean判断是否WINDOWS系统static StringMD5加密static voidoutputData(InputStream input, OutputStream output) 默认一个字节一个字节进行传输static voidoutputData(InputStream input, OutputStream output, int blockSize) 从输入流将数据拷贝到输出流static voidPictureZoom(InputStream source, Dimension target, OutputStream out) 将图片进行自动比例缩放,从一个输入流进行缩放后输出到一个输出流中static voidPictureZoom(InputStream source, Dimension target, OutputStream out, int keepScale) 图片缩放函数,将一个输入流进行缩放后输出到一个输出流中static StringreplaceString(String source, String tag, String value) 将指定字符串中的标记用相应的字符串替换掉static String[]将一个以逗号隔开的字符串转化成字符串数组static String[]将用指定符号格开的字符串转化成字符串数组static final Stringstatic String将一个字符串数组转换成用逗号符隔开的字符串static String将一个字符串数组转换成用分隔符隔开的字符串protected static booleanvalidUserNum(DataCenter dc, String userId) 验证当前登陆用户数是否到达授权用户数
-
字段详细资料
-
classPath
-
AUTH_ERROR_MESSAGE
-
sysParam
-
sysParamEx
-
licenseRangMillis
protected static long licenseRangMillis
-
-
构造器详细资料
-
General
public General()
-
-
方法详细资料
-
getMachineCode
-
convertWideString
替换中文字符- 参数:
str- String- 返回:
- String
-
getLicenseByMachineCode
-
getLicenseByMachineCodeLocal
64位系统使用- 参数:
machineCode- String- 返回:
- String
-
getMaxOnlineUser
public static int getMaxOnlineUser()获取系统允许的最大在线用户数- 返回:
- int
-
convertISOToGBK
将ISO编码格式的字符串转换成GBK编码字符串- 参数:
str- 用ISO编码的字符串- 返回:
- GBK编码的字符串
-
convertISOToUTF8
-
convertGBKToISO
将GBK编码格式的字符串转换成ISO编码字符串- 参数:
str- 用GBK编码的字符串- 返回:
- ISO编码的字符串
-
convertStringToDate
将"yyyy年M月d日"格式的字符串转化成日期- 参数:
str- 日期字符串- 返回:
- 日期对象
- 抛出:
ParseException- ParseException
-
convertStringToDate
将特定格式的字符串转化成日期- 参数:
str- 日期字符串pattern- 字符串模式,如:yyyy年M月d日,yyyy-MM-dd等- 返回:
- 日期对象
- 抛出:
ParseException- ParseException
-
convertDateToString
将日期转化成字符串,日期的模式为"yyyy年MM月dd日"- 参数:
date- 日期对象- 返回:
- 表示日期的字符串
-
convertDateToString
将日期对象转换成特定模式的字符串- 参数:
date- 日期对象pattern- 字符串模式,如:yyyy年M月d日,yyyy-MM-dd等- 返回:
- 特定格式的字符串
-
convertDateToString
将日期对象转换成特定模式的字符串- 参数:
date- 日期对象pattern- 字符串模式,如:yyyy年M月d日,yyyy-MM-dd等toZoneId- 时区- 返回:
- 特定格式的字符串
-
convertStringToInt
将字符串转换成int值- 参数:
str- 字符串- 返回:
- 对应的int值
-
convertStringToShort
将字符串转换成short值- 参数:
str- 字符串- 返回:
- 对应的int值
-
convertStringToLong
将字符串转换成long值- 参数:
str- 字符串- 返回:
- 对应的int值
-
convertStringToFloat
将字符串转换成float值- 参数:
str- 字符串- 返回:
- 对应的float值
-
convertStringToDouble
将字符串转换成double值- 参数:
str- 字符串- 返回:
- 对应的double值
-
convertDateToSqlDate
将java.util.Data类型转化成java.sql.Data- 参数:
date- java.util.Data对象- 返回:
- java.sql.Data对象
-
convertSqlDateToDate
-
convertDateToTimestamp
将java.util.Data类型转化成java.sql.Timestamp- 参数:
date- java.util.Data对象- 返回:
- java.sql.Timestamp对象
-
convertStringToTimestamp
- 抛出:
Exception
-
convertStringToTimestamp
- 抛出:
Exception
-
toJson
-
split
将一个以逗号隔开的字符串转化成字符串数组- 参数:
str- String 以逗号隔开的字符串- 返回:
- String[] 字符串数组
-
split
将用指定符号格开的字符串转化成字符串数组- 参数:
str- 带有指定符号的字符串delim- 指定符号- 返回:
- 对应的字符串数组
-
union
将一个字符串数组转换成用分隔符隔开的字符串- 参数:
str- String[] 字符串数组delim- String 分隔符- 返回:
- String 用分隔符隔开的字符串
-
union
将一个字符串数组转换成用逗号符隔开的字符串- 参数:
str- String[] 字符串数组- 返回:
- String 用逗号符隔开的字符串
-
getToday
-
getToday
取得当天的时间- 参数:
months- 月数days- 天数- 返回:
- 当天的时间
-
getTodayStr
-
getTodayStr
获取当天的时间字符串- 参数:
months- 月数days- 天数pattern- 表达式- 返回:
- String
-
getSysdate
获取数据库的时间- 参数:
dc- DataCenterformat- String- 返回:
- String
-
getSysdate
-
getSysdateDay
-
replaceString
将指定字符串中的标记用相应的字符串替换掉- 参数:
source- 需要替换的字符串tag- 标记value- 替换值- 返回:
- 相关标记被替换的字符串
-
encodeHTML
将文本按照HTML的要进行编码- 参数:
source- 原始的字符串- 返回:
- 转换后的字符串
-
getSystemParameter
从system.ini中读取某一参数的值- 参数:
cls- ClassparaName- 参数- 返回:
- 参数值
-
consume
从属性表中获取某一属性的字符串值- 参数:
p- 属性表对象key- 属性名称- 返回:
- 属性值
-
consumeInt
从属性表中获取某一属性代表的数值- 参数:
p- 属性表对象key- 属性名称- 返回:
- 属性代表的数值
-
convertNullToEmpty
转换字符串,如果值为null,返回""- 参数:
str- 字符串- 返回:
- 返回经过规整的字符串
-
convertNullToDefault
转换字符串,如果值为null,返回默认值- 参数:
str- 字符串defaultValue- 默认值- 返回:
- 返回经过规整的字符串
-
convertNullToHTMLEmpty
将字符串中有空格的地方转化成  - 参数:
str- 普通字符串- 返回:
- 空格经过转化后的字符串
-
PictureZoom
将图片进行自动比例缩放,从一个输入流进行缩放后输出到一个输出流中- 参数:
source- 输入流target- 目标大小out- 输出流
-
PictureZoom
public static void PictureZoom(InputStream source, Dimension target, OutputStream out, int keepScale) 图片缩放函数,将一个输入流进行缩放后输出到一个输出流中- 参数:
source- 输入流target- 目标大小out- 输出流keepScale- 是否保持比例 0不保持比例(拉伸),1自动保持比例,2以宽度为基准保持比例,3以高度为基准保持比例
-
outputData
public static void outputData(InputStream input, OutputStream output, int blockSize) throws Exception 从输入流将数据拷贝到输出流- 参数:
input- 输入流output- 输出流blockSize- int- 抛出:
Exception- Exception
-
outputData
默认一个字节一个字节进行传输- 参数:
input- 输入流output- 输出流- 抛出:
Exception- Exception
-
convertList2StrArray
将一个链表中的数据作为字符串数组输出- 参数:
list- List 链表- 返回:
- String[] 字符串数组
-
addDays
在某一个时间的基础上增加或减少几天- 参数:
today- Date 当前时间days- int 增加或者减少几天,正数表示today之后的某一天,负数表示today之前的某一天- 返回:
- Date 修改后的时间
-
addDays
将用字符串表示的某一格式日期增加或者减少几天- 参数:
today- String 当天days- int 增减天数pattern- String 日期模式- 返回:
- String 经过增加或者减少的最终日期
- 抛出:
Exception- 如果出错抛出异常
-
addMonths
在某一个时间的基础上增加或减少几个月- 参数:
today- Date 当前时间months- int 增加或者减少几个月,正数表示today之后的某一月,负数表示today之前的某一月- 返回:
- Date 修改后的时间
-
addMonths
将用字符串表示的某一格式月份增加或者减少几个月- 参数:
curMonth- String 当前月份months- int 增减月份数pattern- String 月份模式- 返回:
- String 经过增加或者减少的最终月份
- 抛出:
Exception- 如果出错抛出异常
-
getDateField
取得日期中的某一部分- 参数:
field- int 表示日期中的某一部分,参见GregorianCalendar的get方法today- Date 日期- 返回:
- int 取得的某一部分
-
convertAcrossTable2Vertic
public static Datastore convertAcrossTable2Vertic(Datastore acrossDS, int colType, String[] acrossDSColNames, String[] idValues, String vLabelColName, String vValueColName) throws Exception 将横表转化成纵表,返回列名为vLabelColName、vValueColName变量指定的的数据集- 参数:
acrossDS- Datastore 横表数据集colType- int 待转换的数据集中数值字段的类型,注意,所有字段的类型应该移植acrossDSColNames- String[] 供生成的横列名idValues- String[] 区分不同原横列的字段值(原横列对应的名称或意义)vLabelColName- String 生成的新的数据源中对应每个列说明的字段(分类字段)vValueColName- String 值字段- 返回:
- Datastore 新的数据集
- 抛出:
Exception- Exception
-
createRandomID
根据web服务器的会话(session)生成一个唯一的ID- 参数:
session- HttpSession 用户会话- 返回:
- String 唯一的ID
-
byte2hex
将字节数据转换成对应的二进制字符串- 参数:
b- byte[] 字节数组- 返回:
- String 转化后的字符串
-
getEncryptString
利用消息摘要对字符串加密,加密是单向的- 参数:
original- String 需要加密的字符串- 返回:
- String 加密后的字符串
-
md5
MD5加密- 参数:
original- String- 返回:
- String
-
getLinuxMachineCode
获取Linux下的机器码- 返回:
- String
-
getWindowsMachineCode
获取windows下的机器码- 返回:
- String
-
validUserNum
验证当前登陆用户数是否到达授权用户数- 参数:
dc-- 返回:
-
getFileDigest
读取一个文件的内容,并根据文件的内容生成消息摘要- 参数:
cls- ClassfileName- String 文件名字- 返回:
- String 消息摘要
-
getOSName
获取当前操作系统名称. return 操作系统名称 例如:windows xp,linux 等.- 返回:
- String
-
isWindows
public static boolean isWindows()判断是否WINDOWS系统- 返回:
- boolean
-
isLinux
public static boolean isLinux()判断是否Linux系统- 返回:
- boolean
-
getMacAddress
获取服务器的MAC地址- 返回:
- String
-
getMacAddressEx
根据System.properties中的参数配置来获取服务器MAC地址- 返回:
- String
-
encryptMac
通过MAC地址生成安装注册码,以防止未经授权而直接从其他地方拷贝使用该系统- 参数:
mac- String- 返回:
- String
-