dap4/d4cdm/src/main/java/dap4/cdm/CDMUtil.java
static public String
    getChecksumString(byte[] checksum)
    {
        StringBuilder buf = new StringBuilder();
        for(int i = 0; i < checksum.length; i++) {
            byte b = checksum[i];
            buf.append(hexchars.charAt(b >> 4));
            buf.append(hexchars.charAt(b & 0xF));
        }
        return buf.toString();
    }
static public String
    getChecksumString(byte[] checksum)
    {
        StringBuilder buf = new StringBuilder();
        for(int i = 0; i < checksum.length; i++) {
            byte b = checksum[i];
            buf.append(hexchars.charAt(b >> 4));
            buf.append(hexchars.charAt(b & 0xF));
        }
        return buf.toString();
    }
static public String getChecksumString ( byte [ ] checksum ) { StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < checksum . length ; i ++ ) { byte b = checksum [ i ] ; buf . append ( hexchars . charAt ( b >> 4 ) ) ; buf . append ( hexchars . charAt ( b & 0xF ) ) ; } return buf . toString ( ) ; }
/*static public ucar.ma2.Array
arraySlice(ucar.ma2.Array array, Section section)
throws DapException
{
Case it out.
if(!dapvar.getBaseType().isStructType()) { // =>Atomic type
if(dapvar.isTopLevel()) {
Simplest case: use createview, but watch out for final VLEN
List<Range> ranges = section.getRanges();
try {
if(CDMUtil.hasVLEN(ranges))
return array.section(ranges.subList(0, ranges.size() - 2));
else
return array.section(ranges);
} catch (InvalidRangeException ire) {
throw new DapException(ire);
}
} else
throw new UnsupportedOperationException(); // same as other cdm
} else { // struct type
assert (array instanceof CDMArrayStructure);
CDMArrayStructure struct = (CDMArrayStructure) array;
if(dapvar.isTopLevel()) {
Build a new ArrayStructure containing
the relevant instances.
int[] shape = section.getShape();
StructureMembers sm = new StructureMembers(struct.getStructureMembers());
ArrayStructureMA slice = new ArrayStructureMA(sm, shape);
CDMOdometer odom = new CDMOdometer(dapvar.getDimensions(), section.getRanges());
Compute the number of structuredata instances we need
long totalsize = section.computeSize();
List<StructureMembers.Member> mlist = sm.getMembers();
StructureData[] newdata = new StructureData[(int) totalsize];
for(int i = 0;odom.hasNext();odom.next(), i++) {
long recno = odom.index();
StructureDataW clone = new StructureDataW(sm);
newdata[i] = clone;
StructureData record = struct.getStructureData((int) recno);
for(int j = 0;j < mlist.size();j++) {
StructureMembers.Member m = mlist.get(j);
clone.setMemberData(m, record.getArray(m));
}
}
return slice;
} else
throw new UnsupportedOperationException(); // same as other cdm
}
}
/ * static public ucar . ma2 . Array arraySlice ( ucar . ma2 . Array array Section section ) throws DapException { Case it out . if ( !dapvar . getBaseType () . isStructType () ) { // = > Atomic type if ( dapvar . isTopLevel () ) { Simplest case : use createview but watch out for final VLEN List<Range > ranges = section . getRanges () ; try { if ( CDMUtil . hasVLEN ( ranges )) return array . section ( ranges . subList ( 0 ranges . size () - 2 )) ; else return array . section ( ranges ) ; } catch ( InvalidRangeException ire ) { throw new DapException ( ire ) ; } } else throw new UnsupportedOperationException () ; // same as other cdm } else { // struct type assert ( array instanceof CDMArrayStructure ) ; CDMArrayStructure struct = ( CDMArrayStructure ) array ; if ( dapvar . isTopLevel () ) { Build a new ArrayStructure containing the relevant instances . int [] shape = section . getShape () ; StructureMembers sm = new StructureMembers ( struct . getStructureMembers () ) ; ArrayStructureMA slice = new ArrayStructureMA ( sm shape ) ; CDMOdometer odom = new CDMOdometer ( dapvar . getDimensions () section . getRanges () ) ; Compute the number of structuredata instances we need long totalsize = section . computeSize () ; List<StructureMembers . Member > mlist = sm . getMembers () ; StructureData [] newdata = new StructureData [ ( int ) totalsize ] ; for ( int i = 0 ; odom . hasNext () ; odom . next () i ++ ) { long recno = odom . index () ; StructureDataW clone = new StructureDataW ( sm ) ; newdata [ i ] = clone ; StructureData record = struct . getStructureData (( int ) recno ) ; for ( int j = 0 ; j < mlist . size () ; j ++ ) { StructureMembers . Member m = mlist . get ( j ) ; clone . setMemberData ( m record . getArray ( m )) ; } } return slice ; } else throw new UnsupportedOperationException () ; // same as other cdm } }