Class PMMLArrays


  • public final class PMMLArrays
    extends Object
    Utility methods for formatting and parsing PMML arrays
    • Method Detail

      • addChildArrayElement

        public static void addChildArrayElement​(Element element,
                                                double[] values)
        Adds a child Array element to the given element. The child array will be of type PMMLArrays.ArrayType.real.
        Parameters:
        element - the parent element
        values - the values of the array
      • addChildArrayElement

        public static void addChildArrayElement​(Element element,
                                                BigDecimal[] values)
        Adds a child Array element to the given element. The child array will be of type PMMLArrays.ArrayType.real.
        Parameters:
        element - the parent element
        values - the values of the array
      • addChildArrayElement

        public static void addChildArrayElement​(Element element,
                                                int[] values)
        Adds a child Array element to the given element. The child array will be of type PMMLArrays.ArrayType.integer.
        Parameters:
        element - the parent element
        values - the values of the array
      • addChildArrayElement

        public static void addChildArrayElement​(Element element,
                                                long[] values)
        Adds a child Array element to the given element. The child array will be of type PMMLArrays.ArrayType.integer.
        Parameters:
        element - the parent element
        values - the values of the array
      • addChildArrayElement

        public static void addChildArrayElement​(Element element,
                                                Object[] values,
                                                PMMLArrays.ArrayType type)
        Adds a child Array element to the given element. The child array will be of the specified type
        Parameters:
        element - the parent element
        values - the values of the array
        type - the type of the elements of the array
      • addSparseChildArrayElement

        public static void addSparseChildArrayElement​(Element element,
                                                      DoubleTokenSequence sequence)
        Adds a child REAL-SparseArray element to the given element.
        Parameters:
        element - the parent element
        sequence - the sequence (generally a sparse sequence)
      • addSparseChildArrayElement

        public static void addSparseChildArrayElement​(Element element,
                                                      NumericTokenSequence sequence)
        Adds a child REAL-SparseArray element to the given element.
        Parameters:
        element - the parent element
        sequence - the sequence (generally a sparse sequence)
      • addSparseChildArrayElement

        public static void addSparseChildArrayElement​(Element element,
                                                      IntTokenSequence sequence)
        Adds a child INT-SparseArray element to the given element.
        Parameters:
        element - the parent element
        sequence - the sequence (generally a sparse sequence)
      • parseChildArrayElementsAsStrings

        public static String[][] parseChildArrayElementsAsStrings​(Element element)
        Parses all child Array elements as arrays of strings. The type declared in the PMML is ignored.
        Parameters:
        element - the parent element
        Returns:
        a two-dimensional array of strings. the outer array corresponds to the children elements
      • parseChildArrayElementsAsDoubles

        public static Double[][] parseChildArrayElementsAsDoubles​(Element element)
        Parses all child Array elements as arrays of doubles. The type declared in the PMML is ignored.
        Parameters:
        element - the parent element
        Returns:
        a two-dimensional array of double. the outer array corresponds to the children elements
      • parseChildArrayElementsAsBigDecimals

        public static BigDecimal[][] parseChildArrayElementsAsBigDecimals​(Element element)
        Parses all child Array elements as arrays of BigDecimals. The type declared in the PMML is ignored.
        Parameters:
        element - the parent element
        Returns:
        a two-dimensional array of BigDecimals. the outer array corresponds to the children elements
      • parseChildArrayElementAsStrings

        public static String[] parseChildArrayElementAsStrings​(Element element)
        Parses the single child Array element as an array of strings. The type declared in the PMML is ignored.
        Parameters:
        element - the parent element
        Returns:
        an array of strings
        Throws:
        InvalidPMMLException - if there are multiple children arrays
      • parseChildArrayElementAsDoubles

        public static double[] parseChildArrayElementAsDoubles​(Element element)
        Parses the single child Array element as an array of doubles. The type declared in the PMML is ignored.
        Parameters:
        element - the parent element
        Returns:
        an array of doubles
        Throws:
        InvalidPMMLException - if there are multiple children arrays
      • parseChildArrayElementAsBigDecimals

        public static BigDecimal[] parseChildArrayElementAsBigDecimals​(Element element)
        Parses the single child Array element as an array of BigDecimals. The type declared in the PMML is ignored.
        Parameters:
        element - the parent element
        Returns:
        an array of BigDecimals
        Throws:
        InvalidPMMLException - if there are multiple children arrays
      • parseChildArrayElementAsInts

        public static int[] parseChildArrayElementAsInts​(Element element)
        Parses the single child Array element as an array of ints. The type declared in the PMML is ignored.
        Parameters:
        element - the parent element
        Returns:
        an array of ints
        Throws:
        InvalidPMMLException - if there are multiple children arrays
      • parseSparseChildArrayElement

        public static DoubleTokenSequence parseSparseChildArrayElement​(Element element)
        Parses the single child REAL-SparseArray or INT-SparseArray element.
        Parameters:
        element - the parent element
        Returns:
        a sparse token sequence
        Throws:
        InvalidPMMLException - if there are multiple children arrays