Package weka.core.pmml
Class Array
- java.lang.Object
-
- weka.core.pmml.Array
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
SparseArray
public class Array extends java.lang.Object implements java.io.SerializableClass for encapsulating a PMML Array element.- Version:
- $Revision: 10203 $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classArray.ArrayType
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(double value)Returns true if the array contains this real value.booleancontains(float value)Returns true if the array contains this real value.booleancontains(int value)Returns true if the array contains this integer value.booleancontains(java.lang.String value)Returns true if the array contains this string value.static Arraycreate(java.util.List<java.lang.Object> values, java.util.List<java.lang.Integer> indices)static Arraycreate(org.w3c.dom.Element arrayE)Static factory method for creating non-sparse or sparse array types as needed.Array.ArrayTypegetType()Get the type of this array.intindex(int position)Returns the index of the value stored at the given positionstatic booleanisArray(org.w3c.dom.Element arrayE)Utility method to check if an XML element is an array.booleanisSparse()Is this array a SparseArray?intnumValues()Get the number of values in this array.java.lang.StringtoString()java.lang.Stringvalue(int index)Gets the value at index from the array.doublevalueDouble(int index)Gets the value at index from the array as a double.floatvalueFloat(int index)Gets the value at index from the array as a float.intvalueInt(int index)Gets the value at index from the array as an int.java.lang.StringvalueSparse(int indexOfIndex)Gets the value at indexOfIndex from the array.doublevalueSparseDouble(int indexOfIndex)Gets the value at indexOfIndex from the array.floatvalueSparseFloat(int indexOfIndex)Gets the value at indexOfIndex from the array.intvalueSparseInt(int indexOfIndex)Gets the value at indexOfIndex from the array.java.lang.StringvalueSparseString(int indexOfIndex)Gets the value at indexOfIndex from the array.java.lang.StringvalueString(int index)Gets the value at index from the array as a String.
-
-
-
Method Detail
-
isArray
public static boolean isArray(org.w3c.dom.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(java.util.List<java.lang.Object> values, java.util.List<java.lang.Integer> indices) throws java.lang.Exception
- Throws:
java.lang.Exception
-
create
public static Array create(org.w3c.dom.Element arrayE) throws java.lang.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:
java.lang.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(java.lang.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 java.lang.String value(int index) throws java.lang.ExceptionGets 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:
java.lang.Exception- if index is out of bounds.
-
valueString
public java.lang.String valueString(int index) throws java.lang.ExceptionGets 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:
java.lang.Exception- if index is out of bounds.
-
valueDouble
public double valueDouble(int index) throws java.lang.ExceptionGets 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:
java.lang.Exception- if index is out of bounds.
-
valueFloat
public float valueFloat(int index) throws java.lang.ExceptionGets 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:
java.lang.Exception- if index is out of bounds.
-
valueInt
public int valueInt(int index) throws java.lang.ExceptionGets 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:
java.lang.Exception- if index is out of bounds.
-
valueSparse
public java.lang.String valueSparse(int indexOfIndex) throws java.lang.ExceptionGets 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:
java.lang.Exception- if indexOfIndex is out of bounds.
-
valueSparseString
public java.lang.String valueSparseString(int indexOfIndex) throws java.lang.ExceptionGets 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:
java.lang.Exception- if indexOfIndex is out of bounds.
-
valueSparseDouble
public double valueSparseDouble(int indexOfIndex) throws java.lang.ExceptionGets 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:
java.lang.Exception- if indexOfIndex is out of bounds.
-
valueSparseFloat
public float valueSparseFloat(int indexOfIndex) throws java.lang.ExceptionGets 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:
java.lang.Exception- if indexOfIndex is out of bounds.
-
valueSparseInt
public int valueSparseInt(int indexOfIndex) throws java.lang.ExceptionGets 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:
java.lang.Exception- if indexOfIndex is out of bounds.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-