ScriptUtil
ScriptUtil provides methods to create various types of object, to modify Duration objects, and to serialize business objects into or deserialize them from their XML representation.
Factory Methods
Return Type | Function | Comments |
---|---|---|
BigInteger | createBigInteger(Integer) | |
createBigInteger(Text) | ||
createBigInteger(BigDecimal) | ||
BigDecimal | createBigDecimal(Integer) | |
createBigDecimal(Decimal) | This uses an implicit MathContext.DECIMAL64. | |
createBigDecimal (Text) | ||
createBigDecimal (BigInteger) | ||
MathContext | createMathContext(Integer setPrecision) | |
createMathContext(Integer setPrecision, RoundingMode setRoundingMode) | RoundingMode is an enumeration with the following values: CEILING, FLOOR, UP, DOWN, HALF_UP, HALF_DOWN, HALF_EVEN, UNNECESSARY | |
Boolean | createBoolean(Text booleanText) |
The MathContext object specifies the number of digits used to store the number (that is, the size of the mantissa), and also how to round numbers (of various forms, up, down, and nearest to use). For more information about MathContext, see http://java.sun.com/j2se/1.5.0/docs/api/java/math/MathContext.html.
MathContext is not used when creating BigDecimal objects unless otherwise stated. It is the scale parameter in BigDecimal methods that specifies the number of decimal places that should be maintained in the objects. See Other Supported Methods for more details on this format.
Duration Methods
The following ScriptUtil methods are provided to enhance the basic interfaces provided for Duration objects.
Return Type | Method | Comments |
---|---|---|
BigDecimal | getFractionalSeconds(Duration dur) | Returns the fractional part of the seconds of the duration. |
Integer | getMilliseconds(Duration dur) | Returns the fractional second part of the duration measured in milliseconds.
For example: dstField.integerSigned = ScriptUtil.getMilliseconds(srcField.duration); |
XML Serialization Methods
The following ScriptUtil methods allow you to serialize business objects into or deserialize them from their XML representation.
Return Type | Method | Comments |
---|---|---|
Boolean | isConvertableToXML(Class object) | Returns true if the specified object can be converted to XML. |
String | toXML(Class object) | Returns the XML representation of the specified object. |
String | toXML(Class object, String type) | Returns the XML representation of the specified object, using the specified type (which can either be the element name or fully qualified class name. |
Class | fromXML(String string) | Returns the business object represented by the the specified XML string. |