Rev 206 | Rev 242 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
223 | ligi | 1 | public final class DUBwiseHelper |
206 | ligi | 2 | { |
223 | ligi | 3 | public final static String ip_digit_zeroes(int digit) |
206 | ligi | 4 | { return "" + digit/100 + "" + (digit/10)%10 + "" + (digit)%10; } |
5 | |||
6 | |||
223 | ligi | 7 | public final static String ip_str(int[] ip,boolean with_zeroes) |
206 | ligi | 8 | { |
9 | if(with_zeroes) |
||
10 | return ip_digit_zeroes(ip[0]) + "." +ip_digit_zeroes(ip[1]) + "."+ip_digit_zeroes(ip[2]) + "."+ip_digit_zeroes(ip[3]) + ":"+ip_digit_zeroes(ip[4]) ; |
||
11 | else |
||
12 | return ip[0]+"."+ip[1]+"."+ip[2]+"."+ip[3]+":"+ip[4]; |
||
13 | |||
14 | } |
||
15 | |||
223 | ligi | 16 | public final static int pow(int val,int pow) |
206 | ligi | 17 | { |
18 | int res=1; |
||
19 | |||
20 | for (int p=0;p<pow;p++) |
||
21 | res*=val; |
||
22 | |||
23 | return res; |
||
24 | } |
||
25 | |||
26 | |||
223 | ligi | 27 | public final static int mod_decimal(int val,int mod_power,int modder,int setter,int clipper) |
206 | ligi | 28 | { |
29 | |||
30 | int res=0; |
||
31 | |||
32 | for (int power=0;power<4;power++) |
||
33 | { |
||
34 | |||
35 | int act_digit=(val/pow(10,power))%10; |
||
36 | |||
37 | int new_digit=act_digit; |
||
38 | if (power==mod_power) |
||
39 | { |
||
40 | if (setter!=-1) |
||
41 | new_digit=setter; |
||
42 | |||
43 | new_digit+=modder; |
||
44 | |||
45 | if(new_digit<0) |
||
46 | new_digit=0; |
||
47 | |||
48 | if(new_digit>clipper) |
||
49 | new_digit=clipper; |
||
50 | |||
51 | } |
||
52 | |||
53 | // new_digit=1; |
||
54 | res+=new_digit*pow(10,power); |
||
55 | } |
||
56 | |||
57 | |||
58 | return res; |
||
59 | |||
60 | |||
61 | } |
||
62 | |||
63 | } |