SSJ
V. 2.6.

umontreal.iro.lecuyer.util.io
Class DataField

java.lang.Object
  extended by umontreal.iro.lecuyer.util.io.DataField

public class DataField
extends Object

This class represents a data field from a file read by an instance of a class implementing DataReader.


Constructor Summary
DataField(String label, Object data)
          Constructor.
DataField(String label, Object data, int effectiveLength)
          Constructor.
 
Method Summary
 double asDouble()
          Returns the value as double or 0 if it is not of type double See isDouble.
 double[] asDoubleArray()
          Returns the value as one-dimensional double array or null if it is not of type double[].
 double[][] asDoubleArray2D()
          Returns the value as two-dimensional double array or null if it is not of type double[][].
 float asFloat()
          Returns the value as float or 0 if it is not of type float See isFloat.
 float[] asFloatArray()
          Returns the value as one-dimensional float array or null if it is not of type float[].
 float[][] asFloatArray2D()
          Returns the value as two-dimensional float array or null if it is not of type float[][].
 int asInt()
          Returns the value as int or 0 if it is not of type int See isInt.
 int[] asIntArray()
          Returns the value as one-dimensional int array or null if it is not of type int[].
 int[][] asIntArray2D()
          Returns the value as two-dimensional int array or null if it is not of type int[][].
 Object asObject()
          Returns the value of the field as an Object.
 String asString()
          Returns the value as String, or null if it is not of type String.
 String[] asStringArray()
          Returns the value as one-dimensional String array or null if it is not of type String[].
 String[][] asStringArray2D()
          Returns the value as two-dimensional String array or null if it is not of type String[][].
 int getArrayLength()
          Returns the length of the array contained by the field, or -1 if it is not an array.
 String getLabel()
          Returns the field label (or name).
 Class getType()
          Returns the type of the field.
 boolean isArray()
          Returns true if the field contains an array.
 boolean isArray2D()
          Returns true if the field contains a two-dimensional array.
 boolean isAtomic()
          Returns true if the field value is atomic data.
 boolean isDouble()
          Returns true if the field value is an atomic double.
 boolean isFloat()
          Returns true if the field value is an atomic float.
 boolean isInt()
          Returns true if the field value is an atomic int.
 boolean isString()
          Returns true if the field value is an atomic String.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataField

public DataField(String label,
                 Object data)
Constructor. Creates a field named label of value data.

Parameters:
label - name of the field
data - value of the field

DataField

public DataField(String label,
                 Object data,
                 int effectiveLength)
Constructor. Creates a field named label of value data. effectiveLength is the number of significant elements contained in data if it is an array.

Parameters:
label - name of the field
data - value of the field
effectiveLength - number of significant elements contained in data
Method Detail

getLabel

public String getLabel()
Returns the field label (or name).


getType

public Class getType()
Returns the type of the field.


isAtomic

public boolean isAtomic()
Returns true if the field value is atomic data.


isArray

public boolean isArray()
Returns true if the field contains an array.


isArray2D

public boolean isArray2D()
Returns true if the field contains a two-dimensional array.


getArrayLength

public int getArrayLength()
Returns the length of the array contained by the field, or -1 if it is not an array.


isString

public boolean isString()
Returns true if the field value is an atomic String.


isInt

public boolean isInt()
Returns true if the field value is an atomic int.


isFloat

public boolean isFloat()
Returns true if the field value is an atomic float.


isDouble

public boolean isDouble()
Returns true if the field value is an atomic double.


asString

public String asString()
Returns the value as String, or null if it is not of type String. See isString.


asInt

public int asInt()
Returns the value as int or 0 if it is not of type int See isInt.


asFloat

public float asFloat()
Returns the value as float or 0 if it is not of type float See isFloat.


asDouble

public double asDouble()
Returns the value as double or 0 if it is not of type double See isDouble.


asStringArray

public String[] asStringArray()
Returns the value as one-dimensional String array or null if it is not of type String[].


asIntArray

public int[] asIntArray()
Returns the value as one-dimensional int array or null if it is not of type int[].


asFloatArray

public float[] asFloatArray()
Returns the value as one-dimensional float array or null if it is not of type float[].


asDoubleArray

public double[] asDoubleArray()
Returns the value as one-dimensional double array or null if it is not of type double[].


asStringArray2D

public String[][] asStringArray2D()
Returns the value as two-dimensional String array or null if it is not of type String[][].


asIntArray2D

public int[][] asIntArray2D()
Returns the value as two-dimensional int array or null if it is not of type int[][].


asFloatArray2D

public float[][] asFloatArray2D()
Returns the value as two-dimensional float array or null if it is not of type float[][].


asDoubleArray2D

public double[][] asDoubleArray2D()
Returns the value as two-dimensional double array or null if it is not of type double[][].


asObject

public Object asObject()
Returns the value of the field as an Object.


SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.