signature:
public class CoverageCoordAxis1D { /** * only for longitude , only for regular ( do we need a subclass for longitude 1D coords ? ? */
public Optional < CoverageCoordAxis > subsetByIntervals ( List < MAMath . MinMax > lonIntvs , int stride ) { } }

implementation:
if ( axisType != AxisType . Lon ) return Optional . empty ( "subsetByIntervals only for longitude" ) ; if ( ! isRegular ( ) ) return Optional . empty ( "subsetByIntervals only for regular longitude" ) ; CoordAxisHelper helper = new CoordAxisHelper ( this ) ; double start = Double . NaN ; boolean first = true ; List < RangeIterator > ranges = new ArrayList < > ( ) ; for ( MAMath . MinMax lonIntv : lonIntvs ) { if ( first ) start = lonIntv . min ; first = false ; Optional < RangeIterator > opt = helper . makeRange ( lonIntv . min , lonIntv . max , stride ) ; if ( ! opt . isPresent ( ) ) return Optional . empty ( opt . getErrorMessage ( ) ) ; ranges . add ( opt . get ( ) ) ; } try { RangeComposite compositeRange = new RangeComposite ( AxisType . Lon . toString ( ) , ranges ) ; int npts = compositeRange . length ( ) ; double end = start + npts * resolution ; CoverageCoordAxisBuilder builder = new CoverageCoordAxisBuilder ( this ) ; // copy
builder . subset ( npts , start , end , resolution , null ) ; builder . setRange ( null ) ; builder . setCompositeRange ( compositeRange ) ; return Optional . of ( new CoverageCoordAxis1D ( builder ) ) ; } catch ( InvalidRangeException e ) { return Optional . empty ( e . getMessage ( ) ) ; }


signature:
public class CoverageCoordAxis1D { /** * LOOK incomplete handling of subsetting params */
protected Optional < CoverageCoordAxisBuilder > subsetBuilder ( SubsetParams params ) { } }

implementation:
if ( params == null ) return Optional . of ( new CoverageCoordAxisBuilder ( this ) ) ; CoordAxisHelper helper = new CoordAxisHelper ( this ) ; switch ( getAxisType ( ) ) { case GeoZ : case Pressure : case Height : Double dval = params . getVertCoord ( ) ; if ( dval != null ) return Optional . of ( helper . subsetClosest ( dval ) ) ; // use midpoint of interval LOOK may not always be unique
double [ ] intv = params . getVertCoordIntv ( ) ; if ( intv != null ) return Optional . of ( helper . subsetClosest ( ( intv [ 0 ] + intv [ 1 ] ) / 2 ) ) ; double [ ] vertRange = params . getVertRange ( ) ; // used by WCS
if ( vertRange != null ) return helper . subset ( vertRange [ 0 ] , vertRange [ 1 ] , 1 ) ; // default is all
break ; case Ensemble : Double eval = params . getDouble ( SubsetParams . ensCoord ) ; if ( eval != null ) { return Optional . of ( helper . subsetClosest ( eval ) ) ; } // default is all
break ; // x , y get seperately subsetted
case GeoX : case GeoY : case Lat : case Lon : throw new IllegalArgumentException ( ) ; // return null ; / / LOOK heres a case where null is " correct "
case Time : if ( params . isTrue ( SubsetParams . timePresent ) ) return Optional . of ( helper . subsetLatest ( ) ) ; CalendarDate date = ( CalendarDate ) params . get ( SubsetParams . time ) ; if ( date != null ) return Optional . of ( helper . subsetClosest ( date ) ) ; Integer stride = ( Integer ) params . get ( SubsetParams . timeStride ) ; if ( stride == null || stride < 0 ) stride = 1 ; CalendarDateRange dateRange = ( CalendarDateRange ) params . get ( SubsetParams . timeRange ) ; if ( dateRange != null ) return helper . subset ( dateRange , stride ) ; // If no time range or time point , a timeOffset can be used to specify the time point .
/* CalendarDate timeOffsetDate = params . getTimeOffsetDate ( ) ;
 if ( timeOffsetDate ! = null ) {
 return Optional . of ( helper . subsetClosest ( timeOffsetDate ) ) ; */
// A time offset or time offset interval starts from the rundate of the offset
Double timeOffset = params . getTimeOffset ( ) ; CalendarDate runtime = params . getRunTime ( ) ; if ( timeOffset != null ) { if ( runtime != null ) { date = makeDateInTimeUnits ( runtime , timeOffset ) ; return Optional . of ( helper . subsetClosest ( date ) ) ; } else { return Optional . of ( helper . subsetClosest ( timeOffset ) ) ; } } // If a time interval is sent , search for match .
double [ ] timeOffsetIntv = params . getTimeOffsetIntv ( ) ; if ( timeOffsetIntv != null && runtime != null ) { // double midOffset = ( timeOffsetIntv [ 0 ] + timeOffsetIntv [ 1 ] ) / 2;
CalendarDate [ ] dateIntv = new CalendarDate [ 2 ] ; dateIntv [ 0 ] = makeDateInTimeUnits ( runtime , timeOffsetIntv [ 0 ] ) ; dateIntv [ 1 ] = makeDateInTimeUnits ( runtime , timeOffsetIntv [ 1 ] ) ; return Optional . of ( helper . subsetClosest ( dateIntv ) ) ; } if ( stride != 1 ) try { return Optional . of ( helper . subsetByIndex ( getRange ( ) . setStride ( stride ) ) ) ; } catch ( InvalidRangeException e ) { return Optional . empty ( e . getMessage ( ) ) ; } // default is all
break ; case RunTime : CalendarDate rundate = ( CalendarDate ) params . get ( SubsetParams . runtime ) ; if ( rundate != null ) return Optional . of ( helper . subsetClosest ( rundate ) ) ; /* CalendarDateRange rundateRange = ( CalendarDateRange ) params . get ( SubsetParams . runtimeRange ) ;
 if ( rundateRange ! = null )
 return helper . subset ( rundateRange , 1 ) ; */
if ( params . isTrue ( SubsetParams . runtimeAll ) ) break ; // default is latest
return Optional . of ( helper . subsetLatest ( ) ) ; case TimeOffset : Double oval = params . getDouble ( SubsetParams . timeOffset ) ; if ( oval != null ) { return Optional . of ( helper . subsetClosest ( oval ) ) ; } // If a time interval is sent , search for match .
timeOffsetIntv = params . getTimeOffsetIntv ( ) ; if ( timeOffsetIntv != null ) { return Optional . of ( helper . subsetClosest ( ( timeOffsetIntv [ 0 ] + timeOffsetIntv [ 1 ] ) / 2 ) ) ; } if ( params . isTrue ( SubsetParams . timeOffsetFirst ) ) { try { return Optional . of ( helper . subsetByIndex ( new Range ( 1 ) ) ) ; } catch ( InvalidRangeException e ) { return Optional . empty ( e . getMessage ( ) ) ; } } // default is all
break ; } // otherwise return copy the original axis
return Optional . of ( new CoverageCoordAxisBuilder ( this ) ) ;


signature:
public class Int32PrimitiveVector { /** * Reads data from a < code > DataInputStream < / code > . This method is only used
 * on the client side of the OPeNDAP client / server connection .
 * @ param source a < code > DataInputStream < / code > to read from .
 * @ param sv The < code > ServerVersion < / code > returned by the server .
 * ( used by < code > DSequence < / code > to determine which protocol version was
 * used ) .
 * @ param statusUI The < code > StatusUI < / code > object to use for GUI updates
 * and user cancellation notification ( may be null ) .
 * @ throws DataReadException when invalid data is read , or if the user
 * cancels the download .
 * @ throws EOFException if EOF is found before the variable is completely
 * deserialized .
 * @ throws IOException thrown on any other InputStream exception .
 * @ see ClientIO # deserialize ( DataInputStream , ServerVersion , StatusUI ) */
public synchronized void deserialize ( DataInputStream source , ServerVersion sv , StatusUI statusUI ) throws IOException , EOFException , DataReadException { } }

implementation: for ( int i = 0 ; i < vals . length ; i ++ ) { vals [ i ] = source . readInt ( ) ; if ( statusUI != null ) { statusUI . incrementByteCount ( 4 ) ; if ( statusUI . userCancelled ( ) ) throw new DataReadException ( "User cancelled" ) ; } }


signature:
public class Int32PrimitiveVector { /** * Writes data to a < code > DataOutputStream < / code > . This method is used
 * primarily by GUI clients which need to download OPeNDAP data , manipulate
 * it , and then re - save it as a binary file .
 * @ param sink a < code > DataOutputStream < / code > to write to .
 * @ throws IOException thrown on any < code > OutputStream < / code >
 * exception . */
public void externalize ( DataOutputStream sink ) throws IOException { } }

implementation: for ( int i = 0 ; i < vals . length ; i ++ ) { sink . writeInt ( vals [ i ] ) ; }


signature:
public class NCheader { /** * Figure out what kind of netcdf - related file we have .
 * Constraint : leave raf read pointer to point just after
 * the magic number .
 * @ param raf to test type
 * @ return
 * @ throws IOException */
static public int checkFileType ( ucar . unidata . io . RandomAccessFile raf ) throws IOException { } }

implementation:
int format = 0 ; byte [ ] magic = new byte [ MAGIC_NUMBER_LEN ] ; // If this is not an HDF5 file , then the magic number is at
// position 0 ; If it is an HDF5 file , then we need to search
// forward for it .
// Look for the relevant leading tag
raf . seek ( 0 ) ; if ( raf . readBytes ( magic , 0 , MAGIC_NUMBER_LEN ) < MAGIC_NUMBER_LEN ) return 0 ; // unknown
// Some version of CDF
int hdrlen = 0 ; hdrlen = CDF1HEAD . length ; // all CDF headers are assumed to be same length
format = 0 ; if ( memequal ( CDF1HEAD , magic , CDF1HEAD . length ) ) format = NC_FORMAT_CLASSIC ; else if ( memequal ( CDF2HEAD , magic , CDF2HEAD . length ) ) format = NC_FORMAT_64BIT_OFFSET ; else if ( memequal ( CDF5HEAD , magic , CDF5HEAD . length ) ) format = NC_FORMAT_CDF5 ; else if ( memequal ( H4HEAD , magic , H4HEAD . length ) ) format = NC_FORMAT_HDF4 ; if ( format != 0 ) { raf . seek ( hdrlen ) ; return format ; } // For HDF5 , we need to search forward
format = 0 ; long filePos = 0 ; long size = raf . length ( ) ; while ( ( filePos < size - 8 ) && ( filePos < MAXHEADERPOS ) ) { boolean match ; raf . seek ( filePos ) ; if ( raf . readBytes ( magic , 0 , MAGIC_NUMBER_LEN ) < MAGIC_NUMBER_LEN ) return 0 ; // unknown
// Test for HDF5
if ( memequal ( H5HEAD , magic , H5HEAD . length ) ) { format = NC_FORMAT_HDF5 ; break ; } filePos = ( filePos == 0 ) ? 512 : 2 * filePos ; } if ( format != 0 ) raf . seek ( filePos + H5HEAD . length ) ; return format ;


signature:
public class NCheader { /** * Not quite memcmp
 * @ param b1
 * @ param b2
 * @ param len
 * @ return */
static boolean memequal ( byte [ ] b1 , byte [ ] b2 , int len ) { } }

implementation: if ( b1 == b2 ) return true ; if ( b1 == null || b2 == null ) return false ; if ( b1 . length < len || b2 . length < len ) return false ; for ( int i = 0 ; i < len ; i ++ ) { if ( b1 [ i ] != b2 [ i ] ) return false ; } return true ;


signature:
public class asciiArray { /** * Returns a string representation of the variables value . This
 * is really foreshadowing functionality for Server types , but
 * as it may come in useful for clients it is added here . Simple
 * types ( example : DFloat32 ) will return a single value . DConstuctor
 * and DVector types will be flattened . DStrings and DURL ' s will
 * have double quotes around them .
 * @ param addName is a flag indicating if the variable name should
 * appear at the begining of the returned string . */
public void toASCII ( PrintWriter pw , boolean addName , String rootName , boolean newLine ) { } }

implementation: if ( _Debug ) { System . out . println ( "asciiArray.toASCII(" + addName + ",'" + rootName + "')  getName(): " + getEncodedName ( ) ) ; System . out . println ( "  PrimitiveVector size = " + getPrimitiveVector ( ) . getLength ( ) ) ; } if ( addName ) pw . print ( "\n" ) ; int dims = numDimensions ( ) ; int shape [ ] = new int [ dims ] ; int i = 0 ; for ( Enumeration e = getDimensions ( ) ; e . hasMoreElements ( ) ; ) { DArrayDimension d = ( DArrayDimension ) e . nextElement ( ) ; shape [ i ++ ] = d . getSize ( ) ; } if ( newLine ) pw . print ( "\n" ) ;


signature:
public class asciiArray { /** * Print an array . This is a private member function .
 * @ param os is the stream used for writing
 * @ param index is the index of VEC to start printing
 * @ param dims is the number of dimensions in the array
 * @ param shape holds the size of the dimensions of the array .
 * @ param offset holds the current offset into the shape array .
 * @ return the number of elements written . */
private int asciiArray ( PrintWriter os , boolean addName , String label , int index , int dims , int shape [ ] , int offset ) { } }

