public abstract class DapUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.math.BigInteger |
BIG_UMASK64 |
static java.lang.String |
CRLF |
static int |
CRLFSIZE |
static java.util.regex.Pattern |
DAP4EXT_RE |
static java.lang.String |
LF |
static java.nio.ByteOrder |
NATIVE_ORDER |
static java.nio.ByteOrder |
NETWORK_ORDER |
static java.nio.charset.Charset |
UTF8 |
Constructor and Description |
---|
DapUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
absolutize(java.lang.String path) |
static java.util.List<java.lang.String> |
backslashSplit(java.lang.String s,
char sep)
Split a string with respect to a separator
character and taking backslashes into consideration.
|
static java.lang.String |
canonFileURL(java.lang.String url) |
static java.lang.String |
canonicalpath(java.lang.String path)
Convert path to:
1.
|
static java.lang.String |
canonjoin(java.lang.String prefix,
java.lang.String suffix) |
static boolean |
checkFixedSize(DapVariable var) |
static void |
checkruntime(java.lang.Exception e)
Re-throw run-time exceptions
|
static java.lang.String |
denullify(java.lang.String path)
Convert null paths to ""
|
static long |
dimProduct(java.util.List<DapDimension> dimset) |
static java.util.List<Slice> |
dimsetToSlices(java.util.List<DapDimension> dimset) |
static byte[] |
extract(java.nio.ByteBuffer buf)
Properly extract the byte contents of a ByteBuffer
|
static java.lang.String |
fqnPrefix(java.lang.String fqn) |
static java.lang.String |
fqnSuffix(java.lang.String fqn) |
static long[] |
getDimSizes(java.util.List<DapDimension> dims) |
static java.util.List<java.lang.String> |
getProtocols(java.lang.String url,
int[] breakpoint)
Return the set of leading protocols for a url; may be more than one.
|
static java.util.List<DapVariable> |
getStructurePath(DapVariable var)
Given a dap variable, get the path from the
top-level variable to and including the given variable
such that all but the last element is a structure.
|
static boolean |
hasDriveLetter(java.lang.String path)
Return true if this path appears to start with a windows drive letter
This tests the patterns "/x:/" and "x:/"
|
static boolean |
hasSequence(DapNode node) |
static boolean |
hasStrideOne(java.util.List<Slice> slices) |
static boolean |
hasWindowsDrive(java.lang.String path) |
static int[] |
intvector(long[] lv) |
static boolean |
isAbsolutePath(java.lang.String path) |
static boolean |
isContiguous(java.util.List<Slice> slices)
Test if a set of slices represent a contiguous region
This is equivalent to saying all strides are one
|
static boolean |
isScalarSlices(java.util.List<Slice> slices) |
static boolean |
isSinglePoint(java.util.List<Slice> slices)
Test if a set of slices represent a single position
|
static boolean |
isWhole(java.util.List<Slice> slices,
java.util.List<DapDimension> dimset)
Test a List
|
static java.lang.String |
join(java.lang.String[] array,
java.lang.String sep,
int from,
int upto)
Given an Array of Strings and a separator and a count,
concat the first count elements of an array with separator
between them.
|
static java.lang.String |
locateFile(java.lang.String filename,
java.lang.String abspath,
boolean wantdir)
Walk the specified subtree dir tree to try to locate file|dir named filename.
|
static java.lang.String |
locateRelative(java.lang.String relpath,
java.lang.String abspath,
boolean wantdir)
Walk the specified dir tree to locate file specified by relative path.
|
static long[] |
longvector(int[] iv) |
static java.lang.String |
merge(java.lang.String[] pieces,
java.lang.String sep) |
static java.lang.String |
nullify(java.lang.String path)
Convert "" paths to null
|
static byte[] |
readbinaryfile(java.io.InputStream stream) |
static int |
readbinaryfilepartial(java.io.InputStream stream,
byte[] buffer,
int count)
Read a limited number of bytes from a stream
|
static java.lang.String |
readtextfile(java.io.InputStream stream) |
static java.lang.String |
relativize(java.lang.String path) |
static java.lang.String |
repairPath(java.lang.String path)
Convert a path of the form "/x:/" to "x:/" to expose drive letter;
otherwise leave unchanged
|
static long |
sliceProduct(java.util.List<Slice> slices) |
static java.lang.Object |
stringable(java.lang.Object obj)
Convert null objects to ""
|
static java.lang.Integer |
stringToInteger(java.lang.String s) |
static java.lang.String |
stripDap4Extensions(java.lang.String path) |
static java.lang.String |
xrelpath(java.lang.String path)
Relativizing a path => remove any leading '/' and cleaning it
|
public static final java.math.BigInteger BIG_UMASK64
public static final java.nio.charset.Charset UTF8
public static final java.nio.ByteOrder NETWORK_ORDER
public static final java.nio.ByteOrder NATIVE_ORDER
public static final java.lang.String LF
public static final java.lang.String CRLF
public static final int CRLFSIZE
public static java.util.regex.Pattern DAP4EXT_RE
public static java.lang.String fqnSuffix(java.lang.String fqn)
public static java.lang.String fqnPrefix(java.lang.String fqn)
public static java.util.List<java.lang.String> backslashSplit(java.lang.String s, char sep)
s
- The string to splitsep
- The character on which to splitpublic static java.lang.Integer stringToInteger(java.lang.String s)
public static boolean hasSequence(DapNode node)
public static java.lang.String locateFile(java.lang.String filename, java.lang.String abspath, boolean wantdir)
filename
- Name of the file|dir to locateabspath
- Absolute path from which to start searchwantdir
- True if we are looking for a directory,
false if we are looking for a filepublic static java.lang.String locateRelative(java.lang.String relpath, java.lang.String abspath, boolean wantdir)
relpath
- Name of the file|dir to locateabspath
- Absolute path from which to start searchwantdir
- True if we are looking for a directory,
false if we are looking for a filepublic static java.lang.String canonicalpath(java.lang.String path)
path
- convert this pathpublic static java.lang.String relativize(java.lang.String path)
public static java.lang.String absolutize(java.lang.String path)
public static boolean checkFixedSize(DapVariable var)
public static byte[] extract(java.nio.ByteBuffer buf)
buf
- The buffer whose content is to be extracted
as defined by the buffer limit.public static byte[] readbinaryfile(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public static int readbinaryfilepartial(java.io.InputStream stream, byte[] buffer, int count) throws java.io.IOException
stream
- buffer
- into which to readcount
- amount to read; <= |buffer|java.io.IOException
public static java.lang.String readtextfile(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public static java.util.List<DapVariable> getStructurePath(DapVariable var)
public static java.lang.String denullify(java.lang.String path)
path
- public static java.lang.Object stringable(java.lang.Object obj)
obj
- public static java.lang.String nullify(java.lang.String path)
path
- public static long[] getDimSizes(java.util.List<DapDimension> dims)
public static long dimProduct(java.util.List<DapDimension> dimset)
public static boolean isWhole(java.util.List<Slice> slices, java.util.List<DapDimension> dimset)
slices
- the set of slicesdimset
- the list of DapDimensionpublic static long sliceProduct(java.util.List<Slice> slices)
public static boolean hasStrideOne(java.util.List<Slice> slices)
public static java.lang.String join(java.lang.String[] array, java.lang.String sep, int from, int upto)
array
- the array to concatsep
- the separatorfrom
- start point for join (inclusive)upto
- end point for join (exclusive)public static java.lang.String xrelpath(java.lang.String path)
path
- public static boolean hasDriveLetter(java.lang.String path)
path
- public static java.lang.String repairPath(java.lang.String path)
path
- public static java.util.List<java.lang.String> getProtocols(java.lang.String url, int[] breakpoint)
url
- the url whose protocols to returnbreakpoint
- return the index past last protocolpublic static java.lang.String merge(java.lang.String[] pieces, java.lang.String sep)
public static void checkruntime(java.lang.Exception e)
public static java.lang.String canonjoin(java.lang.String prefix, java.lang.String suffix)
public static boolean hasWindowsDrive(java.lang.String path)
public static boolean isAbsolutePath(java.lang.String path)
public static java.lang.String canonFileURL(java.lang.String url)
public static java.lang.String stripDap4Extensions(java.lang.String path)
public static boolean isContiguous(java.util.List<Slice> slices)
slices
- public static boolean isSinglePoint(java.util.List<Slice> slices)
slices
- public static java.util.List<Slice> dimsetToSlices(java.util.List<DapDimension> dimset) throws DapException
DapException
public static boolean isScalarSlices(java.util.List<Slice> slices)
public static long[] longvector(int[] iv)
public static int[] intvector(long[] lv)