spark.data
Class SV

java.lang.Object
  extended by spark.data.SV

public class SV
extends java.lang.Object

This is a general container for Spark data values. A value object can store any of the valid data types (long, double, boolean, string, object, array).

Author:
olsen

Constructor Summary
SV()
          Creates an SV with a NULL type
SV(boolean val)
          Creates an SV with a BOOLEAN type
SV(double val)
          Creates an SV with a DOUBLE type
SV(long val)
          Creates an SV with a LONG type
SV(SA val)
          Creates an SV with an ARRAY type
SV(SO val)
          Creates an SV with an OBJECT type
SV(java.lang.String val)
          Creates an SV with a STRING type
 
Method Summary
static SV askFile()
           
static SV askFile(java.lang.String[] pkgs)
           
 boolean equals(SV v)
           
 SV expand(SO model)
           
 SV get(int idx)
           
 SV get(java.lang.String name)
           
 double getDouble()
          if the type is DOUBLE or LONG then the value is returned, otherwise an exception is thrown.
 long getLong()
          if the type is LONG then the value is returned, otherwise an exception is thrown.
 SA getSA()
          if the type is ARRAY then the value is returned, otherwise an exception is thrown.
 SO getSO()
          if the type is OBJECT then the value is returned, otherwise an exception is thrown.
 java.lang.String getString()
          if the type is STRING then the value is returned, otherwise an exception is thrown.
 boolean isBoolean()
           
 boolean isDouble()
           
 boolean isLong()
           
 boolean isSA()
           
 boolean isSO()
           
 boolean isString()
           
 boolean isTrue()
          if the type is BOOLEAN then the value is returned, otherwise an exception is thrown.
static SV json(java.lang.String source)
          This will parse a string in JSON format and return the corresponding SV.
static SV json(java.lang.String[] pkgs, java.lang.String source)
          This will parse a string in JSON format using class names only from the specified packages.
 boolean match(SA a)
           
 boolean match(SO o)
           
 boolean match(SV v)
           
 void outJSON()
          This will write this SV to System.out in JSON form using fully qualified _class: names.
 void outJSON(java.lang.String[] pkgs)
          This will write an SV to System.out in JSON format using classes from the specified list of packages.
 void outSON()
          This will write this SV to System.out SON form using fully qualified class names.
 void outSON(java.lang.String[] pkgs)
          This will write an SV to System.out in SON format using classes from the specified list of packages.
 void set(boolean val)
          Changes the value to a BOOLEAN
 void set(double val)
          Changes the value to a DOUBLE
 void set(long val)
          Changes the value to a LONG
 void set(SA val)
          Changes the value to an ARRAY
 void set(SO val)
          Changes the value to an OBJECT
 void set(java.lang.String val)
          Changes the value to a STRING
static SV son(java.lang.String source)
          This will parse a string in SON format and return the corresponding SV.
static SV son(java.lang.String[] pkgs, java.lang.String source)
          This will parse a string in SON format using class names only from the specified packages.
 java.lang.String toString()
           
 SVal type()
          Returns the type of value stored.
 java.lang.String typeName()
          Returns the string name of the type of this object
static SV url(java.lang.String theURL)
          This will read an SV from a file referenced by a URL.
static SV url(java.lang.String[] pkgs, java.lang.String theURL)
          This will read an SV from a file referenced by a URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SV

public SV()
Creates an SV with a NULL type


SV

public SV(long val)
Creates an SV with a LONG type

Parameters:
val - the long value

SV

public SV(double val)
Creates an SV with a DOUBLE type

Parameters:
val - the double value

SV

public SV(boolean val)
Creates an SV with a BOOLEAN type

Parameters:
val - the boolean value

SV

public SV(java.lang.String val)
Creates an SV with a STRING type

Parameters:
val - the string value

SV

public SV(SO val)
Creates an SV with an OBJECT type

Parameters:
val - the SO value

SV

public SV(SA val)
Creates an SV with an ARRAY type

Parameters:
val - the array value
Method Detail

type

public SVal type()
Returns the type of value stored. (LONG,DOUBLE, BOOLEAN, STRING, OBJECT, ARRAY, NULL )

Returns:
the type of value stored

set

public void set(long val)
Changes the value to a LONG

Parameters:
val - the new value

getLong

public long getLong()
if the type is LONG then the value is returned, otherwise an exception is thrown.