implementation:
// os . println ( " \ n \ n " ) ;
// os . println ( " \ tdims : " + dims ) ;
// os . println ( " \ toffset : " + offset ) ;
// os . println ( " \ tshape [ " + offset + " ] : " + shape [ offset ] ) ;
// os . println ( " \ tindex : " + index ) ;
// os . println ( " \ n " ) ;
if ( dims == 1 ) { if ( addName ) os . print ( label ) ; for ( int i = 0 ; i < shape [ offset ] ; i ++ ) { PrimitiveVector pv = getPrimitiveVector ( ) ; if ( pv instanceof BaseTypePrimitiveVector ) { BaseType bt = ( ( BaseTypePrimitiveVector ) pv ) . getValue ( index ++ ) ; if ( i > 0 ) { if ( bt instanceof DString ) os . print ( ", " ) ; else os . println ( "" ) ; } ( ( toASCII ) bt ) . toASCII ( os , false , null , false ) ; } else { if ( i > 0 ) os . print ( ", " ) ; pv . printSingleVal ( os , index ++ ) ; } } if ( addName ) os . print ( "\n" ) ; return index ; } else { for ( int i = 0 ; i < shape [ offset ] ; i ++ ) { StringBuilder s = new StringBuilder ( ) ; s . append ( label ) ; s . append ( "[" ) ; s . append ( i ) ; s . append ( "]" ) ; if ( ( dims - 1 ) == 1 ) s . append ( ", " ) ; index = asciiArray ( os , addName , s . toString ( ) , index , dims - 1 , shape , offset + 1 ) ; } return index ; }


signature:
public class AbstractDSP { /** * DSP Extensions */
@ Override public void setContext ( DapContext context ) { } }

implementation:
this . context = context ; // Extract some things from the context
Object o = this . context . get ( Dap4Util . DAP4ENDIANTAG ) ; if ( o != null ) setOrder ( ( ByteOrder ) o ) ; o = this . context . get ( Dap4Util . DAP4CSUMTAG ) ; if ( o != null ) setChecksumMode ( ChecksumMode . modeFor ( o . toString ( ) ) ) ;


signature:
public class AbstractDSP { /** * It is common to want to parse a DMR text to a DapDataset ,
 * so provide this utility .
 * @ param document the dmr to parse
 * @ return the parsed dmr
 * @ throws DapException on parse errors */
protected DapDataset parseDMR ( String document ) throws DapException { } }

implementation:
// Parse the dmr
Dap4Parser parser ; // if ( USEDOM )
parser = new DOM4Parser ( null ) ; // else
// parser = new DOM4Parser ( new DefaultDMRFactory ( ) ) ;
if ( PARSEDEBUG ) parser . setDebugLevel ( 1 ) ; try { if ( ! parser . parse ( document ) ) throw new DapException ( "DMR Parse failed" ) ; } catch ( SAXException se ) { throw new DapException ( se ) ; } if ( parser . getErrorResponse ( ) != null ) throw new DapException ( "Error Response Document not supported" ) ; DapDataset result = parser . getDMR ( ) ; processAttributes ( result ) ; return result ;


signature:
public class AbstractDSP { /** * Walk the dataset tree and remove selected attributes
 * such as _ Unsigned
 * @ param dataset */
protected void processAttributes ( DapDataset dataset ) throws DapException { } }

implementation:
List < DapNode > nodes = dataset . getNodeList ( ) ; for ( DapNode node : nodes ) { switch ( node . getSort ( ) ) { case GROUP : case DATASET : case VARIABLE : Map < String , DapAttribute > attrs = node . getAttributes ( ) ; if ( attrs . size ( ) > 0 ) { List < DapAttribute > suppressed = new ArrayList < > ( ) ; for ( DapAttribute dattr : attrs . values ( ) ) { if ( suppress ( dattr . getShortName ( ) ) ) suppressed . add ( dattr ) ; } for ( DapAttribute dattr : suppressed ) { node . removeAttribute ( dattr ) ; } } break ; default : break ; /* ignore */
} } // Try to extract the byte order
getEndianAttribute ( dataset ) ;


signature:
public class AbstractDSP { /** * Some attributes that are added by the NetcdfDataset
 * need to be kept out of the DMR . This function
 * defines that set .
 * @ param attrname A non - escaped attribute name to be tested for suppression
 * @ return true if the attribute should be suppressed , false otherwise . */
protected boolean suppress ( String attrname ) { } }

implementation: if ( attrname . startsWith ( "_Coord" ) ) return true ; if ( attrname . equals ( "_Unsigned" ) ) return true ; return false ;


signature:
public class DateFromString { /** * Parse the given date string ( starting at the first numeric character )
 * using the given date format string ( as described in
 * java . text . SimpleDateFormat ) and return a Date .
 * @ param dateString the String to be parsed
 * @ param dateFormatString the date format String
 * @ return the Date that was parsed . */
public static Date getDateUsingSimpleDateFormat ( String dateString , String dateFormatString ) { } }

implementation:
// Determine first numeric character in dateString and drop proceeding characters .
int smallestIndex = dateString . length ( ) ; if ( smallestIndex == 0 ) return null ; for ( int i = 0 ; i < 10 ; i ++ ) { int curIndex = dateString . indexOf ( String . valueOf ( i ) ) ; if ( curIndex != - 1 && smallestIndex > curIndex ) smallestIndex = curIndex ; } return getDateUsingCompleteDateFormatWithOffset ( dateString , dateFormatString , smallestIndex ) ;


signature:
public class DateFromString { /** * Parse the given date string , starting at a position given by the offset of the demark character in the dateFormatString .
 * The rest of the dateFormatString is the date format string ( as described in java . text . SimpleDateFormat ) .
 * < pre > Example :
 * dateString = wrfout _ d01_2006-07-06_080000 . nc
 * dateFormatString = wrfout _ d01 _ # yyyy - MM - dd _ HHmm
 * < / pre >
 * This simply counts over " wrfout _ d01 _ " number of chars in dateString , then applies the remaining dateFormatString .
 * @ param dateString the String to be parsed
 * @ param dateFormatString the date format String
 * @ param demark the demarkation character
 * @ return the Date that was parsed . */
public static Date getDateUsingDemarkatedCount ( String dateString , String dateFormatString , char demark ) { } }

implementation:
// the position of the demark char is where to start parsing the dateString
int pos1 = dateFormatString . indexOf ( demark ) ; // the rest of the dateFormatString is the SimpleDateFormat
dateFormatString = dateFormatString . substring ( pos1 + 1 ) ; return getDateUsingCompleteDateFormatWithOffset ( dateString , dateFormatString , pos1 ) ;


signature:
public class DateFromString { /** * Parse the given date string ( between the demarcation characters )
 * using the given date format string ( as described in
 * java . text . SimpleDateFormat ) and return a Date .
 * < pre >
 * Example :
 * dateString = / data / anything / 2006070611 / wrfout _ d01_2006-07-06_080000 . nc
 * dateFormatString = # wrfout _ d01 _ # yyyy - MM - dd _ HHmm
 * would extract the date 2006-07-06T08:00
 * dateString = / data / anything / 2006070611 / wrfout _ d01_2006-07-06_080000 . nc
 * dateFormatString = yyyyMMddHH # / wrfout _ d01 _ #
 * would extract the date 2006-07-06T11:00
 * < / pre >
 * @ param dateString the String to be parsed
 * @ param dateFormatString the date format String
 * @ param demark the demarkation character
 * @ return the Date that was parsed . */
public static Date getDateUsingDemarkatedMatch ( String dateString , String dateFormatString , char demark ) { } }

implementation:
// extract the match string
int pos1 = dateFormatString . indexOf ( demark ) ; int pos2 = dateFormatString . indexOf ( demark , pos1 + 1 ) ; if ( ( pos1 < 0 ) || ( pos2 < 0 ) ) { logger . error ( "Must delineate Date between 2 '#' chars, dateFormatString = '" + dateFormatString + "'" , new Throwable ( ) ) ; return null ; } String match = dateFormatString . substring ( pos1 + 1 , pos2 ) ; int pos3 = dateString . indexOf ( match ) ; if ( pos3 < 0 ) return null ; if ( pos1 > 0 ) { // pos1 > 0 , date is before the match : " yyyyMMddHH # / wrfout _ d01 _ # "
dateFormatString = dateFormatString . substring ( 0 , pos1 ) ; dateString = dateString . substring ( pos3 - dateFormatString . length ( ) , pos3 ) ; } else { // pos1 = = 0 , date is after the match : " # wrfout _ d01 _ # yyyy - MM - dd _ HHmm "
dateFormatString = dateFormatString . substring ( pos2 + 1 ) ; dateString = dateString . substring ( pos3 + match . length ( ) ) ; } // any leading or trailing " . " in the dateFormatString means trim
int posDot1 = 0 ; while ( dateFormatString . charAt ( posDot1 ) == '.' ) posDot1 ++ ; int posDot2 = dateFormatString . length ( ) ; while ( dateFormatString . charAt ( posDot2 - 1 ) == '.' ) posDot2 -- ; if ( posDot1 != 0 || posDot2 != dateFormatString . length ( ) ) { dateFormatString = dateFormatString . substring ( posDot1 , posDot2 ) ; dateString = dateString . substring ( posDot1 , posDot2 ) ; } return getDateUsingCompleteDateFormatWithOffset ( dateString , dateFormatString , 0 ) ;


signature:
public class DateFromString { /** * Parse the given date string ( starting at the given startIndex ) using the
 * given date format string ( as described in java . text . SimpleDateFormat ) and
 * return a Date . Assumes TimeZone is GMT .
 * @ param dateString the String to be parsed
 * @ param dateFormatString the date format String
 * @ param startIndex the index at which to start parsing the date string
 * @ return the Date that was parsed . */
public static Date getDateUsingCompleteDateFormatWithOffset ( String dateString , String dateFormatString , int startIndex ) { } }

implementation:
try { SimpleDateFormat dateFormat = new SimpleDateFormat ( dateFormatString , Locale . US ) ; dateFormat . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; // We have to cut off the dateString , so that it doesnt grab extra characters .
// eg new SimpleDateFormat ( " yyyyMMdd _ HH " ) . parse ( " 20061129_06 " ) - > 2006-12-24T00:00:00Z ( WRONG ! )
String s ; if ( startIndex + dateFormatString . length ( ) <= dateString . length ( ) ) s = dateString . substring ( startIndex , startIndex + dateFormatString . length ( ) ) ; else s = dateString ; Date result = dateFormat . parse ( s ) ; if ( result == null ) throw new RuntimeException ( "SimpleDateFormat bad =" + dateFormatString + " working on =" + s ) ; return result ; } catch ( ParseException e ) { throw new RuntimeException ( "SimpleDateFormat = " + dateFormatString + " fails on " + dateString + " ParseException:" + e . getMessage ( ) ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( "SimpleDateFormat = " + dateFormatString + " fails on " + dateString + " IllegalArgumentException:" + e . getMessage ( ) ) ; }


signature:
public class DateFromString { /** * Use regular expression capture group replacement to construct a date
 * string and return the Date that is obtained by parseing the constructed
 * date string using the date format string " yyyy - MM - dd ' T ' HH : mm " .
 * The date string is constructed by matching the given dateString against
 * the given regular expression matchPattern and then using the capture
 * groups from the match to replace the capture group references , i . e . , " $ n " , where n is an
 * integer .
 * @ param dateString the String to be parsed
 * @ param matchPattern the regular expression String on which to match .
 * @ param substitutionPattern the String to use in the capture group replacement .
 * @ return the calculated Date */
public static Date getDateUsingRegExp ( String dateString , String matchPattern , String substitutionPattern ) { } }

implementation: String dateFormatString = "yyyy-MM-dd'T'HH:mm" ; return getDateUsingRegExpAndDateFormat ( dateString , matchPattern , substitutionPattern , dateFormatString ) ;


signature:
public class DateFromString { /** * The same as getDateUsingRegExp ( ) except the date format string to be used
 * must be specified .
 * @ param dateString the String to be parsed
 * @ param matchPattern the regular expression String on which to match .
 * @ param substitutionPattern the String to use in the capture group replacement .
 * @ param dateFormatString the date format string to use in the parsing of the date string .
 * @ return the calculated Date */
public static Date getDateUsingRegExpAndDateFormat ( String dateString , String matchPattern , String substitutionPattern , String dateFormatString ) { } }

implementation:
// Match the given date string against the regular expression .
java . util . regex . Pattern pattern = java . util . regex . Pattern . compile ( matchPattern ) ; java . util . regex . Matcher matcher = pattern . matcher ( dateString ) ; if ( ! matcher . matches ( ) ) { return null ; } // Build date string to use with date format string by
// substituting the capture groups into the substitution pattern .
StringBuffer dateStringFormatted = new StringBuffer ( ) ; matcher . appendReplacement ( dateStringFormatted , substitutionPattern ) ; if ( dateStringFormatted . length ( ) == 0 ) { return null ; } return getDateUsingCompleteDateFormat ( dateStringFormatted . toString ( ) , dateFormatString ) ;


signature:
public class PolyconicProjection { /** * Convert a LatLonPoint to projection coordinates
 * @ param latlon convert from these lat , lon coordinates
 * @ param result the object to write to
 * @ return the given result */
@ Override public ProjectionPoint latLonToProj ( LatLonPoint latlon , ProjectionPointImpl result ) { } }

implementation: double fromLat = Math . toRadians ( latlon . getLatitude ( ) ) ; double theta = Math . toRadians ( latlon . getLongitude ( ) ) ; if ( projectionLongitude != 0 && ! Double . isNaN ( theta ) ) { theta = MapMath . normalizeLongitude ( theta - projectionLongitude ) ; } ProjectionPointImpl out = new ProjectionPointImpl ( ) ; project ( theta , fromLat , out ) ; result . setLocation ( totalScale * out . getX ( ) + falseEasting , totalScale * out . getY ( ) + falseNorthing ) ; return result ;


signature:
public class PolyconicProjection { /** * Convert projection coordinates to a LatLonPoint
 * Note : a new object is not created on each call for the return value .
 * @ param world convert from these projection coordinates
 * @ param result the object to write to
 * @ return LatLonPoint convert to these lat / lon coordinates */
@ Override public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) { } }

