ucar.nc2.dods
Class DODSNetcdfFile

java.lang.Object
  extended by ucar.nc2.NetcdfFile
      extended by ucar.nc2.dods.DODSNetcdfFile
All Implemented Interfaces:
FileCacheable

public class DODSNetcdfFile
extends NetcdfFile

Access to DODS datasets through the Netcdf API.

Author:
caron
See Also:
NetcdfFile

Field Summary
static boolean debugAttributes
           
static boolean debugCached
           
static boolean debugCE
           
static boolean debugCharArray
           
static boolean debugConstruct
           
static boolean debugConvertData
           
static boolean debugDataResult
           
static boolean debugOpenResult
           
static boolean debugOpenTime
           
static boolean debugPreload
           
static boolean debugServerCall
           
static boolean debugTime
           
static boolean showNCfile
           
 
Fields inherited from class ucar.nc2.NetcdfFile
cache, cacheName, debugCompress, debugSPI, dimensions, gattributes, id, IOSP_MESSAGE_ADD_RECORD_STRUCTURE, IOSP_MESSAGE_CONVERT_RECORD_STRUCTURE, IOSP_MESSAGE_RANDOM_ACCESS_FILE, IOSP_MESSAGE_REMOVE_RECORD_STRUCTURE, location, reserved, reservedCdl, reservedSectionSpec, rootGroup, showRequest, spi, title, unlocked, variables
 
Constructor Summary
DODSNetcdfFile(String datasetURL)
          Open a DODS file.
DODSNetcdfFile(String datasetURL, CancelTask cancelTask)
          Open a DODS file, allow user control over preloading string arrays and making structure data available through netcdf API.
 
Method Summary
static String canonicalURL(String urlName)
          Create the canonical form of the URL.
 void close()
          Close all resources (files, sockets, etc) associated with this file.
static int convertToDODSType(DataType dataType, boolean isUnsigned)
          Get the DODS data class corresponding to the Netcdf data type.
static DataType convertToNCType(BaseType dtype)
          Get the Netcdf data type corresponding to the DODS BaseType class.
static DataType convertToNCType(int dodsDataType)
          Get the Netcdf data type corresponding to the DODS data type.
 void getDetailInfo(Formatter f)
           
static String getDODSshortName(Variable var)
           
 String getFileTypeDescription()
          Get a human-readable description for this file type.
 String getFileTypeId()
          Get the file type id for the underlying data source.
static boolean isUnsigned(BaseType dtype)
          Get whether this is an unsigned type.
static boolean isUnsigned(int dodsDataType)
          Get whether this is an unsigned type.
static void main(String[] arg)
           
protected  int[] makeShape(DArray dodsArray)
           
 List<Array> readArrays(List<Variable> preloadVariables)
          Make a single call to the DODS Server to read all the named variable's data in one client/server roundtrip.
protected  Array readData(Variable v, Section section)
           
 Array readSection(String variableSection)
          Read a variable using the given section specification.
 long readToByteChannel(Variable v, Section section, WritableByteChannel channel)
          Read data from a top level Variable and send data to a WritableByteChannel.
 Array readWithCE(Variable v, String CE)
           
static void setAllowCompression(boolean b)
          Set whether to allow messages to be compressed.
static void setAllowDeflate(boolean b)
          Deprecated. use setAllowCompression
static void setAllowSessions(boolean b)
          Set whether to allow sessions by allowing cookies.
static void setCoordinateVariablePreloadSize(int size)
          If preloading, set maximum size of coordinate variables to be preloaded.
static void setDebugFlags(DebugFlags debugFlag)
          Debugging flags.
static void setPreload(boolean b)
          Set whether small variables are preloaded; only turn off for debugging.
 boolean sync()
          Check if file has changed, and reread metadata if needed.
 
