Class Array

java.lang.Object
weka.core.pmml.Array
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SparseArray

public class Array extends Object implements Serializable
Class for encapsulating a PMML Array element.
Version:
$Revision: 10203 $
Author:
Mark Hall (mhall{[at]}pentaho{[dot]}com)
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double value)
    Returns true if the array contains this real value.
    boolean
    contains(float value)
    Returns true if the array contains this real value.
    boolean
    contains(int value)
    Returns true if the array contains this integer value.
    boolean
    Returns true if the array contains this string value.
    static Array
    create(List<Object> values, List<Integer> indices)
     
    static Array
    create(Element arrayE)
    Static factory method for creating non-sparse or sparse array types as needed.
    Get the type of this array.
    int
    index(int position)
    Returns the index of the value stored at the given position
    static boolean
    isArray(Element arrayE)
    Utility method to check if an XML element is an array.
    boolean
    Is this array a SparseArray?
    int
    Get the number of values in this array.
     
    value(int index)
    Gets the value at index from the array.
    double
    valueDouble(int index)
    Gets the value at index from the array as a double.
    float
    valueFloat(int index)
    Gets the value at index from the array as a float.
    int
    valueInt(int index)
    Gets the value at index from the array as an int.
    valueSparse(int indexOfIndex)
    Gets the value at indexOfIndex from the array.
    double
    valueSparseDouble(int indexOfIndex)
    Gets the value at indexOfIndex from the array.
    float
    valueSparseFloat(int indexOfIndex)
    Gets the value at indexOfIndex from the array.
    int
    valueSparseInt(int indexOfIndex)
    Gets the value at indexOfIndex from the array.
    valueSparseString(int indexOfIndex)
    Gets the value at indexOfIndex from the array.
    valueString(int index)
    Gets the value at index from the array as a String.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • isArray

      public static boolean isArray(Element arrayE)
      Utility method to check if an XML element is an array.
      Parameters:
      arrayE - the XML element to check
      Returns:
      returns true if the XML element is an array
    • create

      public static Array create(List<Object> values, List<Integer> indices) throws Exception
      Throws:
      Exception
    • create

      public static Array create(Element arrayE) throws Exception
      Static factory method for creating non-sparse or sparse array types as needed.
      Parameters:
      arrayE - the XML element encapsulating the array
      Returns:
      an appropriate Array type
      Throws:
      Exception - if there is a problem when constructing the array
    • getType

      public Array.ArrayType getType()
      Get the type of this array.
      Returns:
      the type of the array.
    • isSparse

      public boolean isSparse()
      Is this array a SparseArray?
      Returns:
      true if this array is sparse.
    • numValues

      public int numValues()
      Get the number of values in this array.
      Returns:
      the number of values in this array.
    • contains

      public boolean contains(String value)
      Returns true if the array contains this string value.
      Parameters:
      value - the value to check for.
      Returns:
      true if the array contains this string value
    • contains

      public boolean contains(int value)
      Returns true if the array contains this integer value.
      Parameters:
      value - the value to check for
      Returns:
      true if the array contains this integer value
    • contains

      public boolean contains(double value)
      Returns true if the array contains this real value.
      Parameters:
      value - the value to check for
      Returns:
      true if the array contains this real value
    • contains

      public boolean contains(float value)
      Returns true if the array contains this real value.
      Parameters:
      value - the value to check for
      Returns:
      true if the array contains this real value
    • index

      public int index(int position)
      Returns the index of the value stored at the given position
      Parameters:
      position - the position
      Returns:
      the index of the value stored at the given position
    • value

      public String value(int index) throws Exception
      Gets the value at index from the array.
      Parameters:
      index - the index of the value to get.
      Returns:
      the value at index in the array as as String.
      Throws:
      Exception - if index is out of bounds.
    • valueString

      public String valueString(int index) throws Exception
      Gets the value at index from the array as a String. Calls value().
      Parameters:
      index - the index of the value to get.
      Returns:
      the value at index in the array as a String.
      Throws:
      Exception - if index is out of bounds.
    • valueDouble

      public double valueDouble(int index) throws Exception
      Gets the value at index from the array as a double.
      Parameters:
      index - the index of the value to get.
      Returns:
      the value at index in the array as a double.
      Throws:
      Exception - if index is out of bounds.
    • valueFloat

      public float valueFloat(int index) throws Exception
      Gets the value at index from the array as a float.
      Parameters:
      index - the index of the value to get.
      Returns:
      the value at index in the array as a float.
      Throws:
      Exception - if index is out of bounds.
    • valueInt

      public int valueInt(int index) throws Exception
      Gets the value at index from the array as an int.
      Parameters:
      index - the index of the value to get.
      Returns:
      the value at index in the array as an int.
      Throws:
      Exception - if index is out of bounds.
    • valueSparse

      public String valueSparse(int indexOfIndex) throws Exception
      Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
      Parameters:
      indexOfIndex - the index of the index of the value to get.
      Returns:
      a value from the array as a String.
      Throws:
      Exception - if indexOfIndex is out of bounds.
    • valueSparseString

      public String valueSparseString(int indexOfIndex) throws Exception
      Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
      Parameters:
      indexOfIndex - the index of the index of the value to get.
      Returns:
      a value from the array as a String.
      Throws:
      Exception - if indexOfIndex is out of bounds.
    • valueSparseDouble

      public double valueSparseDouble(int indexOfIndex) throws Exception
      Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
      Parameters:
      indexOfIndex - the index of the index of the value to get.
      Returns:
      a value from the array as a double.
      Throws:
      Exception - if indexOfIndex is out of bounds.
    • valueSparseFloat

      public float valueSparseFloat(int indexOfIndex) throws Exception
      Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
      Parameters:
      indexOfIndex - the index of the index of the value to get.
      Returns:
      a value from the array as a float.
      Throws:
      Exception - if indexOfIndex is out of bounds.
    • valueSparseInt

      public int valueSparseInt(int indexOfIndex) throws Exception
      Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
      Parameters:
      indexOfIndex - the index of the index of the value to get.
      Returns:
      a value from the array as an int.
      Throws:
      Exception - if indexOfIndex is out of bounds.
    • toString

      public String toString()
      Overrides:
      toString in class Object