implementation:
double fromX = ( world . getX ( ) - falseEasting ) / totalScale ; // assumes cartesian coords in km
double fromY = ( world . getY ( ) - falseNorthing ) / totalScale ; ProjectionPointImpl pp = new ProjectionPointImpl ( ) ; projectInverse ( fromX , fromY , pp ) ; if ( pp . getX ( ) < - Math . PI ) { pp . setX ( - Math . PI ) ; } else if ( pp . getX ( ) > Math . PI ) { pp . setX ( Math . PI ) ; } if ( projectionLongitude != 0 && ! Double . isNaN ( pp . getX ( ) ) ) { pp . setX ( MapMath . normalizeLongitude ( pp . getX ( ) + projectionLongitude ) ) ; } result . setLatitude ( Math . toDegrees ( pp . getY ( ) ) ) ; result . setLongitude ( Math . toDegrees ( pp . getX ( ) ) ) ; return result ;


signature:
public class CoordinatePartitionUnionizer { /** * only one message per CoordinatePartitionUnionizer instance */
public void addCoords ( List < Coordinate > coords , PartitionCollectionMutable . Partition part ) { } }

implementation:
Coordinate runtime = null ; for ( Coordinate coord : coords ) { switch ( coord . getType ( ) ) { case runtime : CoordinateRuntime rtime = ( CoordinateRuntime ) coord ; if ( runtimeBuilder == null ) runtimeBuilder = new CoordinateRuntime . Builder2 ( rtime . getTimeUnits ( ) ) ; runtimeBuilder . addAll ( coord ) ; runtime = coord ; if ( debugPartitionErrors && ! duplicateRuntimeMessage && part != null ) testDuplicateRuntime ( rtime , part ) ; break ; case time : CoordinateTime time = ( CoordinateTime ) coord ; if ( timeBuilder == null ) timeBuilder = new CoordinateTime . Builder2 ( coord . getCode ( ) , time . getTimeUnit ( ) , time . getRefDate ( ) ) ; timeBuilder . addAll ( coord ) ; break ; case timeIntv : CoordinateTimeIntv timeIntv = ( CoordinateTimeIntv ) coord ; if ( timeIntvBuilder == null ) timeIntvBuilder = new CoordinateTimeIntv . Builder2 ( null , coord . getCode ( ) , timeIntv . getTimeUnit ( ) , timeIntv . getRefDate ( ) ) ; timeIntvBuilder . addAll ( intervalFilter ( ( CoordinateTimeIntv ) coord ) ) ; break ; case time2D : CoordinateTime2D time2D = ( CoordinateTime2D ) coord ; if ( time2DBuilder == null ) time2DBuilder = new CoordinateTime2DUnionizer ( time2D . isTimeInterval ( ) , time2D . getTimeUnit ( ) , coord . getCode ( ) , false , logger ) ; time2DBuilder . addAll ( time2D ) ; // debug
CoordinateRuntime runtimeFrom2D = time2D . getRuntimeCoordinate ( ) ; if ( ! runtimeFrom2D . equals ( runtime ) ) logger . warn ( "HEY CoordinateUnionizer runtimes not equal" ) ; break ; case ens : if ( ensBuilder == null ) ensBuilder = new CoordinateEns . Builder2 ( coord . getCode ( ) ) ; ensBuilder . addAll ( coord ) ; break ; case vert : CoordinateVert vertCoord = ( CoordinateVert ) coord ; if ( vertBuilder == null ) vertBuilder = new CoordinateVert . Builder2 ( coord . getCode ( ) , vertCoord . getVertUnit ( ) ) ; vertBuilder . addAll ( coord ) ; break ; } }


signature:
public class ParseUtil { /** * Split a < Value > . . . < / Value > into its component strings .
 * Generally , type checking is not performed . String quotes
 * are obeyed and backslash escapes are removed . */
static public List < String > collectValues ( String text ) throws ParseException { } }

implementation:
List < String > values = new ArrayList < String > ( ) ; StringBuffer buf = new StringBuffer ( ) ; text = text . trim ( ) + '\0' ; int i = 0 ; for ( ; ; ) { char c = text . charAt ( i ++ ) ; if ( c == '\0' ) break ; // eos
if ( c <= ' ' || c == 127 ) // whitespace
continue ; if ( c == '\'' ) { // collect char constant
c = text . charAt ( i ++ ) ; if ( c == '\0' ) throw new ParseException ( "Malformed char constant: no final '''" ) ; else if ( i >= 128 ) throw new ParseException ( "Illegal char constant: " + ( int ) c ) ; buf . append ( c ) ; values . add ( buf . toString ( ) ) ; buf . setLength ( 0 ) ; } else if ( c == '"' ) { // collect quoted string
for ( ; ; ) { c = text . charAt ( i ++ ) ; if ( c == '\0' ) { i -- ; break ; } if ( c == '\\' ) { c = text . charAt ( i ++ ) ; } else if ( c == '"' ) break ; buf . append ( c ) ; } if ( c == '\0' ) throw new ParseException ( "Malformed string: no final '\"'" ) ; values . add ( buf . toString ( ) ) ; buf . setLength ( 0 ) ; } else { // collect upto next whitespace or eos
do { if ( c == '\\' ) { c = text . charAt ( i ++ ) ; } buf . append ( c ) ; c = text . charAt ( i ++ ) ; } while ( c > ' ' && c != 127 ) ; values . add ( buf . toString ( ) ) ; buf . setLength ( 0 ) ; if ( c == 0 ) i -- ; // So we never move past the trailing eol
} } return values ;


signature:
public class Fysatiosp { /** * reading */
public void open ( ucar . unidata . io . RandomAccessFile raf , ucar . nc2 . NetcdfFile ncfile , ucar . nc2 . util . CancelTask cancelTask ) throws IOException { } }

implementation: super . open ( raf , ncfile , cancelTask ) ; headerParser = new FysatHeader ( ) ; headerParser . read ( raf , ncfile ) ; ncfile . finish ( ) ;


signature:
public class Fysatiosp { /** * all the work is here , so can be called recursively */
private Array readData ( ucar . nc2 . Variable v2 , long dataPos , int [ ] origin , int [ ] shape , int [ ] stride ) throws IOException , InvalidRangeException { } }

implementation:
// long length = myRaf . length ( ) ;
raf . seek ( dataPos ) ; Vinfo vi = ( Vinfo ) v2 . getSPobject ( ) ; int data_size = vi . vsize ; byte [ ] data = new byte [ data_size ] ; raf . readFully ( data ) ; Array array ; if ( vi . classType == DataType . BYTE . getPrimitiveClassType ( ) ) { array = Array . factory ( DataType . BYTE , v2 . getShape ( ) , data ) ; } else if ( vi . classType == DataType . SHORT . getPrimitiveClassType ( ) ) { EndianByteBuffer byteBuff = new EndianByteBuffer ( data , vi . byteOrder ) ; short [ ] sdata = byteBuff . getShortArray ( ) ; // for ( int i = 0 ; i < sdata . length ; i + + ) {
// System . out . println ( sdata [ i ] ) ;
array = Array . factory ( DataType . SHORT , v2 . getShape ( ) , sdata ) ; } else if ( vi . classType == DataType . INT . getPrimitiveClassType ( ) ) { EndianByteBuffer byteBuff = new EndianByteBuffer ( data , vi . byteOrder ) ; short [ ] idata = byteBuff . getShortArray ( ) ; array = Array . factory ( DataType . INT , v2 . getShape ( ) , idata ) ; } else { throw new UnsupportedEncodingException ( ) ; } return array . sectionNoReduce ( origin , shape , stride ) ;


signature:
public class Fysatiosp { /** * for the compressed data read all out into a array and then parse into requested */
public Array readCompressedData ( ucar . nc2 . Variable v2 , long dataPos , int [ ] origin , int [ ] shape , int [ ] stride ) throws IOException , InvalidRangeException { } }

implementation: long length = raf . length ( ) ; raf . seek ( dataPos ) ; int data_size = ( int ) ( length - dataPos ) ; byte [ ] data = new byte [ data_size ] ; raf . readFully ( data ) ; ByteArrayInputStream ios = new ByteArrayInputStream ( data ) ; BufferedImage image = javax . imageio . ImageIO . read ( ios ) ; Raster raster = image . getData ( ) ; DataBuffer db = raster . getDataBuffer ( ) ; if ( db instanceof DataBufferByte ) { DataBufferByte dbb = ( DataBufferByte ) db ; byte [ ] udata = dbb . getData ( ) ; Array array = Array . factory ( DataType . BYTE , v2 . getShape ( ) , udata ) ; v2 . setCachedData ( array , false ) ; return array . sectionNoReduce ( origin , shape , stride ) ; } return null ;


signature:
public class Fysatiosp { /** * * Name : GetGiniLine
 * * Purpose : Extract a line of data from a GINI image
 * * Parameters :
 * * buf - buffer containing image data
 * * Returns :
 * * SUCCESS = = 1
 * * FAILURE = = 0 */
private byte [ ] getGiniLine ( int nx , int ny , long doff , int lineNumber , int len , int stride ) throws IOException { } }

implementation:
byte [ ] data = new byte [ len ] ; /* * * checking image file and set location of first line in file */
raf . seek ( doff ) ; if ( lineNumber >= ny ) throw new IOException ( "Try to access the file at line number= " + lineNumber + " larger then last line number = " + ny ) ; /* * * Read in the requested line */
int offset = lineNumber * nx + ( int ) doff ; // myRaf . seek ( offset ) ;
for ( int i = 0 ; i < len ; i ++ ) { raf . seek ( offset ) ; data [ i ] = raf . readByte ( ) ; offset = offset + stride ; // myRaf . seek ( offset ) ;
} // myRaf . read ( data , 0 , len ) ;
return data ;


signature:
public class GdsHorizCoordSys { /** * some weird adjustment for la1 and la2. */
public void setGaussianLats ( int nparallels , float la1 , float la2 ) { } }

implementation:
log . debug ( "la1 {}, la2 {}" , la1 , la2 ) ; if ( this . gaussLats != null ) throw new RuntimeException ( "Cant modify GdsHorizCoordSys" ) ; int nlats = ( 2 * nparallels ) ; GaussianLatitudes gaussLats = GaussianLatitudes . factory ( nlats ) ; int bestStartIndex = 0 , bestEndIndex = 0 ; double bestStartDiff = Double . MAX_VALUE ; double bestEndDiff = Double . MAX_VALUE ; for ( int i = 0 ; i < nlats ; i ++ ) { double diff = Math . abs ( gaussLats . latd [ i ] - la1 ) ; if ( diff < bestStartDiff ) { bestStartDiff = diff ; bestStartIndex = i ; } diff = Math . abs ( gaussLats . latd [ i ] - la2 ) ; if ( diff < bestEndDiff ) { bestEndDiff = diff ; bestEndIndex = i ; } } log . debug ( "first pass: bestStartIndex {}, bestEndIndex {}" , bestStartIndex , bestEndIndex ) ; if ( Math . abs ( bestEndIndex - bestStartIndex ) + 1 != nyRaw ) { log . warn ( "GRIB gaussian lats: NP != NY, use NY" ) ; // see email from Toussaint @ dkrz . de datafil :
nlats = nyRaw ; gaussLats = GaussianLatitudes . factory ( nlats ) ; bestStartIndex = 0 ; bestEndIndex = nyRaw - 1 ; } boolean goesUp = bestEndIndex > bestStartIndex ; log . debug ( "bestStartIndex {}, bestEndIndex {}, goesUp {}" , bestStartIndex , bestEndIndex , goesUp ) ; // create the data
int useIndex = bestStartIndex ; float [ ] data = new float [ nyRaw ] ; float [ ] gaussw = new float [ nyRaw ] ; for ( int i = 0 ; i < nyRaw ; i ++ ) { data [ i ] = ( float ) gaussLats . latd [ useIndex ] ; gaussw [ i ] = ( float ) gaussLats . gaussw [ useIndex ] ; log . trace ( "i {}, useIndex {}, data {}, gaussw {}" , i , useIndex , data [ i ] , gaussw [ i ] ) ; if ( goesUp ) { useIndex ++ ; } else { useIndex -- ; } } this . gaussLats = Array . factory ( DataType . FLOAT , new int [ ] { nyRaw } , data ) ; this . gaussw = Array . factory ( DataType . FLOAT , new int [ ] { nyRaw } , gaussw ) ;


signature:
public class Gdc_To_Utm_Converter { /** * _ more _
 * @ param a major axis
 * @ param f inverse flattening
 * @ param zone _ more _
 * @ param isNorth _ more _ */
protected void init ( double a , double f , int zone , boolean isNorth ) { } }


signature:
public class ParsedSectionSpec { /** * Parse a section specification String . These have the form :
 * < pre >
 * section specification : = selector | selector ' . ' selector
 * selector : = varName [ ' ( ' dims ' ) ' ]
 * varName : = ESCAPED _ STRING
 * dims : = dim | dim , dims
 * dim : = ' : ' | slice | start ' : ' end | start ' : ' end ' : ' stride
 * slice : = INTEGER
 * start : = INTEGER
 * stride : = INTEGER
 * end : = INTEGER
 * ESCAPED _ STRING : must escape characters = " . ( "
 * < / pre >
 * Nonterminals are in lower case , terminals are in upper case , literals are in single quotes .
 * Optional components are enclosed between square braces ' [ ' and ' ] ' .
 * @ param ncfile look for variable in here
 * @ param variableSection the string to parse , eg " record ( 12 ) . wind ( 1:20 , : , 3 ) "
 * @ return return ParsedSectionSpec , aprsed representation of the variableSection String
 * @ throws IllegalArgumentException when token is misformed , or variable name doesnt exist in ncfile
 * @ throws ucar . ma2 . InvalidRangeException if section does not match variable shape
 * @ see < a href = " http : / / www . unidata . ucar . edu / software / netcdf - java / reference / SectionSpecification . html " > SectionSpecification < / a > */
public static ParsedSectionSpec parseVariableSection ( NetcdfFile ncfile , String variableSection ) throws InvalidRangeException { } }

