signature:
public class OffsetUnit { /** * Divide this unit by another unit .
 * @ param that
 * The unit to divide this unit by .
 * @ return The quotient of this unit and < code > that < / code > . The offset of
 * this unit will be ignored ; thus , for example
 * " celsius . myDivideBy ( day ) " is equivalent to
 * " kelvin . myDivideBy ( day ) " .
 * @ throws OperationException
 * Can ' t divide these units . */
@ Override protected Unit myDivideBy ( final Unit that ) throws OperationException { } }

implementation: return that instanceof OffsetUnit ? getUnit ( ) . divideBy ( ( ( OffsetUnit ) that ) . getUnit ( ) ) : getUnit ( ) . divideBy ( that ) ;


signature:
public class OffsetUnit { /** * Divide this unit into another unit .
 * @ param that
 * The unit to divide this unit into .
 * @ return The quotient of < code > that < / code > unit and this unit . The offset
 * of this unit will be ignored ; thus , for example
 * " celsius . myDivideInto ( day ) " is equivalent to
 * " kelvin . myDivideInto ( day ) " .
 * @ throws OperationException
 * Can ' t divide these units . */
@ Override protected Unit myDivideInto ( final Unit that ) throws OperationException { } }

implementation: return that instanceof OffsetUnit ? getUnit ( ) . divideInto ( ( ( OffsetUnit ) that ) . getUnit ( ) ) : getUnit ( ) . divideInto ( that ) ;


signature:
public class OffsetUnit { /** * Converts a value in this unit to the equivalent value in the convertible
 * derived unit .
 * @ param amount
 * The value in this unit .
 * @ return The equivalent value in the convertible derived unit .
 * @ throws ConversionException
 * Can ' t convert between units . */
public double toDerivedUnit ( final double amount ) throws ConversionException { } }

implementation: if ( ! ( _unit instanceof DerivableUnit ) ) { throw new ConversionException ( this , getDerivedUnit ( ) ) ; } return ( ( DerivableUnit ) getUnit ( ) ) . toDerivedUnit ( amount + getOffset ( ) ) ;


signature:
public class OffsetUnit { /** * Converts a value in the convertible derived unit to the equivalent value
 * in this unit .
 * @ param amount
 * The value in the convertible derived unit .
 * @ return The equivalent value in this unit .
 * @ throws ConversionException
 * Can ' t convert between units . */
public double fromDerivedUnit ( final double amount ) throws ConversionException { } }

implementation: if ( ! ( _unit instanceof DerivableUnit ) ) { throw new ConversionException ( getDerivedUnit ( ) , this ) ; } return ( ( DerivableUnit ) getUnit ( ) ) . fromDerivedUnit ( amount ) - getOffset ( ) ;


signature:
public class OffsetUnit { /** * Converts values in the convertible derived unit to the equivalent values
 * in this unit .
 * @ param input
 * The values in the convertible derived unit .
 * @ param output
 * The equivalent values in this unit . May be the same array as
 * < code > input < / code > .
 * @ return < code > output < / code > .
 * @ throws ConversionException
 * Can ' t convert between units . */
public double [ ] fromDerivedUnit ( final double [ ] input , final double [ ] output ) throws ConversionException { } }

implementation: if ( ! ( _unit instanceof DerivableUnit ) ) { throw new ConversionException ( getDerivedUnit ( ) , this ) ; } ( ( DerivableUnit ) getUnit ( ) ) . fromDerivedUnit ( input , output ) ; final double origin = getOffset ( ) ; for ( int i = input . length ; -- i >= 0 ; ) { output [ i ] -= origin ; } return output ;


signature:
public class ConvertD2N { /** * Convert a DataDDS into an Array for a Structure member variable .
 * @ param v must be a member of a structure
 * @ param section the requested variable section , as a List of type Range
 * @ param dataV the dataDDS has been parsed into this dodsV , this is the top variable containing v
 * @ param flatten if true , remove the StructureData " wrapper " .
 * @ return the data as as Array
 * @ throws IOException on io error
 * @ throws DAP2Exception on bad things happening */
public Array convertNestedVariable ( ucar . nc2 . Variable v , List < Range > section , DodsV dataV , boolean flatten ) throws IOException , DAP2Exception { } }

implementation:
Array data = convertTopVariable ( v , section , dataV ) ; if ( flatten ) { ArrayStructure as = ( ArrayStructure ) data ; // make list of names
List < String > names = new ArrayList < > ( ) ; Variable nested = v ; while ( nested . isMemberOfStructure ( ) ) { names . add ( 0 , nested . getShortName ( ) ) ; nested = nested . getParentStructure ( ) ; } StructureMembers . Member m = findNested ( as , names , v . getShortName ( ) ) ; Array mdata = m . getDataArray ( ) ; if ( mdata instanceof ArraySequenceNested ) { // gotta unroll
ArraySequenceNested arraySeq = ( ArraySequenceNested ) mdata ; return arraySeq . flatten ( ) ; } return mdata ; } return data ;


signature:
public class ConvertD2N { /** * Convert a DataDDS into an Array for a top level variable , ie not a Structure member variable .
 * @ param v must be a top variable
 * @ param section the requested variable section
 * @ param dataV the dataDDS has been parsed into this dodsV
 * @ return the data as as Array
 * @ throws IOException on io error
 * @ throws DAP2Exception on bad */
public Array convertTopVariable ( ucar . nc2 . Variable v , List < Range > section , DodsV dataV ) throws IOException , DAP2Exception { } }

implementation:
Array data = convert ( dataV ) ; // arrays
if ( ( dataV . darray != null ) && ( dataV . bt instanceof DString ) ) { if ( v . getDataType ( ) == DataType . STRING ) return convertStringArray ( data , v ) ; else if ( v . getDataType ( ) == DataType . CHAR ) return convertStringArrayToChar ( dataV . darray , v , section ) ; else { String mess = "DODSVariable convertArray String invalid dataType= " + v . getDataType ( ) ; logger . error ( mess ) ; throw new IllegalArgumentException ( mess ) ; } } if ( ( dataV . bt instanceof DString ) && ( v . getDataType ( ) == DataType . CHAR ) ) { // special case : convert String back to CHAR
return convertStringToChar ( data , v ) ; } return data ; /* else { / / the DGrid case comes here also
 / / create the array , using DODS internal array so there ' s no copying
 dods . dap . PrimitiveVector pv = dataV . darray . getPrimitiveVector ( ) ;
 Object storage = pv . getInternalStorage ( ) ;
 / / storage = widenArray ( pv , storage ) ; / / LOOK data conversion if needed
 int [ ] shape = ( section = = null ) ? v . getShape ( ) : Range . getShape ( section ) ;
 return Array . factory ( v . getDataType ( ) . getPrimitiveClassType ( ) , shape , storage ) ; */


signature:
public class ConvertD2N { /** * Convert a DataDDS into an Array
 * @ param dataV the dataDDS has been parsed into this dodsV
 * @ return the data as as Array
 * @ throws IOException on io error
 * @ throws DAP2Exception on bad */
public Array convert ( DodsV dataV ) throws IOException , DAP2Exception { } }

implementation:
// scalars
if ( dataV . darray == null ) { if ( dataV . bt instanceof DStructure ) { ArrayStructure structArray = makeArrayStructure ( dataV ) ; iconvertDataStructure ( ( DStructure ) dataV . bt , structArray . getStructureMembers ( ) ) ; return structArray ; } else if ( dataV . bt instanceof DGrid ) { throw new IllegalStateException ( "DGrid without a darray" ) ; } else if ( dataV . bt instanceof DSequence ) { ArrayStructure structArray = makeArrayStructure ( dataV ) ; iconvertDataSequenceArray ( ( DSequence ) dataV . bt , structArray . getStructureMembers ( ) ) ; return structArray ; } else { // scalar
DataType dtype = dataV . getDataType ( ) ; Array scalarData = Array . factory ( dtype , new int [ 0 ] ) ; IndexIterator scalarIndex = scalarData . getIndexIterator ( ) ; iconvertDataPrimitiveScalar ( dataV . bt , scalarIndex ) ; return scalarData ; } } // arrays
if ( dataV . darray != null ) { if ( dataV . bt instanceof DStructure ) { ArrayStructure structArray = makeArrayStructure ( dataV ) ; iconvertDataStructureArray ( dataV . darray , structArray . getStructureMembers ( ) ) ; return structArray ; } else if ( dataV . bt instanceof DString ) { return convertStringArray ( dataV . darray ) ; } else { // the DGrid case comes here also
// create the array , using DODS internal array so there ' s no copying
opendap . dap . PrimitiveVector pv = dataV . darray . getPrimitiveVector ( ) ; Object storage = pv . getInternalStorage ( ) ; DataType dtype = dataV . getDataType ( ) ; return Array . factory ( dtype , makeShape ( dataV . darray ) , storage ) ; } } String mess = "Unknown baseType " + dataV . bt . getClass ( ) . getName ( ) + " name=" + dataV . getEncodedName ( ) ; logger . error ( mess ) ; throw new IllegalStateException ( mess ) ;


signature:
public class ConvertD2N { /** * dataV is an array of DStructure : DArray with BaseTypePrimitiveVector , whose values are DStructure */
private void iconvertDataStructureArray ( DVector darray , StructureMembers members ) throws DAP2Exception { } }

implementation:
List < StructureMembers . Member > mlist = members . getMembers ( ) ; for ( StructureMembers . Member member : mlist ) { // get the Array for this member
String name = member . getName ( ) ; IndexIterator ii = ( IndexIterator ) member . getDataObject ( ) ; // loop over each row , fill up the data
BaseTypePrimitiveVector pv = ( BaseTypePrimitiveVector ) darray . getPrimitiveVector ( ) ; for ( int row = 0 ; row < pv . getLength ( ) ; row ++ ) { DStructure ds_data = ( DStructure ) pv . getValue ( row ) ; BaseType member_data = ds_data . getVariable ( name ) ; iconvertData ( member_data , ii ) ; } }


signature:
public class ConvertD2N { /** * convert a DODS scalar value */
private void iconvertDataPrimitiveScalar ( BaseType dodsScalar , IndexIterator ii ) { } }

implementation:
if ( dodsScalar instanceof DString ) { String sval = ( ( DString ) dodsScalar ) . getValue ( ) ; ii . setObjectNext ( sval ) ; } else if ( dodsScalar instanceof DUInt32 ) { int ival = ( ( DUInt32 ) dodsScalar ) . getValue ( ) ; long lval = DataType . unsignedIntToLong ( ival ) ; // LOOK unsigned
ii . setLongNext ( lval ) ; } else if ( dodsScalar instanceof DUInt16 ) { short sval = ( ( DUInt16 ) dodsScalar ) . getValue ( ) ; // LOOK unsigned
int ival = DataType . unsignedShortToInt ( sval ) ; ii . setIntNext ( ival ) ; } else if ( dodsScalar instanceof DFloat32 ) ii . setFloatNext ( ( ( DFloat32 ) dodsScalar ) . getValue ( ) ) ; else if ( dodsScalar instanceof DFloat64 ) ii . setDoubleNext ( ( ( DFloat64 ) dodsScalar ) . getValue ( ) ) ; else if ( dodsScalar instanceof DInt32 ) ii . setIntNext ( ( ( DInt32 ) dodsScalar ) . getValue ( ) ) ; else if ( dodsScalar instanceof DInt16 ) ii . setShortNext ( ( ( DInt16 ) dodsScalar ) . getValue ( ) ) ; else if ( dodsScalar instanceof DByte ) ii . setByteNext ( ( ( DByte ) dodsScalar ) . getValue ( ) ) ; else throw new IllegalArgumentException ( "DODSVariable extractScalar invalid dataType= " + dodsScalar . getClass ( ) . getName ( ) ) ;


signature:
public class ConvertD2N { /** * convert a DODS scalar value */
private void iconvertDataPrimitiveArray ( PrimitiveVector pv , IndexIterator ii ) { } }

implementation:
BaseType bt = pv . getTemplate ( ) ; // set the data value , using scalarIndex from Variable
if ( bt instanceof DString ) { BaseTypePrimitiveVector bpv = ( BaseTypePrimitiveVector ) pv ; for ( int row = 0 ; row < bpv . getLength ( ) ; row ++ ) { DString ds = ( DString ) bpv . getValue ( row ) ; ii . setObjectNext ( ds . getValue ( ) ) ; // LOOK CHAR ?
} } else if ( bt instanceof DUInt32 ) { UInt32PrimitiveVector bpv = ( UInt32PrimitiveVector ) pv ; for ( int row = 0 ; row < bpv . getLength ( ) ; row ++ ) { int ival = bpv . getValue ( row ) ; long lval = DataType . unsignedIntToLong ( ival ) ; // LOOK unsigned
ii . setLongNext ( lval ) ; } } else if ( bt instanceof DUInt16 ) { UInt16PrimitiveVector bpv = ( UInt16PrimitiveVector ) pv ; for ( int row = 0 ; row < bpv . getLength ( ) ; row ++ ) { short sval = bpv . getValue ( row ) ; // LOOK unsigned
int ival = DataType . unsignedShortToInt ( sval ) ; ii . setIntNext ( ival ) ; } } else if ( bt instanceof DFloat32 ) { Float32PrimitiveVector bpv = ( Float32PrimitiveVector ) pv ; for ( int row = 0 ; row < bpv . getLength ( ) ; row ++ ) ii . setFloatNext ( bpv . getValue ( row ) ) ; } else if ( bt instanceof DFloat64 ) { Float64PrimitiveVector bpv = ( Float64PrimitiveVector ) pv ; for ( int row = 0 ; row < bpv . getLength ( ) ; row ++ ) ii . setDoubleNext ( bpv . getValue ( row ) ) ; } else if ( bt instanceof DInt32 ) { Int32PrimitiveVector bpv = ( Int32PrimitiveVector ) pv ; for ( int row = 0 ; row < bpv . getLength ( ) ; row ++ ) ii . setIntNext ( bpv . getValue ( row ) ) ; } else if ( bt instanceof DInt16 ) { Int16PrimitiveVector bpv = ( Int16PrimitiveVector ) pv ; for ( int row = 0 ; row < bpv . getLength ( ) ; row ++ ) ii . setShortNext ( bpv . getValue ( row ) ) ; } else if ( bt instanceof DByte ) { BytePrimitiveVector bpv = ( BytePrimitiveVector ) pv ; for ( int row = 0 ; row < bpv . getLength ( ) ; row ++ ) ii . setByteNext ( bpv . getValue ( row ) ) ; } else throw new IllegalArgumentException ( "DODSVariable extractScalar invalid dataType= " + bt . getClass ( ) . getName ( ) ) ;


