public final class PMML extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ATT_EXTENSION_NAME
Constant for the
name attribute of the extension element. |
static String |
ATT_EXTENSION_VALUE
Constant for the
value attribute of the extension element. |
static String |
ELEM_EXTENSION
Constant for the
Extension element |
Modifier and Type | Method and Description |
---|---|
static Element |
addChildElement(Element element,
String name)
Creates a new child element and adds it to the given element.
|
static Element |
addChildTextElement(Element element,
String name,
String text)
Adds a child element consisting of purely text.
|
static Element |
addExtensionElement(Element element,
String name,
String value)
Adds a PMML Extension element to the specified element.
|
static Element |
findExtensionElement(Element element,
String name)
Finds a PMML extension element whose name attribute matches that specified or null
if not found.
|
static String |
findExtensionValue(Element element,
String name)
Finds a PMML extension element whose name attribute matches that specified or null
if not found.
|
static BigDecimal |
findExtensionValueAsBigDecimal(Element element,
String name)
Finds a PMML extension element whose name attribute matches that specified or null
if not found.
|
static Double |
findExtensionValueAsDouble(Element element,
String name,
Double defaultValue)
Finds a PMML extension element whose name attribute matches that specified or null
if not found.
|
static String |
getAttribute(Element element,
String attrName)
Gets the value of the given attribute from the given element.
|
static BigDecimal |
getAttributeAsBigDecimal(Element element,
String attrName,
BigDecimal dflt)
Gets the value of the given attribute from the given element as a BigDecimal.
|
static boolean |
getAttributeAsBoolean(Element element,
String attrName,
boolean dflt)
Gets the value of the given attribute from the given element as a boolean.
|
static double |
getAttributeAsDouble(Element element,
String attrName,
double dflt)
Gets the value of the given attribute from the given element as a double.
|
static <T extends Enum<T>> |
getAttributeAsEnum(Element element,
String attrName,
Class<T> enumClass,
T dflt)
Gets the value of the given attribute from the given element as an enum.
|
static int |
getAttributeAsInt(Element element,
String attrName,
int dflt)
Gets the value of the given attribute from the given element as a int.
|
static long |
getAttributeAsLong(Element element,
String attrName,
long dflt)
Gets the value of the given attribute from the given element as a long.
|
static BigDecimal |
getAttributeAsOptionalBigDecimal(Element element,
String attrName)
Gets the value of the given attribute from the given element as a BigDecimal.
|
static Double |
getAttributeAsOptionalDouble(Element element,
String attrName)
Gets the value of the given attribute from the given element as a double.
|
static Integer |
getAttributeAsOptionalInt(Element element,
String attrName)
Gets the value of the given attribute from the given element as a int.
|
static Long |
getAttributeAsOptionalLong(Element element,
String attrName)
Gets the value of the given attribute from the given element as a long.
|
static List<Element> |
getChildElements(Element element,
String... filterTagNames)
Returns all of the children elements of the given element.
|
static Document |
getDocument(Element element)
Return the Document associated with the given element.
|
static Element |
getElementByTagName(Element element,
String tagName)
Returns the single child element of the given tag name
|
static List<Element> |
getElementsByTagName(Element element,
String tagName)
Returns the child elements of the given tag name.
|
static String |
getElementText(Element element)
Parses the text from an element
|
static BigDecimal |
getElementTextAsBigDecimal(Element element,
BigDecimal dflt)
Parses the text of the given element as a BigDecimal value
|
static double |
getElementTextAsDouble(Element element,
double dflt)
Parses the text of the given element as a double value
|
static Element |
getSingleChildElement(Element element)
Returns the single child element of the given element
|
static PMMLVersion |
getVersion(Document document)
Returns the PMML version of the PMML document
|
static Document |
parsePMML(FileClient client,
String filePath)
Validates the PMML against the latest schema and parses
|
static void |
setAttribute(Element element,
String name,
BigDecimal value)
Sets the given attribute to the given value if the value is non null.
|
static void |
setAttribute(Element element,
String name,
Boolean value)
Sets the given attribute to the given value if the value is non null.
|
static void |
setAttribute(Element element,
String name,
double value)
Sets the given attribute to the given value.
|
static void |
setAttribute(Element element,
String name,
Double value)
Sets the given attribute to the given value if the value is non null.
|
static void |
setAttribute(Element element,
String name,
long value)
Sets the given attribute to the given value.
|
static void |
setAttribute(Element element,
String name,
Long value)
Sets the given attribute to the given value if the value is non null.
|
static void |
setAttribute(Element element,
String name,
String value)
Sets the given attribute to the given value if the value is non null.
|
static <T extends Enum<T>> |
setAttribute(Element element,
String name,
T value)
Sets the given attribute to the given value if the value is non null.
|
static void |
setPercentageNumberAttribute(Element element,
String name,
Double value)
Sets the given attribute to the given value if the value is non null.
|
static void |
setProbNumberAttribute(Element element,
String name,
Double value)
Sets the given attribute to the given value if the value is non null.
|
public static final String ELEM_EXTENSION
Extension
elementpublic static final String ATT_EXTENSION_NAME
name
attribute of the extension element.public static final String ATT_EXTENSION_VALUE
value
attribute of the extension element.public static Document getDocument(Element element)
element
- the elementpublic static Element addChildElement(Element element, String name)
element
- The element to add to.name
- The name of the element to add.public static List<Element> getElementsByTagName(Element element, String tagName)
element
- the parent elementtagName
- the tag name to search forpublic static Element getElementByTagName(Element element, String tagName)
element
- the parent elementtagName
- the tag nameInvalidPMMLException
- if there are multiple children of the given namepublic static List<Element> getChildElements(Element element, String... filterTagNames)
element
- the parent elementfilterTagNames
- names of nodes to skip (useful for skipping Extension tags)public static Element getSingleChildElement(Element element)
element
- the parent elementInvalidPMMLException
- if there is more than one child elementpublic static void setAttribute(Element element, String name, String value)
element
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute. May be null, in which case this call is ignored.public static <T extends Enum<T>> void setAttribute(Element element, String name, T value)
T
- the type of the enumelement
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute. May be null, in which case this call is ignored.public static void setAttribute(Element element, String name, Long value)
element
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute. May be null, in which case this call is ignored.public static void setAttribute(Element element, String name, Double value)
element
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute. May be null, in which case this call is ignored.public static void setAttribute(Element element, String name, BigDecimal value)
element
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute. May be null, in which case this call is ignored.public static void setAttribute(Element element, String name, Boolean value)
element
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute. May be null, in which case this call is ignored.public static void setProbNumberAttribute(Element element, String name, Double value)
element
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute. May be null, in which case this call is ignored.public static void setPercentageNumberAttribute(Element element, String name, Double value)
element
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute. May be null, in which case this call is ignored.public static void setAttribute(Element element, String name, long value)
element
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute.public static void setAttribute(Element element, String name, double value)
element
- the element to which the given attribute is being addedname
- the name of the attributevalue
- the value of the attribute.public static String getAttribute(Element element, String attrName)
element
- The elementattrName
- The name of the attribute.public static double getAttributeAsDouble(Element element, String attrName, double dflt)
element
- The elementattrName
- The name of the attribute.dflt
- The default value to use if it doesn't existNumberFormatException
- If the given attribute is not a valid doublepublic static BigDecimal getAttributeAsBigDecimal(Element element, String attrName, BigDecimal dflt)
element
- The elementattrName
- The name of the attributedflt
- The default value to use if it doesn't existNumberFormatException
- If the given attribute is not a valid BigDecimalpublic static int getAttributeAsInt(Element element, String attrName, int dflt)
element
- The elementattrName
- The name of the attribute.dflt
- The default value to use if it doesn't existNumberFormatException
- If the given attribute is not a valid intpublic static long getAttributeAsLong(Element element, String attrName, long dflt)
element
- The elementattrName
- The name of the attribute.dflt
- The default value to use if it doesn't existNumberFormatException
- If the given attribute is not a valid longpublic static boolean getAttributeAsBoolean(Element element, String attrName, boolean dflt)
element
- The elementattrName
- The name of the attribute.dflt
- The default value to use if it doesn't existpublic static Double getAttributeAsOptionalDouble(Element element, String attrName)
element
- The elementattrName
- The name of the attribute.NumberFormatException
- If the given attribute is not a valid doublepublic static BigDecimal getAttributeAsOptionalBigDecimal(Element element, String attrName)
element
- The elementattrName
- The name of the attributepublic static Integer getAttributeAsOptionalInt(Element element, String attrName)
element
- The elementattrName
- The name of the attribute.NumberFormatException
- If the given attribute is not a valid intpublic static Long getAttributeAsOptionalLong(Element element, String attrName)
element
- The elementattrName
- The name of the attribute.NumberFormatException
- If the given attribute is not a valid longpublic static <T extends Enum<T>> T getAttributeAsEnum(Element element, String attrName, Class<T> enumClass, T dflt)
T
- the type of the enumelement
- The elementattrName
- The name of the attribute.enumClass
- the type of the enumdflt
- The default value to use if it doesn't existIllegalArgumentException
- If the given attribute is not a valid value of the enumpublic static Element addChildTextElement(Element element, String name, String text)
element
- the parent elementname
- the name of the child elementtext
- the text of the child elementpublic static String getElementText(Element element)
element
- the elementpublic static double getElementTextAsDouble(Element element, double dflt)
element
- the elementdflt
- the default value to return if the element is nullpublic static BigDecimal getElementTextAsBigDecimal(Element element, BigDecimal dflt)
element
- the elementdflt
- the default value to return if the element is nullpublic static Element addExtensionElement(Element element, String name, String value)
element
- The element to add to.name
- The "name" attribute of the extension. May be null.value
- The "value" attribute of the extension. May be null.public static String findExtensionValue(Element element, String name)
element
- The parent element to search.name
- The "name" attribute to match.public static Double findExtensionValueAsDouble(Element element, String name, Double defaultValue)
element
- The parent element to search.name
- The "name" attribute to match.defaultValue
- Returns this value if the element is not found.public static BigDecimal findExtensionValueAsBigDecimal(Element element, String name)
element
- The parent element to search.name
- The "name" attribute to match.public static Element findExtensionElement(Element element, String name)
element
- The parent element to search.name
- The "name" attribute to match.public static PMMLVersion getVersion(Document document)
document
- the PMML documentpublic static Document parsePMML(FileClient client, String filePath)
client
- the file clientfilePath
- the path to the fileCopyright © 2019 Actian Corporation. All rights reserved.