implementation:
List < String > tokes = EscapeStrings . tokenizeEscapedName ( variableSection ) ; if ( tokes . size ( ) == 0 ) throw new IllegalArgumentException ( "empty sectionSpec = " + variableSection ) ; String selector = tokes . get ( 0 ) ; ParsedSectionSpec outerV = parseVariableSelector ( ncfile , selector ) ; // parse each selector , find the inner variable
ParsedSectionSpec current = outerV ; for ( int i = 1 ; i < tokes . size ( ) ; i ++ ) { selector = tokes . get ( i ) ; current . child = parseVariableSelector ( current . v , selector ) ; current = current . child ; } return outerV ;


signature:
public class ParsedSectionSpec { /** * parse variable name and index selector out of the selector String . variable name must be escaped */
private static ParsedSectionSpec parseVariableSelector ( Object parent , String selector ) throws InvalidRangeException { } }

implementation:
String varNameEsc , indexSelect = null ; int pos1 = EscapeStrings . indexOf ( selector , '(' ) ; if ( pos1 < 0 ) { // no index
varNameEsc = selector ; } else { varNameEsc = selector . substring ( 0 , pos1 ) ; int pos2 = selector . indexOf ( ')' , pos1 + 1 ) ; indexSelect = selector . substring ( pos1 , pos2 ) ; } if ( debugSelector ) System . out . println ( " parseVariableSection <" + selector + "> = <" + varNameEsc + ">, <" + indexSelect + ">" ) ; Variable v = null ; if ( parent instanceof NetcdfFile ) { // then varNameEsc = varFullNameEsc ( i . e . includes groups )
NetcdfFile ncfile = ( NetcdfFile ) parent ; v = ncfile . findVariable ( varNameEsc ) ; } else if ( parent instanceof Structure ) { // then varNameEsc = memberNameEsc ( i . e . includes groups )
Structure s = ( Structure ) parent ; v = s . findVariable ( NetcdfFile . makeNameUnescaped ( varNameEsc ) ) ; // s . findVariable wants unescaped version
} if ( v == null ) throw new IllegalArgumentException ( " cant find variable: " + varNameEsc + " in selector=" + selector ) ; if ( v . getDataType ( ) == DataType . SEQUENCE ) indexSelect = null ; // ignore whatever was sent
// get the selected Ranges , or all , and add to the list
Section section ; if ( indexSelect != null ) { section = new Section ( indexSelect ) ; section = Section . fill ( section , v . getShape ( ) ) ; // Check section has no nulls , set from shape array .
} else { section = v . getShapeAsSection ( ) ; // all
} return new ParsedSectionSpec ( v , section ) ;


signature:
public class ParsedSectionSpec { /** * Make section specification String from a range list for a Variable .
 * @ param v for this Variable .
 * @ param ranges list of Range . Must includes all parent structures . The list be null , meaning use all .
 * Individual ranges may be null , meaning all for that dimension .
 * @ return section specification String .
 * @ throws InvalidRangeException is specified section doesnt match variable shape */
public static String makeSectionSpecString ( Variable v , List < Range > ranges ) throws InvalidRangeException { } }

implementation: StringBuilder sb = new StringBuilder ( ) ; makeSpec ( sb , v , ranges ) ; return sb . toString ( ) ;


signature:
public class GeoGridCoordinate2D { /** * Is the point ( lat , lon ) contained in the ( row , col ) rectangle ?
 * @ param wantLat lat of point
 * @ param wantLon lon of point
 * @ param rectIndex rectangle row , col , will be clipped to [ 0 , nrows ) , [ 0 , ncols )
 * @ return true if contained */
private boolean containsOld ( double wantLat , double wantLon , int [ ] rectIndex ) { } }

implementation: rectIndex [ 0 ] = Math . max ( Math . min ( rectIndex [ 0 ] , nrows - 1 ) , 0 ) ; rectIndex [ 1 ] = Math . max ( Math . min ( rectIndex [ 1 ] , ncols - 1 ) , 0 ) ; int row = rectIndex [ 0 ] ; int col = rectIndex [ 1 ] ; if ( debug ) System . out . printf ( " (%d,%d) contains (%f,%f) in (lat=%f %f) (lon=%f %f) ?%n" , rectIndex [ 0 ] , rectIndex [ 1 ] , wantLat , wantLon , latEdge . get ( row , col ) , latEdge . get ( row + 1 , col ) , lonEdge . get ( row , col ) , lonEdge . get ( row , col + 1 ) ) ; if ( wantLat < latEdge . get ( row , col ) ) return false ; if ( wantLat > latEdge . get ( row + 1 , col ) ) return false ; if ( wantLon < lonEdge . get ( row , col ) ) return false ; if ( wantLon > lonEdge . get ( row , col + 1 ) ) return false ; return true ;


signature:
public class GeoGridCoordinate2D { /** * http : / / mathforum . org / library / drmath / view / 54386 . html
 * Given any three points on the plane ( x0 , y0 ) , ( x1 , y1 ) , and
 * ( x2 , y2 ) , the area of the triangle determined by them is
 * given by the following formula :
 * 1 | x0 y0 1 |
 * A = - | x1 y1 1 | ,
 * 2 | x2 y2 1 |
 * where the vertical bars represent the determinant .
 * the value of the expression above is :
 * ( . 5 ) ( x1 * y2 - y1 * x2 - x0 * y2 + y0 * x2 + x0 * y1 - y0 * x1)
 * The amazing thing is that A is positive if the three points are
 * taken in a counter - clockwise orientation , and negative otherwise .
 * To be inside a rectangle ( or any convex body ) , as you trace
 * around in a clockwise direction from p1 to p2 to p3 to p4 and
 * back to p1 , the " areas " of triangles p1 p2 p , p2 p3 p , p3 p4 p ,
 * and p4 p1 p must all be positive . If you don ' t know the
 * orientation of your rectangle , then they must either all be
 * positive or all be negative .
 * this method works for arbitrary convex regions oo the plane . */
private boolean contains ( double wantLat , double wantLon , int [ ] rectIndex ) { } }

implementation:
rectIndex [ 0 ] = Math . max ( Math . min ( rectIndex [ 0 ] , nrows - 1 ) , 0 ) ; rectIndex [ 1 ] = Math . max ( Math . min ( rectIndex [ 1 ] , ncols - 1 ) , 0 ) ; int row = rectIndex [ 0 ] ; int col = rectIndex [ 1 ] ; double x1 = lonEdge . get ( row , col ) ; double y1 = latEdge . get ( row , col ) ; double x2 = lonEdge . get ( row , col + 1 ) ; double y2 = latEdge . get ( row , col + 1 ) ; double x3 = lonEdge . get ( row + 1 , col + 1 ) ; double y3 = latEdge . get ( row + 1 , col + 1 ) ; double x4 = lonEdge . get ( row + 1 , col ) ; double y4 = latEdge . get ( row + 1 , col ) ; // must all have same determinate sign
boolean sign = detIsPositive ( x1 , y1 , x2 , y2 , wantLon , wantLat ) ; if ( sign != detIsPositive ( x2 , y2 , x3 , y3 , wantLon , wantLat ) ) return false ; if ( sign != detIsPositive ( x3 , y3 , x4 , y4 , wantLon , wantLat ) ) return false ; if ( sign != detIsPositive ( x4 , y4 , x1 , y1 , wantLon , wantLat ) ) return false ; return true ;


signature:
public class GeoGridCoordinate2D { /** * choose x , y such that ( matrix multiply ) :
 * ( wantx ) = ( fxx fxy ) ( x )
 * ( wanty ) ( fyx fyy ) ( y )
 * where fxx = d ( fx ) / dx ~ = delta lon in lon direction
 * where fxy = d ( fx ) / dy ~ = delta lon in lat direction
 * where fyx = d ( fy ) / dx ~ = delta lat in lon direction
 * where fyy = d ( fy ) / dy ~ = delta lat in lat direction
 * 2 linear equations in 2 unknowns , solve in usual way */
private boolean jump2 ( double wantLat , double wantLon , int [ ] rectIndex ) { } }

implementation:
int row = Math . max ( Math . min ( rectIndex [ 0 ] , nrows - 1 ) , 0 ) ; int col = Math . max ( Math . min ( rectIndex [ 1 ] , ncols - 1 ) , 0 ) ; double lat = latEdge . get ( row , col ) ; double lon = lonEdge . get ( row , col ) ; double diffLat = wantLat - lat ; double diffLon = wantLon - lon ; double dlatdy = latEdge . get ( row + 1 , col ) - lat ; double dlatdx = latEdge . get ( row , col + 1 ) - lat ; double dlondx = lonEdge . get ( row , col + 1 ) - lon ; double dlondy = lonEdge . get ( row + 1 , col ) - lon ; // solve for dlon
double dx = ( diffLon - dlondy * diffLat / dlatdy ) / ( dlondx - dlatdx * dlondy / dlatdy ) ; // double dy = ( diffLat - dlatdx * diffLon / dlondx ) / ( dlatdy - dlatdx * dlondy / dlondx ) ;
double dy = ( diffLat - dlatdx * dx ) / dlatdy ; if ( debug ) System . out . printf ( "   jump from %d %d (dlondx=%f dlondy=%f dlatdx=%f dlatdy=%f) (diffLat,Lon=%f %f) (deltalat,Lon=%f %f)" , row , col , dlondx , dlondy , dlatdx , dlatdy , diffLat , diffLon , dy , dx ) ; int drow = ( int ) Math . round ( dy ) ; int dcol = ( int ) Math . round ( dx ) ; if ( ( drow == 0 ) && ( dcol == 0 ) ) { if ( debug ) System . out . printf ( "%n   incr:" ) ; return incr ( wantLat , wantLon , rectIndex ) ; } else { rectIndex [ 0 ] = Math . max ( Math . min ( row + drow , nrows - 1 ) , 0 ) ; rectIndex [ 1 ] = Math . max ( Math . min ( col + dcol , ncols - 1 ) , 0 ) ; if ( debug ) System . out . printf ( " to (%d %d)%n" , rectIndex [ 0 ] , rectIndex [ 1 ] ) ; if ( ( row == rectIndex [ 0 ] ) && ( col == rectIndex [ 1 ] ) ) return false ; // nothing has changed
} return true ;


signature:
public class GeoGridCoordinate2D { /** * we think its got to be in one of the 9 boxes around rectIndex */
private boolean box9 ( double wantLat , double wantLon , int [ ] rectIndex ) { } }

implementation: int row = rectIndex [ 0 ] ; int minrow = Math . max ( row - 1 , 0 ) ; int maxrow = Math . min ( row + 1 , nrows ) ; int col = rectIndex [ 1 ] ; int mincol = Math . max ( col - 1 , 0 ) ; int maxcol = Math . min ( col + 1 , ncols ) ; if ( debug ) System . out . printf ( "%n   box9:" ) ; for ( int i = minrow ; i <= maxrow ; i ++ ) for ( int j = mincol ; j <= maxcol ; j ++ ) { rectIndex [ 0 ] = i ; rectIndex [ 1 ] = j ; if ( contains ( wantLat , wantLon , rectIndex ) ) return true ; } return false ;


signature:
public class CFHybridHeight { /** * Make the < code > CoordinateTransform < / code > from the dataset
 * @ param ds the dataset
 * @ param ctv the variable with the formula
 * @ return the < code > CoordinateTransform < / code > */
public VerticalCT makeCoordinateTransform ( NetcdfDataset ds , AttributeContainer ctv ) { } }

implementation:
String formula_terms = getFormula ( ctv ) ; if ( null == formula_terms ) return null ; // parse the formula string
String [ ] values = parseFormula ( formula_terms , "a b orog" ) ; if ( values == null ) return null ; a = values [ 0 ] ; b = values [ 1 ] ; orog = values [ 2 ] ; VerticalCT rs = new VerticalCT ( "AtmHybridHeight_Transform_" + ctv . getName ( ) , getTransformName ( ) , VerticalCT . Type . HybridHeight , this ) ; rs . addParameter ( new Parameter ( "standard_name" , getTransformName ( ) ) ) ; rs . addParameter ( new Parameter ( "formula_terms" , formula_terms ) ) ; rs . addParameter ( new Parameter ( "formula" , "height(x,y,z) = a(z) + b(z)*orog(x,y)" ) ) ; if ( ! addParameter ( rs , HybridHeight . A , ds , a ) ) { return null ; } if ( ! addParameter ( rs , HybridHeight . B , ds , b ) ) { return null ; } if ( ! addParameter ( rs , HybridHeight . OROG , ds , orog ) ) { return null ; } return rs ;


signature:
public class HTTPMethod { /** * Calling close will force the method to close , and will
 * force any open stream to terminate . If the session is local ,
 * Then that too will be closed . */
public synchronized void close ( ) { } }

implementation:
if ( closed ) return ; // recursive calls ok
closed = true ; // mark as closed to prevent recursive calls
if ( methodstream != null ) { try { this . methodstream . close ( ) ; // May recursr
} catch ( IOException ioe ) { /* failure is ok */
} this . methodstream = null ; } // Force release underlying connection back to the connection manager
if ( this . lastresponse != null ) { if ( false ) { try { try { // Attempt to keep connection alive by consuming its remaining content
EntityUtils . consume ( this . lastresponse . getEntity ( ) ) ; } finally { HttpClientUtils . closeQuietly ( this . lastresponse ) ; // Paranoia
} } catch ( IOException ignore ) { /* ignore */
} } else HttpClientUtils . closeQuietly ( this . lastresponse ) ; this . lastresponse = null ; } if ( session != null ) { session . removeMethod ( this ) ; if ( localsession ) { session . close ( ) ; session = null ; } } this . lastrequest = null ;


signature:
public class HTTPMethod { /** * Create a request , add headers , and content ,
 * then send to HTTPSession to do the bulk of the work .
 * @ return statuscode */
public int execute ( ) throws HTTPException { } }

implementation: HttpResponse res = executeRaw ( ) ; if ( res != null ) return res . getStatusLine ( ) . getStatusCode ( ) ; else throw new HTTPException ( "HTTPMethod.execute: null response" ) ;