Methods inherited from class ucar.nc2.NetcdfFile
addAttribute, addDimension, addGroup, addStringVariable, addVariable, addVariable, addVariableAttribute, canOpen, empty, escapeName, escapeNameCDL, escapeNameSectionSpec, findAttValueIgnoreCase, findDimension, findGlobalAttribute, findGlobalAttributeIgnoreCase, findGroup, findVariable, finish, getCacheName, getDetailInfo, getDimensions, getFileTypeVersion, getGlobalAttributes, getId, getIosp, getLocation, getRootGroup, getStructureIterator, getTitle, getUnlimitedDimension, getVariables, hasUnlimitedDimension, isUnlocked, makeFullName, makeFullName, makeFullNameEscaped, makeFullNameEscapedSectionSpec, makeFullNameWithString, makeRecordStructure, makeRootGroup, makeValidCdmObjectName, open, open, open, open, open, openInMemory, openInMemory, openInMemory, openInMemory, read, readAttributeDouble, readAttributeInteger, registerIOProvider, registerIOProvider, removeDimension, removeRecordStructure, removeVariable, sendIospMessage, setCacheName, setFileCache, setId, setImmutable, setLocation, setProperty, setTitle, showCached, showProxies, syncExtend, toString, toStringDebug, toStringEnd, toStringStart, unescapeName, writeCDL, writeCDL, writeNcML, writeNcML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debugCE

public static boolean debugCE

debugServerCall

public static boolean debugServerCall

debugOpenResult

public static boolean debugOpenResult

debugDataResult

public static boolean debugDataResult

debugCharArray

public static boolean debugCharArray

debugConvertData

public static boolean debugConvertData

debugConstruct

public static boolean debugConstruct

debugPreload

public static boolean debugPreload

debugTime

public static boolean debugTime

showNCfile

public static boolean showNCfile

debugAttributes

public static boolean debugAttributes

debugCached

public static boolean debugCached

debugOpenTime

public static boolean debugOpenTime
Constructor Detail

DODSNetcdfFile

public DODSNetcdfFile(String datasetURL)
               throws IOException
Open a DODS file.

Parameters:
datasetURL - URL of the file. This should start with the protocol "dods:" It may also start with protocol "http:".
Throws:
IOException - on io error
MalformedURLException

DODSNetcdfFile

public DODSNetcdfFile(String datasetURL,
                      CancelTask cancelTask)
               throws IOException
Open a DODS file, allow user control over preloading string arrays and making structure data available through netcdf API.

Parameters:
datasetURL - URL of the file. This should start with the protocol "dods:" or "http:".
cancelTask - check if task is cancelled. may be null.
Throws:
IOException - on io error
MalformedURLException
Method Detail

setAllowSessions

public static void setAllowSessions(boolean b)
Set whether to allow sessions by allowing cookies. This only affects requests to the TDS. Setting this to true can eliminate consistency problems for datasets that are being updated.

Parameters:
b - true or false. default is false.

setAllowDeflate

public static void setAllowDeflate(boolean b)
Deprecated. use setAllowCompression

Set whether to allow messages to be compressed.

Parameters:
b - true or false.

setAllowCompression

public static void setAllowCompression(boolean b)
Set whether to allow messages to be compressed.

Parameters:
b - true or false.

setDebugFlags

public static void setDebugFlags(DebugFlags debugFlag)
Debugging flags. This is a way to decouple setting flags from particular implementations.

Parameters:
debugFlag - set of debug flags.

setPreload

public static void setPreload(boolean b)
Set whether small variables are preloaded; only turn off for debugging.

Parameters:
b - true if small variables are preloaded (default true)

setCoordinateVariablePreloadSize

public static void setCoordinateVariablePreloadSize(int size)
If preloading, set maximum size of coordinate variables to be preloaded.

Parameters:
size - maximum size of coordinate variables to be preloaded.

canonicalURL

public static String canonicalURL(String urlName)
Create the canonical form of the URL. If the urlName starts with "http:", change it to start with "dods:", otherwise leave it alone.

Parameters:
urlName - the url string
Returns:
canonical form

close

public void close()
           throws IOException
Description copied from class: NetcdfFile
Close all resources (files, sockets, etc) associated with this file. If the underlying file was acquired, it will be released, otherwise closed. if isClosed() already, nothing will happen

Specified by:
close in interface FileCacheable
Overrides:
close in class NetcdfFile
Throws:
IOException

sync

public boolean sync()
             throws IOException
Description copied from class: NetcdfFile
Check if file has changed, and reread metadata if needed. All previous object references (variables, dimensions, etc) may become invalid - you must re-obtain. DO NOT USE THIS ROUTINE YET - NOT FULLY TESTED