Returns:
the long value

set

public void set(double val)
Changes the value to a DOUBLE

Parameters:
val - the new value

getDouble

public double getDouble()
if the type is DOUBLE or LONG then the value is returned, otherwise an exception is thrown.

Returns:
the double value

set

public void set(boolean val)
Changes the value to a BOOLEAN

Parameters:
val - the new value

isTrue

public boolean isTrue()
if the type is BOOLEAN then the value is returned, otherwise an exception is thrown.

Returns:
the boolean value

get

public SV get(java.lang.String name)

get

public SV get(int idx)

isLong

public boolean isLong()

isDouble

public boolean isDouble()

isBoolean

public boolean isBoolean()

isString

public boolean isString()

isSO

public boolean isSO()

isSA

public boolean isSA()

set

public void set(java.lang.String val)
Changes the value to a STRING

Parameters:
val - the new value

getString

public java.lang.String getString()
if the type is STRING then the value is returned, otherwise an exception is thrown.

Returns:
the string value

set

public void set(SO val)
Changes the value to an OBJECT

Parameters:
val - the new value

getSO

public SO getSO()
if the type is OBJECT then the value is returned, otherwise an exception is thrown.

Returns:
the SO value

set

public void set(SA val)
Changes the value to an ARRAY

Parameters:
val - the new value

getSA

public SA getSA()
if the type is ARRAY then the value is returned, otherwise an exception is thrown.

Returns:
the SA value

typeName

public java.lang.String typeName()
Returns the string name of the type of this object

Returns:
the string name of the type for this object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

outJSON

public void outJSON()
This will write this SV to System.out in JSON form using fully qualified _class: names.


outJSON

public void outJSON(java.lang.String[] pkgs)
This will write an SV to System.out in JSON format using classes from the specified list of packages.

Parameters:
pkgs - a list of packages from which class names are drawn.

outSON

public void outSON()
This will write this SV to System.out SON form using fully qualified class names.


outSON

public void outSON(java.lang.String[] pkgs)
This will write an SV to System.out in SON format using classes from the specified list of packages.

Parameters:
pkgs - a list of packages from which class names are drawn.

json

public static SV json(java.lang.String source)
This will parse a string in JSON format and return the corresponding SV. Fully qualified type names are required.

Parameters:
source - the string from which the JSON is to be parsed.
Returns:
the resulting SV from the parse.

json

public static SV json(java.lang.String[] pkgs,
                      java.lang.String source)
This will parse a string in JSON format using class names only from the specified packages.

Parameters:
pkgs - these are names of the only packages from which class names can be drawn.
source - the string to be parsed.
Returns:
the value parsed from the string.

son

public static SV son(java.lang.String source)
This will parse a string in SON format and return the corresponding SV. Fully qualified type names are required.

Parameters:
source - the string from which the SON is to be parsed.
Returns:
the resulting SV from the parse.

son

public static SV son(java.lang.String[] pkgs,
                     java.lang.String source)
This will parse a string in SON format using class names only from the specified packages.

Parameters:
pkgs - these are names of the only packages from which class names can be drawn.
source - the string to be parsed.
Returns:
the value parsed from the string.

url

public static SV url(java.lang.String theURL)
This will read an SV from a file referenced by a URL. The extension on the file (.json or .son) will identify the format in which the data is to be read. Fully qualified class names must be used in the file.

Parameters:
theURL - a fully qualified URL from which data can be read.
Returns:
the SV parsed from the input data.
Throws:
java.lang.RuntimeException - if there are any URL errors or parsing errors.

url

public static SV url(java.lang.String[] pkgs,
                     java.lang.String theURL)
This will read an SV from a file referenced by a URL. The extension on the file (.json or .son) will identify the format in which the data is to be read. Fully class names must be drawn from the specified packages.

Parameters:
pkgs - the list of packages from which objects can be created.
theURL - the URL for where the data is to be read.
Returns:
a parsed SV or null if there were errors.
Throws:
java.lang.RuntimeException - if there are any URL errors or parsing errors.

askFile

public static SV askFile()

askFile

public static SV askFile(java.lang.String[] pkgs)

match

public boolean match(SV v)

match

public boolean match(SO o)

match

public boolean match(SA a)

equals

public boolean equals(SV v)

expand

public SV expand(SO model)