Rev 223 |
Rev 255 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
import java.util.Vector;
public final class DUBwiseHelper
{
public final static String ip_digit_zeroes
(int digit
)
{ return "" + digit/
100 +
"" +
(digit/
10)%10 +
"" +
(digit
)%10
; }
public final static String ip_str
(int[] ip,
boolean with_zeroes
)
{
if(with_zeroes
)
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]) ;
else
return ip
[0]+
"."+ip
[1]+
"."+ip
[2]+
"."+ip
[3]+
":"+ip
[4];
}
public final static int pow
(int val,
int pow
)
{
int res=
1;
for (int p=
0;p
<pow
;p++
)
res
*=val
;
return res
;
}
public final static String[] split_str
(String str,
String sep
)
{
Vector nodes =
new Vector();
// Parse nodes into vector
int index = str.
indexOf(sep
);
while(index
>=
0) {
nodes.
addElement( str.
substring(0, index
) );
str = str.
substring(index+sep.
length());
index = str.
indexOf(sep
);
}
// add last element
nodes.
addElement( str
);
// Create splitted string array
String[] result =
new String[ nodes.
size() ];
if( nodes.
size()>0 ) {
for(int loop=
0; loop
<nodes.
size(); loop++
)
{
result
[loop
] =
(String)nodes.
elementAt(loop
);
System.
out.
println(result
[loop
]);
}
}
return result
;
}
public final static int mod_decimal
(int val,
int mod_power,
int modder,
int setter,
int clipper
)
{
int res=
0;
for (int power=
0;power
<4;power++
)
{
int act_digit=
(val/pow
(10,power
))%10
;
int new_digit=act_digit
;
if (power==mod_power
)
{
if (setter
!=-
1)
new_digit=setter
;
new_digit+=modder
;
if(new_digit
<0)
new_digit=
0;
if(new_digit
>clipper
)
new_digit=clipper
;
}
// new_digit=1;
res+=new_digit
*pow
(10,power
);
}
return res
;
}
}