Package dap4.core.util
Class Slice
- java.lang.Object
-
- dap4.core.util.Slice
-
- Direct Known Subclasses:
MultiSlice
public class Slice extends Object
A Slice is used for two purposes- To specify a subset of data to extract.
- To specify a subset of data as specified in a constraint.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSlice.Sort
-
Field Summary
Fields Modifier and Type Field Description protected booleanconstrainedIndicate that this slice's first/last/stride were specifically set; typically from a constraint.static longMAXLENGTHstatic SliceSCALARSLICEstatic List<Slice>SCALARSLICESprotected Slice.Sortsortstatic longUNDEFINED
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Slicecompose(Slice target, Slice src)Take two slices and compose src wrt target Assume neither argument is null.booleanequals(Object o)Compare two slices for equalitySlicefinish()Perform sanity checks on a slice and repair where possible.longgetCount()Compute the number of elements in the slice.longgetFirst()longgetLast()longgetMax()longgetSize()Slice.SortgetSort()longgetStop()longgetStride()SlicegetSubSlice(int i)List<Slice>getSubSlices()inthashCode()BooleanisConstrained()BooleanisWhole()SliceIteratoriterator()SlicesetConstrained(Boolean tf)SlicesetIndices(long first, long stop, long stride)SlicesetIndices(long first, long stop, long stride, long maxsize)SlicesetMaxSize(long size)SlicesetWhole(Boolean tf)StringtoConstraintString()Convert this slice to a string suitable for use in a constraintStringtoString()StringtoString(boolean withbrackets)
-
-
-
Field Detail
-
UNDEFINED
public static final long UNDEFINED
- See Also:
- Constant Field Values
-
MAXLENGTH
public static final long MAXLENGTH
- See Also:
- Constant Field Values
-
SCALARSLICE
public static Slice SCALARSLICE
-
sort
protected Slice.Sort sort
-
constrained
protected boolean constrained
Indicate that this slice's first/last/stride were specifically set; typically from a constraint. Defaults to true.
-
-
Constructor Detail
-
Slice
public Slice()
-
Slice
public Slice(long first, long stop, long stride) throws DapException- Throws:
DapException
-
Slice
public Slice(long first, long stop, long stride, long maxsize) throws DapException- Throws:
DapException
-
Slice
public Slice(Slice s) throws DapException
- Throws:
DapException
-
Slice
public Slice(DapDimension dim) throws DapException
- Throws:
DapException
-
-
Method Detail
-
finish
public Slice finish() throws DapException
Perform sanity checks on a slice and repair where possible.- Returns:
- this (fluent interface)
- Throws:
DapException- if slice is malformed
-
iterator
public SliceIterator iterator()
-
getSort
public Slice.Sort getSort()
-
getFirst
public long getFirst()
-
getStop
public long getStop()
-
getLast
public long getLast()
-
getStride
public long getStride()
-
getSize
public long getSize()
-
getMax
public long getMax()
-
setMaxSize
public Slice setMaxSize(long size) throws DapException
- Throws:
DapException
-
setIndices
public Slice setIndices(long first, long stop, long stride) throws DapException
- Throws:
DapException
-
setIndices
public Slice setIndices(long first, long stop, long stride, long maxsize) throws DapException
- Throws:
DapException
-
isWhole
public Boolean isWhole()
-
isConstrained
public Boolean isConstrained()
-
getCount
public long getCount()
Compute the number of elements in the slice. Note that this is different from getStop() because stride is taken into account.
-
equals
public boolean equals(Object o)
Compare two slices for equality
-
toString
public String toString(boolean withbrackets)
-
toConstraintString
public String toConstraintString() throws DapException
Convert this slice to a string suitable for use in a constraint- Returns:
- constraint usable string
- Throws:
DapException
-
compose
public static Slice compose(Slice target, Slice src) throws DapException
Take two slices and compose src wrt target Assume neither argument is null. This code should match ucar.ma2.Section in thredds and dceconstraint.c in the netcdf-c library.- Parameters:
target-src-- Returns:
- new, composed Range
- Throws:
DapException
-
getSubSlice
public Slice getSubSlice(int i)
-
-