Specified by:
sync in interface FileCacheable
Overrides:
sync in class NetcdfFile
Returns:
true if file was changed.
Throws:
IOException - if error

makeShape

protected int[] makeShape(DArray dodsArray)

getDODSshortName

public static String getDODSshortName(Variable var)

convertToDODSType

public static int convertToDODSType(DataType dataType,
                                    boolean isUnsigned)
Get the DODS data class corresponding to the Netcdf data type. This is the inverse of convertToNCType().

Parameters:
dataType - Netcdf data type.
isUnsigned - if its unsigned
Returns:
the corresponding DODS type enum, from opendap.dap.Attribute.XXXX.

convertToNCType

public static DataType convertToNCType(int dodsDataType)
Get the Netcdf data type corresponding to the DODS data type. This is the inverse of convertToDODSType().

Parameters:
dodsDataType - DODS type enum, from dods.dap.Attribute.XXXX.
Returns:
the corresponding netcdf DataType.
See Also:
isUnsigned(int)

isUnsigned

public static boolean isUnsigned(int dodsDataType)
Get whether this is an unsigned type.

Parameters:
dodsDataType - DODS type enum, from dods.dap.Attribute.XXXX.
Returns:
true if unsigned

convertToNCType

public static DataType convertToNCType(BaseType dtype)
Get the Netcdf data type corresponding to the DODS BaseType class. This is the inverse of convertToDODSType().

Parameters:
dtype - DODS BaseType.
Returns:
the corresponding netcdf DataType.
See Also:
isUnsigned(int)

isUnsigned

public static boolean isUnsigned(BaseType dtype)
Get whether this is an unsigned type.

Parameters:
dtype - DODS BaseType.
Returns:
true if unsigned

readArrays

public List<Array> readArrays(List<Variable> preloadVariables)
                       throws IOException
Make a single call to the DODS Server to read all the named variable's data in one client/server roundtrip.

Overrides:
readArrays in class NetcdfFile
Parameters:
preloadVariables - list of type Variable
Returns:
list of type Array, contains the data
Throws:
IOException - on error

readSection

public Array readSection(String variableSection)
                  throws IOException,
                         InvalidRangeException
Description copied from class: NetcdfFile
Read a variable using the given section specification. The result is always an array of the type of the innermost variable. Its shape is the accumulation of all the shapes of its parent structures.

Overrides:
readSection in class NetcdfFile
Parameters:
variableSection - the constraint expression.
Returns:
data requested
Throws:
IOException - if error
InvalidRangeException - if variableSection is invalid
See Also:
SectionSpecification

readData

protected Array readData(Variable v,
                         Section section)
                  throws IOException,
                         InvalidRangeException
Overrides:
readData in class NetcdfFile
Throws:
IOException
InvalidRangeException

readToByteChannel

public long readToByteChannel(Variable v,
                              Section section,
                              WritableByteChannel channel)
                       throws IOException,
                              InvalidRangeException
Description copied from class: NetcdfFile
Read data from a top level Variable and send data to a WritableByteChannel. Experimental.

Overrides:
readToByteChannel in class NetcdfFile
Parameters:
v - a top-level Variable
section - the section of data to read. There must be a Range for each Dimension in the variable, in order. Note: no nulls allowed. IOSP may not modify.
channel - write data to this WritableByteChannel
Returns:
the number of bytes written to the channel
Throws:
IOException - if read error
InvalidRangeException - if invalid section

readWithCE

public Array readWithCE(Variable v,
                        String CE)
                 throws IOException
Throws:
IOException

getDetailInfo

public void getDetailInfo(Formatter f)
Overrides:
getDetailInfo in class NetcdfFile

getFileTypeId

public String getFileTypeId()
Description copied from class: NetcdfFile
Get the file type id for the underlying data source.

Overrides:
getFileTypeId in class NetcdfFile
Returns:
registered id of the file type
See Also:
"http://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"

getFileTypeDescription

public String getFileTypeDescription()
Description copied from class: NetcdfFile
Get a human-readable description for this file type.

Overrides:
getFileTypeDescription in class NetcdfFile
Returns:
description of the file type
See Also:
"http://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"

main

public static void main(String[] arg)


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.