OMS (v3.0.25)

oms3.io
Class DataIO

java.lang.Object
  extended by oms3.io.DataIO

public class DataIO
extends java.lang.Object

Data Input/Output management.

Author:
Olaf David

Field Summary
static java.lang.String CSPROPERTIES_EXT
           
static java.lang.String CSTABLE_EXT
           
static java.lang.String DATE_END
           
static java.lang.String DATE_FORMAT
           
static java.lang.String DATE_START
           
static java.lang.String HEADER
           
static java.lang.String HEADER1
           
static java.lang.String KEY_CONVERTED_FROM
           
static java.lang.String KEY_CREATED_AT
           
static java.lang.String KEY_CREATED_BY
           
static java.lang.String KEY_DIGEST
           
static java.lang.String KEY_FC_DAYS
           
static java.lang.String KEY_FC_START
           
static java.lang.String KEY_FORMAT
           
static java.lang.String KEY_HIST_YEAR
           
static java.lang.String KEY_MISSING_VAL
           
static java.lang.String KEY_NAME
           
static java.lang.String KEY_TYPE
           
static java.lang.String KEY_UNIT
           
static java.lang.String PROPERTIES
           
static java.lang.String PROPERTIES1
           
static java.lang.String PROPERTY
           
static java.lang.String PROPERTY1
           
static java.lang.String TABLE
           
static java.lang.String TABLE1
           
static java.lang.String VAL_DATE
           
 
Constructor Summary
DataIO()
           
 
Method Summary
static javax.swing.table.TableModel createTableModel(CSTable src)
          Create a r/o data tablemodel
static void dispose(java.util.Iterator i)
           
static int findColumnByName(CSTable t, java.lang.String columnName)
           
static int findRowByDate(java.util.Date date, int dateColumn, CSTable table)
           
static javax.swing.table.TableModel fromCSP(CSProperties p, int dim)
          Returns a r/o table from a CSP file
static javax.swing.table.AbstractTableModel get2DBounded(CSProperties p, java.lang.String pname)
           
static javax.swing.table.AbstractTableModel getBoundProperties(CSProperties p, java.lang.String boundName)
           
static java.util.Date[] getColumnDateValues(CSTable t, java.lang.String columnName)
           
static java.lang.Double[] getColumnDoubleValues(CSTable t, java.lang.String columnName)
          Get a column as an int array.
static double[] getColumnDoubleValuesInterval(java.util.Date start, java.util.Date end, CSTable t, java.lang.String columnName)
           
static java.util.Date getDate(CSProperties p, java.lang.String key)
          Get a value as date.
static int getInt(CSProperties p, java.lang.String key)
          Get a value as int.
static javax.swing.table.AbstractTableModel getProperties(CSProperties p)
          Get the KVP as table.
static javax.swing.table.AbstractTableModel getUnBoundProperties(CSProperties p)
           
static boolean isBound(CSProperties p, java.lang.String key, int dim)
           
static java.util.List<java.lang.String> keysByMeta(CSProperties csp, java.lang.String mkey, java.lang.String mval)
           
static java.util.List<java.lang.String> keysByNotMeta(CSProperties csp, java.lang.String mkey)
           
static java.util.List<java.lang.String> keysForBounds(CSProperties csp, int boundCount)
           
static java.text.SimpleDateFormat lookupDateFormat(CSTable table, int col)
           
static void merge(CSProperties base, CSProperties overlay)
          Merges two Properties, respects permissions
static boolean playsRole(CSProperties p, java.lang.String key, java.lang.String role)
           
static void print(CSProperties props, java.io.PrintWriter out)
          Print CSProperties.
static void print(CSTable table, java.io.File f)
           
static void print(CSTable table, java.io.PrintWriter out)
          Print a CSTable
static void print(java.util.Map<java.lang.String,java.lang.Object> props, java.lang.String header, java.io.PrintWriter out)
           
static CSProperties properties()
          Create Empty properties
static java.util.Properties properties(CSProperties p)
          Convert CSProperties into Properties
static CSProperties properties(java.util.Map<java.lang.String,java.lang.Object> p)
           
static CSProperties properties(java.util.Properties p)
          Convert Properties to CSProperties
static CSProperties properties(java.io.Reader[] r, java.lang.String name)
          Create a CSProperty from an array of reader.
static CSProperties properties(java.io.Reader r, java.lang.String name)
          Parse properties from a reader
static void save(CSProperties csp, java.io.File f, java.lang.String title)
           
static int[] sliceByTime(CSTable table, int timeCol, java.util.Date start, java.util.Date end)
          Get a slice of rows out of the table matching the time window
