public class MDFHeader
extends java.lang.Object
getFieldMap()
is is possible to retrieve a map containing the field definitions.
\s*\$FIELD\s*:\s*"
"\s*[,:;]\s*"
.*"\s*\$\s*
An example of this type of header:
$FIELD: "ProjectGroup","CCP"$ $FIELD: "Comment",""$ $FIELD: "Vehicle","212-881"$ $FIELD: "Carer",""$ $FIELD: "EngineType","Benzin"$
Another variant is also allowed and uses a tab
-character to separate the keyword from value.
There is not identifier like $Field
that help to find a definition.
An example of this type of header:
Stop date 16.02.2010 Stop time 18:44:57 TriggerName MeasurementKey ZEIT ActivityName Signals SerialNumber 80001552
The field map will enriched by some useful attributes listed below.
Key | Description |
Header.Filename | The name of the file defined by the MDF header. |
Header.Date | The date string defined by the MDF header. |
Header.Department | The name of the department defined by the MDF header. |
Header.Project | The name of the project defined by the MDF header. |
Header.Time | The time string defined by the MDF header. |
Header.UnitUnderTest | The name of the unit under test defined in MDF header. |
Header.User | The user name defined in MDF header. |
Some fields will be generated from filename, if not defined in header comment. The filename will be split at a tilde (~), if the index of the result array starts by zero, the following values will be generated, if not already available and the array length if greater than 4.
Key | Array Index | Description |
ConfigName | 1 (second) | The configuration name |
MeasurementKey | length-2 (next to last) | The measurement key. |
TriggerName | length-1 (last) | The name of the activity |
ActivityName | length-1 (last) | The name of the activity |
Some fields will be generated, if not available, by an existing field called TSTDRIVE. For this reason the value will be split at tab character. The elements of the result array will be assigned to following field attributes, if these attributes are not already defined.
Key | Array Index | Description |
RecorderFirmware | 0 (first) | The firmware version of the recorder. |
MeasurementFileName | length-1 (last) | The name of the originial measurement file. |
Modifier and Type | Class and Description |
---|---|
static interface |
MDFHeader.FieldSplitter
The interface that an field splitter must fulfill.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMMENT_TYPE_KEY |
static java.lang.String |
ECU_SEP |
static java.lang.String |
ECU_TYPE |
protected java.lang.String |
errorMessage |
protected int |
exitCode |
protected MDFField[] |
fields |
static java.lang.String |
FILENAME_ATTR |
static java.lang.String |
HD_NODE |
static java.lang.String |
ID_NODE |
protected MdfHeader |
mdfHeader |
static java.lang.String |
TABBED_COMMENT |
Constructor and Description |
---|
MDFHeader() |
MDFHeader(MdfHeader mdfHeader)
The default constructor.
|
MDFHeader(MdfHeader mdfHeader,
int exitCode,
java.lang.String errorMessage)
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
extendFields(java.io.InputStream stream,
MDFHeader.FieldSplitter splitter)
Extends the fields of header.
|
void |
extendFields(MDFField[] fieldArr)
Extends the fields of header.
|
void |
extendFields(java.lang.String filename)
Extends the fields of header.
|
void |
extendFields(java.lang.String filename,
MDFHeader.FieldSplitter splitter)
Extends the fields of header.
|
java.util.Map<java.lang.String,java.lang.String> |
getFieldMap()
Get a map containing the fields.
|
MdfHeader |
getHeader()
Get the header of the document.
|
java.lang.String |
getReaderErrorMessage()
Get the error message of the reader process.
|
int |
getReaderExitCode()
Get the exit code of the reader process.
|
static MDFField[] |
readFieldsFromFile(java.lang.String filename)
Read the fields from header file.
|
protected void |
readFieldsFromHeader()
Read the fields from header.
|
static MDFField[] |
readFieldsFromHeaderStream(java.io.InputStream stream)
Read the fields from header.
|
static MDFField[] |
readFieldsFromTabbedHeaderStream(java.io.InputStream stream)
Reads the fields from a header without correct format.
|
java.lang.String |
toString() |
public static final java.lang.String COMMENT_TYPE_KEY
public static final java.lang.String TABBED_COMMENT
public static final java.lang.String ECU_TYPE
public static final java.lang.String ECU_SEP
public static final java.lang.String FILENAME_ATTR
public static final java.lang.String ID_NODE
public static final java.lang.String HD_NODE
protected MdfHeader mdfHeader
protected MDFField[] fields
protected int exitCode
protected java.lang.String errorMessage
public MDFHeader()
public MDFHeader(MdfHeader mdfHeader) throws java.io.IOException
mdfHeader
- coming from XML schema.java.io.IOException
public MDFHeader(MdfHeader mdfHeader, int exitCode, java.lang.String errorMessage) throws java.io.IOException
mdfHeader
- coming from XML schema.exitCode
- the exit code of the reader process.errorMEssage
- the error message of the reader process.java.io.IOException
protected void readFieldsFromHeader() throws java.io.IOException
java.io.IOException
public static MDFField[] readFieldsFromFile(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public static MDFField[] readFieldsFromHeaderStream(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public static MDFField[] readFieldsFromTabbedHeaderStream(java.io.InputStream stream) throws java.io.IOException
stream
- the stream which contains the dataMDFField
java.io.IOException
public java.util.Map<java.lang.String,java.lang.String> getFieldMap()
public int getReaderExitCode()
public java.lang.String getReaderErrorMessage()
public MdfHeader getHeader()
public void extendFields(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException
filename
- the filename from which the fields should be read.java.io.FileNotFoundException
java.io.IOException
public void extendFields(java.lang.String filename, MDFHeader.FieldSplitter splitter) throws java.io.FileNotFoundException, java.io.IOException
filename
- the filename from which the fields should be read.splitter
- the filed splitter.java.io.FileNotFoundException
java.io.IOException
public void extendFields(java.io.InputStream stream, MDFHeader.FieldSplitter splitter) throws java.io.FileNotFoundException, java.io.IOException
filename
- the filename from which the fields should be read.splitter
- the filed splitter.java.io.FileNotFoundException
java.io.IOException
public void extendFields(MDFField[] fieldArr)
filename
- the filename from which the fields should be read.splitter
- the filed splitter.public java.lang.String toString()
toString
in class java.lang.Object