signature:
public class ConvertD2N { /** * older opendap servers send netcdf char data as Strings of length 1 ( ! ! ) */
private Array convertStringArray ( Array data , Variable ncVar ) { } }

implementation:
String [ ] storage = ( String [ ] ) data . getStorage ( ) ; int max_len = 0 ; for ( String s : storage ) { max_len = Math . max ( max_len , s . length ( ) ) ; } if ( max_len > 1 ) return data ; // below is the length = 1 barfalloney
int count = 0 ; int n = ( int ) data . getSize ( ) ; char [ ] charStorage = new char [ n ] ; for ( String s : storage ) { if ( s . length ( ) > 0 ) charStorage [ count ++ ] = s . charAt ( 0 ) ; } // change it to a char ( ! ! ) . Since its no longer a String , this code wont get called again for this variable .
ncVar . setDataType ( DataType . CHAR ) ; // return data thats been changed to chars
return Array . factory ( DataType . CHAR , data . getShape ( ) , charStorage ) ; /* if ( section = = null )
 section = ncVar . getRanges ( ) ;
 / / add the strLen dimension back to the array
 int [ ] varShape = ncVar . getShape ( ) ;
 int strLen = varShape [ ncVar . getRank ( ) - 1 ] ;
 int total = ( int ) Range . computeSize ( section ) ;
 int newSize = total / strLen ;
 String [ ] newStorage = new String [ newSize ] ;
 / / merge last dimension
 StringBuffer sbuff = new StringBuffer ( ) ;
 int newCount = 0;
 while ( newCount < newSize ) {
 int mergeCount = 0;
 sbuff . setLength ( 0 ) ;
 while ( mergeCount < strLen ) {
 String s = storage [ strLen * newCount + mergeCount ] ;
 if ( s . length ( ) = = 0 ) break ;
 sbuff . append ( s ) ;
 mergeCount + + ;
 newStorage [ newCount + + ] = sbuff . toString ( ) ;
 / * List dims = ncVar . getDimensions ( ) ;
 ncVar . setDimensions ( dims . subList ( 0 , ncVar . getRank ( ) - 1 ) ) ; / / LOOK is this dangerous or what ? ? ?
 int [ ] newShape = ncVar . getShape ( ) ;
 return Array . factory ( DataType . STRING . getPrimitiveClassType ( ) , newShape , newStorage ) ; */


signature:
public class MetadataManager { /** * this is called on TDS shutdown and reinit */
static synchronized public void closeAll ( ) { } }

implementation:
List < MetadataManager > closeDatabases = new ArrayList < > ( openDatabases ) ; for ( MetadataManager mm : closeDatabases ) { if ( debug ) System . out . println ( "  close database " + mm . collectionName ) ; mm . close ( ) ; } openDatabases = new ArrayList < > ( ) ; // empty
if ( myEnv != null ) { try { // Finally , close the store and environment .
myEnv . close ( ) ; myEnv = null ; logger . info ( "closed bdb caching" ) ; } catch ( DatabaseException dbe ) { logger . error ( "Error closing bdb: " , dbe ) ; } }


signature:
public class MetadataManager { /** * assumes only one open at a time ; could have MetadataManagers share open databases */
private synchronized void openDatabase ( ) { } }

implementation: if ( database != null ) return ; DatabaseConfig dbConfig = new DatabaseConfig ( ) ; dbConfig . setReadOnly ( readOnly ) ; dbConfig . setAllowCreate ( ! readOnly ) ; if ( ! readOnly ) dbConfig . setDeferredWrite ( true ) ; database = myEnv . openDatabase ( null , collectionName , dbConfig ) ; openDatabases . add ( this ) ;


signature:
public class DateField { /** * See if edit value is valid , put error message in buff . */
@ Override protected boolean _validate ( StringBuffer buff ) { } }

implementation: try { new DateType ( tf . getText ( ) , null , null ) ; return true ; } catch ( java . text . ParseException e ) { if ( null != buff ) buff . append ( name ) . append ( ": " ) . append ( e . getMessage ( ) ) ; return false ; }


signature:
public class DateField { /** * get current value from editComponent */
@ Override protected Object getEditValue ( ) { } }

implementation: try { return new DateType ( tf . getText ( ) , null , null ) ; } catch ( java . text . ParseException e ) { return null ; }


signature:
public class CalendarDuration { /** * Convert a time udunit string
 * @ param value number of units
 * @ param udunit msec , sec , minute , hour , hr , day , week , month , year ( plural form ok )
 * @ return joda Period */
static org . joda . time . Period convertToPeriod ( int value , String udunit ) { } }

implementation: if ( udunit . endsWith ( "s" ) ) udunit = udunit . substring ( 0 , udunit . length ( ) - 1 ) ; switch ( udunit ) { case "msec" : return Period . millis ( value ) ; case "sec" : return Period . seconds ( value ) ; case "minute" : return Period . minutes ( value ) ; case "hour" : case "hr" : return Period . hours ( value ) ; case "day" : return Period . days ( value ) ; case "week" : return Period . weeks ( value ) ; case "month" : return Period . months ( value ) ; case "year" : return Period . years ( value ) ; } throw new IllegalArgumentException ( "cant convert " + udunit + " to Joda Period" ) ;


signature:
public class EcmwfCodeTable { /** * # Code table 4.2 - Parameter number by product discipline and parameter category
 * 0 0 Estimated precipitation ( kg m - 2)
 * 1 1 Instantaneous rain rate ( kg m - 2 s - 1)
 * 2 2 Cloud top height ( m )
 * 3 3 Cloud top height quality indicator ( Code table 4.219)
 * 4 4 Estimated u - component of wind ( m / s )
 * 5 5 Estimated v - component of wind ( m / s )
 * 6 6 Number of pixel used ( Numeric )
 * 7 7 Solar zenith angle ( deg )
 * 8 8 Relative azimuth angle ( deg )
 * 9 9 Reflectance in 0.6 micron channel ( % )
 * 10 10 Reflectance in 0.8 micron channel ( % )
 * 11 11 Reflectance in 1.6 micron channel ( % )
 * 12 12 Reflectance in 3.9 micron channel ( % )
 * 13 13 Atmospheric divergence ( / s )
 * 14 14 Cloudy brightness temperature ( K )
 * 15 15 Clear - sky brightness temperature ( K )
 * 16 16 Cloudy radiance ( with respect to wave number ) ( W m - 1 sr - 1)
 * 17 17 Clear - sky radiance ( with respect to wave number ) ( W m - 1 sr - 1)
 * 18 18 Reserved
 * 19 19 Wind speed ( m / s )
 * 20 20 Aerosol optical thickness at 0.635 um
 * 21 21 Aerosol optical thickness at 0.810 um
 * 22 22 Aerosol optical thickness at 1.640 um
 * 23 23 Angstrom coefficient
 * # 24-26 Reserved
 * 27 27 Bidirectional reflectance factor ( numeric )
 * 28 28 Brightness temperature ( K )
 * 29 29 Scaled radiance ( numeric )
 * # 30-191 Reserved
 * # 192-254 Reserved for local use
 * 255 255 Missing */
private ImmutableMap < Integer , Entry > readTable ( String path ) throws IOException { } }

implementation: ImmutableMap . Builder < Integer , Entry > builder = ImmutableMap . builder ( ) ; if ( debugOpen ) { System . out . printf ( "readEcmwfTable path= %s%n" , path ) ; } ClassLoader cl = Grib2TableConfig . class . getClassLoader ( ) ; try ( InputStream is = cl . getResourceAsStream ( path ) ) { if ( is == null ) { throw new IllegalStateException ( "Cant find " + path ) ; } try ( BufferedReader dataIS = new BufferedReader ( new InputStreamReader ( is , Charset . forName ( "UTF8" ) ) ) ) { int count = 0 ; while ( true ) { String line = dataIS . readLine ( ) ; if ( line == null ) { break ; } if ( line . startsWith ( "#" ) || line . trim ( ) . length ( ) == 0 ) { continue ; } count ++ ; int posBlank1 = line . indexOf ( ' ' ) ; int posBlank2 = line . indexOf ( ' ' , posBlank1 + 1 ) ; int lastParen = line . lastIndexOf ( '(' ) ; String num1 = line . substring ( 0 , posBlank1 ) . trim ( ) ; String num2 = line . substring ( posBlank1 + 1 , posBlank2 ) ; String desc = ( lastParen > 0 ) ? line . substring ( posBlank2 + 1 , lastParen ) . trim ( ) : line . substring ( posBlank2 + 1 ) . trim ( ) ; if ( ! num1 . equals ( num2 ) ) { if ( debug ) { System . out . printf ( "*****num1 != num2 for %s%n" , line ) ; } continue ; } int code = Integer . parseInt ( num1 ) ; EcmwfEntry entry = new EcmwfEntry ( code , desc ) ; builder . put ( entry . getCode ( ) , entry ) ; if ( debug ) { System . out . printf ( " %s%n" , entry ) ; } } } } return builder . build ( ) ;


signature:
public class GridCoordinate2D { /** * brute force */
public boolean findCoordElementForce ( double wantLat , double wantLon , int [ ] rectIndex ) { } }

implementation:
findBounds ( ) ; if ( wantLat < latMinMax . min ) return false ; if ( wantLat > latMinMax . max ) return false ; if ( wantLon < lonMinMax . min ) return false ; if ( wantLon > lonMinMax . max ) return false ; boolean saveDebug = debug ; debug = false ; for ( int row = 0 ; row < nrows ; row ++ ) { for ( int col = 0 ; col < ncols ; col ++ ) { rectIndex [ 0 ] = row ; rectIndex [ 1 ] = col ; if ( contains ( wantLat , wantLon , rectIndex ) ) { debug = saveDebug ; return true ; } } } // debug = saveDebug ;
return false ;


signature:
public class GridCoordinate2D { /** * Find the best index for the given lat , lon point .
 * @ param wantLat lat of point
 * @ param wantLon lon of point
 * @ param rectIndex return ( row , col ) index , or best guess here . may not be null
 * @ return false if not in the grid . */
public boolean findCoordElementNoForce ( double wantLat , double wantLon , int [ ] rectIndex ) { } }

implementation:
findBounds ( ) ; if ( wantLat < latMinMax . min ) return false ; if ( wantLat > latMinMax . max ) return false ; if ( wantLon < lonMinMax . min ) return false ; if ( wantLon > lonMinMax . max ) return false ; double gradientLat = ( latMinMax . max - latMinMax . min ) / nrows ; double gradientLon = ( lonMinMax . max - lonMinMax . min ) / ncols ; double diffLat = wantLat - latMinMax . min ; double diffLon = wantLon - lonMinMax . min ; // initial guess
rectIndex [ 0 ] = ( int ) Math . round ( diffLat / gradientLat ) ; // row
rectIndex [ 1 ] = ( int ) Math . round ( diffLon / gradientLon ) ; // col
int count = 0 ; while ( true ) { count ++ ; if ( debug ) System . out . printf ( "%nIteration %d %n" , count ) ; if ( contains ( wantLat , wantLon , rectIndex ) ) return true ; if ( ! jump2 ( wantLat , wantLon , rectIndex ) ) return false ; // bouncing around
if ( count > 10 ) { // last ditch attempt
return incr ( wantLat , wantLon , rectIndex ) ; // if ( ! ok )
// log . error ( " findCoordElement didnt converge lat , lon = " + wantLat + " " + wantLon ) ;
// return ok ;
} }


signature:
public class ErddapStringArray { /** * Reads the contents of { @ code inputStream } into a StringArray . Each line of input will result in an element in
 * the array .
 * The specified stream remains open after this method returns .
 * @ param inputStream a stream with line - based content .
 * @ param charset the name of a supported { @ link java . nio . charset . Charset charset } .
 * @ return a StringArray created from the stream .
 * @ throws IOException if an I / O error occurs */
public static ErddapStringArray fromInputStream ( InputStream inputStream , String charset ) throws IOException { } }

implementation:
if ( charset == null || charset . isEmpty ( ) ) { charset = CDM . UTF8 ; } InputStreamReader isr = new InputStreamReader ( inputStream , charset ) ; BufferedReader bufferedReader = new BufferedReader ( isr ) ; ErddapStringArray sa = new ErddapStringArray ( ) ; for ( String s ; ( s = bufferedReader . readLine ( ) ) != null ; ) { sa . add ( s ) ; } // Do not call BufferedReader . close ( ) here ; that would close the underlying InputStream , which is the
// responsibility of the client . This ought to be safe , as neither InputStreamReader nor BufferedReader hold any
// resources that a call to close ( ) would make free and which the garbage collector would not make free anyway .
return sa ;


signature:
public class ErddapStringArray { /** * This adds an item to the array ( increasing ' size ' by 1 ) .
 * @ param value the value to be added to the array */
public void add ( String value ) { } }

implementation:
if ( size == array . length ) // if we ' re at capacity
ensureCapacity ( size + 1L ) ; array [ size ++ ] = value ;


signature:
public class ErddapStringArray { /** * This ensures that the capacity is at least ' minCapacity ' .
 * @ param minCapacity the minimum acceptable capacity .
 * minCapacity is type long , but & gt ; = Integer . MAX _ VALUE will throw exception . */
public void ensureCapacity ( long minCapacity ) { } }

