add XML.getLong() (issue 1378)

This commit is contained in:
benfry
2012-11-25 00:54:44 +00:00
parent 39e169cae1
commit b7ab26c830
3 changed files with 198 additions and 89 deletions

View File

@@ -615,6 +615,28 @@ public class XML implements Serializable {
}
/**
* @webref xml:method
* @brief Sets the content of an element as an int
*/
public void setLong(String name, long value) {
setString(name, String.valueOf(value));
}
/**
* Returns the value of an attribute.
*
* @param name the non-null full name of the attribute.
* @param defaultValue the default value of the attribute.
* @return the value, or defaultValue if the attribute does not exist.
*/
public long getLong(String name, long defaultValue) {
String value = getString(name);
return (value == null) ? defaultValue : Long.parseLong(value);
}
/**
* Returns the value of an attribute, or zero if not present.
*