http://www.oschina.net/code/piece_full?code=6362
http://www.oschina.net/code/piece_full?code=6362
/**
002*
003*/
004@Typed
005packageorg.lucifer.util
006
007importstaticjava.lang.Math.*
008/**
009* @author Lucifer
010*
011*/
012final classMathExt {
013
014privateMathExt() {
015}
016
017staticdoublecot(doublea) {
018returncos(a) / sin(a)
019}
020
021staticdoublesec(doublea) {
022return1/ cos(a)
023}
024
025staticdoublecsc(doublea) {
026return1/ sin(a)
027}
028
029staticdoublearcsin(doublea) {
030returnasin(a)
031}
032
033staticdoublearccos(doublea) {
034returnacos(a)
035}
036
037staticdoublearctan(doublea) {
038returnatan(a)
039}
040
041staticdoublearccot(doublea) {
042returnarctan(1/ a)
043}
044
045staticdoublearcsec(doublea) {
046returnarccos(1/ a)
047}
048
049staticdoublearccsc(doublea) {
050returnarcsin(1/ a)
051}
052
053/**
054* 正矢函数
055* @param a
056* @return
057*/
058staticdoubleversin(doublea) {
059return1- cos(a)
060}
061
062/**
063* 正矢函数
064* @param a
065* @return
066*/
067staticdoublevercosin(doublea) {
068return1+ cos(a)
069}
070
071/**
072* 余矢函数
073* @param a
074* @return
075*/
076staticdoublecoversin(doublea) {
077return1- sin(a)
078}
079
080/**
081* 余矢函数
082* @param a
083* @return
084*/
085staticdoublecovercosin(doublea) {
086return1+ sin(a)
087}
088
089/**
090* 半正矢函数
091* @param a
092* @return
093*/
094staticdoublehaversin(doublea) {
095return(1- cos(a)) / 2
096}
097
098/**
099* 半正矢函数
100* @param a
101* @return
102*/
103staticdoublehavercosin(doublea) {
104return(1+ cos(a)) / 2
105}
106
107/**
108* 半余矢函数
109* @param a
110* @return
111*/
112staticdoublehacoversin(doublea) {
113return(1- sin(a)) / 2
114}
115
116/**
117* 半余矢函数
118* @param a
119* @return
120*/
121staticdoublehacovercosin(doublea) {
122return(1+ sin(a)) / 2
123}
124
125/**
126* 外正割函数
127* @param a
128* @return
129*/
130staticdoubleexsec(doublea) {
131returnsec(a) - 1
132}
133
134/**
135* 外余割函数
136* @param a
137* @return
138*/
139staticdoubleexcsc(doublea) {
140returncsc(a) - 1
141}
142
143staticdoublelog2(doublea) {
144returnlogN(2, a)
145}
146
147/**
148* bNum为底zNum的对数。
149* @param bNum 底数。
150* @param zNum 真数。
151* @return 对数值。
152*/
153staticdoublelogN(doublebNum, doublezNum) {
154returnlog(zNum) / log(bNum)
155}
156
157/**
158* 对num进行四舍五入操作。
159* @param num 要进行舍入操作的数。
160* @param bit 要保留小数的精确位数。
161* @return 舍入后的结果。
162*/
163staticdoubleround(doublenum, intbit) {
164deftmp = pow(10, bit)
165returnround(num * tmp) / tmp
166}
167
168staticdoublemax(double[] args) {
169returnargs.toList().max()
170}
171
172staticintmax(int[] args) {
173returnargs.toList().max()
174}
175
176staticdoublemin(double[] args) {
177returnargs.toList().min()
178}
179
180staticintmin(int[] args) {
181returnargs.toList().min()
182}
183}
[2].[文件] 对日志API的简单包装 ~ 2KB 下载(1)跳至[1][2]
view source
print?
01/**
02*
03*/
04packageorg.lucifer.util
05
06importjava.util.logging.FileHandler
07importjava.util.logging.Level
08importjava.util.logging.Logger
09
10/**
11* @author Lucifer
12*
13*/
14classMyLogger extendsLogger {
15
16publicstaticfinal Level ALL = Level.ALL
17publicstaticfinal Level WARNING = Level.WARNING
18publicstaticfinal Level INFO = Level.INFO
19publicstaticfinal Level CONFIG = Level.CONFIG
20publicstaticfinal Level FINE = Level.FINE
21publicstaticfinal Level FINER = Level.FINER
22publicstaticfinal Level FINEST = Level.FINEST
23publicstaticfinal Level OFF = Level.OFF
24
25final Level defaultDisplayLevel
26final defsrcClass
27
28MyLogger(Class<?> name, String logFile, final Level displayLevel = MyLogger.FINER) {
29this(name)
30super.addHandler(newFileHandler(logFile))
31this.defaultDisplayLevel = displayLevel
32}
33
34MyLogger(Class<?> name, final Level displayLevel = MyLogger.FINER) {
35super(name.getPackage().getName(), null)
36this.setLevel(MyLogger.ALL)
37"http://blog.51cto.com/viewpic.php?refimg=" + this.srcClass = name
38this.defaultDisplayLevel = displayLevel
39}
40
41voidlog(String msg) {
42super.log(this.defaultDisplayLevel, msg)
43}
44
45voidlog(String msg, Object[] params) {
46super.log(this.defaultDispalyLevel, msg, params)
47}
48
49voidlog(String msg, Throwable thrown) {
50super.log(this.defaultDisplayLevel, msg, thrown)
51}
52
53voidlog(String srcMethod, String msg) {
54this.logp(this.defaultDisplayLevel, "http://blog.51cto.com/viewpic.php?refimg=" + this.srcClass.simpleName, srcMethod, msg)
55}
56
57voidlog(String srcMethod, String msg, Object[] params) {
58this.logp(this.defaultDisplayLevel, "http://blog.51cto.com/viewpic.php?refimg=" + this.srcClass.simpleName, srcMethod, msg, params)
59}
60
61voidlog(String srcMethod, String msg, Throwable thrown) {
62this.logp(this.defaultDisplayLevel, "http://blog.51cto.com/viewpic.php?refimg=" + this.srcClass.simpleName, srcMethod, msg, thrown)
63}
64
65voidthrowing(String srcMethod, Throwable thrown) {
66this.throwing("http://blog.51cto.com/viewpic.php?refimg=" + this.srcClass.simpleName, srcMethod, thrown)
67}
68
69voidexiting(String srcMethod, defresult) {
70this.exiting("http://blog.51cto.com/viewpic.php?refimg=" + this.srcClass.simpleName, srcMethod, result)
71}
72
73voidexiting(String srcMethod) {
74super.exiting("http://blog.51cto.com/viewpic.php?refimg=" + this.srcClass.simpleName, srcMethod)
75}
76
77voidentering(String srcMethod) {
78super.entering("http://blog.51cto.com/viewpic.php?refimg=" + this.srcClass.simpleName, srcMethod)
79}
80
81voidentering(String srcMethod, Object[] params) {
82super.entering("http://blog.51cto.com/viewpic.php?refimg=" + this.srcClass.simpleName, srcMethod, params)
83}
84}