signature:
public class HTTPMethod { /** * debug only */
public HttpResponse executeRaw ( ) throws HTTPException { } }

implementation:
if ( this . closed ) throw new IllegalStateException ( "HTTPMethod: attempt to execute closed method" ) ; if ( this . executed ) throw new IllegalStateException ( "HTTPMethod: attempt to re-execute method" ) ; this . executed = true ; if ( this . methodurl == null ) throw new HTTPException ( "HTTPMethod: no url specified" ) ; if ( ! localsession && ! sessionCompatible ( this . methodurl ) ) throw new HTTPException ( "HTTPMethod: session incompatible url: " + this . methodurl ) ; // Capture the current state of the parent HTTPSession ; never to be modified in this class
this . settings = session . mergedSettings ( ) ; try { // add range header
if ( this . range != null ) { this . headers . put ( "Range" , "bytes=" + range [ 0 ] + "-" + range [ 1 ] ) ; range = null ; } RequestBuilder rb = getRequestBuilder ( ) ; setcontent ( rb ) ; setheaders ( rb , this . headers ) ; this . lastrequest = buildRequest ( rb , this . settings ) ; AuthScope methodscope = HTTPAuthUtil . uriToAuthScope ( this . methodurl ) ; AuthScope target = HTTPAuthUtil . authscopeUpgrade ( session . getSessionScope ( ) , methodscope ) ; // AFAIK , targethost , httpclient , rb , and session
// contain non - overlapping info = > we cannot derive one
// from any of the others .
HttpHost targethost = HTTPAuthUtil . authscopeToHost ( target ) ; HttpClientBuilder cb = HttpClients . custom ( ) ; configClient ( cb , this . settings ) ; session . setAuthenticationAndProxy ( cb ) ; HttpClient httpclient = cb . build ( ) ; if ( MOCKEXECUTOR != null ) { URI uri = this . lastrequest . getURI ( ) ; this . lastresponse = MOCKEXECUTOR . execute ( this . lastrequest ) ; } else { this . lastresponse = httpclient . execute ( targethost , this . lastrequest , session . getContext ( ) ) ; } if ( this . lastresponse == null ) throw new HTTPException ( "HTTPMethod.execute: Response was null" ) ; return this . lastresponse ; } catch ( IOException ioe ) { throw new HTTPException ( ioe ) ; }


signature: public class CFpointObs { protected TableConfig getPointConfig ( NetcdfDataset ds , EncodingInfo info , Formatter errlog ) throws IOException { } }

implementation: if ( info . time . getRank ( ) != 1 ) { errlog . format ( "CFpointObs type=point: coord time must have rank 1, coord var= %s %n" , info . time . getNameAndDimensions ( ) ) ; return null ; } Dimension obsDim = info . time . getDimension ( 0 ) ; TableConfig obsTable = makeSingle ( ds , obsDim , errlog ) ; obsTable . featureType = FeatureType . POINT ; return obsTable ;


signature: public class CFpointObs { protected TableConfig getStationConfig ( NetcdfDataset ds , EncodingInfo info , Formatter errlog ) throws IOException { } }

implementation:
if ( ! identifyEncodingStation ( ds , info , CF . FeatureType . timeSeries , errlog ) ) return null ; // make station table
TableConfig stnTable = makeStationTable ( ds , FeatureType . STATION , info , errlog ) ; if ( stnTable == null ) return null ; Dimension obsDim = info . childDim ; TableConfig obsTable = null ; switch ( info . encoding ) { case single : obsTable = makeSingle ( ds , obsDim , errlog ) ; break ; case multidim : obsTable = makeMultidimInner ( ds , stnTable , info . childDim , info , errlog ) ; if ( info . time . getRank ( ) == 1 ) { // join time ( time )
obsTable . addJoin ( new JoinArray ( info . time , JoinArray . Type . raw , 0 ) ) ; obsTable . time = info . time . getFullName ( ) ; } break ; case raggedContiguous : stnTable . numRecords = info . ragged_rowSize . getFullName ( ) ; obsTable = makeRaggedContiguousChildTable ( ds , info . parentDim , info . childDim , info . childStruct , errlog ) ; break ; case raggedIndex : obsTable = makeRaggedIndexChildTable ( ds , info . parentDim , info . childDim , info . ragged_parentIndex , errlog ) ; break ; case flat : info . set ( Encoding . flat , obsDim ) ; obsTable = makeStructTable ( ds , FeatureType . STATION , info , errlog ) ; obsTable . parentIndex = ( info . instanceId == null ) ? null : info . instanceId . getFullName ( ) ; Variable stnIdVar = Evaluator . findVariableWithAttributeAndDimension ( ds , CF . CF_ROLE , CF . STATION_ID , obsDim , errlog ) ; if ( stnIdVar == null ) stnIdVar = Evaluator . findVariableWithAttributeAndDimension ( ds , CF . STANDARD_NAME , CF . STATION_ID , obsDim , errlog ) ; obsTable . stnId = ( stnIdVar == null ) ? null : stnIdVar . getFullName ( ) ; obsTable . stnDesc = Evaluator . findNameOfVariableWithAttributeValue ( ds , CF . STANDARD_NAME , CF . PLATFORM_NAME ) ; if ( obsTable . stnDesc == null ) obsTable . stnDesc = Evaluator . findNameOfVariableWithAttributeValue ( ds , CF . STANDARD_NAME , CF . STATION_DESC ) ; obsTable . stnWmoId = Evaluator . findNameVariableWithStandardNameAndDimension ( ds , CF . STATION_WMOID , obsDim , errlog ) ; obsTable . stnAlt = Evaluator . findNameVariableWithStandardNameAndDimension ( ds , CF . SURFACE_ALTITUDE , obsDim , errlog ) ; if ( obsTable . stnAlt == null ) obsTable . stnAlt = Evaluator . findNameVariableWithStandardNameAndDimension ( ds , CF . STATION_ALTITUDE , obsDim , errlog ) ; break ; } if ( obsTable == null ) return null ; stnTable . addChild ( obsTable ) ; return stnTable ;


signature: public class CFpointObs { protected TableConfig getProfileConfig ( NetcdfDataset ds , EncodingInfo info , Formatter errlog ) throws IOException { } }

implementation:
if ( ! identifyEncodingProfile ( ds , info , errlog ) ) return null ; TableConfig profileTable = makeStructTable ( ds , FeatureType . PROFILE , info , errlog ) ; if ( profileTable == null ) return null ; profileTable . feature_id = identifyIdVariableName ( ds , CF . FeatureType . profile ) ; if ( profileTable . feature_id == null ) { errlog . format ( "CFpointObs getProfileConfig cant find a profile id %n" ) ; } // obs table
VariableDS z = CoordSysEvaluator . findCoordByType ( ds , AxisType . Height ) ; if ( z == null ) z = CoordSysEvaluator . findCoordByType ( ds , AxisType . Pressure ) ; if ( z == null ) z = CoordSysEvaluator . findCoordByType ( ds , AxisType . GeoZ ) ; if ( z == null ) { errlog . format ( "CFpointObs getProfileConfig cant find a Height coordinate %n" ) ; return null ; } if ( info . childStruct == null ) info . childStruct = z . getParentStructure ( ) ; TableConfig obsTable = null ; switch ( info . encoding ) { case single : obsTable = makeSingle ( ds , info . childDim , errlog ) ; break ; case multidim : obsTable = makeMultidimInner ( ds , profileTable , info . childDim , info , errlog ) ; if ( z . getRank ( ) == 1 ) { // z ( z )
obsTable . addJoin ( new JoinArray ( z , JoinArray . Type . raw , 0 ) ) ; obsTable . elev = z . getFullName ( ) ; } break ; case raggedContiguous : profileTable . numRecords = info . ragged_rowSize . getFullName ( ) ; obsTable = makeRaggedContiguousChildTable ( ds , info . parentDim , info . childDim , info . childStruct , errlog ) ; break ; case raggedIndex : obsTable = makeRaggedIndexChildTable ( ds , info . parentDim , info . childDim , info . ragged_parentIndex , errlog ) ; break ; case flat : throw new UnsupportedOperationException ( "CFpointObs: profile flat encoding" ) ; } if ( obsTable == null ) return null ; profileTable . addChild ( obsTable ) ; return profileTable ;


signature: public class CFpointObs { protected TableConfig getTrajectoryConfig ( NetcdfDataset ds , EncodingInfo info , Formatter errlog ) throws IOException { } }

implementation:
if ( ! identifyEncodingTraj ( ds , info , errlog ) ) return null ; TableConfig trajTable = makeStructTable ( ds , FeatureType . TRAJECTORY , info , errlog ) ; if ( trajTable == null ) return null ; trajTable . feature_id = identifyIdVariableName ( ds , CF . FeatureType . trajectory ) ; if ( trajTable . feature_id == null ) { errlog . format ( "CFpointObs getTrajectoryConfig cant find a trajectoy id %n" ) ; } // obs table
// Dimension obsDim = time . getDimension ( time . getRank ( ) - 1 ) ; / / may be time ( time ) or time ( traj , obs )
TableConfig obsConfig = null ; switch ( info . encoding ) { case single : obsConfig = makeSingle ( ds , info . childDim , errlog ) ; break ; case multidim : obsConfig = makeMultidimInner ( ds , trajTable , info . childDim , info , errlog ) ; if ( info . time . getRank ( ) == 1 ) { // join time ( obs ) or time ( time )
obsConfig . addJoin ( new JoinArray ( info . time , JoinArray . Type . raw , 0 ) ) ; obsConfig . time = info . time . getFullName ( ) ; } break ; case raggedContiguous : trajTable . numRecords = info . ragged_rowSize . getFullName ( ) ; obsConfig = makeRaggedContiguousChildTable ( ds , info . parentDim , info . childDim , info . childStruct , errlog ) ; break ; case raggedIndex : obsConfig = makeRaggedIndexChildTable ( ds , info . parentDim , info . childDim , info . ragged_parentIndex , errlog ) ; break ; case flat : throw new UnsupportedOperationException ( "CFpointObs: trajectory flat encoding" ) ; } if ( obsConfig == null ) return null ; trajTable . addChild ( obsConfig ) ; return trajTable ;


signature: public class CFpointObs { protected TableConfig getTimeSeriesProfileConfig ( NetcdfDataset ds , EncodingInfo info , Formatter errlog ) throws IOException { } }

implementation:
if ( ! identifyEncodingTimeSeriesProfile ( ds , info , CF . FeatureType . timeSeriesProfile , errlog ) ) return null ; VariableDS time = CoordSysEvaluator . findCoordByType ( ds , AxisType . Time ) ; if ( time == null ) return null ; if ( time . getRank ( ) == 0 && time . getParentStructure ( ) == null ) { errlog . format ( "CFpointObs timeSeriesProfile cannot have a scalar time coordinate%n" ) ; // why ?
return null ; } /* distinguish multidim from flat
 if ( ( info . encoding = = Encoding . multidim ) & & ( time . getRank ( ) < 3 ) & & ( z . getRank ( ) < 3 ) ) {
 Variable parentId = identifyParent ( ds , CF . FeatureType . timeSeriesProfile ) ;
 if ( ( parentId ! = null ) & & ( parentId . getRank ( ) = = 1 ) & & ( parentId . getDimension ( 0 ) . equals ( time . getDimension ( 0 ) ) ) ) {
 if ( time . getRank ( ) = = 1 ) / / multidim time must be 2 or 3 dim
 info = new EncodingInfo ( Encoding . flat , parentId ) ;
 else if ( time . getRank ( ) = = 2 ) {
 Dimension zDim = z . getDimension ( z . getRank ( ) - 1 ) ; / / may be z ( z ) or z ( profile , z )
 if ( zDim . equals ( time . getDimension ( 1 ) ) ) / / flat 2D time will have time as inner dim
 info = new EncodingInfo ( Encoding . flat , parentId ) ; */
