org.ofbiz.datafile
Class Record

java.lang.Object
  extended by org.ofbiz.datafile.Record
All Implemented Interfaces:
java.io.Serializable

public class Record
extends java.lang.Object
implements java.io.Serializable

Record

See Also:
Serialized Form

Field Summary
protected  java.util.List<Record> childRecords
           
protected  java.util.Map<java.lang.String,java.lang.Object> fields
          Contains a map with field data by name
protected  ModelRecord modelRecord
          Contains the definition for the record
protected  Record parentRecord
           
protected  java.lang.String recordName
          Contains the name of the record definition
 
Constructor Summary
protected Record(ModelRecord modelRecord)
          Creates new Record
protected Record(ModelRecord modelRecord, java.util.Map<java.lang.String,java.lang.Object> fields)
          Creates new Record from existing Map
 
Method Summary
 void addChildRecord(Record record)
           
static Record createDelimitedRecord(java.lang.String line, int lineNum, ModelRecord modelRecord, char delimiter, java.lang.String textDelimiter)
           
static Record createRecord(ModelRecord modelRecord)
          Creates new Record
static Record createRecord(ModelRecord modelRecord, java.util.Map<java.lang.String,java.lang.Object> fields)
          Creates new Record from existing fields Map
static Record createRecord(java.lang.String line, int lineNum, ModelRecord modelRecord)
           
 java.lang.Object get(java.lang.String name)
           
 java.util.List<Record> getChildRecords()
           
 java.sql.Date getDate(java.lang.String name)
           
 java.lang.Double getDouble(java.lang.String name)
           
 java.lang.String getFixedString(java.lang.String name)
           
 java.lang.Float getFloat(java.lang.String name)
           
 java.lang.Integer getInteger(java.lang.String name)
           
 java.lang.Long getLong(java.lang.String name)
           
 ModelRecord getModelRecord()
           
 Record getParentRecord()
           
 java.lang.String getRecordName()
           
 java.lang.String getString(java.lang.String name)
           
 java.lang.String getStringAndEmpty(java.lang.String name)
           
 java.sql.Time getTime(java.lang.String name)
           
 java.sql.Timestamp getTimestamp(java.lang.String name)
           
 int readLEInt(byte[] byteArray)
          little endian reader for 4 byte int.
 long readLELong(byte[] byteArray)
          little endian reader for 8 byte long.
 short readLEShort(byte[] byteArray)
          little endian reader for 2 byte short.
 void set(java.lang.String name, java.lang.Object value)
          Sets the named field to the passed value, even if the value is null
 void set(java.lang.String name, java.lang.Object value, boolean setIfNull)
          Sets the named field to the passed value.
 void setString(java.lang.String name, java.lang.String value)
          Sets the named field to the passed value, converting the value from a String to the corrent type using Type.valueOf()
 java.lang.String writeLineString(ModelDataFile modelDataFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fields

protected java.util.Map<java.lang.String,java.lang.Object> fields
Contains a map with field data by name


recordName

protected java.lang.String recordName
Contains the name of the record definition


modelRecord

protected transient ModelRecord modelRecord
Contains the definition for the record


parentRecord

protected Record parentRecord

childRecords

protected java.util.List<Record> childRecords
Constructor Detail

Record

protected Record(ModelRecord modelRecord)
Creates new Record


Record

protected Record(ModelRecord modelRecord,
                 java.util.Map<java.lang.String,java.lang.Object> fields)
Creates new Record from existing Map

Method Detail

getRecordName

public java.lang.String getRecordName()

getModelRecord

public ModelRecord getModelRecord()

get

public java.lang.Object get(java.lang.String name)

getString

public java.lang.String getString(java.lang.String name)

getStringAndEmpty

public java.lang.String getStringAndEmpty(java.lang.String name)

getTimestamp

public java.sql.Timestamp getTimestamp(java.lang.String name)

getTime

public java.sql.Time getTime(java.lang.String name)

getDate

public java.sql.Date getDate(java.lang.String name)

getInteger

public java.lang.Integer getInteger(java.lang.String name)

getLong

public java.lang.Long getLong(java.lang.String name)

getFloat

public java.lang.Float getFloat(java.lang.String name)

getDouble

public java.lang.Double getDouble(java.lang.String name)

set

public void set(java.lang.String name,
                java.lang.Object value)
Sets the named field to the passed value, even if the value is null

Parameters:
name - The field name to set
value - The value to set

set

public void set(java.lang.String name,
                java.lang.Object value,
                boolean setIfNull)
Sets the named field to the passed value. If value is null, it is only set if the setIfNull parameter is true.

Parameters:
name - The field name to set
value - The value to set
setIfNull - Specifies whether or not to set the value if it is null

readLEShort

public final short readLEShort(byte[] byteArray)
little endian reader for 2 byte short.


readLEInt

public final int readLEInt(byte[] byteArray)
little endian reader for 4 byte int.


readLELong

public final long readLELong(byte[] byteArray)
little endian reader for 8 byte long.


setString

public void setString(java.lang.String name,
                      java.lang.String value)
               throws java.text.ParseException
Sets the named field to the passed value, converting the value from a String to the corrent type using Type.valueOf()

Parameters:
name - The field name to set
value - The String value to convert and set
Throws:
java.text.ParseException

getFixedString

public java.lang.String getFixedString(java.lang.String name)

writeLineString

public java.lang.String writeLineString(ModelDataFile modelDataFile)
                                 throws DataFileException
Throws:
DataFileException

getParentRecord

public Record getParentRecord()

getChildRecords

public java.util.List<Record> getChildRecords()

addChildRecord

public void addChildRecord(Record record)

createRecord

public static Record createRecord(ModelRecord modelRecord)
                           throws DataFileException
Creates new Record

Parameters:
modelRecord -
Returns:
Throws:
DataFileException - Exception thown for various errors, generally has a nested exception

createRecord

public static Record createRecord(ModelRecord modelRecord,
                                  java.util.Map<java.lang.String,java.lang.Object> fields)
                           throws DataFileException
Creates new Record from existing fields Map

Parameters:
modelRecord -
fields -
Returns:
Throws:
DataFileException - Exception thown for various errors, generally has a nested exception

createRecord

public static Record createRecord(java.lang.String line,
                                  int lineNum,
                                  ModelRecord modelRecord)
                           throws DataFileException
Parameters:
line -
lineNum -
modelRecord -
Returns:
Throws:
DataFileException - Exception thown for various errors, generally has a nested exception

createDelimitedRecord

public static Record createDelimitedRecord(java.lang.String line,
                                           int lineNum,
                                           ModelRecord modelRecord,
                                           char delimiter,
                                           java.lang.String textDelimiter)
                                    throws DataFileException
Parameters:
line -
lineNum -
modelRecord -
delimiter -
Returns:
Throws:
DataFileException - Exception thown for various errors, generally has a nested exception