public class GenericWriter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
boolean |
rowMajority |
Constructor and Description |
---|
GenericWriter()
Constructs a column major GenericWriter
|
GenericWriter(boolean rowMajority)
Constructs a GenericWriter of specified row majority
|
Modifier and Type | Method and Description |
---|---|
void |
addData(java.lang.String name,
java.lang.Object data)
Adds data to a variable.same as addData(String name, Object data, false)
|
void |
addData(java.lang.String name,
java.lang.Object data,
boolean relax)
Adds data to a variable.
|
void |
addData(java.lang.String name,
java.lang.Object data,
int[] recordRange)
Adds data for a specified record range to a variable.
|
void |
addData(java.lang.String name,
java.lang.Object data,
int[] recordRange,
boolean relax)
Adds data for a specified record range to a variable.
|
void |
addGlobalAttributeEntry(java.lang.String name,
CDFDataType dataType,
java.lang.Object value)
Adds a global attribute entry of specified type..
|
void |
addGlobalAttributeEntry(java.lang.String name,
java.lang.Object value)
Adds a global attribute entry.
|
void |
addNRVString(java.lang.String name,
java.lang.String value)
Adds an NRV record of string type.
|
void |
addNRVVariable(java.lang.String name,
CDFDataType dataType,
int[] dim,
int size,
java.lang.Object value)
Adds a NRV record of the given type and dimensions.
|
void |
addNRVVariable(java.lang.String name,
CDFDataType dataType,
int[] dim,
java.lang.Object value)
Adds a NRV record of the given numeric type and dimension.
|
void |
addNRVVariable(java.lang.String name,
CDFDataType dataType,
java.lang.Object value)
Adds a scalar NRV record of the given numeric type.
|
void |
addOneD(java.lang.String name,
java.lang.Object data)
Adds data (represented as a one dimensional array) to a variable.same as addOneD(String name, Object data, null, false)
|
void |
addOneD(java.lang.String name,
java.lang.Object data,
boolean relax)
Adds data (represented as a one dimensional array) to a variable.same as addOneD(String name, Object data, null, boolean relax)
|
void |
addOneD(java.lang.String name,
java.lang.Object data,
int[] recordRange)
Adds data (represented as a one dimensional array)
for a specified record range to a variable.same as addOneD(String name, Object data, int[] recordRange, false)
|
void |
addOneD(java.lang.String name,
java.lang.Object data,
int[] recordRange,
boolean relax)
Adds data (represented as a one dimensional array)
for a specified record range to a variable.
|
void |
addVariableAttributeEntry(java.lang.String vname,
java.lang.String aname,
CDFDataType dataType,
java.lang.Object value)
Sets the value of a given attribute for a variable.This method creates a new value for the given attribute.
|
void |
addVariableAttributeEntry(java.lang.String vname,
java.lang.String aname,
java.lang.Object value)
Sets the value of a given attribute for a variable.This method creates a new value for the given attribute.
|
void |
defineCompressedStringVariable(java.lang.String name,
int[] dim,
int size)
Defines a compressed variable of string type with given dimensions.
|
void |
defineCompressedTimeSeries(java.lang.String name,
CDFDataType dataType,
int[] dim,
java.lang.String tname,
CDFTimeType timeType)
Defines a time series of the named variable of specified data type and
the time variable of specified name and type.Variable's data is compressed before it is stored
|
void |
defineCompressedVariable(java.lang.String name,
CDFDataType dataType,
int[] dim)
Defines a compressed variable of specified numeric data type and
dimensions.
|
void |
defineCompressedVariable(java.lang.String name,
CDFDataType dataType,
int[] dim,
int size)
Defines a compressed variable of string type with given dimensions.
|
void |
defineNRVVariable(java.lang.String name,
CDFDataType dataType,
int[] dim,
int size)
Defines a NRV record of the given type and dimensions.Parameter size is ignored for variables of numeric types.
|
void |
defineStringVariable(java.lang.String name,
int[] dim,
boolean[] varys,
boolean recordVariance,
boolean compressed,
java.lang.Object pad,
int size)
Defines a variable of string type using default
sparse record option.same as:
defineStringVariable(String name, int[] dim,
boolean[] varys, boolean recordVariance, boolean compressed,
Object pad, int size, SparseRecordOption.NONE)
|
void |
defineStringVariable(java.lang.String name,
int[] dim,
boolean[] varys,
boolean recordVariance,
boolean compressed,
java.lang.Object pad,
int size,
SparseRecordOption option)
Defines a variable of string type using given
sparse record option.
|
void |
defineStringVariable(java.lang.String name,
int[] dim,
int size)
Defines a named variable of string data type
|
void |
defineTimeSeries(java.lang.String name,
CDFDataType dataType,
int[] dim)
Defines a time series for a new variable of specified data type.Variable's times are contained in a time variable named Epoch which
must have been created before this method is called.
|
void |
defineTimeSeries(java.lang.String name,
CDFDataType dataType,
int[] dim,
java.lang.String tname)
Defines a time series of the named variable of specified data type
and the time variable of specified name.The named time variable must have been defined before this method
is called.Name of the time variable is assigned to the DEPEND_0
attribute.
|
void |
defineTimeSeries(java.lang.String name,
CDFDataType dataType,
int[] dim,
java.lang.String tname,
CDFTimeType timeType,
boolean compressed)
Defines a time series of a new named variable of specified data type
and the time variable of specified name and type.
|
void |
defineTimeVariable(java.lang.String name,
CDFTimeType timeType)
Defines a time variable of the specified
time type . |
void |
defineVariable(java.lang.String name,
CDFDataType dataType,
int[] dim)
Defines a named variable of specified numeric data type
|
void |
defineVariable(java.lang.String name,
CDFDataType dataType,
int[] dim,
boolean[] varys,
boolean recordVariance,
boolean compressed,
java.lang.Object pad)
Defines a variable of specified numeric data type using default
sparse record option.
|
void |
defineVariable(java.lang.String name,
CDFDataType dataType,
int[] dim,
boolean[] varys,
boolean recordVariance,
boolean compressed,
java.lang.Object pad,
int size)
Defines a variable of string type using given
sparse record option.
|
void |
defineVariable(java.lang.String name,
CDFDataType dataType,
int[] dim,
boolean[] varys,
boolean recordVariance,
boolean compressed,
java.lang.Object pad,
int size,
SparseRecordOption option)
Defines a new variable
|
void |
defineVariable(java.lang.String name,
CDFDataType dataType,
int[] dim,
boolean[] varys,
boolean recordVariance,
boolean compressed,
java.lang.Object pad,
SparseRecordOption option)
Defines a variable of specified numeric data type using given
sparse record option.
|
void |
defineVariable(java.lang.String name,
CDFDataType dataType,
int[] dim,
int size)
Defines a named variable of specified numeric data type and dimensions.
|
boolean |
hasTimeVariable(java.lang.String name)
Returns whether the time variable has been defined for a variable.
|
void |
setLastLeapSecondId(int n)
Sets the last Leap Second Id.
|
void |
setMD5Needed(boolean need)
Prescribes whether an MD5 digest is to be included in
the output file.
|
void |
setVariableAttributeEntry(java.lang.String vname,
java.lang.String aname,
CDFDataType dataType,
java.lang.Object value)
Sets the value of a given attribute for a variable.
|
void |
setVariableAttributeEntry(java.lang.String vname,
java.lang.String aname,
java.lang.Object value)
Sets the value of a given attribute for a variable.
|
void |
write(java.lang.String fname)
Writes CDF to a file.
|
boolean |
write(java.lang.String fname,
boolean overwrite) |
public GenericWriter()
public GenericWriter(boolean rowMajority)
bln
- public void addGlobalAttributeEntry(java.lang.String name, java.lang.Object value) throws CDFException.WriterError
name
- name of the attributevalue
- array or wrapped scalar value to assign to attributeCDFException.WriterError
public void addGlobalAttributeEntry(java.lang.String name, CDFDataType dataType, java.lang.Object value) throws CDFException.WriterError
name
- name of the attributedataType
- CDFDataType
desiredvalue
- array or wrapped scalar value to assign to attributeCDFException.WriterError
public void setVariableAttributeEntry(java.lang.String vname, java.lang.String aname, java.lang.Object value) throws CDFException.WriterError
vname
- name of the variableaname
- name of the attributevalue
- array of primitives, or String value to assign to
attributeCDFException.WriterError
public void setVariableAttributeEntry(java.lang.String vname, java.lang.String aname, CDFDataType dataType, java.lang.Object value) throws CDFException.WriterError
vname
- name of the variableaname
- name of the attributedataType
- CDFDataType
desiredvalue
- array of primitives, or String value to assign to
attribute
Overwrites previous value, if anyCDFException.WriterError
public void addVariableAttributeEntry(java.lang.String vname, java.lang.String aname, java.lang.Object value) throws CDFException.WriterError
vname
- name of the variableaname
- name of the attributevalue
- array of primitives, or String value to assign to
attributeCDFException.WriterError
public void addVariableAttributeEntry(java.lang.String vname, java.lang.String aname, CDFDataType dataType, java.lang.Object value) throws CDFException.WriterError
vname
- name of the variableaname
- name of the attributedataType
- CDFDataType
desiredvalue
- array of primitives, or String value to assign to
attributeCDFException.WriterError
public boolean hasTimeVariable(java.lang.String name) throws CDFException.WriterError
name
- CDFException.WriterError
public void defineTimeVariable(java.lang.String name, CDFTimeType timeType) throws CDFException.WriterError
time type
.name
- timeType
- CDFException.WriterError
public void defineTimeSeries(java.lang.String name, CDFDataType dataType, int[] dim) throws CDFException.WriterError
name
- dim
- dataType
- CDFException.WriterError
public void defineTimeSeries(java.lang.String name, CDFDataType dataType, int[] dim, java.lang.String tname) throws CDFException.WriterError
name
- tname
- dataType
- dim
- CDFException.WriterError
public void defineCompressedTimeSeries(java.lang.String name, CDFDataType dataType, int[] dim, java.lang.String tname, CDFTimeType timeType) throws CDFException.WriterError
name
- timeType
- dataType
- tname
- dim
- CDFException.WriterError
public void defineTimeSeries(java.lang.String name, CDFDataType dataType, int[] dim, java.lang.String tname, CDFTimeType timeType, boolean compressed) throws CDFException.WriterError
name
- compressed
- dataType
- timeType
- dim
- tname
- CDFException.WriterError
public void defineVariable(java.lang.String name, CDFDataType dataType, int[] dim) throws CDFException.WriterError
name
- dim
- dataType
- CDFException.WriterError
public void defineStringVariable(java.lang.String name, int[] dim, int size) throws CDFException.WriterError
name
- size
- dim
- CDFException.WriterError
public void defineVariable(java.lang.String name, CDFDataType dataType, int[] dim, int size) throws CDFException.WriterError
name
- size
- dataType
- dim
- CDFException.WriterError
public void defineCompressedVariable(java.lang.String name, CDFDataType dataType, int[] dim) throws CDFException.WriterError
name
- dim
- dataType
- CDFException.WriterError
public void defineCompressedStringVariable(java.lang.String name, int[] dim, int size) throws CDFException.WriterError
name
- size
- dim
- CDFException.WriterError
public void defineCompressedVariable(java.lang.String name, CDFDataType dataType, int[] dim, int size) throws CDFException.WriterError
name
- size
- dataType
- dim
- CDFException.WriterError
public void addNRVString(java.lang.String name, java.lang.String value) throws CDFException.WriterError
name
- value
- CDFException.WriterError
public void addNRVVariable(java.lang.String name, CDFDataType dataType, java.lang.Object value) throws CDFException.WriterError
name
- value
- dataType
- CDFException.WriterError
public void addNRVVariable(java.lang.String name, CDFDataType dataType, int[] dim, java.lang.Object value) throws CDFException.WriterError
name
- value
- dataType
- dim
- CDFException.WriterError
public void addNRVVariable(java.lang.String name, CDFDataType dataType, int[] dim, int size, java.lang.Object value) throws CDFException.WriterError
name
- value
- dataType
- size
- dim
- CDFException.WriterError
public void defineNRVVariable(java.lang.String name, CDFDataType dataType, int[] dim, int size) throws CDFException.WriterError
name
- size
- dataType
- dim
- CDFException.WriterError
public void defineVariable(java.lang.String name, CDFDataType dataType, int[] dim, boolean[] varys, boolean recordVariance, boolean compressed, java.lang.Object pad) throws CDFException.WriterError
name
- dataType
- data tpe
dim
- dimensionsvarys
- dimension variancerecordVariance
- compressed
- whether the values will be saved in compressed formpad
- array or wrapped scalar value to assign to use as padCDFException.WriterError
public void defineVariable(java.lang.String name, CDFDataType dataType, int[] dim, boolean[] varys, boolean recordVariance, boolean compressed, java.lang.Object pad, SparseRecordOption option) throws CDFException.WriterError
name
- dataType
- data tpe
dim
- dimensionsvarys
- dimension variancerecordVariance
- compressed
- whether the values will be saved in compressed formpad
- array or wrapped scalar value to assign to use as padoption
- sparse record option
CDFException.WriterError
public void defineStringVariable(java.lang.String name, int[] dim, boolean[] varys, boolean recordVariance, boolean compressed, java.lang.Object pad, int size) throws CDFException.WriterError
name
- dim
- size
- pad
- varys
- compressed
- recordVariance
- CDFException.WriterError
defineStringVariable(String name, int[] dim,
boolean[] varys, boolean recordVariance, boolean compressed,
Object pad, int size, SparseRecordOption option)
public void defineStringVariable(java.lang.String name, int[] dim, boolean[] varys, boolean recordVariance, boolean compressed, java.lang.Object pad, int size, SparseRecordOption option) throws CDFException.WriterError
name
- dim
- dimensionsvarys
- dimension variancerecordVariance
- compressed
- whether the values will be saved in compressed formpad
- array or wrapped scalar value to assign to use as padsize
- length of character stringoption
- sparse record option
CDFException.WriterError
public void defineVariable(java.lang.String name, CDFDataType dataType, int[] dim, boolean[] varys, boolean recordVariance, boolean compressed, java.lang.Object pad, int size) throws CDFException.WriterError
name
- dataType
- dim
- dimensionsvarys
- dimension variancerecordVariance
- compressed
- whether the values will be saved in compressed formpad
- array or wrapped scalar value to assign to use as padsize
- length of character stringCDFException.WriterError
public void defineVariable(java.lang.String name, CDFDataType dataType, int[] dim, boolean[] varys, boolean recordVariance, boolean compressed, java.lang.Object pad, int size, SparseRecordOption option) throws CDFException.WriterError
name
- Variable namedataType
- data type
of the variabledim
- dimensionvarys
- recordVariance
- compressed
- whether the variable data appears in compressed
form in the CDFpad
- Object to use as a pad value - a Number object
for a numeric variable, a String for a character
variablesize
- length of charater string for character variable,
Must be 1 for numeric type variableoption
- sparse record option
CDFException.WriterError
public void addOneD(java.lang.String name, java.lang.Object data) throws CDFException.WriterError
name
- data
- CDFException.WriterError
addOneD(String name, Object data, int[] recordRange, boolean relax)
public void addOneD(java.lang.String name, java.lang.Object data, boolean relax) throws CDFException.WriterError
name
- relax
- data
- CDFException.WriterError
addOneD(String name, Object data, int[] recordRange, boolean relax)
public void addOneD(java.lang.String name, java.lang.Object data, int[] recordRange) throws CDFException.WriterError
name
- recordRange
- data
- CDFException.WriterError
addOneD(String name, Object data, int[] recordRange, boolean relax)
public void addOneD(java.lang.String name, java.lang.Object data, int[] recordRange, boolean relax) throws CDFException.WriterError
name
- name of the variable.data
- a one dimensional array of a type compatible with
the type of variable.recordRange
- int[2] containing record range. May be null, in
which case range is assumed to be follow last record added.relax
- relevant for unsigned data types, CDF_UINT1,
CDF_UINT2 and CDF_UINT4 only,specifies that values in
data array can be interpreted as unsigned.
CDF Type of Variable | Type of Array |
INT8, TT2000, UINT4 | long |
UINT4 | int, if relax = true, long otherwise |
DOUBLE, EPOCH, EPOCH16 | double |
FLOAT | float or double |
INT4 | int |
UINT2 | short, if relax = true, int otherwise |
INT2 | short |
UINT1 | byte, if relax = true, short otherwise |
INT1 | byte |
CHAR | String |
CDFException.WriterError
public void addData(java.lang.String name, java.lang.Object data) throws CDFException.WriterError
name
- data
- CDFException.WriterError
addData(String name, Object data, boolean relax)
public void addData(java.lang.String name, java.lang.Object data, boolean relax) throws CDFException.WriterError
name
- name of the variable.data
- an array of type compatible with the type of variable.relax
- relevant for unsigned data types, CDF_UINT1,
CDF_UINT2 and CDF_UINT4 only,specifies that values in
data array can be interpreted as unsigned.CDFException.WriterError
for more details.
public void addData(java.lang.String name, java.lang.Object data, int[] recordRange) throws CDFException.WriterError
name
- name of the variable.data
- an array of type compatible with the type of variable, or
a ByteOrder.LITTLE_ENDIAN ByteBuffer containing data to be added.recordRange
- int[2] containing record range. If data is an
array, or variable is to be saved uncompressed, recordRange may be null,
in which case range is assumed to be follow last record added.CDFException.WriterError
addData(String name, Object data, int[] recordRange, boolean relax)
public void addData(java.lang.String name, java.lang.Object data, int[] recordRange, boolean relax) throws CDFException.WriterError
name
- name of the variable.data
- an array of type compatible with the type of variable, or
a ByteOrder.LITTLE_ENDIAN ByteBuffer containing data to be added.recordRange
- int[2] containing record range. If data is an
array, or variable is to be saved uncompressed, recordRange may be null,
in which case range is assumed to be follow last record added.relax
- relevant for unsigned data types, CDF_UINT1,
CDF_UINT2 and CDF_UINT4 only,specifies that values in
data array can be interpreted as unsigned.
CDF Type of Variable | Type of Array |
INT8, TT2000, UINT4 | long |
UINT4 | int, if relax = true, long otherwise |
DOUBLE, EPOCH, EPOCH16 | double |
FLOAT | float or double |
INT4 | int |
UINT2 | short, if relax = true, int otherwise |
INT2 | short |
UINT1 | byte, if relax = true, short otherwise |
INT1 | byte |
CHAR | String |
CDFException.WriterError
public void setMD5Needed(boolean need)
need
- public void write(java.lang.String fname) throws java.io.IOException
fname
- java.io.IOException
public boolean write(java.lang.String fname, boolean overwrite) throws java.io.IOException
fname
- overwrite
- java.io.IOException
public void setLastLeapSecondId(int n)
n
- integer = year*10000 + month*100 + day, where year
month and day refer to the day following the leap second.
A 0 value for n asserts that applications accept the
validity of TT2000 times. n = -1 implies lastLeapSecondId=20120701,
which is the default for CDF versions prior to 3.6.