Package ucar.nc2.dods
Class DODSNetcdfFile
- java.lang.Object
-
- ucar.nc2.NetcdfFile
-
- ucar.nc2.dods.DODSNetcdfFile
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ucar.nc2.util.cache.FileCacheable
@NotThreadSafe public class DODSNetcdfFile extends ucar.nc2.NetcdfFileAccess to DODS datasets through the Netcdf API.- See Also:
NetcdfFile
-
-
Field Summary
Fields Modifier and Type Field Description static booleandebugAttributesstatic booleandebugCachedstatic booleandebugCEstatic booleandebugCharArraystatic booleandebugConstructstatic booleandebugConvertDatastatic booleandebugDataResultstatic booleandebugOpenResultstatic booleandebugOpenTimestatic booleandebugPreloadstatic booleandebugServerCallstatic booleandebugTimestatic booleanshowNCfile-
Fields inherited from class ucar.nc2.NetcdfFile
cache, dimensions, gattributes, id, iosp, IOSP_MESSAGE_ADD_RECORD_STRUCTURE, IOSP_MESSAGE_CONVERT_RECORD_STRUCTURE, IOSP_MESSAGE_GET_NETCDF_FILE_FORMAT, IOSP_MESSAGE_RANDOM_ACCESS_FILE, IOSP_MESSAGE_REMOVE_RECORD_STRUCTURE, location, rootGroup, title, variables
-
-
Constructor Summary
Constructors Constructor Description DODSNetcdfFile(String datasetURL)Open a DODS file.DODSNetcdfFile(String datasetURL, ucar.nc2.util.CancelTask cancelTask)Open a DODS file, allow user control over preloading string arrays and making structure data available through netcdf API.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringcanonicalURL(String urlName)Create the canonical form of the URL.voidclose()protected static ucar.nc2.AttributecombineAxesAttrs(ucar.nc2.Attribute axis1, ucar.nc2.Attribute axis2)Safely combine the multiple axis attributes without duplicationstatic intconvertToDODSType(ucar.ma2.DataType dataType)Get the DODS data class corresponding to the Netcdf data type.static ucar.ma2.DataTypeconvertToNCType(int dodsDataType, boolean isUnsigned)Get the Netcdf data type corresponding to the DODS data type.static ucar.ma2.DataTypeconvertToNCType(BaseType dtype, boolean isUnsigned)Get the Netcdf data type corresponding to the DODS BaseType class.voidgetDetailInfo(Formatter f)static StringgetDODSConstraintName(ucar.nc2.Variable var)Return a variable name suitable for use in a DAP constraint expression.StringgetFileTypeDescription()StringgetFileTypeId()static booleanisUnsigned(BaseType dtype)Get whether this is an unsigned type.protected int[]makeShape(DArray dodsArray)protected ucar.ma2.ArrayreadData(ucar.nc2.Variable v, ucar.ma2.Section section)ucar.ma2.ArrayreadSection(String variableSection)longreadToByteChannel(ucar.nc2.Variable v, ucar.ma2.Section section, WritableByteChannel channel)ucar.ma2.ArrayreadWithCE(ucar.nc2.Variable v, String CE)protected voidreGroup()Go thru the variables/structure-variables and their attributes and move to the proper groups.protected voidreGroupVariable(ucar.nc2.Group rootgroup, DODSVariable dodsv)Deprecated.static voidsetAllowCompression(boolean b)Set whether to allow messages to be compressed.static voidsetAllowDeflate(boolean b)Deprecated.use setAllowCompressionstatic voidsetAllowSessions(boolean b)Set whether to allow sessions by allowing cookies.static voidsetCoordinateVariablePreloadSize(int size)If preloading, set maximum size of coordinate variables to be preloaded.static voidsetDebugFlags(ucar.nc2.util.DebugFlags debugFlag)Debugging flags.static voidsetPreload(boolean b)Set whether small variables are preloaded; only turn off for debugging.-
Methods inherited from class ucar.nc2.NetcdfFile
addAttribute, addAttribute, addDimension, addGroup, addLocalFieldsToBuilder, addStringVariable, addVariable, addVariable, addVariableAttribute, builder, canonicalizeUriString, canOpen, empty, findAttribute, findAttValueIgnoreCase, findDimension, findGlobalAttribute, findGlobalAttributeIgnoreCase, findGroup, findVariable, findVariable, findVariableByAttribute, finish, getCacheName, getDetailInfo, getDimensions, getFileTypeVersion, getGlobalAttributes, getId, getIosp, getLastModified, getLocation, getRootGroup, getStructureIterator, getTitle, getUnlimitedDimension, getVariables, hasUnlimitedDimension, iospDeRegister, iospRegistered, makeFullName, makeFullName, makeFullNameSectionSpec, makeFullNameWithString, makeNameUnescaped, makeRecordStructure, makeValidCDLName, makeValidCdmObjectName, makeValidPathName, makeValidSectionSpecName, open, open, open, open, open, open, openInMemory, openInMemory, openInMemory, openInMemory, reacquire, read, readArrays, readAttributeDouble, readAttributeInteger, readToOutputStream, registerIOProvider, registerIOProvider, registerIOProvider, registerIOProviderPreferred, release, removeDimension, removeRecordStructure, removeVariable, sendIospMessage, setCacheName, setFileCache, setId, setImmutable, setLocation, setProperty, setRootGroup, setTitle, showCached, showProxies, syncExtend, toBuilder, toNcml, toString, toStringDebug, writeCDL, writeCDL, writeCDL, writeNcml, writeNcml
-
-
-
-
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 errorMalformedURLException
-
DODSNetcdfFile
public DODSNetcdfFile(String datasetURL, ucar.nc2.util.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 errorMalformedURLException
-
-
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 setAllowCompressionSet 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(ucar.nc2.util.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:" or "https:", change it to start with "dods:", otherwise leave it alone.- Parameters:
urlName- the url string- Returns:
- canonical form
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceucar.nc2.util.cache.FileCacheable- Overrides:
closein classucar.nc2.NetcdfFile- Throws:
IOException
-
reGroup
protected void reGroup() throws DAP2ExceptionGo thru the variables/structure-variables and their attributes and move to the proper groups.- Throws:
DAP2Exception
-
reGroupVariable
@Deprecated protected void reGroupVariable(ucar.nc2.Group rootgroup, DODSVariable dodsv)
Deprecated.
-
combineAxesAttrs
protected static ucar.nc2.Attribute combineAxesAttrs(ucar.nc2.Attribute axis1, ucar.nc2.Attribute axis2)Safely combine the multiple axis attributes without duplication- Parameters:
axis1- axis attribute 1axis2- axis attribute 2- Returns:
- the combined axis attribute
-
makeShape
protected int[] makeShape(DArray dodsArray)
-
getDODSConstraintName
public static String getDODSConstraintName(ucar.nc2.Variable var)
Return a variable name suitable for use in a DAP constraint expression. [Original code seemed wrong because structures can be nested and hence would have to use the full name just like non-structures]- Parameters:
var- The variable whose name will appear in the CE- Returns:
- The name in a form suitable for use in a cE
-
convertToDODSType
public static int convertToDODSType(ucar.ma2.DataType dataType)
Get the DODS data class corresponding to the Netcdf data type. This is the inverse of convertToNCType().- Parameters:
dataType- Netcdf data type.- Returns:
- the corresponding DODS type enum, from opendap.dap.Attribute.XXXX.
-
convertToNCType
public static ucar.ma2.DataType convertToNCType(int dodsDataType, boolean isUnsigned)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(opendap.dap.BaseType)
-
convertToNCType
public static ucar.ma2.DataType convertToNCType(BaseType dtype, boolean isUnsigned)
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(opendap.dap.BaseType)
-
isUnsigned
public static boolean isUnsigned(BaseType dtype)
Get whether this is an unsigned type.- Parameters:
dtype- DODS BaseType.- Returns:
- true if unsigned
-
readSection
public ucar.ma2.Array readSection(String variableSection) throws IOException, ucar.ma2.InvalidRangeException
- Overrides:
readSectionin classucar.nc2.NetcdfFile- Throws:
IOExceptionucar.ma2.InvalidRangeException
-
readData
protected ucar.ma2.Array readData(ucar.nc2.Variable v, ucar.ma2.Section section) throws IOException, ucar.ma2.InvalidRangeException- Overrides:
readDatain classucar.nc2.NetcdfFile- Throws:
IOExceptionucar.ma2.InvalidRangeException
-
readToByteChannel
public long readToByteChannel(ucar.nc2.Variable v, ucar.ma2.Section section, WritableByteChannel channel) throws IOException, ucar.ma2.InvalidRangeException- Overrides:
readToByteChannelin classucar.nc2.NetcdfFile- Throws:
IOExceptionucar.ma2.InvalidRangeException
-
readWithCE
public ucar.ma2.Array readWithCE(ucar.nc2.Variable v, String CE) throws IOException- Throws:
IOException
-
getDetailInfo
public void getDetailInfo(Formatter f)
- Overrides:
getDetailInfoin classucar.nc2.NetcdfFile
-
getFileTypeId
public String getFileTypeId()
- Overrides:
getFileTypeIdin classucar.nc2.NetcdfFile
-
getFileTypeDescription
public String getFileTypeDescription()
- Overrides:
getFileTypeDescriptionin classucar.nc2.NetcdfFile
-
-