TableConfig stationTable = makeStationTable ( ds , FeatureType . STATION_PROFILE , info , errlog ) ; if ( stationTable == null ) return null ; // Dimension stationDim = ds . findDimension ( stationTable . dimName ) ;
// Dimension profileDim = null ;
// Dimension zDim = null ;
VariableDS z = info . alt ; switch ( info . encoding ) { case single : { assert ( ( time . getRank ( ) >= 1 ) && ( time . getRank ( ) <= 2 ) ) : "time must be rank 1 or 2" ; assert ( ( z . getRank ( ) >= 1 ) && ( z . getRank ( ) <= 2 ) ) : "z must be rank 1 or 2" ; if ( time . getRank ( ) == 2 ) { if ( z . getRank ( ) == 2 ) // 2d time , 2d z
assert time . getDimensions ( ) . equals ( z . getDimensions ( ) ) : "rank-2 time and z dimensions must be the same" ; else // 2d time , 1d z
assert time . getDimension ( 1 ) . equals ( z . getDimension ( 0 ) ) : "rank-2 time must have z inner dimension" ; // profileDim = time . getDimension ( 0 ) ;
// zDim = time . getDimension ( 1 ) ;
} else { // 1d time
if ( z . getRank ( ) == 2 ) { // 1d time , 2d z
assert z . getDimension ( 0 ) . equals ( time . getDimension ( 0 ) ) : "rank-2 z must have time outer dimension" ; // profileDim = z . getDimension ( 0 ) ;
// zDim = z . getDimension ( 1 ) ;
} else { // 1d time , 1d z
assert ! time . getDimension ( 0 ) . equals ( z . getDimension ( 0 ) ) : "time and z dimensions must be different" ; // profileDim = time . getDimension ( 0 ) ;
// zDim = z . getDimension ( 0 ) ;
} } // make profile table
TableConfig profileTable = makeStructTable ( ds , FeatureType . PROFILE , new EncodingInfo ( ) . set ( Encoding . multidim , info . childDim ) , errlog ) ; if ( profileTable == null ) return null ; if ( time . getRank ( ) == 1 ) { // join time ( time )
// profileTable . addJoin ( new JoinArray ( time , JoinArray . Type . raw , 0 ) ) ;
profileTable . addJoin ( new JoinArray ( time , JoinArray . Type . level , 1 ) ) ; profileTable . time = time . getFullName ( ) ; } stationTable . addChild ( profileTable ) ; // make the inner ( z ) table
TableConfig zTable = makeMultidimInner ( ds , profileTable , info . grandChildDim , info , errlog ) ; if ( z . getRank ( ) == 1 ) { // join z ( z )
zTable . addJoin ( new JoinArray ( z , JoinArray . Type . raw , 0 ) ) ; zTable . elev = z . getFullName ( ) ; } profileTable . addChild ( zTable ) ; break ; } case multidim : { assert ( ( time . getRank ( ) >= 1 ) && ( time . getRank ( ) <= 3 ) ) : "time must be rank 2 or 3" ; assert ( ( z . getRank ( ) == 1 ) || ( z . getRank ( ) == 3 ) ) : "z must be rank 1 or 3" ; if ( time . getRank ( ) == 3 ) { if ( z . getRank ( ) == 3 ) // 3d time , 3d z
assert time . getDimensions ( ) . equals ( z . getDimensions ( ) ) : "rank-3 time and z dimensions must be the same" ; else // 3d time , 1d z
assert time . getDimension ( 2 ) . equals ( z . getDimension ( 0 ) ) : "rank-3 time must have z inner dimension" ; // profileDim = time . getDimension ( 1 ) ;
// zDim = time . getDimension ( 2 ) ;
} else if ( time . getRank ( ) == 2 ) { // 2d time
if ( z . getRank ( ) == 3 ) { // 2d time , 3d z
assert z . getDimension ( 1 ) . equals ( time . getDimension ( 1 ) ) : "rank-2 time must have time inner dimension" ; // profileDim = z . getDimension ( 1 ) ;
// zDim = z . getDimension ( 2 ) ;
} else { // 2d time , 1d z
assert ! time . getDimension ( 0 ) . equals ( z . getDimension ( 0 ) ) : "time and z dimensions must be different" ; assert ! time . getDimension ( 1 ) . equals ( z . getDimension ( 0 ) ) : "time and z dimensions must be different" ; // profileDim = time . getDimension ( 1 ) ;
// zDim = z . getDimension ( 0 ) ;
} } else { // 1d time
if ( z . getRank ( ) == 1 ) { assert ! time . getDimension ( 0 ) . equals ( z . getDimension ( 0 ) ) : "time and z dimensions must be different" ; } } TableConfig profileTable = makeMultidimInner ( ds , stationTable , info . childDim , info , errlog ) ; if ( profileTable == null ) return null ; if ( time . getRank ( ) == 1 ) { // join time ( time )
profileTable . addJoin ( new JoinArray ( time , JoinArray . Type . level , 1 ) ) ; profileTable . time = time . getFullName ( ) ; } stationTable . addChild ( profileTable ) ; // make the inner ( z ) table
TableConfig zTable = makeMultidimInner3D ( ds , stationTable , profileTable , info . grandChildDim , errlog ) ; if ( z . getRank ( ) == 1 ) { // join z ( z )
zTable . addJoin ( new JoinArray ( z , JoinArray . Type . raw , 0 ) ) ; zTable . elev = z . getFullName ( ) ; } profileTable . addChild ( zTable ) ; break ; } case raggedIndex : { TableConfig profileTable = makeRaggedIndexChildTable ( ds , info . parentDim , info . childDim , info . ragged_parentIndex , errlog ) ; stationTable . addChild ( profileTable ) ; profileTable . numRecords = info . ragged_rowSize . getFullName ( ) ; TableConfig obsTable = makeRaggedContiguousChildTable ( ds , info . childDim , info . grandChildDim , info . grandChildStruct , errlog ) ; profileTable . addChild ( obsTable ) ; break ; } case raggedContiguous : // NOT USED
throw new UnsupportedOperationException ( "CFpointObs: timeSeriesProfile raggedContiguous encoding not allowed" ) ; /* case flat :
 / / profileDim = time . getDimension ( 0 ) ; / / may be time ( profile ) or time ( profile , z )
 Variable parentId = identifyParent ( ds , CF . FeatureType . timeSeriesProfile ) ;
 TableConfig profileTable = makeStructTable ( ds , FeatureType . PROFILE , info , errlog ) ;
 profileTable . parentIndex = parentId . getName ( ) ;
 profileTable . stnId = findNameVariableWithStandardNameAndDimension ( ds , CF . STATION _ ID , info . childDim , errlog ) ;
 profileTable . stnDesc = findNameVariableWithStandardNameAndDimension ( ds , CF . STATION _ DESC , info . childDim , errlog ) ;
 profileTable . stnWmoId = findNameVariableWithStandardNameAndDimension ( ds , CF . STATION _ WMOID , info . childDim , errlog ) ;
 profileTable . stnAlt = findNameVariableWithStandardNameAndDimension ( ds , CF . STATION _ ALTITUDE , info . childDim , errlog ) ;
 stationTable . addChild ( profileTable ) ;
 / / zDim = z . getDimension ( z . getRank ( ) - 1 ) ; / / may be z ( z ) or z ( profile , z )
 TableConfig zTable = makeMultidimInner ( ds , profileTable , info . grandChildDim , errlog ) ;
 if ( z . getRank ( ) = = 1 ) / / z ( z )
 zTable . addJoin ( new JoinArray ( z , JoinArray . Type . raw , 0 ) ) ;
 profileTable . addChild ( zTable ) ;
 break ; */
} return stationTable ;


signature:
public class CFpointObs { /** * for stations , figure out the encoding */
protected boolean identifyEncodingStation ( NetcdfDataset ds , EncodingInfo info , CF . FeatureType ftype , Formatter errlog ) { } }

implementation:
// find the obs dimension
Dimension obsDim = null ; if ( info . time . getRank ( ) > 0 ) obsDim = info . time . getDimension ( info . time . getRank ( ) - 1 ) ; // may be time ( time ) or time ( stn , obs )
else if ( info . time . getParentStructure ( ) != null ) { Structure parent = info . time . getParentStructure ( ) ; // if time axis is a structure member , try pulling dimension out of parent structure
obsDim = parent . getDimension ( parent . getRank ( ) - 1 ) ; } if ( obsDim == null ) { errlog . format ( "CFpointObs: must have a non-scalar Time coordinate%n" ) ; return false ; } // find the station dimension
if ( info . lat . getRank ( ) == 0 ) { // scalar means single
info . set ( Encoding . single , null , obsDim ) ; return true ; } Dimension stnDim = info . lat . getDimension ( 0 ) ; if ( obsDim == stnDim ) { info . set ( Encoding . flat , null , obsDim ) ; // not used ?
return true ; } // the raggeds
if ( identifyRaggeds ( ds , info , stnDim , obsDim , errlog ) ) return true ; // heres whats left
if ( info . lat . getRank ( ) == 1 ) { // Encoding e = ( info . time . getParentStructure ( ) ! = null ) ? Encoding . multiStructure : Encoding . multidim ;
info . set ( Encoding . multidim , stnDim , obsDim ) ; return true ; } errlog . format ( "CFpointObs: %s Must have Lat/Lon coordinates of rank 0 or 1%n" , ftype ) ; return false ;


signature:
public class CFpointObs { /** * Identify ragged array representations for single nests ( station , profile , trajectory )
 * @ param ds in this dataset
 * @ param info put info here
 * @ param instanceDim the instance dimension , null if not known yet
 * @ param sampleDim the sample dimension , null if not known yet
 * @ param errlog error go here
 * @ return true if ragged array representations is found ; side effect : set ( info . ragged _ rowSize , info . parentStruct ) or ( info . ragged _ parentIndex , info . childStruct ) */
protected boolean identifyRaggeds ( NetcdfDataset ds , EncodingInfo info , Dimension instanceDim , Dimension sampleDim , Formatter errlog ) { } }

implementation:
// check for contiguous
Evaluator . VarAtt varatt = Evaluator . findVariableWithAttribute ( ds , CF . SAMPLE_DIMENSION ) ; // CF 1.6
if ( varatt == null ) varatt = Evaluator . findVariableWithAttribute ( ds , CF . RAGGED_ROWSIZE ) ; // backwards compatibility
if ( varatt != null ) { Variable ragged_rowSize = varatt . var ; String sampleDimName = varatt . att . getStringValue ( ) ; if ( sampleDim != null && ! sampleDimName . equals ( sampleDim . getShortName ( ) ) ) { errlog . format ( "CFpointObs: Contiguous ragged array representation: row_size variable has sample dimension %s must be %s%n" , sampleDimName , sampleDim . getShortName ( ) ) ; return false ; } if ( sampleDim == null ) { sampleDim = ds . findDimension ( sampleDimName ) ; if ( sampleDim == null ) { errlog . format ( "CFpointObs: Contiguous ragged array representation: row_size variable has invalid sample dimension %s%n" , sampleDimName ) ; return false ; } } Dimension rrDim ; if ( ragged_rowSize . getRank ( ) > 0 ) rrDim = ragged_rowSize . getDimension ( 0 ) ; // nobs ( station )
else if ( ragged_rowSize . getParentStructure ( ) != null ) { Structure parent = ragged_rowSize . getParentStructure ( ) ; // if ragged _ rowSize is a structure member , use dimension of parent structure
rrDim = parent . getDimension ( 0 ) ; } else { errlog . format ( "CFpointObs: Contiguous ragged array representation: row_size variable (%s) must have rank 1%n" , ragged_rowSize ) ; return false ; } if ( instanceDim != null && instanceDim != rrDim ) { errlog . format ( "CFpointObs: Contiguous ragged array representation: row_size variable has invalid instance dimension %s must be %s%n" , rrDim , instanceDim ) ; return false ; } instanceDim = rrDim ; if ( ragged_rowSize . getDataType ( ) != DataType . INT ) { errlog . format ( "CFpointObs: Contiguous ragged array representation: row_size variable must be of type integer%n" ) ; return false ; } info . set ( Encoding . raggedContiguous , instanceDim , sampleDim ) ; info . ragged_rowSize = ragged_rowSize ; info . parentStruct = ragged_rowSize . getParentStructure ( ) ; return true ; } // rowsize was found
varatt = Evaluator . findVariableWithAttribute ( ds , CF . INSTANCE_DIMENSION ) ; // CF 1.6
if ( varatt == null ) varatt = Evaluator . findVariableWithAttribute ( ds , CF . RAGGED_PARENTINDEX ) ; // backwards compatibility
if ( varatt != null ) { Variable ragged_parentIndex = varatt . var ; String instanceDimName = varatt . att . getStringValue ( ) ; if ( instanceDim != null && ! instanceDimName . equals ( instanceDim . getShortName ( ) ) ) { errlog . format ( "CFpointObs: Indexed ragged array representation: parent_index variable has instance dimension %s must be %s%n" , instanceDimName , instanceDim . getShortName ( ) ) ; return false ; } if ( instanceDim == null ) { instanceDim = ds . findDimension ( instanceDimName ) ; if ( instanceDim == null ) { errlog . format ( "CFpointObs: Indexed ragged array representation: parent_index variable has invalid instance dimension %s%n" , instanceDimName ) ; return false ; } } if ( ragged_parentIndex . getDataType ( ) != DataType . INT ) { errlog . format ( "CFpointObs: Indexed ragged array representation: parent_index variable must be of type integer%n" ) ; return false ; } // allow netcdf - 4 structures , eg kunicki
if ( ragged_parentIndex . isMemberOfStructure ( ) ) { Structure s = ragged_parentIndex . getParentStructure ( ) ; if ( s . getRank ( ) == 0 || ! s . getDimension ( 0 ) . equals ( sampleDim ) ) { errlog . format ( "CFpointObs: Indexed ragged array representation (structure): parent_index variable must be of form Struct { %s }(%s) %n" , ragged_parentIndex . getFullName ( ) , sampleDim . getShortName ( ) ) ; return false ; } } else { if ( ragged_parentIndex . getRank ( ) != 1 || ! ragged_parentIndex . getDimension ( 0 ) . equals ( sampleDim ) ) { errlog . format ( "CFpointObs: Indexed ragged array representation: parent_index variable must be of form %s(%s) %n" , ragged_parentIndex . getFullName ( ) , sampleDim . getShortName ( ) ) ; return false ; } } info . set ( Encoding . raggedIndex , instanceDim , sampleDim ) ; info . ragged_parentIndex = ragged_parentIndex ; info . childStruct = ragged_parentIndex . getParentStructure ( ) ; return true ; } // parent index was found
/* kunicki 10/21/2011
 Variable ragged _ parentIndex = Evaluator . getVariableWithAttributeValue ( ds , CF . RAGGED _ PARENTINDEX , parentDim . getShortName ( ) ) ;
 if ( ( ragged _ parentIndex = = null ) | |
 ( ! ragged _ parentIndex . isMemberOfStructure ( ) & & ( ragged _ parentIndex . getRank ( ) = = 0 | | ragged _ parentIndex . getDimension ( 0 ) . getShortName ( ) ! = childDim . getShortName ( ) ) | |
 ( ragged _ parentIndex . isMemberOfStructure ( ) & & ( ragged _ parentIndex . getParentStructure ( ) . getRank ( ) = = 0 | | ragged _ parentIndex . getParentStructure ( ) . getDimension ( 0 ) . getShortName ( ) ! = childDim . getShortName ( ) ) ) )
 / / if ( ( null = = ragged _ parentIndex ) | | ( ragged _ parentIndex . getRank ( ) = = 0 ) | | ( ragged _ parentIndex . getDimension ( 0 ) . getShortName ( ) ! = childDim . getShortName ( ) ) ) {
 errlog . format ( " there must be a ragged _ parent _ index variable with outer dimension that matches obs dimension % s % n " , childDim . getShortName ( ) ) ;
 return null ; */