static CSTable synthESPInput(CSTable table, java.util.Date iniStart, java.util.Date iniEnd, int fcDays, int year)
           
static CSTable table(java.io.File r, java.lang.String name)
          Parse a table from a fiven File
static java.lang.String toArrayString(java.lang.String[] arr)
          Create array string.
static java.lang.String toArrayString(java.lang.String[][] arr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE

public static final java.lang.String TABLE
See Also:
Constant Field Values

HEADER

public static final java.lang.String HEADER
See Also:
Constant Field Values

PROPERTIES

public static final java.lang.String PROPERTIES
See Also:
Constant Field Values

PROPERTY

public static final java.lang.String PROPERTY
See Also:
Constant Field Values

TABLE1

public static final java.lang.String TABLE1
See Also:
Constant Field Values

HEADER1

public static final java.lang.String HEADER1
See Also:
Constant Field Values

PROPERTIES1

public static final java.lang.String PROPERTIES1
See Also:
Constant Field Values

PROPERTY1

public static final java.lang.String PROPERTY1
See Also:
Constant Field Values

CSPROPERTIES_EXT

public static final java.lang.String CSPROPERTIES_EXT
See Also:
Constant Field Values

CSTABLE_EXT

public static final java.lang.String CSTABLE_EXT
See Also:
Constant Field Values

KEY_CONVERTED_FROM

public static final java.lang.String KEY_CONVERTED_FROM
See Also:
Constant Field Values

DATE_FORMAT

public static final java.lang.String DATE_FORMAT
See Also:
Constant Field Values

DATE_START

public static final java.lang.String DATE_START
See Also:
Constant Field Values

DATE_END

public static final java.lang.String DATE_END
See Also:
Constant Field Values

KEY_CREATED_AT

public static final java.lang.String KEY_CREATED_AT
See Also:
Constant Field Values

KEY_CREATED_BY

public static final java.lang.String KEY_CREATED_BY
See Also:
Constant Field Values

KEY_UNIT

public static final java.lang.String KEY_UNIT
See Also:
Constant Field Values

KEY_FORMAT

public static final java.lang.String KEY_FORMAT
See Also:
Constant Field Values

KEY_TYPE

public static final java.lang.String KEY_TYPE
See Also:
Constant Field Values

KEY_NAME

public static final java.lang.String KEY_NAME
See Also:
Constant Field Values

KEY_MISSING_VAL

public static final java.lang.String KEY_MISSING_VAL
See Also:
Constant Field Values

KEY_FC_START

public static final java.lang.String KEY_FC_START
See Also:
Constant Field Values

KEY_FC_DAYS

public static final java.lang.String KEY_FC_DAYS
See Also:
Constant Field Values

KEY_HIST_YEAR

public static final java.lang.String KEY_HIST_YEAR
See Also:
Constant Field Values

KEY_DIGEST

public static final java.lang.String KEY_DIGEST
See Also:
Constant Field Values

VAL_DATE

public static final java.lang.String VAL_DATE
See Also:
Constant Field Values
Constructor Detail

DataIO

public DataIO()
Method Detail

getColumnDoubleValuesInterval

public static double[] getColumnDoubleValuesInterval(java.util.Date start,
                                                     java.util.Date end,
                                                     CSTable t,
                                                     java.lang.String columnName)

lookupDateFormat

public static java.text.SimpleDateFormat lookupDateFormat(CSTable table,
                                                          int col)

findRowByDate

public static int findRowByDate(java.util.Date date,
                                int dateColumn,
                                CSTable table)

synthESPInput

public static CSTable synthESPInput(CSTable table,
                                    java.util.Date iniStart,
                                    java.util.Date iniEnd,
                                    int fcDays,
                                    int year)

sliceByTime

public static int[] sliceByTime(CSTable table,
                                int timeCol,
                                java.util.Date start,
                                java.util.Date end)
Get a slice of rows out of the table matching the time window

Parameters:
table -
timeCol -
start -
end -
Returns:
the first and last row that matches the time window start->end

createTableModel

public static javax.swing.table.TableModel createTableModel(CSTable src)
Create a r/o data tablemodel

Parameters:
src -
Returns:
a table model to the CSTable

getProperties

public static javax.swing.table.AbstractTableModel getProperties(CSProperties p)
Get the KVP as table.

Parameters:
p -
Returns:
an AbstractTableModel for properties (KVP)

get2DBounded

public static javax.swing.table.AbstractTableModel get2DBounded(CSProperties p,
                                                                java.lang.String pname)
                                                         throws java.text.ParseException
Throws:
java.text.ParseException

playsRole

public static boolean playsRole(CSProperties p,
                                java.lang.String key,
                                java.lang.String role)

isBound

public static boolean isBound(CSProperties p,
                              java.lang.String key,
                              int dim)

getBoundProperties

public static javax.swing.table.AbstractTableModel getBoundProperties(CSProperties p,
                                                                      java.lang.String boundName)
                                                               throws java.text.ParseException
Throws:
java.text.ParseException

getUnBoundProperties

public static javax.swing.table.AbstractTableModel getUnBoundProperties(CSProperties p)
                                                                 throws java.text.ParseException
Throws:
java.text.ParseException

toArrayString

public static java.lang.String toArrayString(java.lang.String[] arr)
Create array string.

Parameters:
arr -
Returns:
an array String.

toArrayString

public static java.lang.String toArrayString(java.lang.String[][] arr)

fromCSP

public static javax.swing.table.TableModel fromCSP(CSProperties p,
                                                   int dim)
Returns a r/o table from a CSP file

Parameters:
p -
dim -
Returns:
a table model for properties with dimension.

keysByMeta

public static java.util.List<java.lang.String> keysByMeta(CSProperties csp,
                                                          java.lang.String mkey,
                                                          java.lang.String mval)
Parameters:
csp -
mkey -
mval -
Returns:
the list of property keys that have a meta data value.

keysForBounds

public static java.util.List<java.lang.String> keysForBounds(CSProperties csp,
                                                             int boundCount)

keysByNotMeta

public static java.util.List<java.lang.String> keysByNotMeta(CSProperties csp,
                                                             java.lang.String mkey)

findColumnByName

public static int findColumnByName(CSTable t,
                                   java.lang.String columnName)

getColumnDateValues

public static java.util.Date[] getColumnDateValues(CSTable t,
                                                   java.lang.String columnName)

getColumnDoubleValues

public static java.lang.Double[] getColumnDoubleValues(CSTable t,
                                                       java.lang.String columnName)
Get a column as an int array.

Parameters:
t -
columnName -
Returns:
the column data as doubles.

getDate

public static java.util.Date getDate(CSProperties p,
                                     java.lang.String key)
                              throws java.text.ParseException
Get a value as date.

Parameters:
p -
key -
Returns:
a property as Date
Throws:
java.text.ParseException

getInt

public static int getInt(CSProperties p,
                         java.lang.String key)
                  throws java.text.ParseException
Get a value as int.

Parameters:
p -
key -
Returns:
a property value as integer.
Throws:
java.text.ParseException

save

public static void save(CSProperties csp,
                        java.io.File f,
                        java.lang.String title)

print

public static void print(CSProperties props,
                         java.io.PrintWriter out)
Print CSProperties.

Parameters:
props - the Properties to print
out - the outputwriter to print to.

print

public static void print(java.util.Map<java.lang.String,java.lang.Object> props,
                         java.lang.String header,
                         java.io.PrintWriter out)

print

public static void print(CSTable table,
                         java.io.File f)
                  throws java.io.IOException
Throws:
java.io.IOException

print

public static void print(CSTable table,
                         java.io.PrintWriter out)
Print a CSTable

Parameters:
table -
out -

properties

public static CSProperties properties(java.io.Reader r,
                                      java.lang.String name)
                               throws java.io.IOException
Parse properties from a reader

Parameters:
r - the Reader
name - the name of the properties
Returns:
properties from a file.
Throws:
java.io.IOException

properties

public static CSProperties properties(java.io.Reader[] r,
                                      java.lang.String name)
                               throws java.io.IOException
Create a CSProperty from an array of reader.

Parameters:
r -
name -
Returns:
mergesd properties.
Throws:
java.io.IOException

merge

public static void merge(CSProperties base,
                         CSProperties overlay)
Merges two Properties, respects permissions

Parameters:
base -
overlay -

properties

public static java.util.Properties properties(CSProperties p)
Convert CSProperties into Properties

Parameters:
p -
Returns:
the Properties.

properties

public static CSProperties properties(java.util.Properties p)
Convert Properties to CSProperties

Parameters:
p -
Returns:
CVSProperties

properties

public static CSProperties properties(java.util.Map<java.lang.String,java.lang.Object> p)

properties

public static CSProperties properties()
Create Empty properties

Returns:
get some empty properties.

table

public static CSTable table(java.io.File r,
                            java.lang.String name)
                     throws java.io.IOException
Parse a table from a fiven File

Parameters:
r -
name -
Returns:
a CSTable.
Throws:
java.io.IOException

dispose

public static void dispose(java.util.Iterator i)

OMS (v3.0.25)

Generated 2010-08-11 08:44:20 MDT, USDA-ARS-ASRU/CSU, 2150 Center Ave, Fort Collins, CO 80526, U.S.A.