implementation:
if ( array . length < minCapacity ) { // ensure minCapacity is < Integer . MAX _ VALUE
ErddapMath2 . ensureArraySizeOkay ( minCapacity , "StringArray" ) ; // caller may know exact number needed , so don ' t double above 2x current size
int newCapacity = ( int ) Math . min ( Integer . MAX_VALUE - 1 , array . length + ( long ) array . length ) ; if ( newCapacity < minCapacity ) newCapacity = ( int ) minCapacity ; // safe since checked above
String [ ] newArray = new String [ newCapacity ] ; System . arraycopy ( array , 0 , newArray , 0 , size ) ; array = newArray ; // do last to minimize concurrency problems
}


signature:
public class ErddapStringArray { /** * This gets a specified element .
 * @ param index 0 . . . size - 1 */
public String get ( int index ) { } }

implementation: if ( index >= size ) throw new IllegalArgumentException ( ErddapString2 . ERROR + " in StringArray.get: index (" + index + ") >= size (" + size + ")." ) ; return array [ index ] ;


signature:
public class HdfEosOmiConvention { /** * level3
 * group : HDFEOS {
 * group : GRIDS {
 * group : OMI _ Column _ Amount _ O3 {
 * dimensions :
 * XDim = 1440;
 * YDim = 720;
 * group : Data _ Fields {
 * variables :
 * float ColumnAmountO3 ( YDim = 720 , XDim = 1440 ) ;
 * : _ FillValue = - 1.2676506E30f ; / / float
 * : Units = " DU " ;
 * : Title = " Best Total Ozone Solution " ;
 * : UniqueFieldDefinition = " TOMS - OMI - Shared " ;
 * : ScaleFactor = 1.0 ; / / double
 * : Offset = 0.0 ; / / double
 * : ValidRange = 50.0f , 700.0f ; / / float
 * : MissingValue = - 1.2676506E30f ; / / float
 * : _ ChunkSize = 180 , 180 ; / / int
 * float Reflectivity331 ( YDim = 720 , XDim = 1440 ) ;
 * : _ FillValue = - 1.2676506E30f ; / / float
 * : Units = " % " ;
 * : Title = " Effective Surface Reflectivity at 331 nm " ;
 * : UniqueFieldDefinition = " TOMS - OMI - Shared " ;
 * : ScaleFactor = 1.0 ; / / double
 * : Offset = 0.0 ; / / double
 * : ValidRange = - 15.0f , 115.0f ; / / float
 * : MissingValue = - 1.2676506E30f ; / / float
 * : _ ChunkSize = 180 , 180 ; / / int
 * float UVAerosolIndex ( YDim = 720 , XDim = 1440 ) ;
 * : _ FillValue = - 1.2676506E30f ; / / float
 * : Units = " NoUnits " ;
 * : Title = " UV Aerosol Index " ;
 * : UniqueFieldDefinition = " TOMS - OMI - Shared " ;
 * : ScaleFactor = 1.0 ; / / double
 * : Offset = 0.0 ; / / double
 * : ValidRange = - 30.0f , 30.0f ; / / float
 * : MissingValue = - 1.2676506E30f ; / / float
 * : _ ChunkSize = 180 , 180 ; / / int
 * group attributes :
 * : GCTPProjectionCode = 0 ; / / int
 * : Projection = " Geographic " ;
 * : GridOrigin = " Center " ;
 * : NumberOfLongitudesInGrid = 1440 ; / / int
 * : NumberOfLatitudesInGrid = 720 ; / / int */
public void augmentDataset ( NetcdfDataset ds , CancelTask cancelTask ) throws IOException { } }

implementation:
final Attribute levelAtt = ds . findAttribute ( "/HDFEOS/ADDITIONAL/FILE_ATTRIBUTES/@ProcessLevel" ) ; if ( levelAtt == null ) { return ; } final int level = levelAtt . getStringValue ( ) . startsWith ( "2" ) ? 2 : 3 ; // Attribute time = ds . findAttribute ( " / HDFEOS / ADDITIONAL / FILE _ ATTRIBUTES / @ TAI93At0zOfGranule " ) ;
if ( level == 3 ) { augmentDataset3 ( ds ) ; }


signature:
public class RotatedPole { /** * Transform a " real " longitude and latitude into the rotated longitude ( X ) and
 * rotated latitude ( Y ) . */
public ProjectionPoint latLonToProj ( LatLonPoint latlon , ProjectionPointImpl destPoint ) { } }

implementation:
double lat = latlon . getLatitude ( ) ; double lon = latlon . getLongitude ( ) ; // Lon - lat pair to xyz coordinates on sphere with radius 1
double [ ] p0 = new double [ ] { Math . cos ( lat * RAD_PER_DEG ) * Math . cos ( lon * RAD_PER_DEG ) , Math . cos ( lat * RAD_PER_DEG ) * Math . sin ( lon * RAD_PER_DEG ) , Math . sin ( lat * RAD_PER_DEG ) } ; // Rotate around Z - axis
double [ ] p1 = new double [ ] { rotZ [ 0 ] [ 0 ] * p0 [ 0 ] + rotZ [ 0 ] [ 1 ] * p0 [ 1 ] + rotZ [ 0 ] [ 2 ] * p0 [ 2 ] , rotZ [ 1 ] [ 0 ] * p0 [ 0 ] + rotZ [ 1 ] [ 1 ] * p0 [ 1 ] + rotZ [ 1 ] [ 2 ] * p0 [ 2 ] , rotZ [ 2 ] [ 0 ] * p0 [ 0 ] + rotZ [ 2 ] [ 1 ] * p0 [ 1 ] + rotZ [ 2 ] [ 2 ] * p0 [ 2 ] } ; // Rotate around Y - axis
double [ ] p2 = new double [ ] { rotY [ 0 ] [ 0 ] * p1 [ 0 ] + rotY [ 0 ] [ 1 ] * p1 [ 1 ] + rotY [ 0 ] [ 2 ] * p1 [ 2 ] , rotY [ 1 ] [ 0 ] * p1 [ 0 ] + rotY [ 1 ] [ 1 ] * p1 [ 1 ] + rotY [ 1 ] [ 2 ] * p1 [ 2 ] , rotY [ 2 ] [ 0 ] * p1 [ 0 ] + rotY [ 2 ] [ 1 ] * p1 [ 1 ] + rotY [ 2 ] [ 2 ] * p1 [ 2 ] } ; final double lonR = LatLonPointImpl . range180 ( Math . atan2 ( p2 [ 1 ] , p2 [ 0 ] ) * DEG_PER_RAD ) ; // final double lonR = Math . atan2 ( p2[1 ] , p2[0 ] ) * DEG _ PER _ RAD ;
final double latR = Math . asin ( p2 [ 2 ] ) * DEG_PER_RAD ; if ( destPoint == null ) destPoint = new ProjectionPointImpl ( lonR , latR ) ; else destPoint . setLocation ( lonR , latR ) ; if ( show ) System . out . println ( "LatLon= " + latlon + " proj= " + destPoint ) ; return destPoint ;


signature:
public class RotatedPole { /** * Transform a rotated longitude ( X ) and rotated latitude ( Y ) into a " real "
 * longitude - latitude pair . */
public LatLonPoint projToLatLon ( ProjectionPoint ppt , LatLonPointImpl destPoint ) { } }

implementation:
// " x " and " y " input for rotated pole coords are actually a lon - lat pair
final double lonR = LatLonPointImpl . range180 ( ppt . getX ( ) ) ; // LOOK guessing
final double latR = ppt . getY ( ) ; // Lon - lat pair to xyz coordinates on sphere with radius 1
double [ ] p0 = new double [ ] { Math . cos ( latR * RAD_PER_DEG ) * Math . cos ( lonR * RAD_PER_DEG ) , Math . cos ( latR * RAD_PER_DEG ) * Math . sin ( lonR * RAD_PER_DEG ) , Math . sin ( latR * RAD_PER_DEG ) } ; // Inverse rotate around Y - axis ( using transpose of Y matrix )
double [ ] p1 = new double [ ] { rotY [ 0 ] [ 0 ] * p0 [ 0 ] + rotY [ 1 ] [ 0 ] * p0 [ 1 ] + rotY [ 2 ] [ 0 ] * p0 [ 2 ] , rotY [ 0 ] [ 1 ] * p0 [ 0 ] + rotY [ 1 ] [ 1 ] * p0 [ 1 ] + rotY [ 2 ] [ 1 ] * p0 [ 2 ] , rotY [ 0 ] [ 2 ] * p0 [ 0 ] + rotY [ 1 ] [ 2 ] * p0 [ 1 ] + rotY [ 2 ] [ 2 ] * p0 [ 2 ] } ; // Inverse rotate around Z - axis ( using transpose of Z matrix )
double [ ] p2 = new double [ ] { rotZ [ 0 ] [ 0 ] * p1 [ 0 ] + rotZ [ 1 ] [ 0 ] * p1 [ 1 ] + rotZ [ 2 ] [ 0 ] * p1 [ 2 ] , rotZ [ 0 ] [ 1 ] * p1 [ 0 ] + rotZ [ 1 ] [ 1 ] * p1 [ 1 ] + rotZ [ 2 ] [ 1 ] * p1 [ 2 ] , rotZ [ 0 ] [ 2 ] * p1 [ 0 ] + rotZ [ 1 ] [ 2 ] * p1 [ 1 ] + rotZ [ 2 ] [ 2 ] * p1 [ 2 ] } ; final double lon = Math . atan2 ( p2 [ 1 ] , p2 [ 0 ] ) * DEG_PER_RAD ; final double lat = Math . asin ( p2 [ 2 ] ) * DEG_PER_RAD ; if ( destPoint == null ) destPoint = new LatLonPointImpl ( lat , lon ) ; else destPoint . set ( lat , lon ) ; if ( show ) System . out . println ( "Proj= " + ppt + " latlon= " + destPoint ) ; return destPoint ;


signature:
public class InvDatasetScan { /** * Resets the location being scanned ( DO NOT USE THIS METHOD , " public by accident " ) .
 * < p > Used by DataRootHandler to allow scanning an aliased directory ( " content " ) .
 * @ param scanLocation the scan location . */
public void setScanLocation ( String scanLocation ) { } }

implementation:
// ToDo LOOK Instead hand InvDatasetScan ( or InvCatFactory ? ) an algorithm for converting an aliased location .
if ( ! scanLocation . equals ( this . scanLocation ) ) { this . isValid = true ; this . scanLocation = scanLocation ; this . scanLocationCrDs = createScanLocationCrDs ( ) ; if ( this . scanLocationCrDs == null ) { isValid = false ; invalidMessage = new StringBuilder ( "Invalid InvDatasetScan <path=" ) . append ( rootPath ) . append ( "; scanLocation=" ) . append ( scanLocation ) . append ( ">: could not create CrawlableDataset for scanLocation." ) ; } else if ( ! this . scanLocationCrDs . exists ( ) ) { isValid = false ; invalidMessage = new StringBuilder ( "Invalid InvDatasetScan <path=" ) . append ( rootPath ) . append ( "; scanLocation=" ) . append ( scanLocation ) . append ( ">: CrawlableDataset for scanLocation does not exist." ) ; } else if ( ! this . scanLocationCrDs . isCollection ( ) ) { isValid = false ; invalidMessage = new StringBuilder ( "Invalid InvDatasetScan <path=" ) . append ( rootPath ) . append ( "; scanLocation=" ) . append ( scanLocation ) . append ( ">: CrawlableDataset for scanLocation not a collection." ) ; } }


signature:
public class InvDatasetScan { /** * Return the CrawlableDataset path / location that corresponds to the
 * given dataset path . The given dataset path must start with the
 * datasetScan path for this InvDatasetScan , if not , a null is returned .
 * @ param dsPath a datasetScan dsPath that
 * @ return the CrawlableDataset path that corresponds to the given dataset path or null . */
public String translatePathToLocation ( String dsPath ) { } }

implementation:
if ( dsPath == null ) return null ; if ( dsPath . length ( ) > 0 ) if ( dsPath . startsWith ( "/" ) ) dsPath = dsPath . substring ( 1 ) ; if ( ! dsPath . startsWith ( this . getPath ( ) ) ) return null ; // remove the matching part , the rest is the " data directory "
String dataDir = dsPath . substring ( this . getPath ( ) . length ( ) ) ; if ( dataDir . startsWith ( "/" ) ) dataDir = dataDir . substring ( 1 ) ; CrawlableDataset curCrDs = scanLocationCrDs . getDescendant ( dataDir ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "translatePathToLocation(): url dsPath= " + dsPath + " to dataset dsPath= " + curCrDs . getPath ( ) ) ; return curCrDs . getPath ( ) ;


signature:
public class InvDatasetScan { /** * Return the CrawlableDataset for the given path , null if this InvDatasetScan
 * does not allow ( filters out ) the requested CrawlableDataset .
 * < p > This method can handle requests for regular datasets and proxy datasets .
 * @ param path the path of the requested CrawlableDataset
 * @ return the CrawlableDataset for the given path or null if the path is not allowed by this InvDatasetScan .
 * @ throws IOException if an I / O error occurs while locating the children datasets .
 * @ throws IllegalArgumentException if the given path is not a descendant of ( or the same as ) this InvDatasetScan collection level . */
public CrawlableDataset requestCrawlableDataset ( String path ) throws IOException { } }

implementation: String crDsPath = translatePathToLocation ( path ) ; if ( crDsPath == null ) return null ; CatalogBuilder catBuilder = buildCatalogBuilder ( ) ; if ( catBuilder == null ) return null ; return catBuilder . requestCrawlableDataset ( crDsPath ) ;


signature:
public class InvDatasetScan { /** * Try to build a catalog for the given path by scanning the location
 * associated with this InvDatasetScan . The given path must start with
 * the path of this InvDatasetScan .
 * @ param orgPath the part of the baseURI that is the path
 * @ param catURI the base URL for the catalog , used to resolve relative URLs .
 * @ return the catalog for this path ( uses version 1.1 ) or null if build unsuccessful . */
public InvCatalogImpl makeCatalogForDirectory ( String orgPath , URI catURI ) { } }

