ucar.ma2.ArraySequenceNested Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of netcdf Show documentation
Show all versions of netcdf Show documentation
The NetCDF-Java Library is a Java interface to NetCDF files,
as well as to many other types of scientific data formats.
/*
* Copyright 1998-2009 University Corporation for Atmospheric Research/Unidata
*
* Portions of this software were developed by the Unidata Program at the
* University Corporation for Atmospheric Research.
*
* Access and use of this software shall impose the following obligations
* and understandings on the user. The user is granted the right, without
* any fee or cost, to use, copy, modify, alter, enhance and distribute
* this software, and any derivative works thereof, and its supporting
* documentation for any purpose whatsoever, provided that this entire
* notice appears in all copies of the software, derivative works and
* supporting documentation. Further, UCAR requests that the user credit
* UCAR/Unidata in any publications that result from the use of this
* software or in any product that includes this software. The names UCAR
* and/or Unidata, however, may not be used in any advertising or publicity
* to endorse or promote any products or commercial entity unless specific
* written permission is obtained from UCAR/Unidata. The user also
* understands that UCAR/Unidata is not obligated to provide the user with
* any support, consulting, training or assistance of any kind with regard
* to the use, operation and performance of this software nor to provide
* the user with any updates, revisions, new versions or "bug fixes."
*
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package ucar.ma2;
/**
* Handles nested sequences: a 1D array of variable length 1D arrays of StructureData.
* Uses same technique as ArrayStructureMA for the inner fields; data storage is in member arrays.
* Used only by opendap internals.
*
* Example use:
*
ArraySequence aseq = new ArraySequence( members, outerLength);
for (int seq=0; seq < outerLength; seq++) {
aseq.setSequenceLength(seq, seqLength);
}
aseq.finish();
*
* @author caron
*/
public class ArraySequenceNested extends ArrayStructure {
private int[] sequenceLen;
private int[] sequenceOffset;
private int total = 0;
/**
* This is used for inner sequences, ie variable length structures nested inside of another structure.
* @param members the members of the STructure
* @param nseq the number of sequences, ie the length of the outer structure.
*/
public ArraySequenceNested(StructureMembers members, int nseq) {
super(members, new int[] {nseq});
sequenceLen = new int[nseq];
}
// not sure how this is used
protected StructureData makeStructureData( ArrayStructure as, int index) {
return new StructureDataA( as, index);
}
public StructureData getStructureData(int index) {
return new StructureDataA( this, index);
}
/**
* Set the length of one of the sequences.
* @param outerIndex which sequence?
* @param len what is its length?
*/
public void setSequenceLength( int outerIndex, int len) {
sequenceLen[outerIndex] = len;
}
/**
* Get the length of the ith sequence.
* @param outerIndex which sequence?
* @return its length
*/
public int getSequenceLength( int outerIndex) {
return sequenceLen[outerIndex];
}
/**
* Get the the starting index of the ith sequence.
* @param outerIndex which sequence?
* @return its starting index
*/
public int getSequenceOffset( int outerIndex) {
return sequenceOffset[outerIndex];
}
/**
* Call this when you have set all the sequence lengths.
*/
public void finish() {
sequenceOffset = new int[nelems];
total = 0;
for (int i=0; i