return false ;


signature:
public class CFpointObs { /** * Identify ragged array representations for double nests ( timeSeries profile , timeSeries trajectory )
 * This uses the contiguous ragged array representation for each profile ( 9.5.43.3 ) , and the indexed ragged array
 * representation to organise the profiles into time series ( 9.3.54 ) . The canonical use case is when writing real - time
 * data streams that contain profiles from many stations , arriving randomly , with the data for each entire profile written all at once .
 * @ param ds in this dataset
 * @ param info put info here
 * @ param errlog error go here
 * @ return EncodingInfo if ragged array representations is found */
protected boolean identifyDoubleRaggeds ( NetcdfDataset ds , EncodingInfo info , Formatter errlog ) { } }

implementation:
// the timeseries are stored as ragged index
Evaluator . VarAtt varatt = Evaluator . findVariableWithAttribute ( ds , CF . INSTANCE_DIMENSION ) ; if ( varatt == null ) varatt = Evaluator . findVariableWithAttribute ( ds , CF . RAGGED_PARENTINDEX ) ; if ( varatt == null ) return false ; Variable ragged_parentIndex = varatt . var ; String instanceDimName = varatt . att . getStringValue ( ) ; Dimension stationDim = ds . findDimension ( instanceDimName ) ; if ( stationDim == null ) { errlog . format ( "CFpointObs: Indexed ragged array representation: parent_index variable has illegal value for %s = %s%n" , CF . INSTANCE_DIMENSION , instanceDimName ) ; return false ; } if ( ragged_parentIndex . getDataType ( ) != DataType . INT ) { errlog . format ( "CFpointObs: Indexed ragged array representation: parent_index variable must be of type integer%n" ) ; return false ; } if ( ragged_parentIndex . getRank ( ) != 1 && info . childStruct == null ) { errlog . format ( "CFpointObs: Indexed ragged array representation: parent_index variable %s must be 1D %n" , ragged_parentIndex ) ; return false ; } Dimension profileDim = ( info . childDim != null ) ? info . childDim : ragged_parentIndex . getDimension ( 0 ) ; // onto the profiles , stored contiguously
varatt = Evaluator . findVariableWithAttribute ( ds , CF . SAMPLE_DIMENSION ) ; if ( varatt == null ) varatt = Evaluator . findVariableWithAttribute ( ds , CF . RAGGED_ROWSIZE ) ; if ( varatt == null ) return false ; Variable ragged_rowSize = varatt . var ; String obsDimName = varatt . att . getStringValue ( ) ; Dimension obsDim = ds . findDimension ( obsDimName ) ; if ( obsDimName == null ) { errlog . format ( "CFpointObs: Contiguous ragged array representation: parent_index variable has illegal value for %s = %s%n" , CF . SAMPLE_DIMENSION , obsDimName ) ; return false ; } if ( ! obsDimName . equals ( info . grandChildDim . getShortName ( ) ) ) { errlog . format ( "CFpointObs: Contiguous ragged array representation: row_size variable has obs dimension %s must be %s%n" , obsDimName , info . childDim ) ; return false ; } if ( ragged_rowSize . getDataType ( ) != DataType . INT ) { errlog . format ( "CFpointObs: Contiguous ragged array representation: row_size variable must be of type integer%n" ) ; return false ; } if ( info . childDim == null ) { // nc4 ext
Dimension profileDim2 = ragged_rowSize . getDimension ( 0 ) ; if ( profileDim2 != profileDim ) { errlog . format ( "CFpointObs: Double ragged array representation dimensions do not agree: %s != %s%n" , profileDim2 . getShortName ( ) , profileDim . getShortName ( ) ) ; return false ; } } info . set ( Encoding . raggedIndex , stationDim , profileDim , obsDim ) ; info . ragged_parentIndex = ragged_parentIndex ; info . ragged_rowSize = ragged_rowSize ; return true ;


signature:
public class CFpointObs { /** * for station and stationProfile , not flat */
private TableConfig makeStationTable ( NetcdfDataset ds , FeatureType ftype , EncodingInfo info , Formatter errlog ) throws IOException { } }

implementation:
Variable lat = CoordSysEvaluator . findCoordByType ( ds , AxisType . Lat ) ; Variable lon = CoordSysEvaluator . findCoordByType ( ds , AxisType . Lon ) ; if ( lat == null || lon == null ) { errlog . format ( "CFpointObs: must have lat and lon coordinates%n" ) ; return null ; } // Dimension stationDim = ( info . encoding = = Encoding . single ) ? null : lat . getDimension ( 0 ) ; / / assumes outer dim of lat is parent dimension , single = scalar
Table . Type stationTableType = Table . Type . Structure ; if ( info . encoding == Encoding . single ) stationTableType = Table . Type . Top ; if ( info . encoding == Encoding . flat ) stationTableType = Table . Type . Construct ; Dimension stationDim = ( info . encoding == Encoding . flat ) ? info . childDim : info . parentDim ; String name = ( stationDim == null ) ? " single" : stationDim . getShortName ( ) ; TableConfig stnTable = new TableConfig ( stationTableType , name ) ; stnTable . featureType = ftype ; // stnId
Variable stnIdVar = Evaluator . findVariableWithAttributeAndDimension ( ds , CF . CF_ROLE , CF . TIMESERIES_ID , stationDim , errlog ) ; if ( stnIdVar == null ) stnIdVar = Evaluator . findVariableWithAttributeAndDimension ( ds , CF . STANDARD_NAME , CF . STATION_ID , stationDim , errlog ) ; if ( stnIdVar == null ) { errlog . format ( "CFpointObs: must have a Station id variable with %s = %s%n" , CF . CF_ROLE , CF . TIMESERIES_ID ) ; return null ; } stnTable . stnId = stnIdVar . getFullName ( ) ; info . instanceId = stnIdVar ; stnTable . stnDesc = Evaluator . findNameVariableWithStandardNameAndDimension ( ds , CF . PLATFORM_NAME , stationDim , errlog ) ; if ( stnTable . stnDesc == null ) stnTable . stnDesc = Evaluator . findNameVariableWithStandardNameAndDimension ( ds , CF . STATION_DESC , stationDim , errlog ) ; stnTable . stnWmoId = Evaluator . findNameVariableWithStandardNameAndDimension ( ds , CF . PLATFORM_ID , stationDim , errlog ) ; if ( stnTable . stnWmoId == null ) stnTable . stnWmoId = Evaluator . findNameVariableWithStandardNameAndDimension ( ds , CF . STATION_WMOID , stationDim , errlog ) ; stnTable . stnAlt = Evaluator . findNameVariableWithStandardNameAndDimension ( ds , CF . SURFACE_ALTITUDE , stationDim , errlog ) ; if ( stnTable . stnAlt == null ) stnTable . stnAlt = Evaluator . findNameVariableWithStandardNameAndDimension ( ds , CF . STATION_ALTITUDE , stationDim , errlog ) ; stnTable . lat = lat . getFullName ( ) ; stnTable . lon = lon . getFullName ( ) ; if ( info . encoding != Encoding . single && stationDim != null ) { stnTable . dimName = stationDim . getShortName ( ) ; makeStructureInfo ( stnTable , ds , stnIdVar . getParentStructure ( ) , stationDim ) ; } // LOOK probably need a standard name here
// optional alt coord - detect if its a station height or actually associated with the obs , eg for a profile
if ( stnTable . stnAlt == null ) { Variable alt = CoordSysEvaluator . findCoordByType ( ds , AxisType . Height ) ; if ( alt != null ) { if ( ( info . encoding == Encoding . single ) && alt . getRank ( ) == 0 ) stnTable . stnAlt = alt . getFullName ( ) ; if ( ( info . encoding != Encoding . single ) && ( lat . getRank ( ) == alt . getRank ( ) ) && alt . getRank ( ) > 0 && alt . getDimension ( 0 ) . equals ( stationDim ) ) stnTable . stnAlt = alt . getFullName ( ) ; } } return stnTable ;


signature: public class CFpointObs { private TableConfig makeRaggedContiguousChildTable ( NetcdfDataset ds , Dimension parentDim , Dimension childDim , Structure childStruct , Formatter errlog ) throws IOException { } }

implementation: TableConfig childTable = new TableConfig ( Table . Type . Contiguous , childDim . getShortName ( ) ) ; childTable . dimName = childDim . getShortName ( ) ; childTable . lat = matchAxisTypeAndDimension ( ds , AxisType . Lat , childDim ) ; childTable . lon = matchAxisTypeAndDimension ( ds , AxisType . Lon , childDim ) ; childTable . elev = matchAxisTypeAndDimension ( ds , AxisType . Height , childDim ) ; if ( childTable . elev == null ) childTable . elev = matchAxisTypeAndDimension ( ds , AxisType . Pressure , childDim ) ; if ( childTable . elev == null ) childTable . elev = matchAxisTypeAndDimension ( ds , AxisType . GeoZ , childDim ) ; childTable . time = matchAxisTypeAndDimension ( ds , AxisType . Time , childDim ) ; makeStructureInfo ( childTable , ds , childStruct , childDim ) ; return childTable ;


signature:
public class CFpointObs { /** * the inner table of Structure ( outer , inner ) and middle table of Structure ( outer , middle , inner ) */
private TableConfig makeMultidimInner ( NetcdfDataset ds , TableConfig parentTable , Dimension obsDim , EncodingInfo info , Formatter errlog ) throws IOException { } }

implementation:
Dimension parentDim = ds . findDimension ( parentTable . dimName ) ; Table . Type obsTableType = ( parentTable . structureType == TableConfig . StructureType . PsuedoStructure ) ? Table . Type . MultidimInnerPsuedo : Table . Type . MultidimInner ; // if ( info . time . isMemberOfStructure ( ) ) obsTableType = Table . Type . Structure ;
TableConfig obsTable = new TableConfig ( obsTableType , obsDim . getShortName ( ) ) ; obsTable . lat = matchAxisTypeAndDimension ( ds , AxisType . Lat , parentDim , obsDim ) ; obsTable . lon = matchAxisTypeAndDimension ( ds , AxisType . Lon , parentDim , obsDim ) ; obsTable . elev = matchAxisTypeAndDimension ( ds , AxisType . Height , parentDim , obsDim ) ; if ( obsTable . elev == null ) obsTable . elev = matchAxisTypeAndDimension ( ds , AxisType . Pressure , parentDim , obsDim ) ; if ( obsTable . elev == null ) obsTable . elev = matchAxisTypeAndDimension ( ds , AxisType . GeoZ , parentDim , obsDim ) ; obsTable . time = matchAxisTypeAndDimension ( ds , AxisType . Time , parentDim , obsDim ) ; // divide up the variables between the parent and the obs
List < String > obsVars ; List < Variable > vars = ds . getVariables ( ) ; List < String > parentVars = new ArrayList < > ( vars . size ( ) ) ; obsVars = new ArrayList < > ( vars . size ( ) ) ; for ( Variable orgV : vars ) { if ( orgV instanceof Structure ) continue ; Dimension dim0 = orgV . getDimension ( 0 ) ; if ( ( dim0 != null ) && dim0 . equals ( parentDim ) ) { if ( ( orgV . getRank ( ) == 1 ) || ( ( orgV . getRank ( ) == 2 ) && orgV . getDataType ( ) == DataType . CHAR ) ) { parentVars . add ( orgV . getShortName ( ) ) ; } else { Dimension dim1 = orgV . getDimension ( 1 ) ; if ( ( dim1 != null ) && dim1 . equals ( obsDim ) ) obsVars . add ( orgV . getShortName ( ) ) ; } } } parentTable . vars = parentVars ; // parentTable . vars = parentTable . isPsuedoStructure ? parentVars : null ; / / restrict to these if psuedoStruct
obsTable . structureType = parentTable . structureType ; obsTable . outerName = parentDim . getShortName ( ) ; obsTable . innerName = obsDim . getShortName ( ) ; obsTable . dimName = ( parentTable . structureType == TableConfig . StructureType . PsuedoStructure ) ? obsTable . outerName : obsTable . innerName ; obsTable . structName = obsDim . getShortName ( ) ; obsTable . vars = obsVars ; return obsTable ;


signature:
public class CFpointObs { /** * the inner table of Structure ( outer , middle , inner ) */
private TableConfig makeMultidimInner3D ( NetcdfDataset ds , TableConfig outerTable , TableConfig middleTable , Dimension innerDim , Formatter errlog ) throws IOException { } }

implementation:
Dimension outerDim = ds . findDimension ( outerTable . dimName ) ; Dimension middleDim = ds . findDimension ( middleTable . innerName ) ; Table . Type obsTableType = ( outerTable . structureType == TableConfig . StructureType . PsuedoStructure ) ? Table . Type . MultidimInnerPsuedo3D : Table . Type . MultidimInner3D ; TableConfig obsTable = new TableConfig ( obsTableType , innerDim . getShortName ( ) ) ; obsTable . structureType = TableConfig . StructureType . PsuedoStructure2D ; obsTable . dimName = outerTable . dimName ; obsTable . outerName = middleTable . innerName ; obsTable . innerName = innerDim . getShortName ( ) ; obsTable . structName = innerDim . getShortName ( ) ; obsTable . lat = matchAxisTypeAndDimension ( ds , AxisType . Lat , outerDim , middleDim , innerDim ) ; obsTable . lon = matchAxisTypeAndDimension ( ds , AxisType . Lon , outerDim , middleDim , innerDim ) ; obsTable . elev = matchAxisTypeAndDimension ( ds , AxisType . Height , outerDim , middleDim , innerDim ) ; if ( obsTable . elev == null ) obsTable . elev = matchAxisTypeAndDimension ( ds , AxisType . Pressure , middleDim , innerDim ) ; if ( obsTable . elev == null ) obsTable . elev = matchAxisTypeAndDimension ( ds , AxisType . GeoZ , middleDim , innerDim ) ; obsTable . time = matchAxisTypeAndDimension ( ds , AxisType . Time , outerDim , middleDim , innerDim ) ; // divide up the variables between the 3 tables
List < Variable > vars = ds . getVariables ( ) ; List < String > outerVars = new ArrayList < > ( vars . size ( ) ) ; List < String > middleVars = new ArrayList < > ( vars . size ( ) ) ; List < String > innerVars = new ArrayList < > ( vars . size ( ) ) ; for ( Variable orgV : vars ) { if ( orgV instanceof Structure ) continue ; if ( ( orgV . getRank ( ) == 1 ) || ( ( orgV . getRank ( ) == 2 ) && orgV . getDataType ( ) == DataType . CHAR ) ) { if ( outerDim . equals ( orgV . getDimension ( 0 ) ) ) outerVars . add ( orgV . getShortName ( ) ) ; } else if ( orgV . getRank ( ) == 2 ) { if ( outerDim . equals ( orgV . getDimension ( 0 ) ) && middleDim . equals ( orgV . getDimension ( 1 ) ) ) middleVars . add ( orgV . getShortName ( ) ) ; } else if ( orgV . getRank ( ) == 3 ) { if ( outerDim . equals ( orgV . getDimension ( 0 ) ) && middleDim . equals ( orgV . getDimension ( 1 ) ) && innerDim . equals ( orgV . getDimension ( 2 ) ) ) innerVars . add ( orgV . getShortName ( ) ) ; } } outerTable . vars = outerVars ; middleTable . vars = middleVars ; obsTable . vars = innerVars ; return obsTable ;