implementation:
if ( log . isDebugEnabled ( ) ) { log . debug ( "baseURI=" + catURI ) ; log . debug ( "orgPath=" + orgPath ) ; log . debug ( "rootPath=" + rootPath ) ; log . debug ( "scanLocation=" + scanLocation ) ; } // Get the dataset path .
String dsDirPath = translatePathToLocation ( orgPath ) ; if ( dsDirPath == null ) { String tmpMsg = "makeCatalogForDirectory(): Requesting path <" + orgPath + "> must start with \"" + rootPath + "\"." ; log . error ( tmpMsg ) ; return null ; } // Setup and create catalog builder .
CatalogBuilder catBuilder = buildCatalogBuilder ( ) ; if ( catBuilder == null ) return null ; // A very round about way to remove the filename ( e . g . , " catalog . xml " ) .
// Note : Gets around " path separator at end of path " issues that are CrDs implementation dependant .
// Note : Does not check that CrDs is allowed by filters .
String dsPath = dsDirPath . substring ( scanLocationCrDs . getPath ( ) . length ( ) ) ; if ( dsPath . startsWith ( "/" ) ) dsPath = dsPath . substring ( 1 ) ; CrawlableDataset reqCrDs = scanLocationCrDs . getDescendant ( dsPath ) ; CrawlableDataset parent = reqCrDs . getParentDataset ( ) ; if ( parent == null ) { log . error ( "makeCatalogForDirectory(): I/O error getting parent crDs level <" + dsDirPath + ">: " ) ; return null ; } dsDirPath = parent . getPath ( ) ; // Get the CrawlableDataset for the desired catalog level ( checks that allowed by filters ) .
CrawlableDataset catalogCrDs ; try { catalogCrDs = catBuilder . requestCrawlableDataset ( dsDirPath ) ; } catch ( IOException e ) { log . error ( "makeCatalogForDirectory(): I/O error getting catalog level <" + dsDirPath + ">: " + e . getMessage ( ) , e ) ; return null ; } if ( catalogCrDs == null ) { log . warn ( "makeCatalogForDirectory(): requested catalog level <" + dsDirPath + "> not allowed (filtered out)." ) ; return null ; } if ( ! catalogCrDs . isCollection ( ) ) { log . warn ( "makeCatalogForDirectory(): requested catalog level <" + dsDirPath + "> is not a collection." ) ; return null ; } // Generate the desired catalog using the builder .
InvCatalogImpl catalog ; try { catalog = catBuilder . generateCatalog ( catalogCrDs ) ; } catch ( IOException e ) { log . error ( "makeCatalogForDirectory(): catalog generation failed <" + catalogCrDs . getPath ( ) + ">: " + e . getMessage ( ) ) ; return null ; } // Set the catalog base URI .
if ( catalog != null ) catalog . setBaseURI ( catURI ) ; // InvDatasetImpl top = ( InvDatasetImpl ) catalog . getDataset ( ) ;
// / / if we name it carefully , can get catalogRef to useProxy = = true ( disappear top dataset )
// if ( service . isRelativeBase ( ) ) {
// pos = dataDir . lastIndexOf ( " / " ) ;
// String lastDir = ( pos > 0 ) ? dataDir . substring ( pos + 1 ) : dataDir ;
// String topName = lastDir . length ( ) > 0 ? lastDir : getName ( ) ;
// top . setName ( topName ) ;
return catalog ;


signature:
public class InvDatasetScan { /** * Try to build a catalog for the given resolver path by scanning the
 * location associated with this InvDatasetScan . The given path must start
 * with the path of this InvDatasetScan and refer to a resolver
 * ProxyDatasetHandler that is part of this InvDatasetScan .
 * @ param path the part of the baseURI that is the path
 * @ param baseURI the base URL for the catalog , used to resolve relative URLs .
 * @ return the resolver catalog for this path ( uses version 1.1 ) or null if build unsuccessful . */
public InvCatalogImpl makeProxyDsResolverCatalog ( String path , URI baseURI ) { } }

implementation:
if ( path == null ) return null ; if ( path . endsWith ( "/" ) ) return null ; // Get the dataset path .
String dsDirPath = translatePathToLocation ( path ) ; if ( dsDirPath == null ) { log . error ( "makeProxyDsResolverCatalog(): Requesting path <" + path + "> must start with \"" + rootPath + "\"." ) ; return null ; } // Split into parent path and dataset name .
int pos = dsDirPath . lastIndexOf ( '/' ) ; if ( pos == - 1 ) { log . error ( "makeProxyDsResolverCatalog(): Requesting path <" + path + "> must contain a slash (\"/\")." ) ; return null ; } String dsName = dsDirPath . substring ( pos + 1 ) ; dsDirPath = dsDirPath . substring ( 0 , pos ) ; // Find matching ProxyDatasetHandler .
ProxyDatasetHandler pdh = this . getProxyDatasetHandlers ( ) . get ( dsName ) ; if ( pdh == null ) { log . error ( "makeProxyDsResolverCatalog(): No matching proxy dataset handler found <" + dsName + ">." ) ; return null ; } // Setup and create catalog builder .
CatalogBuilder catBuilder = buildCatalogBuilder ( ) ; if ( catBuilder == null ) return null ; // Get the CrawlableDataset for the desired catalog level .
CrawlableDataset catalogCrDs ; try { catalogCrDs = catBuilder . requestCrawlableDataset ( dsDirPath ) ; } catch ( IOException e ) { log . error ( "makeProxyDsResolverCatalog(): failed to create CrawlableDataset for catalogLevel <" + dsDirPath + "> and class <" + crDsClassName + ">: " + e . getMessage ( ) , e ) ; return null ; } if ( catalogCrDs == null ) { log . warn ( "makeProxyDsResolverCatalog(): requested catalog level <" + dsDirPath + "> not allowed (filtered out)." ) ; return null ; } if ( ! catalogCrDs . isCollection ( ) ) { log . warn ( "makeProxyDsResolverCatalog(): requested catalog level <" + dsDirPath + "> not a collection." ) ; return null ; } // Generate the desired catalog using the builder .
InvCatalogImpl catalog ; try { catalog = ( InvCatalogImpl ) catBuilder . generateProxyDsResolverCatalog ( catalogCrDs , pdh ) ; } catch ( IOException e ) { log . error ( "makeProxyDsResolverCatalog(): catalog generation failed <" + catalogCrDs . getPath ( ) + ">: " + e . getMessage ( ) ) ; return null ; } // Set the catalog base URI .
if ( catalog != null ) catalog . setBaseURI ( baseURI ) ; return catalog ;


signature:
public class AggregationNew { /** * What is the data type of the aggregation coordinate ?
 * @ return the data type of the aggregation coordinate */
private DataType getCoordinateType ( ) { } }

implementation: List < Dataset > nestedDatasets = getDatasets ( ) ; DatasetOuterDimension first = ( DatasetOuterDimension ) nestedDatasets . get ( 0 ) ; return first . isStringValued ? DataType . STRING : DataType . DOUBLE ;


signature:
public class Grib2Pds { /** * Factory for Grib2Pds
 * @ param template pds template number
 * @ param input raw bytes
 * @ return Grib2Pds or null on error */
@ Nullable public static Grib2Pds factory ( int template , byte [ ] input ) { } }

implementation: switch ( template ) { case 0 : return new Grib2Pds0 ( input ) ; case 1 : return new Grib2Pds1 ( input ) ; case 2 : return new Grib2Pds2 ( input ) ; case 5 : return new Grib2Pds5 ( input ) ; case 6 : return new Grib2Pds6 ( input ) ; case 8 : return new Grib2Pds8 ( input ) ; case 9 : return new Grib2Pds9 ( input ) ; case 10 : return new Grib2Pds10 ( input ) ; case 11 : return new Grib2Pds11 ( input ) ; case 12 : return new Grib2Pds12 ( input ) ; case 15 : return new Grib2Pds15 ( input ) ; case 30 : return new Grib2Pds30 ( input ) ; case 31 : return new Grib2Pds31 ( input ) ; case 48 : return new Grib2Pds48 ( input ) ; case 61 : return new Grib2Pds61 ( input ) ; default : log . warn ( "Missing template " + template ) ; return null ; }


signature:
public class Grib2Pds { /** * / * public double getProbabilityLowerLimit ( ) {
 * return GribNumbers . UNDEFINED ;
 * public double getProbabilityUpperLimit ( ) {
 * return GribNumbers . UNDEFINED ;
 * public int getProbabilityType ( ) {
 * return GribNumbers . UNDEFINED ;
 * public boolean isPercentile ( ) {
 * return false ;
 * public int getPercentileValue ( ) {
 * return - 1; */
public void show ( Formatter f ) { } }

implementation: f . format ( "Grib2Pds{ id=%d-%d template=%d, forecastTime= %d timeUnit=%s vertLevel=%f}" , getParameterCategory ( ) , getParameterNumber ( ) , template , getForecastTime ( ) , getTimeUnit ( ) , getLevelValue1 ( ) ) ;


signature:
public class Grib2Pds { /** * null means use refTime */
protected CalendarDate calcTime ( int startIndex ) { } }

implementation:
int year = GribNumbers . int2 ( getOctet ( startIndex ++ ) , getOctet ( startIndex ++ ) ) ; int month = getOctet ( startIndex ++ ) ; int day = getOctet ( startIndex ++ ) ; int hour = getOctet ( startIndex ++ ) ; int minute = getOctet ( startIndex ++ ) ; int second = getOctet ( startIndex ++ ) ; if ( ( year == 0 ) && ( month == 0 ) && ( day == 0 ) && ( hour == 0 ) && ( minute == 0 ) && ( second == 0 ) ) return CalendarDate . UNKNOWN ; // href . t00z . prob . f36 . grib2
if ( hour > 23 ) { day += ( hour / 24 ) ; hour = hour % 24 ; } return CalendarDate . of ( null , year , month , day , hour , minute , second ) ;


signature:
public class Grib2Pds { /** * Apply scale factor to value , return a double result .
 * @ param scale signed scale factor
 * @ param value apply to this value
 * @ return value ^ - scale */
double applyScaleFactor ( int scale , int value ) { } }

implementation: return ( ( scale == 0 ) || ( scale == 255 ) || ( value == 0 ) ) ? value : value * Math . pow ( 10 , - scale ) ;


signature:
public class DatasetHtmlWriter { /** * Write an Html representation of the given dataset .
 * < p > With datasetEvents , catrefEvents = true , this is used to construct an HTML page on the client
 * ( eg using HtmlPage ) ; the client then detects URL clicks and processes .
 * < p > With datasetEvents , catrefEvents = false , this is used to construct an HTML page on the server .
 * ( eg using HtmlPage ) ; the client then detects URL clicks and processes .
 * @ param out put HTML here .
 * @ param ds the dataset .
 * @ param complete if true , add HTML header and ender so its a complete , valid HTML page .
 * @ param isServer if true , then we are in the thredds data server , so do the following : < ul >
 * < li > append " html " to DODS Access URLs
 * < / ul >
 * @ param datasetEvents if true , prepend " dataset : " to any dataset access URLS
 * @ param catrefEvents if true , prepend " catref : " to any catref URLS */
public void writeHtmlDescription ( Formatter out , Dataset ds , boolean complete , boolean isServer , boolean datasetEvents , boolean catrefEvents , boolean resolveRelativeUrls ) { } }

