|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.nc2.Variable
ucar.nc2.Structure
public class Structure
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, ot 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/interfaces inherited from class ucar.nc2.Variable |
---|
Variable.Cache |
Field Summary | |
---|---|
protected static int |
defaultBufferSize
|
protected boolean |
isSubset
|
protected static org.slf4j.Logger |
log
|
protected HashMap<String,Variable> |
memberHash
|
protected List<Variable> |
members
|
Fields inherited from class ucar.nc2.Variable |
---|
attributes, cache, dataType, debugCaching, defaultCoordsSizeToCache, defaultSizeToCache, dimensions, elementSize, group, hashCode, isMetadata, isVariableLength, ncfile, parent, proxyReader, shape, shapeAsSection, shortName, sizeToCache, spiObject |
Constructor Summary | |
---|---|
|
Structure(NetcdfFile ncfile,
Group group,
Structure parent,
String shortName)
|
protected |
Structure(Structure from)
Copy constructor. |
Method Summary | |
---|---|
Variable |
addMemberVariable(Variable v)
Add a member variable |
void |
calcElementSize()
Force recalculation of size of one element of this structure - equals the sum of sizes of its members. |
protected int |
calcStructureSize()
|
protected Variable |
copy()
|
Variable |
findVariable(String shortName)
Find the Variable member with the specified (short) name. |
int |
getElementSize()
Get the size of one element of the Structure. |
String |
getNameAndAttributes()
Get String with name and attributes. |
int |
getNumberOfMemberVariables()
Get the number of variables contained directly in this Structure. |
StructureDataIterator |
getStructureIterator()
Iterator over all the data in a Structure. |
StructureDataIterator |
getStructureIterator(int bufferSize)
Get an efficient iterator over all the data in the 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 |
isCaching()
Caching is not allowed |
boolean |
isSubset()
Find if this was created from a subset() method. |
StructureMembers |
makeStructureMembers()
Create a StructureMembers object that describes this Structure. |
StructureData |
readStructure()
Use this when this is a scalar Structure. |
StructureData |
readStructure(int index)
Use this when this is a one dimensional array of Structures, or you are doing the index calculation yourself for a multidimension array. |
ArrayStructure |
readStructure(int start,
int count)
For rank 1 array of Structures, read count Structures and return the data as an ArrayStructure. |
boolean |
removeMemberVariable(Variable v)
Remove a Variable : uses the Variable name to find it. |
boolean |
replaceMemberVariable(Variable newVar)
Replace a Variable with another that has the same name : uses the variable name to find it. |
Structure |
select(List<String> memberNames)
Create a subset of the Structure consisting only of the given member variables |
Structure |
select(String varName)
Create a subset of the Structure consisting only of the one member variable |
void |
setCaching(boolean caching)
Caching is not allowed |
Variable |
setImmutable()
Make this immutable. |
void |
setMemberVariables(List<Variable> vars)
Set the list of member variables. |
void |
setParentGroup(Group group)
Set the parent group of this Structure, and all member variables. |
protected void |
writeCDL(Formatter buf,
String indent,
boolean useFullName,
boolean strict)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static org.slf4j.Logger log
protected static int defaultBufferSize
protected List<Variable> members
protected HashMap<String,Variable> memberHash
protected boolean isSubset
Constructor Detail |
---|
public Structure(NetcdfFile ncfile, Group group, Structure parent, String shortName)
protected Structure(Structure from)
from
- copy from thisMethod Detail |
---|
public Structure select(List<String> memberNames)
memberNames
- list of Variable names, already a member
public Structure select(String varName)
varName
- name of member Variable
public boolean isSubset()
protected Variable copy()
copy
in class Variable
protected int calcStructureSize()
public boolean isCaching()
isCaching
in class Variable
public void setCaching(boolean caching)
setCaching
in class Variable
caching
- set if caching.public Variable addMemberVariable(Variable v)
v
- add this variable as a member of this structure
public void setMemberVariables(List<Variable> vars)
vars
- this is the list of member variablespublic boolean removeMemberVariable(Variable v)
v
- remove this variable as a member of this structure
public boolean replaceMemberVariable(Variable newVar)
newVar
- add this variable as a member of this structure
public void setParentGroup(Group group)
setParentGroup
in class Variable
group
- set to this valuepublic Variable setImmutable()
Variable
setImmutable
in class Variable
public List<Variable> getVariables()
public int getNumberOfMemberVariables()
public List<String> getVariableNames()
public Variable findVariable(String shortName)
shortName
- name of the member variable.
public StructureMembers makeStructureMembers()
public int getElementSize()
getElementSize
in interface VariableIF
getElementSize
in class Variable
public void calcElementSize()
public StructureData readStructure() throws IOException
IOException
- on read errorpublic StructureData readStructure(int index) throws IOException, InvalidRangeException
index
- index into 1D array
IOException
- on read error
InvalidRangeException
- if index out of rangepublic ArrayStructure readStructure(int start, int count) throws IOException, InvalidRangeException
start
- start at this indexcount
- return this many StructureData
IOException
- on read error
InvalidRangeException
- if start, count out of rangepublic StructureDataIterator getStructureIterator() throws IOException
StructureDataIterator ii = structVariable.getStructureIterator(); while (ii.hasNext()) { StructureData sdata = ii.next(); }
IOException
- on read errorgetStructureIterator(int bufferSize)
public StructureDataIterator getStructureIterator(int bufferSize) throws IOException
Example: StructureDataIterator ii = structVariable.getStructureIterator(100 * 1000); while (ii.hasNext()) { StructureData sdata = ii.next(); }
bufferSize
- size in bytes to buffer, set < 0 to use default size
IOException
- on read errorpublic String getNameAndAttributes()
protected void writeCDL(Formatter buf, String indent, boolean useFullName, boolean strict)
writeCDL
in class Variable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |