Package ucar.nc2
Class Structure
- java.lang.Object
-
- ucar.nc2.Variable
-
- ucar.nc2.Structure
-
- All Implemented Interfaces:
Comparable<Variable>
,ProxyReader
- Direct Known Subclasses:
Sequence
,StructureDS
@Immutable public class Structure extends Variable
A Structure is a type of Variable that contains other Variables, like a struct in C. A Structure can be scalar or multidimensional.A call to structure.read() will read all of the data in a Structure, including nested structures, and returns an Array of StructureData, with all of the data in memory. If there is a nested sequence, the sequence data may be read into memory all at once, or it may be read in increments as the iteration proceeds.
Generally, the programmer can assume that the data in one Structure are stored together, so that it is efficient to read an entire Structure, and then access the Variable data through the Arrays in the StructureData.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Structure.Builder<T extends Structure.Builder<T>>
-
Field Summary
-
Fields inherited from class ucar.nc2.Variable
permitCaching
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Structure.Builder<?>
builder()
Get Builder for this class that allows subclassing.Variable
findVariable(String shortName)
Find the Variable member with the specified (short) name, or null if not found.int
getElementSize()
The size of one element of this structure - equals the sum of sizes of its members.String
getNameAndAttributes()
Get String with name and attributes.int
getNumberOfMemberVariables()
Get the number of variables contained directly in this Structure.List<String>
getVariableNames()
Get the (short) names of the variables contained directly in this Structure.List<Variable>
getVariables()
Get the variables contained directly in this Structure.boolean
isSubset()
Find if this was created from a subset() method.StructureMembers.Builder
makeStructureMembersBuilder()
Create a StructureMembers.Builder from the Variables of this Structure.StructureData
readRecord(int recno)
Read one StructureData at index recno.Structure
select(String varName)
Create a subset of the Structure consisting only of the one member variableStructure
select(List<String> memberNames)
Create a subset of the Structure consisting only of the given member variablesStructure.Builder<?>
toBuilder()
Turn into a mutable Builder.-
Methods inherited from class ucar.nc2.Variable
attributes, compareTo, equals, findAttribute, findAttributeString, findDimensionIndex, getArrayType, getDatasetLocation, getDescription, getDimension, getDimensions, getDimensionSet, getDimensionsString, getEnumTypedef, getFileTypeId, getFullName, getNameAndDimensions, getNameAndDimensions, getNetcdfFile, getParentGroup, getParentStructure, getRank, getSection, getShape, getShape, getShortName, getSize, getSizeToCache, getSPobject, getUnitsString, hasCachedData, hashCode, isCaching, isCoordinateVariable, isMemberOfStructure, isMetadata, isScalar, isUnlimited, isVariableLength, lookupEnumString, proxyReadArray, proxyReadArray, readArray, readArray, readScalarByte, readScalarDouble, readScalarFloat, readScalarInt, readScalarLong, readScalarShort, readScalarString, reduce, section, setCaching, slice, toString
-
-
-
-
Method Detail
-
findVariable
@Nullable public Variable findVariable(String shortName)
Find the Variable member with the specified (short) name, or null if not found.
-
getNumberOfMemberVariables
public int getNumberOfMemberVariables()
Get the number of variables contained directly in this Structure.
-
getVariables
public List<Variable> getVariables()
Get the variables contained directly in this Structure.
-
getVariableNames
public List<String> getVariableNames()
Get the (short) names of the variables contained directly in this Structure.
-
isSubset
public boolean isSubset()
Find if this was created from a subset() method.
-
makeStructureMembersBuilder
public StructureMembers.Builder makeStructureMembersBuilder()
Create a StructureMembers.Builder from the Variables of this Structure. Used to create StructureDataArray.
-
select
public Structure select(List<String> memberNames)
Create a subset of the Structure consisting only of the given member variables- Parameters:
memberNames
- list of Variable names, already a member- Returns:
- Structure containing just those members
-
select
public Structure select(String varName)
Create a subset of the Structure consisting only of the one member variable- Parameters:
varName
- name of member Variable- Returns:
- containing just that member
-
getElementSize
public int getElementSize()
The size of one element of this structure - equals the sum of sizes of its members. This is the canonical size, not the actual size stored on disk.- Overrides:
getElementSize
in classVariable
-
getNameAndAttributes
public String getNameAndAttributes()
Get String with name and attributes. Used in short descriptions like tooltips.
-
readRecord
public StructureData readRecord(int recno) throws IOException, InvalidRangeException
Read one StructureData at index recno. For rank 0 or 1 Structure, eg netcdf3 record variables.- Parameters:
recno
- start at this index- Throws:
IOException
InvalidRangeException
-
toBuilder
public Structure.Builder<?> toBuilder()
Turn into a mutable Builder. Can use toBuilder().build() to copy.
-
builder
public static Structure.Builder<?> builder()
Get Builder for this class that allows subclassing.- See Also:
- "https://community.oracle.com/blogs/emcmanus/2010/10/24/using-builder-pattern-subclasses"
-
-