implementation:
if ( ds == null ) return ; if ( complete ) { out . format ( "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"%n" ) ; out . format ( "        \"http://www.w3.org/TR/html4/loose.dtd\">%n" ) ; out . format ( "%n" ) ; out . format ( "%n" ) ; out . format ( "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">%n" ) ; out . format ( "%n" ) ; out . format ( "%n" ) ; } out . format ( "
Dataset: %s
%n
" , ds . getName ( ) ) ; if ( ds . getDataFormatName ( ) != null ) out . format ( "
Data format: %s
%n" , htmlEscaper . escape ( ds . getDataFormatName ( ) ) ) ; if ( ( ds . getDataSize ( ) > 0 ) ) out . format ( "
Data size: %s
%n" , Format . formatByteSize ( ds . getDataSize ( ) ) ) ; if ( ds . getFeatureTypeName ( ) != null ) out . format ( "
Feature type: %s
%n" , htmlEscaper . escape ( ds . getFeatureTypeName ( ) ) ) ; if ( ds . getCollectionType ( ) != null ) out . format ( "
Collection type: %s
%n" , htmlEscaper . escape ( ds . getCollectionType ( ) ) ) ; if ( ds . isHarvest ( ) ) out . format ( "
Harvest: true
%n" ) ; if ( ds . getAuthority ( ) != null ) out . format ( "
Naming Authority: %s
%n%n" , htmlEscaper . escape ( ds . getAuthority ( ) ) ) ; if ( ds . getId ( ) != null ) out . format ( "
ID: %s
%n" , htmlEscaper . escape ( ds . getId ( ) ) ) ; if ( ds . getRestrictAccess ( ) != null ) out . format ( "
RestrictAccess: %s
%n" , htmlEscaper . escape ( ds . getRestrictAccess ( ) ) ) ; if ( ds instanceof CatalogRef ) { CatalogRef catref = ( CatalogRef ) ds ; String href = resolveRelativeUrls | catrefEvents ? resolve ( ds , catref . getXlinkHref ( ) ) : catref . getXlinkHref ( ) ; if ( catrefEvents ) href = "catref:" + href ; out . format ( "
CatalogRef: %s
%n" , makeHref ( href , null , null ) ) ; } out . format ( "
%n" ) ; java . util . List < Documentation > docs = ds . getDocumentation ( ) ; if ( docs . size ( ) > 0 ) { out . format ( "
Documentation:
%n
%n" ) ; for ( Documentation doc : docs ) { String type = ( doc . getType ( ) == null ) ? "" : "" + htmlEscaper . escape ( doc . getType ( ) ) + ": " ; String inline = doc . getInlineContent ( ) ; if ( ( inline != null ) && ( inline . length ( ) > 0 ) ) out . format ( "
%s %s
%n" , type , htmlEscaper . escape ( inline ) ) ; if ( doc . hasXlink ( ) ) { out . format ( "
%s %s
%n" , type , makeHref ( doc . getXlinkHref ( ) , null , doc . getXlinkTitle ( ) ) ) ; } } out . format ( "
%n" ) ; } java . util . List < Access > access = ds . getAccess ( ) ; if ( access . size ( ) > 0 ) { out . format ( "
Access:
%n
%n" ) ; for ( Access a : access ) { Service s = a . getService ( ) ; String urlString = resolveRelativeUrls || datasetEvents ? a . getStandardUrlName ( ) : a . getUnresolvedUrlName ( ) ; String queryString = null ; // String fullUrlString = urlString ;
if ( datasetEvents ) urlString = "dataset:" + urlString ; ServiceType stype = s . getType ( ) ; if ( isServer && stype != null ) switch ( stype ) { case OPENDAP : case DODS : urlString = urlString + ".html" ; break ; case DAP4 : urlString = urlString + ".dmr.xml" ; break ; case WCS : queryString = "service=WCS&version=1.0.0&request=GetCapabilities" ; break ; case WMS : queryString = "service=WMS&version=1.3.0&request=GetCapabilities" ; break ; case NCML : case UDDC : case ISO : String catalogUrl = ds . getCatalogUrl ( ) ; String datasetId = ds . getId ( ) ; if ( catalogUrl != null && datasetId != null ) { if ( catalogUrl . indexOf ( '#' ) > 0 ) catalogUrl = catalogUrl . substring ( 0 , catalogUrl . lastIndexOf ( '#' ) ) ; /* try {
 catalogUrl = URLEncoder . encode ( catalogUrl , " UTF - 8 " ) ;
 datasetId = URLEncoder . encode ( datasetId , " UTF - 8 " ) ;
 } catch ( UnsupportedEncodingException e ) {
 e . printStackTrace ( ) ; */
queryString = "catalog=" + urlParamEscaper . escape ( catalogUrl ) + "&dataset=" + urlParamEscaper . escape ( datasetId ) ; } break ; case NetcdfSubset : urlString = urlString + "/dataset.html" ; break ; case CdmRemote : queryString = "req=cdl" ; break ; case CdmrFeature : queryString = "req=form" ; } out . format ( "
 %s: %s
%n" , s . getServiceTypeName ( ) , makeHref ( urlString , queryString , null ) ) ; } out . format ( "
%n" ) ; } java . util . List < ThreddsMetadata . Contributor > contributors = ds . getContributors ( ) ; if ( contributors . size ( ) > 0 ) { out . format ( "
Contributors:
%n
%n" ) ; for ( ThreddsMetadata . Contributor t : contributors ) { String role = ( t . getRole ( ) == null ) ? "" : " (" + htmlEscaper . escape ( t . getRole ( ) ) + ") " ; out . format ( "
%s %s
%n" , htmlEscaper . escape ( t . getName ( ) ) , role ) ; } out . format ( "
%n" ) ; } java . util . List < ThreddsMetadata . Vocab > keywords = ds . getKeywords ( ) ; if ( keywords . size ( ) > 0 ) { out . format ( "
Keywords:
%n
%n" ) ; for ( ThreddsMetadata . Vocab t : keywords ) { String vocab = ( t . getVocabulary ( ) == null ) ? "" : " (" + htmlEscaper . escape ( t . getVocabulary ( ) ) + ") " ; out . format ( "
%s %s
%n" , htmlEscaper . escape ( t . getText ( ) ) , vocab ) ; } out . format ( "
%n" ) ; } java . util . List < DateType > dates = ds . getDates ( ) ; if ( dates . size ( ) > 0 ) { out . format ( "
Dates:
%n
%n" ) ; for ( DateType d : dates ) { String type = ( d . getType ( ) == null ) ? "" : " (" + htmlEscaper . escape ( d . getType ( ) ) + ") " ; out . format ( "
%s %s
%n" , htmlEscaper . escape ( d . getText ( ) ) , type ) ; } out . format ( "
%n" ) ; } java . util . List < ThreddsMetadata . Vocab > projects = ds . getProjects ( ) ; if ( projects . size ( ) > 0 ) { out . format ( "
Projects:
%n
%n" ) ; for ( ThreddsMetadata . Vocab t : projects ) { String vocab = ( t . getVocabulary ( ) == null ) ? "" : " (" + htmlEscaper . escape ( t . getVocabulary ( ) ) + ") " ; out . format ( "
%s %s
%n" , htmlEscaper . escape ( t . getText ( ) ) , vocab ) ; } out . format ( "
%n" ) ; } java . util . List < ThreddsMetadata . Source > creators = ds . getCreators ( ) ; if ( creators . size ( ) > 0 ) { out . format ( "
Creators:
%n
%n" ) ; for ( ThreddsMetadata . Source t : creators ) { out . format ( "
%s
%n" , htmlEscaper . escape ( t . getName ( ) ) ) ; out . format ( "
email: %s
%n" , htmlEscaper . escape ( t . getEmail ( ) ) ) ; if ( t . getUrl ( ) != null ) { String newUrl = resolveRelativeUrls ? makeHrefResolve ( ds , t . getUrl ( ) , null ) : makeHref ( t . getUrl ( ) , null , null ) ; out . format ( "
 %s
%n" , newUrl ) ; } out . format ( "

%n" ) ; } out . format ( "
%n" ) ; } java . util . List < ThreddsMetadata . Source > publishers = ds . getPublishers ( ) ; if ( publishers . size ( ) > 0 ) { out . format ( "
Publishers:
%n
%n" ) ; for ( ThreddsMetadata . Source t : publishers ) { out . format ( "
%s
%n" , htmlEscaper . escape ( t . getName ( ) ) ) ; out . format ( "
email: %s%n" , htmlEscaper . escape ( t . getEmail ( ) ) ) ; if ( t . getUrl ( ) != null ) { String urlLink = resolveRelativeUrls ? makeHrefResolve ( ds , t . getUrl ( ) , null ) : makeHref ( t . getUrl ( ) , null , null ) ; out . format ( "
 %s
%n" , urlLink ) ; } out . format ( "
%n" ) ; } out . format ( "
%n" ) ; } /* 4.2:

 Variables :

  Vocabulary  [ DIF ] :

  Reflectivity  =   = EARTH SCIENCE & gt ; Spectral / Engineering & gt ; Radar & gt ; Radar Reflectivity ( db )

  Velocity  =   = EARTH SCIENCE & gt ; Spectral / Engineering & gt ; Radar & gt ; Doppler Velocity ( m / s )

  SpectrumWidth  =   = EARTH SCIENCE & gt ; Spectral / Engineering & gt ; Radar & gt ; Doppler Spectrum Width ( m / s )

 4.3:

 Variables :

  Vocabulary  [ CF - 1.0 ] :

  d3d ( meters )  =  3D Depth at Nodes

  = depth _ at _ nodes

  depth ( meters )  =  Bathymetry  = depth

  eta ( m )  =   =

  temp ( Celsius )  =  Temperature

  = sea _ water _ temperature

  u ( m / s )  =  Eastward Water

 Velocity

  = eastward _ sea _ water _ velocity

  v ( m / s )  =  Northward Water

 Velocity

  = northward _ sea _ water _ velocity

 */
java . util . List < ThreddsMetadata . VariableGroup > vars = ds . getVariables ( ) ; if ( vars . size ( ) > 0 ) { out . format ( "
Variables:
%n
%n" ) ; for ( ThreddsMetadata . VariableGroup t : vars ) { out . format ( "
Vocabulary [" ) ; if ( t . getVocabUri ( ) != null ) { ThreddsMetadata . UriResolved uri = t . getVocabUri ( ) ; String vocabLink = resolveRelativeUrls ? makeHref ( uri . resolved . toString ( ) , null , t . getVocabulary ( ) ) : makeHref ( uri . href , null , t . getVocabulary ( ) ) ; out . format ( vocabLink ) ; } else { out . format ( htmlEscaper . escape ( t . getVocabulary ( ) ) ) ; } out . format ( "]:%n
%n" ) ; java . util . List < ThreddsMetadata . Variable > vlist = t . getVariableList ( ) ; if ( vlist . size ( ) > 0 ) { for ( ThreddsMetadata . Variable v : vlist ) { String units = ( v . getUnits ( ) == null || v . getUnits ( ) . length ( ) == 0 ) ? "" : " (" + v . getUnits ( ) + ") " ; out . format ( "
%s = " , htmlEscaper . escape ( v . getName ( ) + units ) ) ; if ( v . getDescription ( ) != null ) out . format ( " %s = " , htmlEscaper . escape ( v . getDescription ( ) ) ) ; if ( v . getVocabularyName ( ) != null ) out . format ( "%s" , htmlEscaper . escape ( v . getVocabularyName ( ) ) ) ; out . format ( "%n" ) ; } } out . format ( "
%n" ) ; } out . format ( "
%n" ) ; } // LOOK what about VariableMapLink string ? ?
if ( ds . getVariableMapLink ( ) != null ) { out . format ( "
Variables:
%n" ) ; ThreddsMetadata . UriResolved uri = ds . getVariableMapLink ( ) ; out . format ( "

%s

%n" , makeHref ( uri . resolved . toASCIIString ( ) , null , "VariableMap" ) ) ; } ThreddsMetadata . GeospatialCoverage gc = ds . getGeospatialCoverage ( ) ; if ( gc != null ) { out . format ( "
GeospatialCoverage:
%n
%n" ) ; // if ( gc . isGlobal ( ) ) out . format ( "
  Global  % n " ) ;
out . format ( "
 Longitude:  %s
%n" , rangeString ( gc . getEastWestRange ( ) ) ) ; out . format ( "
 Latitude:  %s
%n" , rangeString ( gc . getNorthSouthRange ( ) ) ) ; if ( gc . getUpDownRange ( ) != null ) { out . format ( "
 Altitude:  %s (positive is %s)
%n" , rangeString ( gc . getUpDownRange ( ) ) , gc . getZPositive ( ) ) ; } java . util . List < ThreddsMetadata . Vocab > nlist = gc . getNames ( ) ; if ( ( nlist != null ) && ( nlist . size ( ) > 0 ) ) { out . format ( "
  Names:
%n" ) ; for ( ThreddsMetadata . Vocab elem : nlist ) { out . format ( "
%s
%n" , htmlEscaper . escape ( elem . getText ( ) ) ) ; } out . format ( "
%n" ) ; } out . format ( "
%n" ) ; } DateRange tc = ds . getTimeCoverage ( ) ; if ( tc != null ) { out . format ( "
TimeCoverage:
%n
%n" ) ; DateType start = tc . getStart ( ) ; if ( start != null ) out . format ( "
  Start:  %s
%n" , start . toString ( ) ) ; DateType end = tc . getEnd ( ) ; if ( end != null ) { out . format ( "
  End:  %s
%n" , end . toString ( ) ) ; } TimeDuration duration = tc . getDuration ( ) ; if ( duration != null ) out . format ( "
  Duration:  %s
%n" , htmlEscaper . escape ( duration . toString ( ) ) ) ; TimeDuration resolution = tc . getResolution ( ) ; if ( resolution != null ) { out . format ( "
  Resolution:  %s
%n" , htmlEscaper . escape ( resolution . toString ( ) ) ) ; } out . format ( "
%n" ) ; } java . util . List < ThreddsMetadata . MetadataOther > metadata = ds . getMetadataOther ( ) ; boolean gotSomeMetadata = false ; for ( ThreddsMetadata . MetadataOther m : metadata ) { if ( m . getXlinkHref ( ) != null ) gotSomeMetadata = true ; } if ( gotSomeMetadata ) { out . format ( "
Metadata:
%n
%n" ) ; for ( ThreddsMetadata . MetadataOther m : metadata ) { String type = ( m . getType ( ) == null ) ? "" : m . getType ( ) ; if ( m . getXlinkHref ( ) != null ) { String title = ( m . getTitle ( ) == null ) ? "Type " + type : m . getTitle ( ) ; String mdLink = resolveRelativeUrls ? makeHrefResolve ( ds , m . getXlinkHref ( ) , title ) : makeHref ( m . getXlinkHref ( ) , null , title ) ; out . format ( "
 %s
%n" , mdLink ) ; } // else {
// out . format ( "

 " + m . getMetadataType ( ) + " " + m . getContentObject ( ) + "
 % n " ) ;
} out . format ( "
%n" ) ; } java . util . List < Property > propsOrg = ds . getProperties ( ) ; java . util . List < Property > props = new ArrayList < > ( ds . getProperties ( ) . size ( ) ) ; for ( Property p : propsOrg ) { if ( ! p . getName ( ) . startsWith ( "viewer" ) ) // eliminate the viewer properties from the html view
props . add ( p ) ; } if ( props . size ( ) > 0 ) { out . format ( "
Properties:
%n
%n" ) ; for ( Property p : props ) { if ( p . getName ( ) . equals ( "attachments" ) ) { // LOOK whats this ?
String attachLink = resolveRelativeUrls ? makeHrefResolve ( ds , p . getValue ( ) , p . getName ( ) ) : makeHref ( p . getValue ( ) , null , p . getName ( ) ) ; out . format ( "
%s
%n" , attachLink ) ; } else { out . format ( "
%s = \"%s\"
%n" , htmlEscaper . escape ( p . getName ( ) ) , htmlEscaper . escape ( p . getValue ( ) ) ) ; } } out . format ( "
%n" ) ; } if ( complete ) out . format ( "" ) ;


signature:
public class DatasetHtmlWriter { /** * resolve reletive URLS against the catalog URL .
 * @ param ds use ds parent catalog , if it exists
 * @ param href URL to resolve
 * @ return resolved URL */
public String resolve ( Dataset ds , String href ) { } }

implementation: Catalog cat = ds . getParentCatalog ( ) ; if ( cat != null ) { try { java . net . URI uri = cat . resolveUri ( href ) ; href = uri . toString ( ) ; } catch ( java . net . URISyntaxException e ) { return "DatasetHtmlWriter: error parsing URL= " + href ; } } return href ;


signature:
public class EcmwfLocalConcepts { /** * Parse the localConcept files needed to create grib1 tables for use by the CDM . */
private void parseLocalConcept ( String filename , String conceptName ) throws IOException { } }

implementation: try ( InputStream is = new FileInputStream ( filename ) ) { addLocalConcept ( is , conceptName ) ; }


signature:
public class EcmwfLocalConcepts { /** * Add the information from a localConcept file to super HashMap localConcepts
 * @ param is InputStream of the localConcept file
 * @ param conceptName " type " of localConcept being added */
private void addLocalConcept ( InputStream is , String conceptName ) throws IOException { } }

implementation:
/* example entry from name . def :
 # Total precipitation of at least 5 mm
 ' Total precipitation of at least 5 mm ' = {
 table2Version = 131 ;
 indicatorOfParameter = 61 ; */
try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( is , ENCODING ) ) ) { String line = br . readLine ( ) ; while ( ! line . startsWith ( "#" ) ) line = br . readLine ( ) ; // skip
while ( true ) { HashMap < String , String > items = new HashMap < > ( ) ; line = br . readLine ( ) ; if ( line == null ) break ; // done with the file
if ( ( line . length ( ) == 0 ) || line . startsWith ( "#" ) ) continue ; line = cleanLine ( line ) ; if ( line . contains ( "{" ) ) { String paramName = line . split ( "=" ) [ 0 ] . trim ( ) ; line = br . readLine ( ) ; if ( line == null ) break ; // done with the file
line = cleanLine ( line ) ; while ( line . contains ( "=" ) ) { String [ ] kvp = line . split ( "=" ) ; items . put ( kvp [ 0 ] . trim ( ) , kvp [ 1 ] . trim ( ) ) ; line = br . readLine ( ) ; if ( line == null ) break ; // done with the file
line = cleanLine ( line ) ; } String tableVersion = items . get ( TABLE_VERSION_ID ) ; String parameterNumber = items . get ( PARAM_NUM_ID ) ; storeConcept ( tableVersion , parameterNumber , conceptName , paramName ) ; } } }


signature:
public class EcmwfLocalConcepts { /** * clean the string representation of a line in the localConcept
 * file . Basic removal of tabs , semicolons , single quotes , etc .
 * @ param lineIn line ( String ) to be cleaned
 * @ return cleaned version of lineIn */
private String cleanLine ( String lineIn ) { } }

implementation: String lineOut ; lineOut = lineIn . replaceAll ( "'" , "" ) ; lineOut = lineOut . replaceAll ( "\t" , "" ) ; lineOut = lineOut . replaceAll ( ";" , "" ) ; return lineOut . trim ( ) ;


signature:
public class EcmwfLocalConcepts { /** * Store localConcept information in super HashMap localConcepts
 * @ param tableVersion - version of the table to add parameter to
 * @ param parameterNumber - parameter number
 * @ param key Type of metadata to be added ( shortName , Description , Units )
 * @ param value Value of metadata */
private void storeConcept ( String tableVersion , String parameterNumber , String key , String value ) { } }

implementation: HashMap < String , HashMap < String , String > > tmpTable ; if ( localConcepts . containsKey ( tableVersion ) ) { tmpTable = localConcepts . get ( tableVersion ) ; if ( tmpTable . containsKey ( parameterNumber ) ) { HashMap < String , String > tmpParam = tmpTable . get ( parameterNumber ) ; if ( ! tmpParam . containsKey ( key ) ) { tmpParam . put ( key , value ) ; } else { System . out . println ( "already has key value pair: " + key + ":" + value ) ; } } else { HashMap < String , String > tmpParam = new HashMap < > ( 4 ) ; tmpParam . put ( key , value ) ; tmpTable . put ( parameterNumber , tmpParam ) ; } } else { tmpTable = new HashMap < > ( ) ; HashMap < String , String > tmpParam = new HashMap < > ( 4 ) ; tmpParam . put ( key , value ) ; tmpTable . put ( parameterNumber , tmpParam ) ; } localConcepts . put ( tableVersion , tmpTable ) ;


signature:
public class EcmwfLocalConcepts { /** * Write out grib1 tables based on localConcepts files - these are the tables
 * that the CDM will read . */
private void writeGrib1Tables ( ) throws IOException { } }

implementation: SimpleDateFormat dateFormat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ssz" ) ; Calendar cal = Calendar . getInstance ( ) ; String writeDate = dateFormat . format ( cal . getTime ( ) ) ; String grib1Info ; List < String > tableNums = new ArrayList < > ( ) ; HashMap < String , String > paramInfo ; Path dir = Paths . get ( ecmwfLocalConceptsLoc . replace ( "sources/" , "resources/resources/grib1/" ) ) ; for ( String tableNum : localConcepts . keySet ( ) ) { tableNums . add ( tableNum ) ; String fileName = "2.98." + tableNum + ".table" ; System . out . println ( "Writing: " + fileName ) ; Path newFile = dir . resolve ( fileName ) ; Files . deleteIfExists ( newFile ) ; Files . createFile ( newFile ) ; try ( BufferedWriter writer = Files . newBufferedWriter ( newFile , ENCODING ) ) { writer . write ( "# Generated by " + this . getClass ( ) . getCanonicalName ( ) + " on " + writeDate ) ; writer . newLine ( ) ; for ( String paramNum : localConcepts . get ( tableNum ) . keySet ( ) ) { paramInfo = localConcepts . get ( tableNum ) . get ( paramNum ) ; String shortName = paramInfo . get ( SHORTNAME_ID ) ; String description = paramInfo . get ( DESCRIPTION_ID ) ; String units = paramInfo . get ( UNIT_ID ) ; grib1Info = paramNum + " " + shortName + " [" + description + "] (" + units + ")" ; writer . write ( grib1Info ) ; writer . newLine ( ) ; } } } writeLookupTableFile ( tableNums , dir , writeDate ) ;


signature:
public class EcmwfLocalConcepts { /** * Write the lookupTables . txt file , which basically registers all of the new grib1 tables
 * with the CDM
 * @ param tableNums List of Table Numbers
 * @ param dir Directory where the tables live
 * @ param writeDate Date on which the main method of this class was run , resulting in new tables */
private void writeLookupTableFile ( List < String > tableNums , Path dir , String writeDate ) throws IOException { } }

implementation: System . out . println ( "Writing: lookupTables.txt" ) ; Collections . sort ( tableNums ) ; Path lookupTableReg = dir . resolve ( "lookupTables.txt" ) ; Files . deleteIfExists ( lookupTableReg ) ; Files . createFile ( lookupTableReg ) ; try ( BufferedWriter writer = Files . newBufferedWriter ( lookupTableReg , ENCODING ) ) { writer . write ( "# Generated by " + this . getClass ( ) . getCanonicalName ( ) + " on " + writeDate ) ; writer . newLine ( ) ; for ( String tn : tableNums ) { String tableName = "2.98." + tn + ".table" ; String reg = "98:\t-1:\t" + tn + ":\t" + tableName ; writer . write ( reg ) ; writer . newLine ( ) ; } }


signature:
public class EcmwfLocalConcepts { /** * Quick prinout to System . out of the different parameter metadata fields */
private void showLocalConcepts ( ) { } }

implementation: for ( String tableNum : localConcepts . keySet ( ) ) { for ( String paramNum : localConcepts . get ( tableNum ) . keySet ( ) ) { for ( String key : localConcepts . get ( tableNum ) . get ( paramNum ) . keySet ( ) ) { System . out . println ( key + ":" + localConcepts . get ( tableNum ) . get ( paramNum ) . get ( key ) ) ; } } }


signature:
public class EcmwfLocalConcepts { /** * Generate grib1 tables for the CDM based on the localConcept files from ECMWF GRIB - API
 * @ param args None */
public static void main ( String [ ] args ) { } }

implementation: EcmwfLocalConcepts ec = new EcmwfLocalConcepts ( ) ; try { ec . writeGrib1Tables ( ) ; System . out . println ( "Finished!" ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; }


signature:
public class DsgSubsetWriter { /** * / / / / / Static / / / / / */
public void respond ( HttpServletResponse res , FeatureDataset ft , String requestPathInfo , SubsetParams queryParams , SupportedFormat format ) throws Exception { } }

implementation: write ( ) ;


signature:
public class DsgSubsetWriter { /** * TODO : This needs testing . */
public static List < VariableSimpleIF > getWantedVariables ( FeatureDatasetPoint fdPoint , SubsetParams ncssParams ) throws VariableNotContainedInDatasetException { } }

implementation:
List < String > vars = ncssParams . getVariables ( ) ; if ( vars . size ( ) == 1 && vars . get ( 0 ) . equals ( "all" ) ) { return fdPoint . getDataVariables ( ) ; // Return all variables .
} // restrict to these variables
Map < String , VariableSimpleIF > dataVarsMap = new HashMap < > ( ) ; for ( VariableSimpleIF dataVar : fdPoint . getDataVariables ( ) ) { dataVarsMap . put ( dataVar . getShortName ( ) , dataVar ) ; } List < String > allVarNames = new ArrayList < > ( dataVarsMap . keySet ( ) ) ; List < VariableSimpleIF > wantedVars = new ArrayList < > ( ) ; for ( String varName : vars ) { if ( allVarNames . contains ( varName ) ) { VariableSimpleIF var = dataVarsMap . get ( varName ) ; wantedVars . add ( var ) ; } else { throw new VariableNotContainedInDatasetException ( "Variable: " + varName + " is not contained in the requested dataset" ) ; } } return wantedVars ;


signature:
public class DsgSubsetWriter { /** * TODO : This needs testing . */
public static CalendarDateRange getWantedDateRange ( SubsetParams ncssParams ) throws NcssException { } }

implementation:
if ( ncssParams . isTrue ( SubsetParams . timePresent ) ) { // present
CalendarDate time = CalendarDate . present ( ) ; CalendarPeriod timeWindow = ncssParams . getTimeWindow ( ) ; if ( timeWindow == null ) timeWindow = CalendarPeriod . Hour ; return CalendarDateRange . of ( time . subtract ( timeWindow ) , time . add ( timeWindow ) ) ; } else if ( ncssParams . getTime ( ) != null ) { // Means we want just one single time .
CalendarDate time = ncssParams . getTime ( ) ; CalendarPeriod timeWindow = ncssParams . getTimeWindow ( ) ; if ( timeWindow == null ) timeWindow = CalendarPeriod . Hour ; // To prevent features from being too agressively excluded , we are accepting times that are within
// an hour of the specified time .
// LOOK : Do we really need the + - increment ?
// CalendarDate startR = CalendarDate . parseISOformat ( null , time ) ;
// startR = startR . subtract ( CalendarPeriod . Hour ) ;
// CalendarDate endR = CalendarDate . parseISOformat ( null , time ) ;
// endR = endR . add ( CalendarPeriod . Hour ) ;
return CalendarDateRange . of ( time . subtract ( timeWindow ) , time . add ( timeWindow ) ) ; } else if ( ncssParams . getTimeRange ( ) != null ) { return ncssParams . getTimeRange ( ) ; } else if ( ncssParams . isTrue ( SubsetParams . timeAll ) ) { // Client explicitly requested all times .
return null ; // " null " means that we want ALL times , i . e . " do not subset " .
} else { // Client didn ' t specify a time parameter .
return null ; // Do not subset .
}


signature: public class Ghcnm2 { @ Override public Array readData ( Variable v2 , Section section ) throws IOException , InvalidRangeException { } }

implementation: StructureDataRegexp . Vinfo vinfo = ( StructureDataRegexp . Vinfo ) v2 . getSPobject ( ) ; return new ArraySequence ( vinfo . sm , new SeqIter ( vinfo ) , vinfo . nelems ) ;


signature: public class Ghcnm2 { private void readIndex ( String indexFilename ) throws IOException { } }

implementation: try ( FileInputStream fin = new FileInputStream ( indexFilename ) ) { if ( ! NcStream . readAndTest ( fin , MAGIC_START_IDX . getBytes ( CDM . utf8Charset ) ) ) throw new IllegalStateException ( "bad index file" ) ; int version = fin . read ( ) ; if ( version != 1 ) throw new IllegalStateException ( "Bad version = " + version ) ; int count = NcStream . readVInt ( fin ) ; for ( int i = 0 ; i < count ; i ++ ) { int size = NcStream . readVInt ( fin ) ; byte [ ] pb = new byte [ size ] ; NcStream . readFully ( fin , pb ) ; StationIndex si = decodeStationIndex ( pb ) ; map . put ( si . stnId , si ) ; } } System . out . println ( " read index map size=" + map . values ( ) . size ( ) ) ;


signature:
public class DAP2Exception { /** * Reads an Error description from the named InputStream . This
 * method calls a generated parser to interpret an ASCII representation of an
 * < code > Error < / code > , and regenerate it as a < code > DAP2Exception < / code > .
 * @ param stream the text containing the < code > Error < / code > to parse . */
public final boolean parse ( InputStream stream ) { } }

implementation: Dap2Parser parser = new Dap2Parser ( new DefaultFactory ( ) ) ; String text ; try { text = DConnect2 . captureStream ( stream ) ; if ( parser . errparse ( text , this ) != Dap2Parser . DapERR ) return false ; } catch ( ParseException pe ) { this . initCause ( pe ) ; } catch ( IOException pe ) { this . initCause ( pe ) ; } return true ;


signature:
public class DAP2Exception { /** * Print the Error message on the given < code > PrintWriter < / code > .
 * This code can be used by servlets to throw DAP2Exception to client .
 * @ param os the < code > PrintWriter < / code > to use for output . */
public void print ( PrintWriter os ) { } }

implementation:
os . println ( "Error {" ) ; os . println ( "    code = " + errorCode + ";" ) ; if ( errorMessage != null ) os . println ( "    message = " + dumpword ( errorMessage ) + ";" ) ; // if ( programType > 0 ) os . println ( " program _ type = " + programType + " ; " ) ;
if ( programSource != null ) os . println ( "    program = " + dumpword ( programSource ) + ";" ) ; os . println ( "};" ) ;


signature: public class Grib1TablesViewer { private void showFile ( TableBean bean ) { } }

implementation: infoTA . setText ( "Table:" + bean . getPath ( ) + "\n" ) ; try ( InputStream is = GribResourceReader . getInputStream ( bean . getPath ( ) ) ) { infoTA . appendLine ( IO . readContents ( is ) ) ; infoWindow . setVisible ( true ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; }


signature:
public class DatasetSourceType { /** * Find the DatasetSourceType that matches this name .
 * @ param name
 * @ return DatasetSourceType or null if no match . */
public static DatasetSourceType getType ( String name ) { } }

implementation: if ( name == null ) return null ; return ( ( DatasetSourceType ) hash . get ( name ) ) ;


signature:
public class NcCodeWithAuthorityType { /** * wml2 : Collection / wml2 : observationMember / om : OM _ Observation / om : featureOfInterest / wml2 : MonitoringPoint / gml : identifier */
public static CodeWithAuthorityType initIdentifier ( CodeWithAuthorityType identifier , StationTimeSeriesFeature stationFeat ) { } }

implementation:
// @ codespace
identifier . setCodeSpace ( "http://unidata.ucar.edu/" ) ; // TEXT
identifier . setStringValue ( stationFeat . getName ( ) ) ; return identifier ;


signature:
public class DatasetSource { /** * Factory method for this abstract class .
 * @ param name
 * @ param type
 * @ param structure
 * @ param accessPoint
 * @ throws IllegalArgumentException if DatasetSource type is null or unsupported . */
public static final DatasetSource newDatasetSource ( String name , DatasetSourceType type , DatasetSourceStructure structure , String accessPoint , ResultService resultService ) { } }

implementation:
if ( type == null ) { String tmpMsg = "DatasetSource type cannot be null" ; logger . error ( "newDatasetSource(): " + tmpMsg ) ; throw new IllegalArgumentException ( tmpMsg ) ; } DatasetSource tmpDsSource = null ; if ( type == DatasetSourceType . getType ( "Local" ) ) { tmpDsSource = new LocalDatasetSource ( ) ; } else if ( type == DatasetSourceType . getType ( "DodsDir" ) ) { tmpDsSource = new DodsDirDatasetSource ( ) ; } else if ( type == DatasetSourceType . getType ( "DodsFileServer" ) ) { tmpDsSource = new DodsFileServerDatasetSource ( ) ; } else if ( type == DatasetSourceType . getType ( "GrADSDataServer" ) ) { tmpDsSource = new GrADSDataServerDatasetSource ( ) ; } else { String tmpMsg = "Unsupported DatasetSource type <" + type . toString ( ) + ">." ; logger . error ( "newDatasetSource(): " + tmpMsg ) ; throw new IllegalArgumentException ( tmpMsg ) ; } tmpDsSource . setName ( name ) ; tmpDsSource . setStructure ( structure ) ; tmpDsSource . setAccessPoint ( accessPoint ) ; tmpDsSource . setResultService ( resultService ) ; // Test validity and append messages to log .
logger . debug ( "DatasetSource(): constructor done." ) ; StringBuilder log = new StringBuilder ( ) ; if ( tmpDsSource . validate ( log ) ) { logger . debug ( "DatasetSource(): new DatasetSource is valid: {}" , log . toString ( ) ) ; } else { logger . debug ( "DatasetSource(): new DatasetSource is invalid: {}" , log . toString ( ) ) ; } return ( tmpDsSource ) ;


signature:
public class DatasetSource { /** * Crawl this DatasetSource and generate a new InvCatalog , return the
 * top - level InvDataset .
 * Each object found on the DatasetSource becomes an InvDataset if it is
 * accepted by at least one DatasetFilter . The catalog reflects the
 * heirarchical structure of the DatasetSource . All datasets are named
 * with the location of the object they represent on the dataset source .
 * @ return the top - level InvDataset in the generated InvCatalog .
 * @ throws IOException if the accessPoint for this DatasetSource is not a container dataset . */
public InvDataset expand ( ) throws IOException { } }

implementation:
// Get the new catalog being generated and its top - level dataset .
this . resultingCatalog = this . createSkeletonCatalog ( prefixUrlPath ) ; this . accessPointDataset = ( InvDataset ) this . resultingCatalog . getDatasets ( ) . get ( 0 ) ; // IOException thrown by createSkeletonCatalog ( ) so this check should not be necessary .
if ( ! this . isCollection ( this . accessPointDataset ) ) { String tmpMsg = "The access point dataset <" + this . accessPointDataset . getName ( ) + "> must be a collection dataset." ; logger . warn ( "expand(): {}" , tmpMsg ) ; throw new IOException ( tmpMsg ) ; } // Recurse into directory structure and expand .
expandRecursive ( this . accessPointDataset ) ; // Finish the catalog .
( ( InvCatalogImpl ) this . resultingCatalog ) . finish ( ) ; // Remove empty collection datasets . @ todo HACK - should use filters instead .
this . recursivelyRemoveEmptyCollectionDatasets ( this . accessPointDataset ) ; // Return the top - level dataset .
return ( this . accessPointDataset ) ;


signature:
public class DatasetSource { /** * Crawl this DatasetSource and generate a new InvCatalog with all datasets
 * named , sorted , and organized as defined by this DatasetSource , return the
 * newly generated InvCatalog .
 * @ return the generated InvCatalog .
 * @ throws IOException if DatasetSource does not reference a container dataset . */
public InvCatalog fullExpand ( ) throws IOException { } }

implementation:
logger . debug ( "fullExpand(): expanding DatasetSource named \"{}\"" , this . getName ( ) ) ; InvDataset topDs = this . expand ( ) ; InvCatalog generatedCat = topDs . getParentCatalog ( ) ; // Add metadata to all datasets .
for ( Iterator it = this . getDatasetEnhancerList ( ) . iterator ( ) ; it . hasNext ( ) ; ) { DatasetEnhancer1 dsE = ( DatasetEnhancer1 ) it . next ( ) ; dsE . addMetadata ( topDs ) ; } // Name all datasets .
logger . debug ( "fullExpand(): naming the datasets." ) ; this . nameDatasets ( ( InvDatasetImpl ) topDs ) ; // Sort all datasets
logger . debug ( "fullExpand(): sorting the datasets." ) ; this . sortDatasets ( topDs ) ; // Return the generated catalog
( ( InvCatalogImpl ) generatedCat ) . finish ( ) ; return ( generatedCat ) ;


signature:
public class DatasetSource { /** * Use the list of dsNamers to name the given list of datasets .
 * @ param datasetContainer - a InvDatasetImpl that contains one or
 * more datasets to be named . */
private void nameDatasets ( InvDatasetImpl datasetContainer ) { } }

implementation: if ( this . getDatasetNamerList ( ) . isEmpty ( ) ) return ; if ( this . isFlatten ( ) ) { logger . debug ( "nameDatasets(): structure is FLAT calling nameDatasetList()" ) ; this . nameDatasetList ( datasetContainer ) ; } else { logger . debug ( "nameDatasets(): structure is DIRECTORY_TREE calling" + " nameDatasetTree() on each dataset in dataset container" ) ; InvDatasetImpl curDs = null ; for ( int j = 0 ; j < datasetContainer . getDatasets ( ) . size ( ) ; j ++ ) { curDs = ( InvDatasetImpl ) datasetContainer . getDatasets ( ) . get ( j ) ; this . nameDatasetTree ( curDs ) ; } } return ;


signature:
public class DatasetSource { /** * Name the datasets contained in the given dataset .
 * The given dataset contains a flat list of datasets . */
private void nameDatasetList ( InvDatasetImpl dataset ) { } }

implementation:
// Create temporary dataset in which to hold named datasets .
InvDatasetImpl namedDs = new InvDatasetImpl ( dataset , "nameDatastList() temp dataset" , null , null , null ) ; // InvDatasetImpl ( parentDs , name , dataType , serviceName , urlPath )
dataset . addDataset ( namedDs ) ; // Loop through the DatasetNamers
DatasetNamer curNamer = null ; for ( int i = 0 ; i < this . datasetNamerList . size ( ) ; i ++ ) { curNamer = ( DatasetNamer ) this . datasetNamerList . get ( i ) ; logger . debug ( "nameDatasetList(): trying namer ({})" , curNamer . getName ( ) ) ; // If the current DatasetNamer adds a new level , create a new dataset .
InvDatasetImpl addLevelDs = null ; if ( curNamer . getAddLevel ( ) ) { addLevelDs = new InvDatasetImpl ( null , curNamer . getName ( ) , null , null , null ) ; } // Iterate over remaining unnamed datasets .
InvDatasetImpl curDs = null ; java . util . Iterator dsIter = dataset . getDatasets ( ) . iterator ( ) ; while ( dsIter . hasNext ( ) ) { curDs = ( InvDatasetImpl ) dsIter . next ( ) ; logger . debug ( "nameDatasetList(): try namer on this ds ({}-{})" , curDs . getName ( ) , curDs . getUrlPath ( ) ) ; // Try to name the current dataset .
if ( curNamer . nameDataset ( curDs ) ) { logger . debug ( "nameDatasetList(): ds named ({})" , curDs . getName ( ) ) ; // If adding a level , add named datasets to the added level dataset .
if ( curNamer . getAddLevel ( ) ) { addLevelDs . addDataset ( curDs ) ; } // Otherwise , add the named datasets to namedDs .
else { namedDs . addDataset ( curDs ) ; } // Remove the now - named dataset from list of unnamed datasets .
dsIter . remove ( ) ; } } // END - InvDatasetImpl loop
// If the namer added a level and a dataset was named by this namer , add the
// new level to the list of named datasets .
if ( curNamer . getAddLevel ( ) ) { if ( addLevelDs . hasNestedDatasets ( ) ) { namedDs . addDataset ( addLevelDs ) ; } } } // END - DatasetNamer loop
namedDs . finish ( ) ; // Once all datasets are named ( or unnamable with these DatasetNamers ) ,
// add all the datasets in namedDs back into the given containerDataset .
if ( logger . isDebugEnabled ( ) ) { logger . debug ( "nameDatasetList(): number of unnamed datasets is " + dataset . getDatasets ( ) . size ( ) + "." ) ; logger . debug ( "nameDatasetList(): add named datasets back to container." ) ; } for ( int i = 0 ; i < namedDs . getDatasets ( ) . size ( ) ; i ++ ) { dataset . addDataset ( ( InvDatasetImpl ) namedDs . getDatasets ( ) . get ( i ) ) ; } dataset . removeDataset ( namedDs ) ; return ;


signature:
public class DatasetSource { /** * Name the datasets in the given dataset hierarchy using this
 * DatasetSource ' s list of datasetNamers . */
private void nameDatasetTree ( InvDatasetImpl dataset ) { } }

implementation:
// If dataset does not have a name , try naming it with dsNamers .
// @ todo Rethink naming of directories ( look at how DatasetFilter deals with collection vs atomic datasets ) .
if ( dataset . getName ( ) . equals ( "" ) || ! dataset . hasAccess ( ) ) { logger . debug ( "nameDatasetTree(): naming dataset ({})..." , dataset . getUrlPath ( ) ) ; DatasetNamer dsN = null ; for ( int i = 0 ; i < this . datasetNamerList . size ( ) ; i ++ ) { dsN = ( DatasetNamer ) this . datasetNamerList . get ( i ) ; if ( dsN . nameDataset ( dataset ) ) { logger . debug ( "nameDatasetTree(): ... used namer ({})" , dsN . getName ( ) ) ; break ; } } } // Try to name any child datasets .
InvDatasetImpl curDs = null ; for ( int j = 0 ; j < dataset . getDatasets ( ) . size ( ) ; j ++ ) { curDs = ( InvDatasetImpl ) dataset . getDatasets ( ) . get ( j ) ; logger . debug ( "nameDatasetTree(): recurse to name child dataset ({})" , curDs . getUrlPath ( ) ) ; this . nameDatasetTree ( curDs ) ; } return ;


signature:
public class ScalablePicture { /** * method to invoke with a filename or URL of a picture that is to be loaded and scaled in
 * a new thread . This is handy to update the screen while the loading chuggs along in the background .
 * Make sure you invoked setScaleFactor or setScaleSize before
 * invoking this method .
 * Step 1 : Am I already loading what I need somewhere ?
 * If yes - > use it .
 * Has it finished loading ?
 * If no - > wait for it
 * If yes - > use it
 * Else - > load it
 * @ param priority The Thread priority
 * @ param imageUrl The URL of the image you want to load
 * @ param rotation The rotation 0-360 that the image should be put through
 * after loading . */
public void loadAndScalePictureInThread ( URL imageUrl , int priority , double rotation ) { } }

implementation:
this . imageUrl = imageUrl ; boolean alreadyLoading = false ; Tools . log ( "ScalablePicture.loadAndScalePictureInThread: checking if picture " + imageUrl + " is already being loaded." ) ; if ( ( sourcePicture != null ) && ( sourcePicture . getUrl ( ) . toString ( ) . equals ( imageUrl . toString ( ) ) ) ) { Tools . log ( "ScalablePicture.loadAndScalePictureInThread: the SourcePicture is already loading the sourcePictureimage" ) ; alreadyLoading = true ; } else if ( PictureCache . isInCache ( imageUrl ) ) { // in case the old image has a listener connected remove it
// fist time round the sourcePicture is still null therefore the if .
if ( sourcePicture != null ) sourcePicture . removeListener ( this ) ; sourcePicture = PictureCache . getSourcePicture ( imageUrl ) ; String status = sourcePicture . getStatusMessage ( ) ; if ( status == null ) status = "" ; Tools . log ( "ScalablePicture.loadAndScalePictureInThread: Picture in cache! Status: " + status ) ; if ( sourcePicture . getRotation ( ) == rotation ) { alreadyLoading = true ; Tools . log ( "ScalablePicture.loadAndScalePictureInThread: Picture was even rotated to the correct angle!" ) ; } else { alreadyLoading = false ; Tools . log ( "ScalablePicture.loadAndScalePictureInThread: Picture was in cache but with wrong rotation. Forcing reload." ) ; } } if ( alreadyLoading ) { switch ( sourcePicture . getStatusCode ( ) ) { case SourcePicture . UNINITIALISED : alreadyLoading = false ; Tools . log ( "ScalablePicture.loadAndScalePictureInThread: pictureStatus was: UNINITIALISED" ) ; break ; case SourcePicture . ERROR : alreadyLoading = false ; Tools . log ( "ScalablePicture.loadAndScalePictureInThread: pictureStatus was: ERROR" ) ; break ; case SourcePicture . LOADING : Tools . log ( "ScalablePicture.loadAndScalePictureInThread: pictureStatus was: LOADING" ) ; sourcePicture . addListener ( this ) ; setStatus ( LOADING , "Loading: " + imageUrl . toString ( ) ) ; sourceLoadProgressNotification ( SourcePicture . LOADING_PROGRESS , sourcePicture . getPercentLoaded ( ) ) ; scaleAfterLoad = true ; break ; case SourcePicture . ROTATING : Tools . log ( "ScalablePicture.loadAndScalePictureInThread: pictureStatus was: ROTATING" ) ; setStatus ( LOADING , "Rotating: " + imageUrl . toString ( ) ) ; sourceLoadProgressNotification ( SourcePicture . LOADING_PROGRESS , sourcePicture . getPercentLoaded ( ) ) ; scaleAfterLoad = true ; break ; case SourcePicture . READY : Tools . log ( "ScalablePicture.loadAndScalePictureInThread: pictureStatus was: READY. Sending SCALING status." ) ; setStatus ( SCALING , "Scaling: " + imageUrl . toString ( ) ) ; createScaledPictureInThread ( priority ) ; break ; default : Tools . log ( "ScalablePicture.loadAndScalePictureInThread: Don't know what status this is:" + Integer . toString ( sourcePicture . getStatusCode ( ) ) ) ; break ; } } // if the image is not already there then load it .
if ( ! alreadyLoading ) { if ( sourcePicture != null ) sourcePicture . removeListener ( this ) ; sourcePicture = new SourcePicture ( ) ; sourcePicture . addListener ( this ) ; setStatus ( LOADING , "Loading: " + imageUrl . toString ( ) ) ; scaleAfterLoad = true ; sourcePicture . loadPictureInThread ( imageUrl , priority , rotation ) ; // when the thread is done it sends a sourceStatusChange message to us
}


signature:
public class ScalablePicture { /** * Synchroneous method to load the image .
 * It should only be called by something which is a thread itself such as the HtmlDistillerThread .
 * Since this intended for large batch operations this bypasses the cache .
 * @ param imageUrl The Url of the image to be loaded
 * @ param rotation The angle by which it is to be roated upon loading . */
public void loadPictureImd ( URL imageUrl , double rotation ) { } }

implementation: Tools . log ( "loadPictureImd invoked with URL: " + imageUrl . toString ( ) ) ; if ( sourcePicture != null ) sourcePicture . removeListener ( this ) ; sourcePicture = new SourcePicture ( ) ; sourcePicture . addListener ( this ) ; setStatus ( LOADING , "Loading: " + imageUrl . toString ( ) ) ; scaleAfterLoad = true ; sourcePicture . loadPicture ( imageUrl , rotation ) ;


signature:
public class ScalablePicture { /** * stops all picture loading except if the Url we desire is being loaded
 * @ param url The URL of the image which is to be loaded . */
public void stopLoadingExcept ( URL url ) { } }

implementation:
if ( sourcePicture != null ) { boolean isCurrentlyLoading = sourcePicture . stopLoadingExcept ( url ) ; if ( ! isCurrentlyLoading ) { // sourcePicture . removeListener ( this ) ;
} PictureCache . stopBackgroundLoadingExcept ( url ) ; }


signature:
public class ScalablePicture { /** * method that is invoked by the SourcePictureListener interface . Usually this
 * will be called by the SourcePicture telling the ScalablePicture that
 * it has completed loading . The ScalablePicture should then change it ' s own
 * status and tell the ScalableListeners what ' s up . */
public void sourceStatusChange ( int statusCode , String statusMessage , SourcePicture sp ) { } }

implementation:
// Tools . log ( " ScalablePicture . sourceStatusChange : status received from SourceImage : " + statusMessage ) ;
switch ( statusCode ) { case SourcePicture . UNINITIALISED : Tools . log ( "ScalablePicture.sourceStatusChange: pictureStatus was: UNINITIALISED message: " + statusMessage ) ; setStatus ( UNINITIALISED , statusMessage ) ; break ; case SourcePicture . ERROR : Tools . log ( "ScalablePicture.sourceStatusChange: pictureStatus was: ERROR message: " + statusMessage ) ; setStatus ( ERROR , statusMessage ) ; sourcePicture . removeListener ( this ) ; break ; case SourcePicture . LOADING : Tools . log ( "ScalablePicture.sourceStatusChange: pictureStatus was: LOADING message: " + statusMessage ) ; setStatus ( LOADING , statusMessage ) ; break ; case SourcePicture . ROTATING : Tools . log ( "ScalablePicture.sourceStatusChange: pictureStatus was: ROTATING message: " + statusMessage ) ; setStatus ( LOADING , statusMessage ) ; break ; case SourcePicture . READY : Tools . log ( "ScalablePicture.sourceStatusChange: pictureStatus was: READY message: " + statusMessage ) ; setStatus ( LOADED , statusMessage ) ; sourcePicture . removeListener ( this ) ; if ( scaleAfterLoad ) { createScaledPictureInThread ( Thread . MAX_PRIORITY ) ; scaleAfterLoad = false ; } break ; default : Tools . log ( "ScalablePicture.sourceStatusChange: Don't recognize this status: " + statusMessage ) ; break ; }


signature:
public class ScalablePicture { /** * pass on the update on the loading Progress to the listening objects */
public void sourceLoadProgressNotification ( int statusCode , int percentage ) { } }

implementation: Enumeration e = scalablePictureStatusListeners . elements ( ) ; while ( e . hasMoreElements ( ) ) { ( ( ScalablePictureListener ) e . nextElement ( ) ) . sourceLoadProgressNotification ( statusCode , percentage ) ; }


signature:
public class ScalablePicture { /** * method that creates the scaled image in the background in it ' s own thread .
 * @ param priority The priority this image takes relative to the others . */
public void createScaledPictureInThread ( int priority ) { } }

implementation: setStatus ( SCALING , "Scaling picture." ) ; ScaleThread t = new ScaleThread ( this ) ; t . setPriority ( priority ) ; t . start ( ) ;


signature:
public class ScalablePicture { /** * return the size of the scaled image or Zero if there is none */
public Dimension getScaledSize ( ) { } }

implementation: if ( scaledPicture != null ) return new Dimension ( scaledPicture . getWidth ( ) , scaledPicture . getHeight ( ) ) ; else return new Dimension ( 0 , 0 ) ;


signature:
public class ScalablePicture { /** * return the size of the scaled image as a neatly formatted text or Zero if there is none */
public String getScaledSizeString ( ) { } }

implementation: if ( scaledPicture != null ) return Integer . toString ( scaledPicture . getWidth ( ) ) + " x " + Integer . toString ( scaledPicture . getHeight ( ) ) ; else return "0 x 0" ;


signature:
public class ScalablePicture { /** * This static method writes the indicated renderedImage ( BufferedImage )
 * to the indicated file .
 * @ param writeFile The File that shall receive the jpg data
 * @ param renderedImage The RenderedImage ( BufferedImage ) to be written
 * @ param jpgQuality The quality with which to compress to jpg */
public static void writeJpg ( File writeFile , RenderedImage renderedImage , float jpgQuality ) { } }

implementation:
Iterator writers = ImageIO . getImageWritersByFormatName ( "jpg" ) ; ImageWriter writer = ( ImageWriter ) writers . next ( ) ; JPEGImageWriteParam params = new JPEGImageWriteParam ( null ) ; params . setCompressionMode ( ImageWriteParam . MODE_EXPLICIT ) ; params . setCompressionQuality ( jpgQuality ) ; params . setProgressiveMode ( ImageWriteParam . MODE_DISABLED ) ; params . setDestinationType ( new ImageTypeSpecifier ( java . awt . image . IndexColorModel . getRGBdefault ( ) , IndexColorModel . getRGBdefault ( ) . createCompatibleSampleModel ( 16 , 16 ) ) ) ; try ( ImageOutputStream ios = ImageIO . createImageOutputStream ( new FileOutputStream ( writeFile ) ) ) { writer . setOutput ( ios ) ; writer . write ( null , new IIOImage ( renderedImage , null , null ) , params ) ; ios . close ( ) ; } catch ( IOException e ) { // Tools . log ( " ScalablePicture . writeJpg caught IOException : " + e . getMessage ( ) + " \ nwhile writing " + writeFile . toString ( ) ) ;
e . printStackTrace ( ) ; } // writer = null ;
writer . dispose ( ) ; // 1.4.1 documentation says to do this .


signature:
public class ScalablePicture { /** * Method that sets the status of the ScalablePicture object and notifies
 * intereasted objects of a change in status ( not built yet ) . */
private void setStatus ( int statusCode , String statusMessage ) { } }

implementation: String filename = ( imageUrl == null ) ? "" : imageUrl . toString ( ) ; Tools . log ( "ScalablePicture.setStatus: sending: " + statusMessage + " to all Listeners from Image: " + filename ) ; pictureStatusCode = statusCode ; pictureStatusMessage = statusMessage ; Enumeration e = scalablePictureStatusListeners . elements ( ) ; while ( e . hasMoreElements ( ) ) { ( ( ScalablePictureListener ) e . nextElement ( ) ) . scalableStatusChange ( pictureStatusCode , pictureStatusMessage ) ; }


signature:
public class GempakSoundingFileReader { /** * Initialize the file , read in all the metadata ( ala DM _ OPEN )
 * @ param raf RandomAccessFile to read .
 * @ param fullCheck if true , check entire structure
 * @ return A GempakSoundingFileReader
 * @ throws IOException problem reading file */
public static GempakSoundingFileReader getInstance ( RandomAccessFile raf , boolean fullCheck ) throws IOException { } }

implementation: GempakSoundingFileReader gsfr = new GempakSoundingFileReader ( ) ; gsfr . init ( raf , fullCheck ) ; return gsfr ;


signature:
public class GempakSoundingFileReader { /** * Initialize this reader . Get the Grid specific info
 * @ param fullCheck check to make sure there are grids we can handle
 * @ return true if successful
 * @ throws IOException problem reading the data */
protected boolean init ( boolean fullCheck ) throws IOException { } }

implementation:
if ( ! super . init ( fullCheck ) ) { return false ; } // Modeled after SN _ OFIL
if ( dmLabel . kftype != MFSN ) { logError ( "not a sounding data file " ) ; return false ; } DMPart part = getPart ( SNDT ) ; if ( part != null ) { // merged file
subType = MERGED ; String vertName = part . params . get ( 0 ) . kprmnm ; switch ( vertName ) { case "PRES" : ivert = PRES_COORD ; break ; case "THTA" : ivert = THTA_COORD ; break ; case "HGHT" : case "MHGT" : case "DHGT" : ivert = HGHT_COORD ; break ; default : logError ( "unknown vertical coordinate in merged file" ) ; return false ; } } else { unmergedParts = SN_CKUA ( ) ; boolean haveUnMerged = ! unmergedParts . isEmpty ( ) ; if ( ! haveUnMerged ) { logError ( "unknown sounding file type - not merged/unmerged" ) ; return false ; } else { ivert = PRES_COORD ; subType = UNMERGED ; } } if ( ! readStationsAndTimes ( true ) ) { logError ( "Unable to read stations and times" ) ; return false ; } return true ;


signature:
public class GempakSoundingFileReader { /** * Get the list of merged parts in this file
 * @ return a list of the unmerged parts ( only SNDT ) */
public List < String > getMergedParts ( ) { } }

implementation: List < String > list = new ArrayList < > ( 1 ) ; list . add ( SNDT ) ; return list ;


signature:
public class GempakSoundingFileReader { /** * Print the list of dates in the file
 * @ param row ob row
 * @ param col ob column */
public void printOb ( int row , int col ) { } }

implementation: GempakStation station = getStations ( ) . get ( col - 1 ) ; String time = getDateString ( row - 1 ) ; StringBuilder builder = new StringBuilder ( "\n" ) ; builder . append ( makeHeader ( station , time ) ) ; builder . append ( "\n" ) ; boolean merge = getFileSubType ( ) . equals ( MERGED ) ; List < String > parts ; if ( merge ) { parts = new ArrayList < > ( ) ; parts . add ( SNDT ) ; } else { parts = unmergedParts ; } for ( String part : parts ) { RData rd ; try { rd = DM_RDTR ( row , col , part ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; rd = null ; } if ( rd == null ) { continue ; } if ( ! merge ) { builder . append ( "    " ) ; builder . append ( part ) ; builder . append ( "    " ) ; builder . append ( time . substring ( time . indexOf ( "/" ) + 1 ) ) ; } builder . append ( "\n" ) ; if ( ! merge ) { builder . append ( "\t" ) ; } List < GempakParameter > params = getParameters ( part ) ; for ( GempakParameter parm : params ) { builder . append ( StringUtil2 . padLeft ( parm . getName ( ) , 7 ) ) ; builder . append ( "\t" ) ; } builder . append ( "\n" ) ; if ( ! merge ) { builder . append ( "\t" ) ; } float [ ] data = rd . data ; int numParams = params . size ( ) ; int numLevels = data . length / numParams ; for ( int j = 0 ; j < numLevels ; j ++ ) { for ( int i = 0 ; i < numParams ; i ++ ) { builder . append ( StringUtil2 . padLeft ( Format . formatDouble ( data [ j * numParams + i ] , 7 , 1 ) , 7 ) ) ; builder . append ( "\t" ) ; } builder . append ( "\n" ) ; if ( ! merge ) { builder . append ( "\t" ) ; } } builder . append ( "\n" ) ; } builder . append ( "\n" ) ; System . out . println ( builder . toString ( ) ) ;