Package ucar.nc2.write
Class NetcdfFormatWriter.Builder
- java.lang.Object
-
- ucar.nc2.write.NetcdfFormatWriter.Builder
-
- Enclosing class:
- NetcdfFormatWriter
public static class NetcdfFormatWriter.Builder extends Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NetcdfFormatWriter.Builder
addAttribute(Attribute att)
Add a global attributeDimension
addDimension(String dimName, int length)
Add a dimension to the root group.Dimension
addDimension(Dimension dim)
Add a dimension to the root group.Structure.Builder
addStructure(String shortName, String dimString)
Add a Structure to the root group.Dimension
addUnlimitedDimension(String dimName)
Add an unlimited dimension to the root group.Variable.Builder
addVariable(String shortName, DataType dataType, String dimString)
Add a Variable to the root group.Variable.Builder
addVariable(String shortName, DataType dataType, List<Dimension> dims)
Add a Variable to the root group.NetcdfFormatWriter
build()
Once this is called, do not use the Builder again.long
calcSize()
NetcdfFileFormat
getFormat()
IOServiceProvider
getIosp()
Group.Builder
getRootGroup()
Get the root groupNetcdfFormatWriter.Builder
setChunker(Nc4Chunking chunker)
Nc4Chunking, used only for netcdf4NetcdfFormatWriter.Builder
setExtraHeader(int extraHeaderBytes)
Set extra bytes to reserve in the header.NetcdfFormatWriter.Builder
setFill(boolean fill)
Set the fill flag.NetcdfFormatWriter.Builder
setFormat(NetcdfFileFormat format)
Set the format version.NetcdfFormatWriter.Builder
setIosp(IOServiceProvider iosp)
NetcdfFormatWriter.Builder
setLocation(String location)
The file locatipnNetcdfFormatWriter.Builder
setNewFile(boolean newFile)
True if its a new file, false if its an existing file.NetcdfFormatWriter.Builder
setPreallocateSize(long preallocateSize)
Preallocate the file size, for efficiency.NetcdfFormatWriter.Builder
setRootGroup(Group.Builder rootGroup)
Set the root group.NetcdfFormatWriter.Builder
setUseJna(boolean useJna)
Set if you want to use JNA / netcdf c library to do the writing.
-
-
-
Method Detail
-
setLocation
public NetcdfFormatWriter.Builder setLocation(String location)
The file locatipn
-
setIosp
public NetcdfFormatWriter.Builder setIosp(IOServiceProvider iosp)
-
getIosp
public IOServiceProvider getIosp()
-
setFormat
public NetcdfFormatWriter.Builder setFormat(NetcdfFileFormat format)
Set the format version. Only needed when its a new file. Default is NetcdfFileFormat.NETCDF3
-
getFormat
public NetcdfFileFormat getFormat()
-
setNewFile
public NetcdfFormatWriter.Builder setNewFile(boolean newFile)
True if its a new file, false if its an existing file. Default true.
-
setFill
public NetcdfFormatWriter.Builder setFill(boolean fill)
Set the fill flag. Only used by netcdf-3. If true, the data is first written with fill values. Default is fill = true, to follow the C library. Set false if you expect to write all data values, which makes writing faster. Set true if you want to be sure that unwritten data values are set to the fill value.
-
setExtraHeader
public NetcdfFormatWriter.Builder setExtraHeader(int extraHeaderBytes)
Set extra bytes to reserve in the header. Only used by netcdf-3. This can prevent rewriting the entire file on redefine.- Parameters:
extraHeaderBytes
- # bytes extra for the header
-
setPreallocateSize
public NetcdfFormatWriter.Builder setPreallocateSize(long preallocateSize)
Preallocate the file size, for efficiency. Only used by netcdf-3.
-
setChunker
public NetcdfFormatWriter.Builder setChunker(Nc4Chunking chunker)
Nc4Chunking, used only for netcdf4
-
setUseJna
public NetcdfFormatWriter.Builder setUseJna(boolean useJna)
Set if you want to use JNA / netcdf c library to do the writing. Default is false.
-
addAttribute
public NetcdfFormatWriter.Builder addAttribute(Attribute att)
Add a global attribute
-
addDimension
public Dimension addDimension(String dimName, int length)
Add a dimension to the root group.
-
addUnlimitedDimension
public Dimension addUnlimitedDimension(String dimName)
Add an unlimited dimension to the root group.
-
getRootGroup
public Group.Builder getRootGroup()
Get the root group
-
setRootGroup
public NetcdfFormatWriter.Builder setRootGroup(Group.Builder rootGroup)
Set the root group. This allows all metadata to be built externally.
-
addVariable
public Variable.Builder addVariable(String shortName, DataType dataType, String dimString)
Add a Variable to the root group.
-
addVariable
public Variable.Builder addVariable(String shortName, DataType dataType, List<Dimension> dims)
Add a Variable to the root group.
-
addStructure
public Structure.Builder addStructure(String shortName, String dimString)
Add a Structure to the root group.
-
calcSize
public long calcSize()
-
build
public NetcdfFormatWriter build() throws IOException
Once this is called, do not use the Builder again.- Throws:
IOException
-
-