DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7264>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7264
optional hexadecimal forms for integer types
------- Additional Comments From jakarta@ehatchersolutions.com 2002-04-13 14:15 -------
Curt,
Using your request as inspiration for an example in our forthcoming Ant book I
implemented a Hex class. Here is the code:
package org.example.antbook.tasks;
public class Hex {
private Integer value;
public Hex(String hex) {
value = Integer.decode(hex);
}
public int intValue() {
return value.intValue();
}
public String toString() {
return "0x" + Integer.toHexString(value.intValue());
}
}
-----
In your task you can simply have a setter like this:
private Hex hex;
public void setHex(Hex hex) {
this.hex = hex;
}
And here is an example of getting the values either as integer or hexadecimal
(from my execute method):
log(hex + " = " + hex.intValue());
Note that this class is even more flexible than just hexadecimal numbers.
Integer.decode allows decimal, hexadecimal, or octal formatted strings.
Thanks for the example idea! I'm going to leave this issue open a bit longer.
If others feel this is a worthy feature to have built into Ant, please speak
now so that it can make it to Ant 1.5. I'll rename it to FlexibleNumber or
something more generic.
Erik
--
To unsubscribe, e-mail: <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
|