public class CDF extends Object
Constructor and Description |
---|
CDF()
A container of information about a CDF file.
|
CDF(RandomAccessFile in)
Parse a CDF file.
|
CDF(String pathname)
Parse a CDF file.
|
Modifier and Type | Method and Description |
---|---|
void |
dump(boolean showAttributes,
boolean showVariables)
Display a description of each attribute or variable.
|
void |
dumpVariable(String varName)
Display a description of a variable.
|
ADRecord |
getADR(long index)
Retrieve a
ADRecord with the given index. |
AEDRecord |
getAEDR(long index)
Retrieve a
AEDRecord with the given index. |
Attribute |
getAttribute(String name)
Retrieve the description of a global attribute with the given name.
|
ArrayList<Attribute> |
getAttributes()
Retrieve the description of each global attribute defined in the CDF.
|
String |
getAttributeValue(String name)
Retrieve the value of a global attribute with the given name.
|
String |
getAttributeValue(String name,
String delim)
Retrieve the value of a global attribute with the given name.
|
ArrayList<String> |
getAttributeValues(ADRecord adr)
Retrieve all values for an attribute.
|
ArrayList<String> |
getAttributeValues(String name)
Retrieve all values for an attribute given the attribute name.
|
String |
getByteOrder()
Return a name for the defined byte order.
|
CDRecord |
getCDR()
Retrieve the
CDRecord for the CDF. |
int |
getCompression()
Retrieve the compression value declared in the CDF.
|
String |
getDataTypeName(int dataType)
Retrieve the CDF name for the data type.
|
String |
getDataTypePDS(int dataType)
Retrieve the PDS name for the data type.
|
String |
getDataTypePDS(int dataType,
int encoding)
Retrieve the PDS name for the data type.
|
ArrayList<Variable> |
getDataVariables()
Retrieve the description of each variable which has the VAR_TYPE attribute of "data".
|
int |
getEncoding()
Return a numeric value for the defined encoding.
|
String |
getEncodingName()
Return a name for the defined encoding.
|
GDRecord |
getGDR()
Retrieve the
GDRecord for the CDF. |
ADRecord |
getGlobalAttribute(String name)
Retrieve the ADRecord for the global attribute with the given name.
|
ArrayList<String> |
getGlobalAttributeNames()
Retrieve a list of all global attribute names.
|
HashMap<String,Object> |
getHashMap()
Generate a nested HashMap for the CDF file that includes file information.
|
long |
getOffset()
Retrieve the current offset value.
|
String |
getPathName()
Retrieve the current pathname value.
|
ArrayList<Record> |
getRecordList()
Retrieve a list of all records defined in the CDF.
|
UIRecord |
getUIR(long index)
Retrieve a UIRecord with the given index.
|
Variable |
getVariable(String name)
Retrieve the
VDRecord for the variable with the given name. |
ADRecord |
getVariableAttribute(String name)
Retrieve the
ADRecord for the variable attribute with the given name. |
ArrayList<String> |
getVariableAttributeNames()
Retrieve a list of all variable attribute names.
|
ArrayList<String> |
getVariableNames()
Retrieve a list of all variable names.
|
VDRecord |
getVariableRecord(String name)
Retrieve the
VDRecord for the variable with the given name. |
ArrayList<Variable> |
getVariables()
Retrieve the description of each variable defined in the CDF.
|
long |
getVariableStartByte(String name)
Retrieve the start byte of the data for a variable with a given name.
|
long |
getVariableStartByte(VDRecord vdr)
Retrieve the start byte of the data for a variable using the
VDRecord for the variable. |
VDRecord |
getVDR(long index)
Retrieve a VDRecord with the given index.
|
boolean |
getVerbose()
Return the current verbose state.
|
int |
getVersion()
Retrieve the version number declared in the CDF.
|
VVRecord |
getVVR(long index)
Retrieve a VXRecord with the given index.
|
VXRecord |
getVXR(long index)
Retrieve a VXRecord with the given index.
|
boolean |
hasSparseness()
Determine if any data is sparse.
|
boolean |
isCompressed()
Determine if the CDF is compressed.
|
static void |
main(String[] args)
Parse and view information about a CDF file from the command line.
|
void |
parse(RandomAccessFile in)
Parse a CDF file.
|
void |
readDataValues(RandomAccessFile in,
Variable var,
int start,
int stop) |
Record |
readRecord(RandomAccessFile in)
Read a CDF record from the input stream.
|
String |
setAttributeValue(String name,
String value)
Set the value of a global attribute with the given name.
|
void |
setOffset(long offset)
Set the offset value used maintained during the parsing of the CDF file.
|
boolean |
setVerbose(boolean state)
Set the verbose state.
|
void |
showHelp()
Display help information.
|
public CDF()
public CDF(String pathname) throws IOException
pathname
- the file system path and file name to a CDF file.IOException
public CDF(RandomAccessFile in) throws IOException
in
- pre-opened RandomAccessFile
to a CDF file.IOException
public static void main(String[] args)
args
- command line argumentspublic void showHelp()
public void parse(RandomAccessFile in) throws IOException
in
- pre-opened RandomAccessFile
to a CDF file.IOException
public void readDataValues(RandomAccessFile in, Variable var, int start, int stop) throws IOException
IOException
public Record readRecord(RandomAccessFile in) throws IOException
in
- A pre-opened (@link RandomAccessFile}.Record
containing the information parsed from the input stream.IOException
public ADRecord getADR(long index)
ADRecord
with the given index.index
- the file offset as defined in the CDF file.ADRecord
or null if none found.public AEDRecord getAEDR(long index)
AEDRecord
with the given index.index
- the file offset as defined in the CDF file.AEDRecord
or null if none found.public VDRecord getVDR(long index)
index
- the file offset as defined in the CDF file.VDRecord
or null if none found.public VXRecord getVXR(long index)
index
- the file offset as defined in the CDF file.VXRecord
or null if none found.public UIRecord getUIR(long index)
index
- the file offset as defined in the CDF file.UIRecord
or null if none found.public VVRecord getVVR(long index)
index
- the file offset as defined in the CDF file.VVRecord
or null if none found.public ArrayList<String> getAttributeValues(String name)
name
- the attribute name.public ArrayList<String> getAttributeValues(ADRecord adr)
adr
- The ADRecord for this attributepublic ArrayList<String> getGlobalAttributeNames()
ArrayList
containing names of all global attributes.public ADRecord getGlobalAttribute(String name)
name
- the attribute name.ADRecord
associated with the name or null if no attribute exists.public ArrayList<String> getVariableAttributeNames()
ArrayList
containing names of all variable attributes.public ADRecord getVariableAttribute(String name)
ADRecord
for the variable attribute with the given name.ADRecord
associated with the name or null if no attribute exists.public ArrayList<String> getVariableNames()
ArrayList
of names.public VDRecord getVariableRecord(String name)
VDRecord
for the variable with the given name.name
- the name associated with the variable.VDRecord
associated with the name or null if no variable exists.public long getVariableStartByte(String name)
public long getVariableStartByte(VDRecord vdr)
VDRecord
for the variable.public HashMap<String,Object> getHashMap()
HashMap
is a keyword, value map. Each OBJECT is stored
in a ArrayList with a HashMap of the object. The value assigned
to the OBJECT keyword is mapped to "OBJECT_NAME" in the HashMap
.
The first file referenced by an object pointer is assigned to "PRODUCT_FILE"
and the MD5 checksum for the file is assigned to "PRODUCT_MD5".public void dump(boolean showAttributes, boolean showVariables)
showAttributes
- if true show attributes, otherwise do not.showVariables
- if true show variables, otherwise do not.public void dumpVariable(String varName)
showAttributes
- if true show attributes, otherwise do not.showVariables
- if true show variables, otherwise do not.public boolean hasSparseness()
public int getVersion()
public int getCompression()
public boolean isCompressed()
public void setOffset(long offset)
offset
- the offset in bytes.public long getOffset()
public String getPathName()
public CDRecord getCDR()
CDRecord
for the CDF.CDRecord
for the CDF.public GDRecord getGDR()
GDRecord
for the CDF.GDRecord
for the CDF.public ArrayList<Attribute> getAttributes()
public Attribute getAttribute(String name)
name
- the name of the attributeAttribute
with the matching name or NULL if none found.public String getAttributeValue(String name)
name
- the name of the attributepublic String getAttributeValue(String name, String delim)
name
- the name of the attributedelim
- the delimiter string to place between values.public String setAttributeValue(String name, String value)
name
- the name of the attributevalue
- the value to set.public Variable getVariable(String name)
VDRecord
for the variable with the given name.name
- the name associated with the variable.VDRecord
associated with the name or null if no variable exists.public ArrayList<Variable> getVariables()
public ArrayList<Variable> getDataVariables()
public ArrayList<Record> getRecordList()
public String getDataTypePDS(int dataType, int encoding)
dataType
- encoding
- public String getDataTypePDS(int dataType)
dataType
- public String getDataTypeName(int dataType)
dataType
- public String getByteOrder()
public int getEncoding()
public String getEncodingName()
public boolean setVerbose(boolean state)
state
- true to turn verbose mode on, otherwise false.public boolean getVerbose()
Copyright © 2014-2015 Regents University of California. All Rights Reserved.