public class Variable extends java.lang.Object implements CDFObject, CDFConstants
zMODE = 2
, all variables
are by default, zVariables.AHUFF_COMPRESSION, ALPHAOSF1_DECODING, ALPHAOSF1_ENCODING, ALPHAVMSd_DECODING, ALPHAVMSd_ENCODING, ALPHAVMSg_DECODING, ALPHAVMSg_ENCODING, ALPHAVMSi_DECODING, ALPHAVMSi_ENCODING, ARM_BIG_DECODING, ARM_BIG_ENCODING, ARM_LITTLE_DECODING, ARM_LITTLE_ENCODING, ATTR_, ATTR_EXISTENCE_, ATTR_EXISTS, ATTR_MAXgENTRY_, ATTR_MAXrENTRY_, ATTR_MAXzENTRY_, ATTR_NAME_, ATTR_NAME_TRUNC, ATTR_NUMBER_, ATTR_NUMgENTRIES_, ATTR_NUMrENTRIES_, ATTR_NUMzENTRIES_, ATTR_SCOPE_, BACKWARD_, BACKWARDFILEoff, BACKWARDFILEon, BAD_ALLOCATE_RECS, BAD_ARGUMENT, BAD_ATTR_NAME, BAD_ATTR_NUM, BAD_BLOCKING_FACTOR, BAD_CACHE_SIZE, BAD_CDF_EXTENSION, BAD_CDF_ID, BAD_CDF_NAME, BAD_CDFSTATUS, BAD_CHECKSUM, BAD_COMPRESSION_PARM, BAD_DATA_TYPE, BAD_DECODING, BAD_DIM_COUNT, BAD_DIM_INDEX, BAD_DIM_INTERVAL, BAD_DIM_SIZE, BAD_ENCODING, BAD_ENTRY_NUM, BAD_FNC_OR_ITEM, BAD_FORMAT, BAD_INITIAL_RECS, BAD_MAJORITY, BAD_MALLOC, BAD_NEGtoPOSfp0_MODE, BAD_NUM_DIMS, BAD_NUM_ELEMS, BAD_NUM_STRINGS, BAD_NUM_VARS, BAD_READONLY_MODE, BAD_REC_COUNT, BAD_REC_INTERVAL, BAD_REC_NUM, BAD_SCOPE, BAD_SCRATCH_DIR, BAD_SPARSEARRAYS_PARM, BAD_VAR_NAME, BAD_VAR_NUM, BAD_zMODE, BADDATE_LEAPSECOND_UPDATED, BeginUnixTimeEPOCH, BeginUnixTimeEPOCH16, BLOCKINGFACTOR_TOO_SMALL, BLOCKINGFACTOR_TOO_SMALL2, CANNOT_ALLOCATE_RECORDS, CANNOT_CHANGE, CANNOT_COMPRESS, CANNOT_CONVERT_WIDECHAR, CANNOT_COPY, CANNOT_INSERT_RECORDS, CANNOT_SPARSEARRAYS, CANNOT_SPARSERECORDS, CDF_, CDF_ACCESS_, CDF_ATTR_NAME_LEN, CDF_ATTR_NAME_LEN256, CDF_BYTE, CDF_CACHESIZE_, CDF_CHAR, CDF_CHECKSUM_, CDF_CLOSE_ERROR, CDF_COMPRESSION_, CDF_COPYRIGHT_, CDF_COPYRIGHT_LEN, CDF_CREATE_ERROR, CDF_DECODING_, CDF_DELETE_ERROR, CDF_DOUBLE, CDF_ENCODING_, CDF_EPOCH, CDF_EPOCH16, CDF_EXISTS, CDF_FLOAT, CDF_FORMAT_, CDF_INCREMENT_, CDF_INFO_, CDF_INT1, CDF_INT2, CDF_INT4, CDF_INT8, CDF_INTERNAL_ERROR, CDF_LEAPSECONDLASTUPDATED_, CDF_MAJORITY_, CDF_MAX_DIMS, CDF_MAX_PARMS, CDF_MIN_DIMS, CDF_NAME_, CDF_NAME_TRUNC, CDF_NEGtoPOSfp0_MODE_, CDF_NUMATTRS_, CDF_NUMgATTRS_, CDF_NUMrVARS_, CDF_NUMvATTRS_, CDF_NUMzVARS_, CDF_OK, CDF_OPEN_ERROR, CDF_PATHNAME_LEN, CDF_READ_ERROR, CDF_READONLY_MODE_, CDF_REAL4, CDF_REAL8, CDF_RELEASE_, CDF_SAVE_ERROR, CDF_SCRATCHDIR_, CDF_STATUS_, CDF_STATUSTEXT_LEN, CDF_TIME_TT2000, CDF_UCHAR, CDF_UINT1, CDF_UINT2, CDF_UINT4, CDF_VAR_NAME_LEN, CDF_VAR_NAME_LEN256, CDF_VERSION_, CDF_WARN, CDF_WRITE_ERROR, CDF_zMODE_, CDFwithSTATS_, CHECKSUM_, CHECKSUM_ERROR, CHECKSUM_NOT_ALLOWED, CLOSE_, COLUMN_MAJOR, COMPRESS_CACHESIZE_, COMPRESSION_ERROR, CONFIRM_, CORRUPTED_V2_CDF, CORRUPTED_V3_CDF, CREATE_, CURgENTRY_EXISTENCE_, CURrENTRY_EXISTENCE_, CURzENTRY_EXISTENCE_, DATATYPE_MISMATCH, DATATYPE_SIZE_, DECOMPRESSION_ERROR, DECSTATION_DECODING, DECSTATION_ENCODING, DEFAULT_BYTE_PADVALUE, DEFAULT_CHAR_PADVALUE, DEFAULT_DOUBLE_PADVALUE, DEFAULT_EPOCH_PADVALUE, DEFAULT_EPOCH16_PADVALUE, DEFAULT_FLOAT_PADVALUE, DEFAULT_INT1_PADVALUE, DEFAULT_INT2_PADVALUE, DEFAULT_INT4_PADVALUE, DEFAULT_INT8_PADVALUE, DEFAULT_REAL4_PADVALUE, DEFAULT_REAL8_PADVALUE, DEFAULT_TT2000_PADVALUE, DEFAULT_UCHAR_PADVALUE, DEFAULT_UINT1_PADVALUE, DEFAULT_UINT2_PADVALUE, DEFAULT_UINT4_PADVALUE, DELETE_, DID_NOT_COMPRESS, EMPTY_COMPRESSED_CDF, END_OF_VAR, EPOCH_STRING_LEN, EPOCH_STRING_LEN_EXTEND, EPOCH1_STRING_LEN, EPOCH1_STRING_LEN_EXTEND, EPOCH2_STRING_LEN, EPOCH2_STRING_LEN_EXTEND, EPOCH3_STRING_LEN, EPOCH3_STRING_LEN_EXTEND, EPOCH4_STRING_LEN, EPOCH4_STRING_LEN_EXTEND, EPOCHx_FORMAT_MAX, EPOCHx_STRING_MAX, FILLED_TT2000_VALUE, FORCED_PARAMETER, FUNCTION_NOT_SUPPORTED, gENTRY_, gENTRY_DATA_, gENTRY_DATASPEC_, gENTRY_DATATYPE_, gENTRY_EXISTENCE_, gENTRY_NUMELEMS_, GET_, GETCDFCHECKSUM_, GETCDFFILEBACKWARD_, GETCDFVALIDATE_, GETLEAPSECONDSENVVAR_, GLOBAL_SCOPE, GZIP_COMPRESSION, HOST_DECODING, HOST_ENCODING, HP_DECODING, HP_ENCODING, HUFF_COMPRESSION, IA64VMSd_DECODING, IA64VMSd_ENCODING, IA64VMSg_DECODING, IA64VMSg_ENCODING, IA64VMSi_DECODING, IA64VMSi_ENCODING, IBM_PC_OVERFLOW, IBMPC_DECODING, IBMPC_ENCODING, IBMRS_DECODING, IBMRS_ENCODING, ILLEGAL_EPOCH_FIELD, ILLEGAL_EPOCH_VALUE, ILLEGAL_FOR_SCOPE, ILLEGAL_IN_zMODE, ILLEGAL_ON_V1_CDF, ILLEGAL_TT2000_VALUE, IS_A_NETCDF, LIB_COPYRIGHT_, LIB_INCREMENT_, LIB_RELEASE_, LIB_subINCREMENT_, LIB_VERSION_, MAC_DECODING, MAC_ENCODING, MD5_CHECKSUM, MULTI_FILE, MULTI_FILE_FORMAT, NA_FOR_VARIABLE, NEGATIVE_FP_ZERO, NEGtoPOSfp0off, NEGtoPOSfp0on, NETWORK_DECODING, NETWORK_ENCODING, NeXT_DECODING, NeXT_ENCODING, NO_ATTR_SELECTED, NO_CDF_SELECTED, NO_CHECKSUM, NO_COMPRESSION, NO_DELETE_ACCESS, NO_ENTRY_SELECTED, NO_MORE_ACCESS, NO_PADVALUE_SPECIFIED, NO_SPARSEARRAYS, NO_SPARSERECORDS, NO_STATUS_SELECTED, NO_SUCH_ATTR, NO_SUCH_CDF, NO_SUCH_ENTRY, NO_SUCH_RECORD, NO_SUCH_VAR, NO_VAR_SELECTED, NO_VARS_IN_CDF, NO_WRITE_ACCESS, NONE_CHECKSUM, NOT_A_CDF, NOT_A_CDF_OR_NOT_SUPPORTED, NOVARY, NULL_, OPEN_, OPTIMAL_ENCODING_TREES, OTHER_CHECKSUM, PAD_SPARSERECORDS, PPC_DECODING, PPC_ENCODING, PRECEEDING_RECORDS_ALLOCATED, PREV_SPARSERECORDS, PUT_, READ_ONLY_DISTRIBUTION, READ_ONLY_MODE, READONLYoff, READONLYon, rENTRY_, rENTRY_DATA_, rENTRY_DATASPEC_, rENTRY_DATATYPE_, rENTRY_EXISTENCE_, rENTRY_NAME_, rENTRY_NUMELEMS_, rENTRY_NUMSTRINGS_, rENTRY_STRINGSDATA_, RLE_COMPRESSION, RLE_OF_ZEROs, ROW_MAJOR, rVAR_, rVAR_ALLOCATEBLOCK_, rVAR_ALLOCATEDFROM_, rVAR_ALLOCATEDTO_, rVAR_ALLOCATERECS_, rVAR_BLOCKINGFACTOR_, rVAR_CACHESIZE_, rVAR_COMPRESSION_, rVAR_DATA_, rVAR_DATASPEC_, rVAR_DATATYPE_, rVAR_DIMVARYS_, rVAR_EXISTENCE_, rVAR_HYPERDATA_, rVAR_INITIALRECS_, rVAR_MAXallocREC_, rVAR_MAXREC_, rVAR_NAME_, rVAR_nINDEXENTRIES_, rVAR_nINDEXLEVELS_, rVAR_nINDEXRECORDS_, rVAR_NUMallocRECS_, rVAR_NUMBER_, rVAR_NUMELEMS_, rVAR_NUMRECS_, rVAR_PADVALUE_, rVAR_RECORDS_, rVAR_RECORDS_RENUMBER_, rVAR_RECVARY_, rVAR_RESERVEPERCENT_, rVAR_SEQDATA_, rVAR_SEQPOS_, rVAR_SPARSEARRAYS_, rVAR_SPARSERECORDS_, rVARs_CACHESIZE_, rVARs_DIMCOUNTS_, rVARs_DIMINDICES_, rVARs_DIMINTERVALS_, rVARs_DIMSIZES_, rVARs_MAXREC_, rVARs_NUMDIMS_, rVARs_RECCOUNT_, rVARs_RECDATA_, rVARs_RECINTERVAL_, rVARs_RECNUMBER_, SAVE_, SCRATCH_CREATE_ERROR, SCRATCH_DELETE_ERROR, SCRATCH_READ_ERROR, SCRATCH_WRITE_ERROR, SELECT_, SGi_DECODING, SGi_ENCODING, SINGLE_FILE, SINGLE_FILE_FORMAT, SOME_ALREADY_ALLOCATED, STAGE_CACHESIZE_, STATUS_TEXT_, STRING_NOT_UTF8_ENCODING, STRINGDELIMITER, SUN_DECODING, SUN_ENCODING, TOO_MANY_PARMS, TOO_MANY_VARS, TRY_TO_READ_NONSTRING_DATA, TT2000_0_STRING_LEN, TT2000_1_STRING_LEN, TT2000_2_STRING_LEN, TT2000_3_STRING_LEN, TT2000_4_STRING_LEN, TT2000_CDF_MAYNEEDUPDATE, TT2000_TIME_ERROR, TT2000_USED_OUTDATED_TABLE, UNABLE_TO_PROCESS_CDF, UNKNOWN_COMPRESSION, UNKNOWN_SPARSENESS, UNSUPPORTED_OPERATION, VALIDATE_, VALIDATEFILEoff, VALIDATEFILEon, VAR_ALREADY_CLOSED, VAR_CLOSE_ERROR, VAR_CREATE_ERROR, VAR_DELETE_ERROR, VAR_EXISTS, VAR_NAME_TRUNC, VAR_OPEN_ERROR, VAR_READ_ERROR, VAR_SAVE_ERROR, VAR_WRITE_ERROR, VARIABLE_SCOPE, VARY, VAX_DECODING, VAX_ENCODING, VIRTUAL_RECORD_DATA, zENTRY_, zENTRY_DATA_, zENTRY_DATASPEC_, zENTRY_DATATYPE_, zENTRY_EXISTENCE_, zENTRY_NAME_, zENTRY_NUMELEMS_, zENTRY_NUMSTRINGS_, zENTRY_STRINGSDATA_, ZLIB_COMPRESS_ERROR, ZLIB_UNCOMPRESS_ERROR, zMODEoff, zMODEon1, zMODEon2, zVAR_, zVAR_ALLOCATEBLOCK_, zVAR_ALLOCATEDFROM_, zVAR_ALLOCATEDTO_, zVAR_ALLOCATERECS_, zVAR_BLOCKINGFACTOR_, zVAR_CACHESIZE_, zVAR_COMPRESSION_, zVAR_DATA_, zVAR_DATASPEC_, zVAR_DATATYPE_, zVAR_DIMCOUNTS_, zVAR_DIMINDICES_, zVAR_DIMINTERVALS_, zVAR_DIMSIZES_, zVAR_DIMVARYS_, zVAR_EXISTENCE_, zVAR_HYPERDATA_, zVAR_INITIALRECS_, zVAR_MAXallocREC_, zVAR_MAXREC_, zVAR_NAME_, zVAR_nINDEXENTRIES_, zVAR_nINDEXLEVELS_, zVAR_nINDEXRECORDS_, zVAR_NUMallocRECS_, zVAR_NUMBER_, zVAR_NUMDIMS_, zVAR_NUMELEMS_, zVAR_NUMRECS_, zVAR_PADVALUE_, zVAR_RECCOUNT_, zVAR_RECINTERVAL_, zVAR_RECNUMBER_, zVAR_RECORDS_, zVAR_RECORDS_RENUMBER_, zVAR_RECVARY_, zVAR_RESERVEPERCENT_, zVAR_SEQDATA_, zVAR_SEQPOS_, zVAR_SPARSEARRAYS_, zVAR_SPARSERECORDS_, zVARs_CACHESIZE_, zVARs_MAXREC_, zVARs_RECDATA_, zVARs_RECNUMBER_
Modifier and Type | Method and Description |
---|---|
void |
allocateBlock(long firstRec,
long lastRec)
Allocates a range of records for this variable.
|
void |
allocateRecords(long num0toRecords)
Allocates a number of records, starting from record number 0.
|
boolean |
checkPadValueExistence()
Checks if the pad value has been defined for this variable.
|
void |
concatenateDataRecords(Variable destVar)
Concatenates this variable's data records to the destination variable.
|
long |
confirmCacheSize()
Gets the number of 512-byte cache buffers defined for this variable.
|
long |
confirmPadValue()
Checks the existence of an explicitly specified pad value for the
current z variable.
|
long |
confirmReservePercent()
Gets the reserve percentage set for this variable.
|
Variable |
copy(CDF destCDF,
java.lang.String varName)
Copies this variable into a new variable and puts it into the designated
CDF file.
|
Variable |
copy(java.lang.String varName)
Copies this variable to a new variable.
|
void |
copyDataRecords(Variable destVar)
Copies this variable's data to the destination variable.
|
static Variable |
create(CDF myCDF,
java.lang.String varName,
long dataType,
long numElements,
long numDims,
long[] dimSizes,
long recVary,
long[] dimVarys)
Creates a variable.
|
void |
delete()
Deletes this variable.
|
void |
deleteRecords(long firstRec,
long lastRec)
Deletes a range of records from this variable.
|
void |
deleteRecordsRenumber(long firstRec,
long lastRec)
Deletes a range of records from this variable.
|
void |
dumpDataWithFormat(CDFData data)
Dump the data, either the variable value or metadata, with
the format.
|
void |
dumpDataWithFormat(java.lang.Object data)
Dump the data, either the variable value or metadata, with or without
the format.
|
void |
dumpDataWithFormat(java.lang.Object data,
java.io.PrintWriter outWriter)
Dump the data, either the variable value or metadata, with or without
the format.
|
Variable |
duplicate(CDF destCDF,
java.lang.String varName)
Duplicates this variable and put it into the designated CDF file.
|
Variable |
duplicate(java.lang.String varName)
Duplicates this variable to a new variable.
|
long |
getAllocatedFrom(long recNum)
Inquires the next allocated record at or after a given record for this
variable.
|
long |
getAllocatedTo(long firstRec)
Inquires the last allocated record (before the next unallocated record)
at or after a given record for this variable.
|
java.lang.Object |
getAllRecords()
Get all written records, from record number 0 till the last written
record number, from this variable.
|
CDFData |
getAllRecordsObject()
Get all written records, from record number 0 till the last written
record number, from this variable.
|
java.util.Vector |
getAttributes()
Returns the variable attributes that are associated with this
variable.
|
java.util.Map |
getAttributesandEntries()
Returns the variable attributes and their entries that are associated
with this variable.
|
java.util.Map |
getAttributesandEntries(boolean encoding)
Returns the variable attributes and their entries that are associated
with this variable.
|
long |
getBlockingFactor()
Gets the blocking factor for this variable.
|
java.lang.String |
getCompression()
Gets the string representation of the compression type and parameters
set for this variable.
|
long[] |
getCompressionParms()
Sets the compression parameters of this variable.
|
long |
getCompressionPct()
Gets the compression percentage rate of this variable.
|
long |
getCompressionType()
Gets the compression type of this variable.
|
long |
getDataType()
Gets the CDF data type of this variable.
|
long[] |
getDimSizes()
Gets the dimensions size of this variable.
|
long[] |
getDimVariances()
Gets the dimension variances for this variable.
|
java.lang.Object |
getEntryData(java.lang.String attrName)
Gets the attribute entry data for this variable.
|
java.lang.Object |
getHyperData(long recNum,
long recCount,
long recInterval,
long[] dimIndices,
long[] dimCounts,
long[] dimIntervals)
Reads one or more values from the current z variable.
|
CDFData |
getHyperDataObject(long recNum,
long recCount,
long recInterval,
long[] dimIndices,
long[] dimCounts,
long[] dimIntervals)
Reads one or more values from the current z variable.
|
long |
getID()
Gets the ID of this variable.
|
long |
getMaxAllocatedRecord()
Gets the maximum allocated record number for this variable.
|
long |
getMaxWrittenRecord()
Gets the last written record number, beginning with 0.
|
CDF |
getMyCDF()
Gets the CDF object to which this variable belongs.
|
java.lang.String |
getName()
Gets the name of this variable.
|
long |
getNumAllocatedRecords()
Gets the number of records allocated for this variable.
|
long |
getNumDims()
Gets the number of dimensions for this variable.
|
long |
getNumElements()
Gets the number of elements for this variable.
|
long |
getNumWrittenRecords()
Gets the number of records physically written (not allocated) for
this variable.
|
java.lang.Object |
getPadValue()
Gets the pad value for this variable.
|
java.lang.Object |
getRecord(long recNum)
Gets a single record from this variable.
|
CDFData |
getRecordObject(long recNum)
Get a single record of data from this variable.
|
CDFData |
getRecordsObject(long recNum,
long numRecs)
Get a number of records of data from this variable.
|
boolean |
getRecVariance()
Gets the value of record variance.
|
java.lang.Object |
getScalarData()
Gets the scalar data from a non-record varying 0-dimensional variable.
|
java.lang.Object |
getScalarData(long recNum)
Get the scalar data from a record varying 0-dimensional variable.
|
CDFData |
getScalarDataObject()
Get the scalar data from a non-record varying 0-dimensional
variable.
|
CDFData |
getScalarDataObject(long recNum)
Get the scalar data from this record varying 0-dimensional variable.
|
java.lang.Object |
getSingleData(long recNum,
long[] indices)
Gets a single data value.
|
CDFData |
getSingleDataObject(long recNum,
long[] indices)
Gets a single data object from this variable.
|
long |
getSparseRecords()
Gets the sparse record type for this variable.
|
void |
putEntry(Attribute attr,
long dataType,
java.lang.Object data)
Creates an attribute entry for this variable.
|
void |
putEntry(java.lang.String attrName,
long dataType,
java.lang.Object data)
Creates an attribute entry for this variable.
|
CDFData |
putHyperData(long recNum,
long recCount,
long recInterval,
long[] dimIndices,
long[] dimCounts,
long[] dimIntervals,
java.lang.Object data)
Writes one or more values from the current z variable.
|
CDFData |
putRecord(long recNum,
java.lang.Object data)
Adds a single record to a record-varying variable.
|
CDFData |
putRecord(java.lang.Object data)
Adds a single record to a non-record-varying variable.
|
CDFData |
putRecords(long startRec,
long recCount,
java.lang.Object data)
Writes a number of records from the current z variable.
|
CDFData |
putScalarData(long recNum,
java.lang.Object data)
Adds a scalar data to this variable (of 0 dimensional).
|
CDFData |
putScalarData(java.lang.Object data)
Adds a scalar data to this variable (of 0 dimensional).
|
CDFData |
putSingleData(long recNum,
long[] indices,
java.lang.Object data)
Adds a single data value to this variable.
|
java.util.Map |
readVariable()
Gets the full variable information, its specification, metadata and
data.
|
java.util.Map |
readVariable(boolean encoding,
boolean basic,
boolean metadata,
boolean vardata)
Gets the specified variable information: its specification, metadata
and data.
|
java.util.Map |
readVariableData()
Gets the variable's data.
|
java.util.Map |
readVariableMetaData()
Gets the variable's metadata.
|
java.util.Map |
readVariableSpec()
Gets the variable's specification.
|
void |
rename(java.lang.String newName)
Renames the current variable.
|
void |
selectCacheSize(long cacheSize)
Sets the number of 512-byte cache buffers to be used.
|
void |
selectReservePercent(long reservePercent)
Sets the reserve percentage to be used for this variable.
|
void |
setBlockingFactor(long blockingFactor)
Sets the blocking factor for this variable.
|
void |
setCompression(long cType,
long[] cParms)
Sets the compression type and parameters for this variable.
|
void |
setDimVariances(long[] dimVariances)
Sets the dimension variances for this variable.
|
void |
setInitialRecords(long nRecords)
Sets the number of records to be written initially for this variable.
|
void |
setPadValue(java.lang.Object padValue)
Sets the pad value for this variable.
|
void |
setRecVariance(long recVariance)
Sets the record variance for this variable.
|
void |
setSparseRecords(long sparseRecords)
Sets the sparse record type for this variable.
|
java.lang.String |
toString()
Gets the name of this variable.
|
void |
updateDataSpec(long dataType,
long numElements)
Update the data specification (data type and number of elements)
of the variable.
|
public static Variable create(CDF myCDF, java.lang.String varName, long dataType, long numElements, long numDims, long[] dimSizes, long recVary, long[] dimVarys) throws CDFException
The following example creates a variable called "Longitude" that is scalar (non-array) and record-varying:
longitude = Variable.create(cdf, "Longitude", CDF_INT2, 1L, 0L, new long [] {1}, VARY, new long [] {NOVARY});The following example creates a variable called "TestData" whose data is 2-dimensional (3 x 2), record variance is TURE, and dimension variances are TRUE.
data = Variable.create(cdf, "TestData", CDF_INT2, 1L, 2L, new long [] {3,2}, VARY, new long [] {VARY, VARY});
myCDF
- the CDF to which this variable belongs varName
- the name of the variable to create dataType
- the CDF data type for this variable that should be one
of the following:
numElements
- for CDF_CHAR and CDF_UCHAR this is the
string length, 1 otherwise numDims
- the dimensionality dimSizes
- The dimension sizes. An array of length numDims
indicating the size of each dimension recVary
- the record variance that should be either
VARY or NOVARY dimVarys
- The dimension variance(s). Each dimension variance
should be either VARY or NOVARY.CDFException
- if there is a problem creating a variablepublic void delete() throws CDFException
delete
in interface CDFObject
CDFException
- if there was an error deleting this variablepublic void rename(java.lang.String newName) throws CDFException
rename
in interface CDFObject
newName
- the new variable name CDFException
- if there was a problem renaming this variablepublic Variable copy(java.lang.String varName) throws CDFException
varName
- the name of the variable to copy this variable into CDFException
- if there was a problem copying a variablepublic Variable copy(CDF destCDF, java.lang.String varName) throws CDFException
destCDF
- the destination CDF into which copy this variablevarName
- the new variable nameCDFException
- if there was a problem copying a variablepublic Variable duplicate(java.lang.String varName) throws CDFException
Note: This copies everything from the existing variable to a new variable. It includes the metadata associated with this variable, all data records as well as other information such as blocking factor/compression/sparseness/pad value.
varName
- the name of the variable to duplicate this variable into CDFException
- if there was a problem duplicating a variablepublic Variable duplicate(CDF destCDF, java.lang.String varName) throws CDFException
Note: This copies everything from the current variable to a new variable. It includes the metadata associated with this variable, all data records as well as other information such as blocking factor/compression/sparseness/pad value.
destCDF
- the destination CDF to duplicate this variable into varName
- the name of the variable to duplicate this variable
into CDFException
- if there was a problem duplicating a variablepublic void copyDataRecords(Variable destVar) throws CDFException
destVar
- the destination variable to copy data into CDFException
- if there was a problem copying data records
Note: This copies data records from the current variable to
the destination variable. The metadata associated with the
destination variable will be not changed.The current CDF file MUST be saved first (by calling the save() method) before 'copying/duplicating data records' operation is performed. Otherwise the program will either fail or produce undesired results.
public void concatenateDataRecords(Variable destVar) throws CDFException
destVar
- the destination variable to copy data records into CDFException
- if there was a problem copying data records
Note: This copies only the data records from the current variable
to the destination variable. The metadata associated with the
destination variable will be not changed.public java.lang.Object getEntryData(java.lang.String attrName) throws CDFException
The following examples retrieves the 'Longitude' variable entry for the attribute VALIDMIN:
Variable var = cdf.getVariable("Longitude"); float longitude = (float) var.getEntryData("VALIDMIN");
attrName
- the name of the attribute to get entry data from CDFException
- if there was a problem getting entry datapublic java.lang.Object getSingleData(long recNum, long[] indices) throws CDFException
Let's assume that variable TestData is defined to be 1-dimensional array that has 3 elements in it. The following example extracts the last element from the second record:
Variable var = cdf.getVariable("TestData"); int data = (int) var.getSingleData(1L, new long [] {2});Let's assume that variable TestData is defined to be 2-dimensional (3x2 - 3 rows and 2 columns) array. The following example extracts the first element of the second row from the first record:
Variable var = cdf.getVariable("TestData"); int data = (int) var.getSingleData(0L, new long [] {1,0});
recNum
- the record number to retrieve data from indices
- the index, within a record, to extract data fromCDFException
- if there was a problem extracting datapublic CDFData getSingleDataObject(long recNum, long[] indices) throws CDFException
recNum
- the record number to retrieve data from indices
- the index, within a record, to extract data fromCDFException
- if there was a problem extracting datapublic java.lang.Object getRecord(long recNum) throws CDFException
Let's assume that variable TestData is defined to be 2-dimensional (3x2 - 3 rows and 2 columns). The following example extracts an entire record (containing 6 elements) from the first record from a variable of data type CDF_INT4:
Variable var = cdf.getVariable("TestData"); int[][] data = (int [][]) var.getRecord(0L);However, if a dimensional variable with all indices being invariant, e.g., 2-dimensional (1x1), the retrieved object will be different. (Since the variable has only one data value per record, it is preferred to be defined as an 0-dim, rather.). The object is not an array, instead, a single Java class item, e.g., Integer, Double, Short, etc. The following example extracts an record from the first record of a variable, 2-dim (1x1), with data type CDF_INT2:
Variable var = cdf.getVariable("TestVar"); short data = ((Short) var.getRecord(0L)).shortValue();
recNum
- the record number to retrieve data from CDFException
- if there was a problem getting a recordpublic CDFData getRecordObject(long recNum) throws CDFException
recNum
- the record number to retrieve data from CDFException
- if there was a problem getting a recordpublic CDFData getRecordsObject(long recNum, long numRecs) throws CDFException
recNum
- the record number to start to retrieve data from numRecs
- the number of records to retrieve CDFException
- if there was a problem getting the record(s)public CDFData getAllRecordsObject() throws CDFException
CDFException
- if there was a problem getting the record(s)public java.lang.Object getAllRecords() throws CDFException
CDFException
- if there was a problem getting the record(s)public java.lang.Object getScalarData() throws CDFException
CDFException
- if there was a problem getting datapublic java.lang.Object getScalarData(long recNum) throws CDFException
recNum
- The record number to retrieve data from CDFException
- if there was a problem getting datapublic CDFData getScalarDataObject() throws CDFException
CDFException
- if there was a problem getting datapublic CDFData getScalarDataObject(long recNum) throws CDFException
recNum
- the record number to retrieve data from CDFException
- if there was a problem getting datapublic java.lang.Object getHyperData(long recNum, long recCount, long recInterval, long[] dimIndices, long[] dimCounts, long[] dimIntervals) throws CDFException
Let's assume that variable TestData is defined to be 2-dimensional (3x2 - 3 rows and 2 columns). The following example extracts the entire record (containing 6 elements) from the first, second, and third records:
Variable var = cdf.getVariable("TestData"); int[][][] data = (int [][][]) var.getHyperData (0L, 3L, 1L, new long[] {0, 0}, new long[] {3, 2}, new long[] {1, 1});The following example will extract the entire record from the first record:
Variable var = cdf.getVariable("TestData"); int[][] data = (int [][]) var.getHyperData (0L, 1L, 1L, new long[] {0, 0}, new long[] {3, 2}, new long[] {1, 1});Note: it returns a 2-dimensional object as only one record is involved. The following example will extract the second row from the first, and third records:
Variable var = cdf.getVariable("TestData"); int[][] data = (int [][]) var.getHyperData (0L, 3L, 2L, new long[] {1, 0}, new long[] {1, 2}, new long[] {1, 1});The following example will extract the first column from the first and second records:
Variable var = cdf.getVariable("TestData"); int[][] data = (int [][]) var.getHyperData (0L, 2L, 1L, new long[] {0, 0}, new long[] {3, 1}, new long[] {1, 1});
recNum
- the record number at which data search begins recCount
- the number of records to read recInterval
- the number of records to skip between reads dimIndices
- the dimension index within a record at which data
search begins dimCounts
- the number of elements to read from dimIndices dimIntervals
- the number of elements to skip between reads CDFException
- if there was a problem getting datapublic CDFData getHyperDataObject(long recNum, long recCount, long recInterval, long[] dimIndices, long[] dimCounts, long[] dimIntervals) throws CDFException
recNum
- the record number at which data search beginsrecCount
- the number of records to readrecInterval
- the number of records to skip between readsdimIndices
- the dimension index within a record at which data
search beginsdimCounts
- the number of elements to read from dimIndicesdimIntervals
- the number of elements to skip between reads CDFException
- if there was a problem getting datapublic java.util.Map readVariable()
Variable v = cdf.getVariable("var1"); Map var = v.readVariable(); // Three key-value pairs will be included with keys of as // "VarSpec", "VarMetaData", "VarData" // Key: "VarSpec" contains variable specification - another Map object // These include: keys of "DataType", "NumElements", "NumDims", // "DimSizes" and "PadValue". System.out.println(" specification: "+var.get("VarSpec")); // Key: "VarMetaData" contains variable attributes - another Map object // These include variable attribute name (key) and its entry (value) System.out.println(" meta: "+var.get("VarMetaData")); // Key: "VarData" has variable data - an object System.out.println(" data:"); CDFUtils.printData(var.get("VarData"));
public java.util.Map readVariableSpec()
public java.util.Map readVariableMetaData()
public java.util.Map readVariableData()
public java.util.Map readVariable(boolean encoding, boolean basic, boolean metadata, boolean vardata)
Variable v = cdf.getVariable("var1"); Map var = v.readVariable(true, true, true, true); // Three key-value pairs might be included with keys of as // "VarSpec" and "VarMetaData" and/or "VarData" if there are data. // Key: "VarSpec" contains variable specification - another Map object // These include: keys of "DataType", "NumElements", "NumDims", // "DimSizes" and "PadValue". System.out.println(" specification: "+var.get("VarSpec")); // Key: "VarMetaData" contains variable attributes - another Map object // These include variable attribute name (key) and its entry (value) System.out.println(" meta: "+var.get("VarMetaData")); // Key: "VarData" has variable data - an object System.out.println(" data:"); CDFUtils.printData(var.get("VarData"));
encoding
- A true/false flag indicates whether to encode epoch
data type from metadata to date/time string.basic
- A true/false flag indicates whether to return the
specification of the variablemetadata
- A true/false flag indicates whether to return the
metadata from the variablevardata
- true/false flag indicates whether to return the
data from the variablepublic void putEntry(java.lang.String attrName, long dataType, java.lang.Object data) throws CDFException
The following example creates a variable entry for the variable "Longitude" associated with the attribute "VALIDMIN":
Variable longitude = cdf.getVariable("Longitude"); longitude.putEntry("VALIDMIN", CDF_INT2, new Short((short)180));
attrName
- the attribute to which this attribute entry is attacheddataType
- the CDF data type of the entry data - see the
description of the create method in this class for
a list of the CDF data types supporteddata
- the attribute entry data to be addedCDFException
- if a problem occurs putting an entryAttribute
,
Entry
public void putEntry(Attribute attr, long dataType, java.lang.Object data) throws CDFException
Variable longitude = cdf.getVariable("Longitude"); Attribute validMin = Attribute.create(cdf, "VALIDMIN", VARIABLE_SCOPE); Entry.create(validMin, longitude.getID(), CDF_INT2, new Short((short)10)); OR longitude.putEntry(validMin, CDF_INT2, new Short((short)180));
attr
- the attribute to which this attribute entry is attached dataType
- the CDF data type of the entry data - see the
description of the create method in this class for
a list of the CDF data types supporteddata
- the attribute entry data to be added CDFException
- if a problem occurs putting an entryAttribute
,
Entry
public CDFData putSingleData(long recNum, long[] indices, java.lang.Object data) throws CDFException
longitude = cdf.getVariable("Longitude"); longitude.putSingleData(0L, new long[] {1}, new Short((short)200)); or longitude.putSingleData(0L, new long[] {1}, longitudeData[1]);
recNum
- the record number to which this data belongs indices
- the index (location) in the specified record data
- the data to be added CDFException
- if there was an error writing datapublic CDFData putScalarData(long recNum, java.lang.Object data) throws CDFException
longitude = cdf.getVariable("Longitude"); longitude.putScalarData(0L, new Short((short)200)); or longitude.putScalarData(0L, longitudeData[0]);
recNum
- the record number to which this data belongs data
- the data to be added CDFException
- if there was an error writing datapublic CDFData putScalarData(java.lang.Object data) throws CDFException
longitude = cdf.getVariable("Longitude"); longitude.putScalarData(new Short((short)200)); or longitude.putScalarData(longitudeData[0]);
data
- the data to be added CDFException
- if there was an error writing datapublic CDFData putRecord(long recNum, java.lang.Object data) throws CDFException
The following example adds a scalar data to record number 0: longitude = cdf.getVariable("Longitude"); longitude.putRecord(0L, new Short((short)200)); The following example adds multiple elements (array) to record number 0: short [] longitudeData = {10, 20, 30}; longitude = cdf.getVariable("Longitude"); longitude.putRecord(0L, longitudeData);
recNum
- the record number to which this data belongs data
- the data to be added CDFException
- if there was a problem writing datapublic CDFData putRecord(java.lang.Object data) throws CDFException
The following example adds a scalar data to record number 0: longitude = cdf.getVariable("Longitude"); longitude.putRecord(new Short((short)200)); The following example adds multiple elements (array) to record number 0: short [] longitudeData = {10, 20, 30}; longitude = cdf.getVariable("Longitude"); longitude.putRecord(longitudeData);
data
- the data to be added CDFException
- if there was a problem writing datapublic CDFData putHyperData(long recNum, long recCount, long recInterval, long[] dimIndices, long[] dimCounts, long[] dimIntervals, java.lang.Object data) throws CDFException
Let's assume that variable TestData is defined to be 2-dimensional (3x2 - 3 rows and 2 columns). The following example writes the entire record (containing 6 elements) to the first, second, and third records:
long [][][] testData = {{{10,20},{30,40},{50, 60}}, {{15,25},{45,55},{75, 85}} {{90,95},{96,97},{2147483648L,4294967295L}} }; testData.putHyperData (0L, 3L, 1L, new long[] {0, 0}, new long[] {3, 2}, new long[] {1, 1}, testData);The following example will write the first two rows of testData to the first, third, and fifth records:
testData.putHyperData (0L, 3L, 2L, new long[] {0, 0}, new long[] {2, 2}, new long[] {1, 1}, testData);
recNum
- the record number at which data write begins recCount
- the number of records to write recInterval
- the number of records to skip between writes dimIndices
- the dimension index within a record at which data
write begins dimCounts
- the number of elements to write from dimIndices dimIntervals
- the number of elements to skip between writes data
- the data to be written CDFException
- if there was a problem writing datapublic CDFData putRecords(long startRec, long recCount, java.lang.Object data) throws CDFException
Let's assume that variable TestData is defined to be 2-dimensional (3x2 - 3 rows and 2 columns). The following example writes three records to the variable as the first, second, and third record:
long [][][] testData = {{{10,20},{30,40},{50, 60}}, {{15,25},{45,55},{75, 85}} {{90,95},{96,97},{2147483648L,4294967295L}} }; testData.putRecords (0L, 3L, testData);
startRec
- the starting record number at which data write begins recCount
- the number of records to write data
- the data to be written CDFException
- if there was a problem writing datapublic CDF getMyCDF()
public long getCompressionType()
public long getCompressionPct()
public long[] getCompressionParms()
public void setCompression(long cType, long[] cParms) throws CDFException
cType
- the compression typecParms
- the compression parameters that go with cTypeCDFException
- if a problem occurs setting compression
type and parameterspublic java.lang.String getCompression() throws CDFException
CDFException
- if a problem occurs getting the compression
type and parameterspublic long getNumDims()
public long[] getDimSizes()
public long getNumElements()
public java.lang.String getName()
public long getID()
public java.lang.String toString()
toString
in class java.lang.Object
public void setRecVariance(long recVariance) throws CDFException
recVariance
- the record variance that should be either
VARY or NOVARY. CDFException
- if a problem occurs setting the record
variancepublic boolean getRecVariance()
public void setDimVariances(long[] dimVariances) throws CDFException
dimVariances
- the dimension variances for this variable CDFException
- if a problem occurs setting the
dimension variancespublic long[] getDimVariances()
public long getDataType()
public void deleteRecords(long firstRec, long lastRec) throws CDFException
firstRec
- the first record to be deletedlastRec
- the last record to be deleted CDFException
- if a problem occurs deleting recordspublic void deleteRecordsRenumber(long firstRec, long lastRec) throws CDFException
firstRec
- the first record to be deletedlastRec
- the last record to be deleted CDFException
- if a problem occurs deleting recordspublic void allocateBlock(long firstRec, long lastRec) throws CDFException
firstRec
- the first record to be allocatedlastRec
- the last record to be allocated CDFException
- if a problem occurs allocating recordspublic void allocateRecords(long num0toRecords) throws CDFException
num0toRecords
- the number of records to be allocated CDFException
- if a problem occurs allocating recordspublic long getNumWrittenRecords() throws CDFException
CDFException
- if a problem occurs getting the number
of records written physicallypublic long getMaxWrittenRecord() throws CDFException
CDFException
- if a problem occurs getting the last
written record numberpublic long getNumAllocatedRecords() throws CDFException
CDFException
- if a problem occurs getting the
number of records allocatedpublic long getMaxAllocatedRecord() throws CDFException
CDFException
- if a problem occurs getting the
maximum allocated record numberpublic void setPadValue(java.lang.Object padValue) throws CDFException
padValue
- the pad value to be used for undefined values CDFException
- if a problem occurs setting the pad valuepublic boolean checkPadValueExistence() throws CDFException
CDFException
- if a problem occurs checking the existence of the
pad value
Note: The getPadValue() method will return a pad value, whether it is
the user defined or the default.public java.lang.Object getPadValue() throws CDFException
CDFException
- if a problem occurs reading the pad valuepublic void setSparseRecords(long sparseRecords) throws CDFException
sparseRecords
- sparse record type that should be one of the
following types:
CDFException
- if a problem occurs setting the sparse
record typepublic long getSparseRecords()
public void setBlockingFactor(long blockingFactor) throws CDFException
blockingFactor
- the blocking factor - a value of zero (0)
indicates that the default blocking
factor should be used CDFException
- if a problem occurs setting the blocking factorpublic long getBlockingFactor() throws CDFException
CDFException
- if a problem occurs getting the blocking
factor set for this variablepublic void setInitialRecords(long nRecords) throws CDFException
nRecords
- the number of records to be written initially CDFException
- if a problem occurs writing initial recordspublic void selectCacheSize(long cacheSize) throws CDFException
cacheSize
- the number of 512-byte cache buffers CDFException
- if a problem occurs allocating cache bufferspublic long confirmCacheSize() throws CDFException
CDFException
- if a problem occurs getting the number
of cache buffers set for this variablepublic void selectReservePercent(long reservePercent) throws CDFException
reservePercent
- the reserve percentage to be usedCDFException
- if a problem occurs setting a reserve
percentagepublic long confirmReservePercent() throws CDFException
CDFException
- if a problem occurs getting the reserve
percentagepublic long confirmPadValue() throws CDFException
CDFException
- if a problem occurs checking the
existence of pad value.
Note: for NO_PADVALUE_SPECIFIED, getPadValue method will return the
default pad value.public long getAllocatedFrom(long recNum) throws CDFException
recNum
- The record number at which to begin searching for the
next allocated record. If this record exists, it will
be considered the next allocated record. CDFException
- if a problem occurs getting the number
of the next allocated recordpublic long getAllocatedTo(long firstRec) throws CDFException
firstRec
- the record number at which to begin searching for the
last allocated record CDFException
- if a problem occurs getting the number
of the last allocated recordpublic void updateDataSpec(long dataType, long numElements) throws CDFException
dataType
- the data type of the entry datanumElements
- the number of elements fo the entry dataCDFException
- An exception is thrown if the operation failspublic java.util.Vector getAttributes()
The following example describes how to retrieve all the variable attributes that are associated with a particular variable. Variable v = cdf.getVariable("myVariable"); Vector attrs = v.getAttributes(); if (attrs.size() > 0) { for (Enumeration e=attrs.elements(); e.hasMoreElements();) { Attribute a = (Attribute) e.nextElement(); // manipulate the attribute } }
public java.util.Map getAttributesandEntries()
The following example describes how to retrieve all the variable attributes and their entries that are associated with a particular variable. Variable v = cdf.getVariable("myVariable"); Map vaes = v.getAttributesandEntries(); if (vaes != null) { for (Object key : vaes.keySet()) { System.oit.println("Attribute:"+key+" entry:"+vaes.get(key)); } }Note: Each attribute's entry, an object, can be a single data or an array of values. CDF Epoch type data will be encoded in date/time string.
public java.util.Map getAttributesandEntries(boolean encoding)
The following example describes how to retrieve all the variable attributes and their entries that are associated with a particular variable. Variable v = cdf.getVariable("myVariable"); Map vaes = v.getAttributesandEntries(true); if (vaes != null) { for (Object key : vaes.keySet()) { System.oit.println("Attribute:"+key+" entry:"+vaes.get(key)); } }Note: Each attribute's entry, an object, can be a single data or an array of values.
encoding
- A true/false flag indicates whether to encode epoch
type data to date/time string.public void dumpDataWithFormat(java.lang.Object data)
data
- An object, likely an attribute entry, for outputpublic void dumpDataWithFormat(java.lang.Object data, java.io.PrintWriter outWriter)
data
- An object, likely an attribute entry, for outputoutWriter
- the print writer to which formatted representations
of the object/data is printed as a text-output streampublic void dumpDataWithFormat(CDFData data)
data
- A CDFData object, likely variable data, for output