Package ucar.ma2
Class ArraySequenceNested
- java.lang.Object
-
- ucar.ma2.Array
-
- ucar.ma2.ArrayStructure
-
- ucar.ma2.ArraySequenceNested
-
- All Implemented Interfaces:
Iterable<StructureData>
public class ArraySequenceNested extends ArrayStructure
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();
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ucar.ma2.ArrayStructure
ArrayStructure.ArrayStructureIterator
-
-
Constructor Summary
Constructors Constructor Description ArraySequenceNested(StructureMembers members, int nseq)
This is used for inner sequences, ie variable length structures nested inside of another structure.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finish()
Call this when you have set all the sequence lengths.ArrayStructure
flatten()
Flatten the Structures into a 1D array of Structures of length getTotalNumberOfStructures().ArrayStructure
getArrayStructure(int recnum, StructureMembers.Member m)
Get member data of type array of Structure.byte[]
getJavaArrayByte(int recnum, StructureMembers.Member m)
Get member data of type byte as a 1D array.char[]
getJavaArrayChar(int recnum, StructureMembers.Member m)
Get member data of type char as a 1D array.double[]
getJavaArrayDouble(int recnum, StructureMembers.Member m)
Get member data of type double as a 1D array.float[]
getJavaArrayFloat(int recnum, StructureMembers.Member m)
Get member data of type float as a 1D array.int[]
getJavaArrayInt(int recnum, StructureMembers.Member m)
Get member data of type int as a 1D array.long[]
getJavaArrayLong(int recnum, StructureMembers.Member m)
Get member data of type long as a 1D array.short[]
getJavaArrayShort(int recnum, StructureMembers.Member m)
Get member data of type short as a 1D array.String[]
getJavaArrayString(int recnum, StructureMembers.Member m)
Get member data of type String as a 1D array.byte
getScalarByte(int recnum, StructureMembers.Member m)
Get scalar member data of type byte.char
getScalarChar(int recnum, StructureMembers.Member m)
Get scalar member data of type char.double
getScalarDouble(int recnum, StructureMembers.Member m)
Get scalar member data of type double.float
getScalarFloat(int recnum, StructureMembers.Member m)
Get scalar member data of type float.int
getScalarInt(int recnum, StructureMembers.Member m)
Get scalar member data of type int.long
getScalarLong(int recnum, StructureMembers.Member m)
Get scalar member data of type long.short
getScalarShort(int recnum, StructureMembers.Member m)
Get scalar member data of type short.String
getScalarString(int recnum, StructureMembers.Member m)
Get member data of type String or char.StructureData
getScalarStructure(int recnum, StructureMembers.Member m)
Get member data of type Structure.int
getSequenceLength(int outerIndex)
Get the length of the ith sequence.int
getSequenceOffset(int outerIndex)
Get the the starting index of the ith sequence.StructureData
getStructureData(int index)
Get the index-th StructureData of this ArrayStructure.int
getTotalNumberOfStructures()
protected StructureData
makeStructureData(ArrayStructure as, int index)
void
setSequenceLength(int outerIndex, int len)
Set the length of one of the sequences.-
Methods inherited from class ucar.ma2.ArrayStructure
convertScalarDouble, convertScalarFloat, convertScalarInt, convertScalarLong, copy, copyBytes, copyChars, copyDoubles, copyFloats, copyFrom1DJavaArray, copyInts, copyLongs, copyObjects, copySequences, copyShorts, copyStructures, copyTo1DJavaArray, createView, extractMemberArray, findMember, getArray, getArrayObject, getArraySequence, getBoolean, getBoolean, getByte, getByte, getChar, getChar, getDouble, getDouble, getElementType, getFloat, getFloat, getInt, getInt, getLong, getLong, getMembers, getObject, getObject, getScalarObject, getShort, getShort, getSizeBytes, getStorage, getStructureData, getStructureDataIterator, getStructureMemberNames, getStructureMembers, getStructureSize, iterator, sectionNoReduce, setBoolean, setBoolean, setByte, setByte, setChar, setChar, setDouble, setDouble, setFloat, setFloat, setInt, setInt, setLong, setLong, setMemberArray, setObject, setObject, setShort, setShort, showInternal, showInternalMembers
-
Methods inherited from class ucar.ma2.Array
arraycopy, copyTo1DJavaArray, copyToNDJavaArray, factory, factory, factory, factory, factoryConstant, factoryCopy, flip, get1DJavaArray, get1DJavaArray, getDataAsByteBuffer, getDataAsByteBuffer, getDataAsByteBuffer, getDataType, getIndex, getIndexIterator, getRangeIterator, getRank, getShape, getSize, hasNext, isConstant, isUnsigned, isVlen, makeArray, makeArray, makeArray, makeArrayRankPlusOne, makeFromJavaArray, makeFromJavaArray, makeObjectArray, makeVlenArray, next, nextBoolean, nextByte, nextChar, nextDouble, nextFloat, nextInt, nextLong, nextShort, permute, reduce, reduce, resetLocalIterator, reshape, reshapeNoCopy, section, section, section, sectionNoReduce, shapeToString, slice, toString, transpose
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ArraySequenceNested
public ArraySequenceNested(StructureMembers members, int nseq)
This is used for inner sequences, ie variable length structures nested inside of another structure.- Parameters:
members
- the members of the STructurenseq
- the number of sequences, ie the length of the outer structure.
-
-
Method Detail
-
makeStructureData
protected StructureData makeStructureData(ArrayStructure as, int index)
- Specified by:
makeStructureData
in classArrayStructure
-
getStructureData
public StructureData getStructureData(int index)
Description copied from class:ArrayStructure
Get the index-th StructureData of this ArrayStructure.- Overrides:
getStructureData
in classArrayStructure
- Parameters:
index
- which one to get, specified by an integer.- Returns:
- object of type StructureData.
-
setSequenceLength
public void setSequenceLength(int outerIndex, int len)
Set the length of one of the sequences.- Parameters:
outerIndex
- which sequence?len
- what is its length?
-
getSequenceLength
public int getSequenceLength(int outerIndex)
Get the length of the ith sequence.- Parameters:
outerIndex
- which sequence?- Returns:
- its length
-
getSequenceOffset
public int getSequenceOffset(int outerIndex)
Get the the starting index of the ith sequence.- Parameters:
outerIndex
- which sequence?- Returns:
- its starting index
-
finish
public void finish()
Call this when you have set all the sequence lengths.
-
getTotalNumberOfStructures
public int getTotalNumberOfStructures()
- Returns:
- the total number of Structures over all the nested sequences.
-
flatten
public ArrayStructure flatten()
Flatten the Structures into a 1D array of Structures of length getTotalNumberOfStructures().- Returns:
- Array of Structures
-
getScalarDouble
public double getScalarDouble(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get scalar member data of type double.- Overrides:
getScalarDouble
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type double.- Returns:
- scalar double value
-
getJavaArrayDouble
public double[] getJavaArrayDouble(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type double as a 1D array. The member data may be any rank.- Overrides:
getJavaArrayDouble
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type double.- Returns:
- double[]
-
getScalarFloat
public float getScalarFloat(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get scalar member data of type float.- Overrides:
getScalarFloat
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type float.- Returns:
- scalar double value
-
getJavaArrayFloat
public float[] getJavaArrayFloat(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type float as a 1D array.- Overrides:
getJavaArrayFloat
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type float.- Returns:
- float[]
-
getScalarByte
public byte getScalarByte(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get scalar member data of type byte.- Overrides:
getScalarByte
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type byte.- Returns:
- scalar double value
-
getJavaArrayByte
public byte[] getJavaArrayByte(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type byte as a 1D array.- Overrides:
getJavaArrayByte
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type byte.- Returns:
- byte[]
-
getScalarShort
public short getScalarShort(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get scalar member data of type short.- Overrides:
getScalarShort
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type short.- Returns:
- scalar double value
-
getJavaArrayShort
public short[] getJavaArrayShort(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type short as a 1D array.- Overrides:
getJavaArrayShort
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type float.- Returns:
- short[]
-
getScalarInt
public int getScalarInt(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get scalar member data of type int.- Overrides:
getScalarInt
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type int.- Returns:
- scalar double value
-
getJavaArrayInt
public int[] getJavaArrayInt(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type int as a 1D array.- Overrides:
getJavaArrayInt
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type int.- Returns:
- int[]
-
getScalarLong
public long getScalarLong(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get scalar member data of type long.- Overrides:
getScalarLong
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type long.- Returns:
- scalar double value
-
getJavaArrayLong
public long[] getJavaArrayLong(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type long as a 1D array.- Overrides:
getJavaArrayLong
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type long.- Returns:
- long[]
-
getScalarChar
public char getScalarChar(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get scalar member data of type char.- Overrides:
getScalarChar
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type char.- Returns:
- scalar double value
-
getJavaArrayChar
public char[] getJavaArrayChar(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type char as a 1D array.- Overrides:
getJavaArrayChar
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type char.- Returns:
- char[]
-
getScalarString
public String getScalarString(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type String or char.- Overrides:
getScalarString
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type String or char.- Returns:
- scalar String value
-
getJavaArrayString
public String[] getJavaArrayString(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type String as a 1D array.- Overrides:
getJavaArrayString
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type String.- Returns:
- String[]
-
getScalarStructure
public StructureData getScalarStructure(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type Structure.- Overrides:
getScalarStructure
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type Structure.- Returns:
- scalar StructureData
-
getArrayStructure
public ArrayStructure getArrayStructure(int recnum, StructureMembers.Member m)
Description copied from class:ArrayStructure
Get member data of type array of Structure.- Overrides:
getArrayStructure
in classArrayStructure
- Parameters:
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type Structure.- Returns:
- nested ArrayStructure.
-
-