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 class
Slice.Sort
-
Field Summary
Fields Modifier and Type Field Description protected boolean
constrained
Indicate that this slice's first/last/stride were specifically set; typically from a constraint.static int
MAXLENGTH
static Slice
SCALARSLICE
static List<Slice>
SCALARSLICES
protected Slice.Sort
sort
static int
UNDEFINED
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Slice
compose(Slice target, Slice src)
Take two slices and compose src wrt target Assume neither argument is null.boolean
equals(Object o)
Compare two slices for equalitySlice
finish()
Perform sanity checks on a slice and repair where possible.int
getCount()
Compute the number of elements in the slice.int
getFirst()
int
getLast()
int
getMax()
int
getSize()
Slice.Sort
getSort()
int
getStop()
int
getStride()
Slice
getSubSlice(int i)
List<Slice>
getSubSlices()
int
hashCode()
Boolean
isConstrained()
boolean
isScalar()
Boolean
isWhole()
SliceIterator
iterator()
Slice
setConstrained(Boolean tf)
Slice
setIndices(int first, int stop, int stride)
Slice
setIndices(int first, int stop, int stride, int maxsize)
Slice
setMaxSize(int size)
Slice
setWhole(Boolean tf)
String
toConstraintString()
Convert this slice to a string suitable for use in a constraintString
toString()
String
toString(boolean withbrackets)
-
-
-
Field Detail
-
UNDEFINED
public static final int UNDEFINED
- See Also:
- Constant Field Values
-
MAXLENGTH
public static final int 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(int first, int stop, int stride) throws DapException
- Throws:
DapException
-
Slice
public Slice(int first, int stop, int stride, int 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 int getFirst()
-
getStop
public int getStop()
-
getLast
public int getLast()
-
getStride
public int getStride()
-
getSize
public int getSize()
-
getMax
public int getMax()
-
isScalar
public boolean isScalar()
-
setMaxSize
public Slice setMaxSize(int size) throws DapException
- Throws:
DapException
-
setIndices
public Slice setIndices(int first, int stop, int stride) throws DapException
- Throws:
DapException
-
setIndices
public Slice setIndices(int first, int stop, int stride, int maxsize) throws DapException
- Throws:
DapException
-
isWhole
public Boolean isWhole()
-
isConstrained
public Boolean isConstrained()
-
getCount
public int 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)
-
-