signature:
public class CFpointObs { /** * class , I don ' t understand enough of the code base to anticipate implementation artifacts . */
protected String matchAxisTypeAndDimension ( NetcdfDataset ds , AxisType type , final Dimension outer ) { } }

implementation:
Variable var = CoordSysEvaluator . findCoordByType ( ds , type , new CoordSysEvaluator . Predicate ( ) { public boolean match ( CoordinateAxis axis ) { if ( ( outer == null ) && ( axis . getRank ( ) == 0 ) ) return true ; if ( ( outer != null ) && ( axis . getRank ( ) == 1 ) && ( outer . equals ( axis . getDimension ( 0 ) ) ) ) return true ; // if axis is structure member , try pulling dimension out of parent structure
if ( axis . getParentStructure ( ) != null ) { Structure parent = axis . getParentStructure ( ) ; if ( ( outer != null ) && ( parent . getRank ( ) == 1 ) && ( outer . equals ( parent . getDimension ( 0 ) ) ) ) return true ; } return false ; } } ) ; if ( var == null ) return null ; return var . getFullName ( ) ;


signature:
public class CBZip2InputStream { /** * Added 5-30-2006 to allow for resetting of the input used
 * by this object . This saves in memory allocation costs */
public void setStream ( InputStream zStream ) { } }

implementation:
last = 0 ; origPtr = 0 ; blockSize100k = 0 ; blockRandomised = false ; bsBuff = 0 ; bsLive = 0 ; mCrc = new CRC ( ) ; nInUse = 0 ; bsStream = null ; streamEnd = false ; currentChar = - 1 ; currentState = START_BLOCK_STATE ; storedBlockCRC = storedCombinedCRC = 0 ; computedBlockCRC = computedCombinedCRC = 0 ; i2 = count = chPrev = ch2 = 0 ; i = tPos = 0 ; rNToGo = 0 ; rTPos = 0 ; j2 = 0 ; z = 0 ; bsSetStream ( zStream ) ; initialize ( ) ; if ( ! streamEnd ) { // Handle if initialize does not detect valid bz2 stream
initBlock ( ) ; setupBlock ( ) ; }


signature:
public class CBZip2InputStream { /** * Reads the stream .
 * @ throws BZip2ReadException if there is a problem . InputStream does
 * not throw an IOException , so we throw a RuntimeException . */
public int read ( ) { } }

implementation: if ( streamEnd ) { return - 1 ; } else { int retChar = currentChar ; switch ( currentState ) { case START_BLOCK_STATE : break ; case RAND_PART_A_STATE : break ; case RAND_PART_B_STATE : setupRandPartB ( ) ; break ; case RAND_PART_C_STATE : setupRandPartC ( ) ; break ; case NO_RAND_PART_A_STATE : break ; case NO_RAND_PART_B_STATE : setupNoRandPartB ( ) ; break ; case NO_RAND_PART_C_STATE : setupNoRandPartC ( ) ; break ; default : break ; } return retChar ; }


signature:
public class ProgressMonitor { /** * Call this from awt event thread .
 * The task is run in a background thread .
 * @ param top put ProgressMonitor on top of this component ( may be null )
 * @ param taskName display name of task
 * @ param progressMaxCount maximum number of Progress indicator */
public void start ( java . awt . Component top , String taskName , int progressMaxCount ) { } }

implementation:
// create ProgressMonitor
pm = new javax . swing . ProgressMonitor ( top , taskName , "" , 0 , progressMaxCount ) ; pm . setMillisToDecideToPopup ( millisToDecideToPopup ) ; pm . setMillisToPopup ( millisToPopup ) ; // do task in a seperate , non - event , thread
taskThread = new Thread ( task ) ; taskThread . start ( ) ; // create timer , whose events happen on the awt event Thread
ActionListener watcher = new ActionListener ( ) { public void actionPerformed ( ActionEvent evt ) { secs ++ ; if ( pm . isCanceled ( ) ) { task . cancel ( ) ; } else { // indicate progress
String note = task . getNote ( ) ; pm . setNote ( note == null ? secs + " secs" : note ) ; int progress = task . getProgress ( ) ; pm . setProgress ( progress <= 0 ? secs : progress ) ; } // need to make sure task acknowledges the cancel ; so dont shut down
// until the task is done
if ( task . isDone ( ) ) { timer . stop ( ) ; pm . close ( ) ; // Toolkit . getDefaultToolkit ( ) . beep ( ) ;
if ( task . isError ( ) ) { javax . swing . JOptionPane . showMessageDialog ( null , task . getErrorMessage ( ) ) ; } if ( task . isSuccess ( ) ) fireEvent ( new ActionEvent ( this , 0 , "success" ) ) ; else if ( task . isError ( ) ) fireEvent ( new ActionEvent ( this , 0 , "error" ) ) ; else if ( task . isCancel ( ) ) fireEvent ( new ActionEvent ( this , 0 , "cancel" ) ) ; else fireEvent ( new ActionEvent ( this , 0 , "done" ) ) ; } } } ; timer = new javax . swing . Timer ( 1000 , watcher ) ; // every second
timer . start ( ) ;


signature:
public class HTTPUtil { /** * Misc . */
static public byte [ ] readbinaryfile ( File f ) throws IOException { } }

implementation: try ( FileInputStream fis = new FileInputStream ( f ) ) { return readbinaryfile ( fis ) ; }


signature:
public class HTTPUtil { /** * Convert a uri string to an instance of java . net . URI .
 * The critical thing is that this procedure can handle backslash
 * escaped uris as well as % xx escaped uris .
 * @ param u the uri to convert
 * @ return The URI corresponding to u .
 * @ throws URISyntaxException */
static public URI parseToURI ( final String u ) throws URISyntaxException { } }

implementation: StringBuilder buf = new StringBuilder ( ) ; int i = 0 ; while ( i < u . length ( ) ) { char c = u . charAt ( i ) ; if ( c == '\\' ) { if ( i + 1 == u . length ( ) ) throw new URISyntaxException ( u , "Trailing '\' at end of url" ) ; buf . append ( "%5c" ) ; i ++ ; c = u . charAt ( i ) ; buf . append ( String . format ( "%%%02x" , ( int ) c ) ) ; } else buf . append ( c ) ; i ++ ; } return new URI ( buf . toString ( ) ) ;


signature:
public class HTTPUtil { /** * Remove selected fields from a URI producing a new URI
 * @ param uri the uri to convert
 * @ param excludes the parts to exclude
 * @ return The new URI instance */
static URI uriExclude ( final URI uri , URIPart ... excludes ) { } }

implementation: URIBuilder urib = new URIBuilder ( ) ; EnumSet < URIPart > set = EnumSet . of ( excludes [ 0 ] , excludes ) ; for ( URIPart part : URIPart . values ( ) ) { if ( set . contains ( part ) ) continue ; switch ( part ) { case SCHEME : urib . setScheme ( uri . getScheme ( ) ) ; break ; case USERINFO : urib . setUserInfo ( uri . getUserInfo ( ) ) ; break ; case HOST : urib . setHost ( uri . getHost ( ) ) ; break ; case PORT : urib . setPort ( uri . getPort ( ) ) ; break ; case PATH : urib . setPath ( uri . getPath ( ) ) ; break ; case QUERY : urib . setCustomQuery ( uri . getQuery ( ) ) ; break ; case FRAGMENT : urib . setFragment ( uri . getFragment ( ) ) ; break ; } } try { return urib . build ( ) ; } catch ( URISyntaxException e ) { throw new IllegalArgumentException ( e . getMessage ( ) ) ; }


signature:
public class HTTPUtil { /** * Convert a zero - length string to null
 * @ param s the string to check for length
 * @ return null if s . length ( ) = = 0 , s otherwise */
static public String nullify ( String s ) { } }

implementation: if ( s != null && s . length ( ) == 0 ) s = null ; return s ;


signature:
public class HTTPUtil { /** * Join two string together to form proper path
 * WITHOUT trailing slash
 * @ param prefix
 * @ param suffix
 * @ return */
static public String canonjoin ( String prefix , String suffix ) { } }

implementation: if ( prefix == null ) prefix = "" ; if ( suffix == null ) suffix = "" ; prefix = HTTPUtil . canonicalpath ( prefix ) ; suffix = HTTPUtil . canonicalpath ( suffix ) ; StringBuilder result = new StringBuilder ( ) ; result . append ( prefix ) ; int prelen = prefix . length ( ) ; if ( prelen > 0 && result . charAt ( prelen - 1 ) != '/' ) { result . append ( '/' ) ; prelen ++ ; } if ( suffix . length ( ) > 0 && suffix . charAt ( 0 ) == '/' ) result . append ( suffix . substring ( 1 ) ) ; else result . append ( suffix ) ; int len = result . length ( ) ; if ( len > 0 && result . charAt ( len - 1 ) == '/' ) { result . deleteCharAt ( len - 1 ) ; len -- ; } return result . toString ( ) ;


signature:
public class HTTPUtil { /** * Convert path to use ' / ' consistently and
 * to remove any trailing ' / '
 * @ param path convert this path
 * @ return canonicalized version */
static public String canonicalpath ( String path ) { } }

implementation: if ( path == null ) return null ; StringBuilder b = new StringBuilder ( path ) ; canonicalpath ( b ) ; return b . toString ( ) ;


signature:
public class HTTPUtil { /** * Convert path to remove any leading ' / ' or drive letter assumes canonical .
 * @ param path convert this path
 * @ return relatived version */
static public String relpath ( String path ) { } }

implementation: if ( path == null ) return null ; StringBuilder b = new StringBuilder ( path ) ; canonicalpath ( b ) ; if ( b . length ( ) > 0 ) { if ( b . charAt ( 0 ) == '/' ) b . deleteCharAt ( 0 ) ; if ( hasDriveLetter ( b ) ) b . delete ( 0 , 2 ) ; } return b . toString ( ) ;


signature:
public class HTTPUtil { /** * Support function */
static protected boolean hasDriveLetter ( StringBuilder path ) { } }

implementation: return ( path . length ( ) >= 2 && path . charAt ( 1 ) == ':' && DRIVELETTERS . indexOf ( path . charAt ( 0 ) ) >= 0 ) ;


signature:
public class HTTPUtil { /** * Convert path to add a leading ' / ' ; assumes canonical .
 * @ param path convert this path
 * @ return absolute version */
static public String abspath ( String path ) { } }

implementation: if ( path == null ) return "/" ; StringBuilder b = new StringBuilder ( path ) ; canonicalpath ( b ) ; if ( b . charAt ( 0 ) == '/' ) b . deleteCharAt ( 0 ) ; if ( b . charAt ( 0 ) != '/' || ! hasDriveLetter ( b ) ) b . insert ( 0 , '/' ) ; return b . toString ( ) ;


signature:
public class LastModifiedLimitFilter { /** * Accept datasets whose last modified date is at least the
 * last modified limit of milliseconds in the past .
 * @ param dataset the dataset to filter
 * @ return true if the datasets last modified date is at least lastModifiedLimitInMillis in the past . */
public boolean accept ( CrawlableDataset dataset ) { } }

implementation: Date lastModDate = dataset . lastModified ( ) ; if ( lastModDate != null ) { long now = System . currentTimeMillis ( ) ; if ( now - lastModDate . getTime ( ) > lastModifiedLimitInMillis ) return true ; } return false ;


signature: public class GribCollectionMutable { static MFile makeIndexMFile ( String collectionName , File directory ) { } }

implementation: String nameNoBlanks = StringUtil2 . replace ( collectionName , ' ' , "_" ) ; return new GcMFile ( directory , nameNoBlanks + GribCdmIndex . NCX_SUFFIX , - 1 , - 1 , - 1 ) ; // LOOK dont know lastMod , size . can it be added later ?


signature:
public class GribCollectionMutable { /** * for making partition collection */
void copyInfo ( GribCollectionMutable from ) { } }

implementation: this . center = from . center ; this . subcenter = from . subcenter ; this . master = from . master ; this . local = from . local ; this . genProcessType = from . genProcessType ; this . genProcessId = from . genProcessId ; this . backProcessId = from . backProcessId ;


signature:
public class GribCollectionMutable { /** * The files that comprise the collection .
 * Actual paths , including the grib cache if used .
 * @ return list of filename . */
public List < String > getFilenames ( ) { } }

implementation: List < String > result = new ArrayList < > ( ) ; for ( MFile file : fileMap . values ( ) ) result . add ( file . getPath ( ) ) ; Collections . sort ( result ) ; return result ;