signature:
public class JmaTables { /** * / / / / / local time types */
@ Override public Grib1ParamTime getParamTime ( Grib1SectionProductDefinition pds ) { } }

implementation:
int p1 = pds . getTimeValue1 ( ) ; // octet 19
int p2 = pds . getTimeValue2 ( ) ; // octet 20
int timeRangeIndicator = pds . getTimeRangeIndicator ( ) ; // octet 21
int n = pds . getNincluded ( ) ; int start ; int end ; int forecastTime = 0 ; boolean isInterval ; switch ( timeRangeIndicator ) { /* Monthly - diurnal ( ds628.5 / fcst _ phy2m125 _ diurnal )
 Average over the days of the month .
 128 : Average of N forecast products with a valid time ranging between reference time + P1 and reference time + P2;
 products have reference times at Intervals of 24 hours , beginning at the given reference time . */
case 128 : isInterval = true ; start = p1 ; end = p2 ; break ; /* 129 : Temporal variance of N forecasts ; each product has valid time ranging between reference time + P1 and reference time + P2;
 products have reference times at intervals of 24 hours , beginning at the given reference time ;
 unit of measurement is square of that in Code Table 2 */
// LOOK
/* 131 : Temporal variance of N forecasts ; valid time of the first product ranges between R + P1 and R + P2,
 where R is reference time given in octets 13 to 17 , then subsequent products have valid time range at interval of P2 - P1;
 thus all N products cover continuous time span ; products have reference times at intervals of P2 - P1 , beginning at the given reference time ;
 unit of measurement is square of that in Code Table 2 */
// LOOK
case 129 : case 131 : isInterval = true ; start = p1 ; end = p2 ; break ; /* 130 : Average of N forecast products ; valid time of the first product ranges between R + P1 and R + P2 , where R is reference time given in octets 13 to 17,
 then subsequent products have valid time range at interval of P2 - P1 ; thus all N products cover continuous time span ; products have reference times at
 intervals of P2 - P1 , beginning at the given reference time */
case 130 : isInterval = true ; start = p1 ; end = ( n > 0 ) ? p1 + n * ( p2 - p1 ) : p2 ; // prob n > = 1
break ; /* Temporal variance of N uninitialized analyses ( P1 = 0 ) or instantaneous forecasts ( P1 > 0 ) ;
 each product has valid time at the reference time + P1;
 products have reference times at intervals of P2 , beginning at the given reference time ;
 unit of measurement is square of that in Code Table 2 */
// LOOK
case 132 : forecastTime = p1 ; start = p1 ; end = ( n > 0 ) ? p1 + ( n - 1 ) * p2 : p1 ; // LOOK ? ?
isInterval = ( n > 0 ) ; break ; default : return super . getParamTime ( pds ) ; } return new Grib1ParamTime ( this , timeRangeIndicator , isInterval , start , end , forecastTime ) ;


signature:
public class ServerDDS { /** * Get the dataset filename .
 * @ return The filename of the dataset .
 * @ see # setDatasetFilename ( String ) */
public String getDatasetFilename ( ) { } }

implementation: String s = getEncodedName ( ) ; System . out . println ( s ) ; return ( s ) ;


signature:
public class ServerDDS { /** * Print the constrained < code > DDS < / code > on the given
 * < code > PrintWriter < / code > .
 * @ param os the < code > PrintWriter < / code > to use for output . */
public void printConstrained ( PrintWriter os ) { } }

implementation:
os . println ( "Dataset {" ) ; for ( Enumeration e = getVariables ( ) ; e . hasMoreElements ( ) ; ) { BaseType bt = ( BaseType ) e . nextElement ( ) ; // System . err . println ( " check : " + bt . getLongName ( ) + " = " + ( ( ServerMethods ) bt ) . isProject ( ) ) ;
ServerMethods sm = ( ServerMethods ) bt ; if ( sm . isProject ( ) ) { bt . printDecl ( os , "    " , true , true ) ; } } os . print ( "} " ) ; if ( getEncodedName ( ) != null ) os . print ( getEncodedName ( ) ) ; os . println ( ";" ) ;


signature:
public class GempakSurfaceIOSP { /** * Is this a valid file ?
 * @ param raf RandomAccessFile to check
 * @ return true if a valid Gempak grid file
 * @ throws IOException problem reading file */
public boolean isValidFile ( RandomAccessFile raf ) throws IOException { } }

implementation:
if ( ! super . isValidFile ( raf ) ) { return false ; } // TODO : handle other types of surface files
return gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . STANDARD ) || gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . SHIP ) ;


signature:
public class GempakSurfaceIOSP { /** * Get the CF feature type
 * @ return the feature type */
public String getCFFeatureType ( ) { } }

implementation: if ( gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . SHIP ) ) { return CF . FeatureType . point . toString ( ) ; } return CF . FeatureType . timeSeries . toString ( ) ;


signature:
public class GempakSurfaceIOSP { /** * Read the data for the variable
 * @ param v2 Variable to read
 * @ param section section infomation
 * @ return Array of data
 * @ throws IOException problem reading from file
 * @ throws InvalidRangeException invalid Range */
public Array readData ( Variable v2 , Section section ) throws IOException , InvalidRangeException { } }

implementation:
if ( gemreader == null ) { return null ; } // System . out . println ( " looking for " + v2 ) ;
// System . out . println ( " Section = " + section ) ;
// Trace . call1 ( " GEMPAKSIOSP : readData " ) ;
Array array = null ; if ( gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . SHIP ) ) { array = readShipData ( v2 , section ) ; } else if ( gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . STANDARD ) ) { array = readStandardData ( v2 , section ) ; } else { // climate data
// array = readClimateData ( v2 , section ) ;
} // long took = System . currentTimeMillis ( ) - start ;
// System . out . println ( " read data took = " + took + " msec " ) ;
// Trace . call2 ( " GEMPAKSIOSP : readData " ) ;
return array ;


signature:
public class GempakSurfaceIOSP { /** * Read in the data for the variable . In this case , it should be
 * a Structure . The section should be rank 2 ( station , time ) .
 * @ param v2 variable to read
 * @ param section section of the variable
 * @ return the array of data
 * @ throws IOException problem reading the file */
private Array readStandardData ( Variable v2 , Section section ) throws IOException { } }

implementation:
Array array = null ; if ( v2 instanceof Structure ) { List < GempakParameter > params = gemreader . getParameters ( GempakSurfaceFileReader . SFDT ) ; Structure pdata = ( Structure ) v2 ; StructureMembers members = pdata . makeStructureMembers ( ) ; List < StructureMembers . Member > mbers = members . getMembers ( ) ; int i = 0 ; int numBytes = 0 ; int totalNumBytes = 0 ; for ( StructureMembers . Member member : mbers ) { member . setDataParam ( 4 * i ++ ) ; numBytes = member . getDataType ( ) . getSize ( ) ; totalNumBytes += numBytes ; } // one member is a byte
members . setStructureSize ( totalNumBytes ) ; float [ ] missing = new float [ mbers . size ( ) ] ; int missnum = 0 ; for ( Variable v : pdata . getVariables ( ) ) { Attribute att = v . findAttribute ( "missing_value" ) ; missing [ missnum ++ ] = ( att == null ) ? GempakConstants . RMISSD : att . getNumericValue ( ) . floatValue ( ) ; } // int num = 0;
Range stationRange = section . getRange ( 0 ) ; Range timeRange = section . getRange ( 1 ) ; int size = stationRange . length ( ) * timeRange . length ( ) ; // Create a ByteBuffer using a byte array
byte [ ] bytes = new byte [ totalNumBytes * size ] ; ByteBuffer buf = ByteBuffer . wrap ( bytes ) ; array = new ArrayStructureBB ( members , new int [ ] { size } , buf , 0 ) ; for ( int stnIdx : stationRange ) { for ( int timeIdx : timeRange ) { GempakFileReader . RData vals = gemreader . DM_RDTR ( timeIdx + 1 , stnIdx + 1 , GempakSurfaceFileReader . SFDT ) ; if ( vals == null ) { int k = 0 ; for ( StructureMembers . Member member : mbers ) { if ( member . getDataType ( ) . equals ( DataType . FLOAT ) ) { buf . putFloat ( missing [ k ] ) ; } else { buf . put ( ( byte ) 1 ) ; } k ++ ; } } else { float [ ] reals = vals . data ; int var = 0 ; for ( GempakParameter param : params ) { if ( members . findMember ( param . getName ( ) ) != null ) { buf . putFloat ( reals [ var ] ) ; } var ++ ; } // always add the missing flag
buf . put ( ( byte ) 0 ) ; } } } // Trace . call2 ( " GEMPAKSIOSP : readStandardData " ) ;
} return array ;


signature:
public class GempakSurfaceIOSP { /** * Read in the data for the record variable . In this case , it should be
 * a Structure of record dimension . We can handle a subset of the
 * variables in a structure .
 * @ param v2 variable to read
 * @ param section section of the variable
 * @ return the array of data
 * @ throws IOException problem reading the file */
private Array readShipData ( Variable v2 , Section section ) throws IOException { } }

implementation:
Array array = null ; if ( v2 instanceof Structure ) { List < GempakParameter > params = gemreader . getParameters ( GempakSurfaceFileReader . SFDT ) ; Structure pdata = ( Structure ) v2 ; StructureMembers members = pdata . makeStructureMembers ( ) ; List < StructureMembers . Member > mbers = members . getMembers ( ) ; int ssize = 0 ; // int stnVarNum = 0;
List < String > stnKeyNames = gemreader . getStationKeyNames ( ) ; for ( StructureMembers . Member member : mbers ) { if ( stnKeyNames . contains ( member . getName ( ) ) ) { int varSize = getStnVarSize ( member . getName ( ) ) ; member . setDataParam ( ssize ) ; ssize += varSize ; } else if ( member . getName ( ) . equals ( TIME_VAR ) ) { member . setDataParam ( ssize ) ; ssize += 8 ; } else if ( member . getName ( ) . equals ( MISSING_VAR ) ) { member . setDataParam ( ssize ) ; ssize += 1 ; } else { member . setDataParam ( ssize ) ; ssize += 4 ; } } members . setStructureSize ( ssize ) ; // TODO : figure out how to get the missing value for data
// float [ ] missing = new float [ mbers . size ( ) ] ;
// int missnum = 0;
// for ( Variable v : pdata . getVariables ( ) ) {
// Attribute att = v . findAttribute ( " missing _ value " ) ;
// missing [ missnum + + ] = ( att = = null )
// ? GempakConstants . RMISSD
// : att . getNumericValue ( ) . floatValue ( ) ;
Range recordRange = section . getRange ( 0 ) ; int size = recordRange . length ( ) ; // Create a ByteBuffer using a byte array
byte [ ] bytes = new byte [ ssize * size ] ; ByteBuffer buf = ByteBuffer . wrap ( bytes ) ; array = new ArrayStructureBB ( members , new int [ ] { size } , buf , 0 ) ; List < GempakStation > stationList = gemreader . getStations ( ) ; List < Date > dateList = gemreader . getDates ( ) ; boolean needToReadData = ! pdata . isSubset ( ) ; if ( ! needToReadData ) { // subset , see if we need some param data
for ( GempakParameter param : params ) { if ( members . findMember ( param . getName ( ) ) != null ) { needToReadData = true ; break ; } } } // boolean hasTime = ( members . findMember ( TIME _ VAR ) ! = null ) ;
// fill out the station information
for ( int recIdx : recordRange ) { GempakStation stn = stationList . get ( recIdx ) ; for ( String varname : stnKeyNames ) { if ( members . findMember ( varname ) == null ) { continue ; } String temp = null ; switch ( varname ) { case GempakStation . STID : temp = StringUtil2 . padRight ( stn . getName ( ) , 8 ) ; break ; case GempakStation . STNM : buf . putInt ( stn . getSTNM ( ) ) ; break ; case GempakStation . SLAT : buf . putFloat ( ( float ) stn . getLatitude ( ) ) ; break ; case GempakStation . SLON : buf . putFloat ( ( float ) stn . getLongitude ( ) ) ; break ; case GempakStation . SELV : buf . putFloat ( ( float ) stn . getAltitude ( ) ) ; break ; case GempakStation . STAT : temp = StringUtil2 . padRight ( stn . getSTAT ( ) , 2 ) ; break ; case GempakStation . COUN : temp = StringUtil2 . padRight ( stn . getCOUN ( ) , 2 ) ; break ; case GempakStation . STD2 : temp = StringUtil2 . padRight ( stn . getSTD2 ( ) , 4 ) ; break ; case GempakStation . SPRI : buf . putInt ( stn . getSPRI ( ) ) ; break ; case GempakStation . SWFO : temp = StringUtil2 . padRight ( stn . getSWFO ( ) , 4 ) ; break ; case GempakStation . WFO2 : temp = StringUtil2 . padRight ( stn . getWFO2 ( ) , 4 ) ; break ; } if ( temp != null ) { buf . put ( temp . getBytes ( CDM . utf8Charset ) ) ; } } if ( members . findMember ( TIME_VAR ) != null ) { // put in the time
Date time = dateList . get ( recIdx ) ; buf . putDouble ( time . getTime ( ) / 1000.d ) ; } if ( needToReadData ) { int column = stn . getIndex ( ) ; GempakFileReader . RData vals = gemreader . DM_RDTR ( 1 , column , GempakSurfaceFileReader . SFDT ) ; if ( vals == null ) { for ( GempakParameter param : params ) { if ( members . findMember ( param . getName ( ) ) != null ) { buf . putFloat ( GempakConstants . RMISSD ) ; } } buf . put ( ( byte ) 1 ) ; } else { float [ ] reals = vals . data ; int var = 0 ; for ( GempakParameter param : params ) { if ( members . findMember ( param . getName ( ) ) != null ) { buf . putFloat ( reals [ var ] ) ; } var ++ ; } buf . put ( ( byte ) 0 ) ; } } } // Trace . call2 ( " GEMPAKSIOSP : readShipData " ) ;
} return array ;


signature:
public class GempakSurfaceIOSP { /** * Build the netCDF file
 * @ throws IOException problem reading the file */
protected void fillNCFile ( ) throws IOException { } }

implementation: String fileType = gemreader . getFileSubType ( ) ; switch ( fileType ) { case GempakSurfaceFileReader . STANDARD : buildStandardFile ( ) ; break ; case GempakSurfaceFileReader . SHIP : buildShipFile ( ) ; break ; default : buildClimateFile ( ) ; break ; }


signature:
public class GempakSurfaceIOSP { /** * Build a standard station structure */
private void buildStandardFile ( ) { } }

implementation:
// Build station list
List < GempakStation > stations = gemreader . getStations ( ) ; // Trace . msg ( " GEMPAKSIOSP : now have " + stations . size ( ) + " stations " ) ;
Dimension station = new Dimension ( "station" , stations . size ( ) , true ) ; ncfile . addDimension ( null , station ) ; ncfile . addDimension ( null , DIM_LEN8 ) ; ncfile . addDimension ( null , DIM_LEN4 ) ; ncfile . addDimension ( null , DIM_LEN2 ) ; List < Variable > stationVars = makeStationVars ( stations , station ) ; // loop through and add to ncfile
for ( Variable stnVar : stationVars ) { ncfile . addVariable ( null , stnVar ) ; } // Build variable list ( var ( station , time ) )
// time
List < Date > timeList = gemreader . getDates ( ) ; int numTimes = timeList . size ( ) ; Dimension times = new Dimension ( TIME_VAR , numTimes , true ) ; ncfile . addDimension ( null , times ) ; Array varArray ; Variable timeVar = new Variable ( ncfile , null , null , TIME_VAR , DataType . DOUBLE , TIME_VAR ) ; timeVar . addAttribute ( new Attribute ( CDM . UNITS , "seconds since 1970-01-01 00:00:00" ) ) ; timeVar . addAttribute ( new Attribute ( "long_name" , TIME_VAR ) ) ; varArray = new ArrayDouble . D1 ( numTimes ) ; int i = 0 ; for ( Date date : timeList ) { ( ( ArrayDouble . D1 ) varArray ) . set ( i , date . getTime ( ) / 1000.d ) ; i ++ ; } timeVar . setCachedData ( varArray , false ) ; ncfile . addVariable ( null , timeVar ) ; List < Dimension > stationTime = new ArrayList < > ( ) ; stationTime . add ( station ) ; stationTime . add ( times ) ; // TODO : handle other parts
Structure sfData = makeStructure ( GempakSurfaceFileReader . SFDT , stationTime , true ) ; if ( sfData == null ) { return ; } sfData . addAttribute ( new Attribute ( CF . COORDINATES , "time SLAT SLON SELV" ) ) ; ncfile . addVariable ( null , sfData ) ; ncfile . addAttribute ( null , new Attribute ( "CF:featureType" , CF . FeatureType . timeSeries . toString ( ) ) ) ;


signature:
public class GempakSurfaceIOSP { /** * Build a ship station structure . Here the columns are the
 * stations / reports and the rows ( 1 ) are the reports . */
private void buildShipFile ( ) { } }

implementation:
// Build variable list ( var ( station , time ) )
List < GempakStation > stations = gemreader . getStations ( ) ; int numObs = stations . size ( ) ; // Trace . msg ( " GEMPAKSIOSP : now have " + numObs + " stations " ) ;
Dimension record = new Dimension ( "record" , numObs , true , ( numObs == 0 ) , false ) ; ncfile . addDimension ( null , record ) ; List < Dimension > records = new ArrayList < > ( 1 ) ; records . add ( record ) ; // time
Variable timeVar = new Variable ( ncfile , null , null , TIME_VAR , DataType . DOUBLE , ( String ) null ) ; timeVar . addAttribute ( new Attribute ( CDM . UNITS , "seconds since 1970-01-01 00:00:00" ) ) ; timeVar . addAttribute ( new Attribute ( "long_name" , TIME_VAR ) ) ; ncfile . addDimension ( null , DIM_LEN8 ) ; ncfile . addDimension ( null , DIM_LEN4 ) ; ncfile . addDimension ( null , DIM_LEN2 ) ; List < Variable > stationVars = makeStationVars ( stations , null ) ; List < GempakParameter > params = gemreader . getParameters ( GempakSurfaceFileReader . SFDT ) ; if ( params == null ) { return ; } Structure sVar = new Structure ( ncfile , null , null , "Obs" ) ; sVar . setDimensions ( records ) ; // loop through and add to ncfile
boolean hasElevation = false ; for ( Variable stnVar : stationVars ) { if ( stnVar . getShortName ( ) . equals ( "SELV" ) ) { hasElevation = true ; } sVar . addMemberVariable ( stnVar ) ; } sVar . addMemberVariable ( timeVar ) ; for ( GempakParameter param : params ) { Variable var = makeParamVariable ( param , null ) ; sVar . addMemberVariable ( var ) ; } sVar . addMemberVariable ( makeMissingVariable ( ) ) ; String coords = "Obs.time Obs.SLAT Obs.SLON" ; if ( hasElevation ) { coords = coords + " Obs.SELV" ; } sVar . addAttribute ( new Attribute ( CF . COORDINATES , coords ) ) ; ncfile . addVariable ( null , sVar ) ; ncfile . addAttribute ( null , new Attribute ( "CF:featureType" , CF . FeatureType . point . toString ( ) ) ) ;


signature:
public class Misc { /** * Returns the absolute difference between two numbers , i . e . { @ code | a - b | } .
 * @ param a first number .
 * @ param b second number .
 * @ return the absolute difference . */
public static float absoluteDifference ( float a , float b ) { } }

implementation:
if ( Float . compare ( a , b ) == 0 ) { // Shortcut : handles infinities and NaNs .
return 0 ; } else { return Math . abs ( a - b ) ; }


signature:
public class Misc { /** * Same as { @ link # absoluteDifference ( float , float ) } , but for doubles . */
public static double absoluteDifference ( double a , double b ) { } }

implementation:
if ( Double . compare ( a , b ) == 0 ) { // Shortcut : handles infinities and NaNs .
return 0 ; } else { return Math . abs ( a - b ) ; }


signature:
public class Misc { /** * Returns the relative difference between two numbers , i . e . { @ code | a - b | / max ( | a | , | b | ) } .
 * For cases where { @ code a = = 0 } , { @ code b = = 0 } , or { @ code a } and { @ code b } are extremely close , traditional
 * relative difference calculation breaks down . So , in those instances , we compute the difference relative to
 * { @ link Float # MIN _ NORMAL } , i . e . { @ code | a - b | / Float . MIN _ NORMAL } .
 * @ param a first number .
 * @ param b second number .
 * @ return the relative difference .
 * @ see < a href = " http : / / floating - point - gui . de / errors / comparison / " > The Floating - Point Guide < / a >
 * @ see < a href = " https : / / randomascii . wordpress . com / 2012/02/25 / comparing - floating - point - numbers - 2012 - edition / " >
 * Comparing Floating Point Numbers , 2012 Edition < / a > */
public static float relativeDifference ( float a , float b ) { } }

implementation:
float absDiff = absoluteDifference ( a , b ) ; if ( Float . compare ( a , b ) == 0 ) { // Shortcut : handles infinities and NaNs .
return 0 ; } else if ( a == 0 || b == 0 || absDiff < Float . MIN_NORMAL ) { return absDiff / Float . MIN_NORMAL ; } else { float maxAbsValue = Math . max ( Math . abs ( a ) , Math . abs ( b ) ) ; return absDiff / maxAbsValue ; }


signature:
public class Misc { /** * Check if two numbers are nearly equal with given absolute tolerance .
 * @ param a first number .
 * @ param b second number .
 * @ param maxAbsDiff the maximum { @ link # absoluteDifference absolute difference } the two numbers may have .
 * @ return true if within tolerance . */
public static boolean nearlyEqualsAbs ( float a , float b , float maxAbsDiff ) { } }

implementation: return absoluteDifference ( a , b ) <= Math . abs ( maxAbsDiff ) ;


signature: public class Misc { static public boolean compare ( byte [ ] raw1 , byte [ ] raw2 , Formatter f ) { } }

implementation: if ( raw1 == null || raw2 == null ) return false ; if ( raw1 . length != raw2 . length ) { f . format ( "length 1= %3d != length 2=%3d%n" , raw1 . length , raw2 . length ) ; } int len = Math . min ( raw1 . length , raw2 . length ) ; int ndiff = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( raw1 [ i ] != raw2 [ i ] ) { f . format ( " %3d : %3d != %3d%n" , i + 1 , raw1 [ i ] , raw2 [ i ] ) ; ndiff ++ ; } } f . format ( "tested %d bytes  diff = %d %n" , len , ndiff ) ; return ndiff == 0 && ( raw1 . length == raw2 . length ) ;


signature: public class DeepCopyUtils { public static InvDataset copyDataset ( InvDataset dataset , List < InvService > availableServices , boolean copyInheritedMetadataFromParents ) { } }

implementation:
if ( dataset == null ) throw new IllegalArgumentException ( "Dataset may not be null." ) ; if ( availableServices == null ) throw new IllegalArgumentException ( "List of available services may not be null." ) ; InvDatasetImpl resultDs ; // ToDo Deal with InvDatasetScan and its ilk .
if ( dataset instanceof InvCatalogRef ) { InvCatalogRef catRef = ( InvCatalogRef ) dataset ; resultDs = new InvCatalogRef ( null , catRef . getName ( ) , catRef . getXlinkHref ( ) ) ; } else { resultDs = new InvDatasetImpl ( null , dataset . getName ( ) ) ; } resultDs . setID ( dataset . getID ( ) ) ; resultDs . transferMetadata ( ( InvDatasetImpl ) dataset , copyInheritedMetadataFromParents ) ; // Only copy child InvAccess if the current dataset is not an InvCatalogRef .
if ( ! ( dataset instanceof InvCatalogRef ) ) { String urlPath = ( ( InvDatasetImpl ) dataset ) . getUrlPath ( ) ; if ( urlPath != null ) resultDs . setUrlPath ( urlPath ) ; else { for ( InvAccess curAccess : dataset . getAccess ( ) ) { InvAccess access = copyAccess ( curAccess , resultDs , availableServices ) ; if ( access != null ) resultDs . addAccess ( access ) ; } } } // Only recurse into child datasets if the current dataset is not an InvCatalogRef .
if ( ! ( dataset instanceof InvCatalogRef ) ) { for ( InvDataset curDs : dataset . getDatasets ( ) ) { InvDatasetImpl curDsCopy = ( InvDatasetImpl ) copyDataset ( curDs , availableServices , false ) ; curDsCopy . setParent ( resultDs ) ; resultDs . addDataset ( curDsCopy ) ; } } return resultDs ;


signature:
public class WmoXmlReader { /** * 14.1
 * < BC _ TableB _ BUFR14_1_0 _ CREX _ 6_1_0 >
 * < SNo > 1 < / SNo >
 * < Class > 00 < / Class >
 * < FXY > 000001 < / FXY >
 * < ElementName _ E > Table A : entry < / ElementName _ E >
 * < ElementName _ F > Table A : entr ? e < / ElementName _ F >
 * < ElementName _ R > ? ? ? ? ? ? : ? ? ? ? ? < / ElementName _ R >
 * < ElementName _ S > Tabla A : elemento < / ElementName _ S >
 * < BUFR _ Unit > CCITT IA5 < / BUFR _ Unit >
 * < BUFR _ Scale > 0 < / BUFR _ Scale >
 * < BUFR _ ReferenceValue > 0 < / BUFR _ ReferenceValue >
 * < BUFR _ DataWidth _ Bits > 24 < / BUFR _ DataWidth _ Bits >
 * < CREX _ Unit > Character < / CREX _ Unit >
 * < CREX _ Scale > 0 < / CREX _ Scale >
 * < CREX _ DataWidth > 3 < / CREX _ DataWidth >
 * < Status > Operational < / Status >
 * < NotesToTable _ E > Notes : ( see ) # BUFR14_1_0 _ CREX6_1_0 _ Notes . doc # BC _ Cl000 < / NotesToTable _ E >
 * < / BC _ TableB _ BUFR14_1_0 _ CREX _ 6_1_0 >
 * 14.2
 * < Exporting _ BCTableB _ E >
 * < No > 2 < / No >
 * < ClassNo > 00 < / ClassNo >
 * < ClassName > BUFR / CREX table entries < / ClassName >
 * < FXY > 000002 < / FXY >
 * < ElementName > Table A : data category description , line 1 < / ElementName >
 * < BUFR _ Unit > CCITT IA5 < / BUFR _ Unit >
 * < BUFR _ Scale > 0 < / BUFR _ Scale >
 * < BUFR _ ReferenceValue > 0 < / BUFR _ ReferenceValue >
 * < BUFR _ DataWidth _ Bits > 256 < / BUFR _ DataWidth _ Bits >
 * < CREX _ Unit > Character < / CREX _ Unit >
 * < CREX _ Scale > 0 < / CREX _ Scale >
 * < CREX _ DataWidth > 32 < / CREX _ DataWidth >
 * < Status > Operational < / Status >
 * < / Exporting _ BCTableB _ E >
 * 15.1
 * < Exp _ JointTableB _ E >
 * < No > 1 < / No >
 * < ClassNo > 00 < / ClassNo >
 * < ClassName _ E > BUFR / CREX table entries < / ClassName _ E >
 * < FXY > 000001 < / FXY >
 * < ElementName _ E > Table A : entry < / ElementName _ E >
 * < BUFR _ Unit > CCITT IA5 < / BUFR _ Unit >
 * < BUFR _ Scale > 0 < / BUFR _ Scale >
 * < BUFR _ ReferenceValue > 0 < / BUFR _ ReferenceValue >
 * < BUFR _ DataWidth _ Bits > 24 < / BUFR _ DataWidth _ Bits >
 * < CREX _ Unit > Character < / CREX _ Unit >
 * < CREX _ Scale > 0 < / CREX _ Scale >
 * < CREX _ DataWidth _ Char > 3 < / CREX _ DataWidth _ Char >
 * < Status > Operational < / Status >
 * < / Exp _ JointTableB _ E >
 * 16.0
 * < Exp _ BUFRCREXTableB _ E >
 * < No > 681 < / No >
 * < ClassNo > 13 < / ClassNo >
 * < ClassName _ E > Hydrographic and hydrological elements < / ClassName _ E >
 * < FXY > 013060 < / FXY >
 * < ElementName _ E > Total accumulated precipitation < / ElementName _ E >
 * < BUFR _ Unit > kg m - 2 < / BUFR _ Unit >
 * < BUFR _ Scale > 1 < / BUFR _ Scale >
 * < BUFR _ ReferenceValue > - 1 < / BUFR _ ReferenceValue >
 * < BUFR _ DataWidth _ Bits > 17 < / BUFR _ DataWidth _ Bits >
 * < CREX _ Unit > kg m - 2 < / CREX _ Unit >
 * < CREX _ Scale > 1 < / CREX _ Scale >
 * < CREX _ DataWidth _ Char > 5 < / CREX _ DataWidth _ Char >
 * < Status > Operational < / Status >
 * < / Exp _ BUFRCREXTableB _ E >
 * < BUFRCREX _ 17_0_0 _ TableB _ en >
 * < No > 8 < / No >
 * < ClassNo > 00 < / ClassNo >
 * < ClassName _ en > BUFR / CREX table entries < / ClassName _ en >
 * < FXY > 000008 < / FXY >
 * < ElementName _ en > BUFR Local table version number < / ElementName _ en >
 * < Note _ en > ( see Note 4 ) < / Note _ en >
 * < BUFR _ Unit > CCITT IA5 < / BUFR _ Unit >
 * < BUFR _ Scale > 0 < / BUFR _ Scale >
 * < BUFR _ ReferenceValue > 0 < / BUFR _ ReferenceValue >
 * < BUFR _ DataWidth _ Bits > 16 < / BUFR _ DataWidth _ Bits >
 * < CREX _ Unit > Character < / CREX _ Unit >
 * < CREX _ Scale > 0 < / CREX _ Scale >
 * < CREX _ DataWidth _ Char > 2 < / CREX _ DataWidth _ Char >
 * < Status > Operational < / Status >
 * < / BUFRCREX _ 17_0_0 _ TableB _ en >
 * < BUFRCREX _ 22_0_1 _ TableB _ en >
 * < No > 1018 < / No >
 * < ClassNo > 21 < / ClassNo >
 * < ClassName _ en > BUFR / CREX Radar data < / ClassName _ en >
 * < FXY > 021073 < / FXY >
 * < ElementName _ en > Satellite altimeter instrument mode < / ElementName _ en >
 * < BUFR _ Unit > Flag table < / BUFR _ Unit >
 * < BUFR _ Scale > 0 < / BUFR _ Scale >
 * < BUFR _ ReferenceValue > 0 < / BUFR _ ReferenceValue >
 * < BUFR _ DataWidth _ Bits > 9 < / BUFR _ DataWidth _ Bits >
 * < CREX _ Unit > Flag table < / CREX _ Unit >
 * < CREX _ Scale > 0 < / CREX _ Scale >
 * < CREX _ DataWidth _ Char > 3 < / CREX _ DataWidth _ Char >
 * < Status > Operational < / Status >
 * < / BUFRCREX _ 22_0_1 _ TableB _ en > */
static void readWmoXmlTableB ( InputStream ios , TableB b ) throws IOException { } }

implementation:
org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; doc = builder . build ( ios ) ; } catch ( JDOMException e ) { throw new IOException ( e . getMessage ( ) ) ; } Element root = doc . getRootElement ( ) ; String [ ] elems = null ; for ( Version v : Version . values ( ) ) { elems = v . getElemNamesB ( ) ; List < Element > featList = root . getChildren ( elems [ 0 ] ) ; if ( featList != null && featList . size ( ) > 0 ) { break ; } } // if not found using element name , assume its BUFR _ WMO
if ( elems == null ) { elems = Version . BUFR_WMO . getElemNamesB ( ) ; } List < Element > featList = root . getChildren ( ) ; for ( Element elem : featList ) { Element ce = elem . getChild ( elems [ 1 ] ) ; if ( ce == null ) continue ; String name = Util . cleanName ( elem . getChildTextNormalize ( elems [ 1 ] ) ) ; String units = cleanUnit ( elem . getChildTextNormalize ( "BUFR_Unit" ) ) ; int x = 0 , y = 0 , scale = 0 , reference = 0 , width = 0 ; String fxy = null ; String s = null ; try { fxy = elem . getChildTextNormalize ( "FXY" ) ; int xy = Integer . parseInt ( cleanNumber ( fxy ) ) ; x = xy / 1000 ; y = xy % 1000 ; } catch ( NumberFormatException e ) { System . out . printf ( " key %s name '%s' fails parsing %n" , fxy , name ) ; } try { s = elem . getChildTextNormalize ( "BUFR_Scale" ) ; scale = Integer . parseInt ( cleanNumber ( s ) ) ; } catch ( NumberFormatException e ) { System . out . printf ( " key %s name '%s' has bad scale='%s'%n" , fxy , name , s ) ; } try { s = elem . getChildTextNormalize ( "BUFR_ReferenceValue" ) ; reference = Integer . parseInt ( cleanNumber ( s ) ) ; } catch ( NumberFormatException e ) { System . out . printf ( " key %s name '%s' has bad reference='%s' %n" , fxy , name , s ) ; } try { s = elem . getChildTextNormalize ( "BUFR_DataWidth_Bits" ) ; width = Integer . parseInt ( cleanNumber ( s ) ) ; } catch ( NumberFormatException e ) { System . out . printf ( " key %s name '%s' has bad width='%s' %n" , fxy , name , s ) ; } b . addDescriptor ( ( short ) x , ( short ) y , scale , reference , width , name , units , null ) ; } ios . close ( ) ;


signature:
public class WmoXmlReader { /** * < B _ TableD _ BUFR14_1_0 _ CREX _ 6_1_0 >
 * < SNo > 2647 < / SNo >
 * < Category > 10 < / Category >
 * < FXY1 > 310013 < / FXY1 >
 * < ElementName1 _ E > ( AVHRR ( GAC ) report ) < / ElementName1 _ E >
 * < FXY2 > 004005 < / FXY2 >
 * < ElementName2 _ E > Minute < / ElementName2 _ E >
 * < Remarks _ E > Minute < / Remarks _ E >
 * < Status > Operational < / Status >
 * < / B _ TableD _ BUFR14_1_0 _ CREX _ 6_1_0 >
 * 14.2.0
 * < Exporting _ BUFRTableD _ E >
 * < No > 2901 < / No >
 * < Category > 10 < / Category >
 * < CategoryOfSequences > Vertical sounding sequences ( satellite data ) < / CategoryOfSequences >
 * < FXY1 > 310025 < / FXY1 >
 * < ElementName1 > ( SSMIS Temperature data record ) < / ElementName1 >
 * < FXY2 > 004006 < / FXY2 >
 * < Status > Operational < / Status >
 * < / Exporting _ BUFRTableD _ E >
 * 15.1.1
 * < Exp _ BUFRTableD _ E >
 * < No > 102 < / No >
 * < Category > 01 < / Category >
 * < CategoryOfSequences _ E > Location and identification sequences < / CategoryOfSequences _ E >
 * < FXY1 > 301034 < / FXY1 >
 * < Title _ E > ( Buoy / platform - fixed ) < / Title _ E >
 * < FXY2 > 001005 < / FXY2 >
 * < ElementName _ E > Buoy / platform identifier < / ElementName _ E >
 * < ExistingElementName _ E > Buoy / platform identifier < / ExistingElementName _ E >
 * < Status > Operational < / Status >
 * < / Exp _ BUFRTableD _ E >
 * 16.0.0
 * < Exp _ BUFRTableD _ E >
 * < No > 402 < / No >
 * < Category > 02 < / Category >
 * < CategoryOfSequences _ E > Meteorological sequences common to surface data < / CategoryOfSequences _ E >
 * < FXY1 > 302001 < / FXY1 >
 * < FXY2 > 010051 < / FXY2 >
 * < ElementName _ E > Pressure reduced to mean sea level < / ElementName _ E >
 * < ExistingElementName _ E > Pressure reduced to mean sea level < / ExistingElementName _ E >
 * < Status > Operational < / Status >
 * < / Exp _ BUFRTableD _ E >
 * < BUFR _ 19_1_1 _ TableD _ en >
 * < No > 4 < / No >
 * < Category > 00 < / Category >
 * < CategoryOfSequences _ en > BUFR table entries sequences < / CategoryOfSequences _ en >
 * < FXY1 > 300003 < / FXY1 >
 * < Title _ en > ( F , X , Y of descriptor to be added or defined ) < / Title _ en >
 * < FXY2 > 000011 < / FXY2 >
 * < ElementName _ en > X descriptor to be added or defined < / ElementName _ en >
 * < Status > Operational < / Status >
 * < / BUFR _ 19_1_1 _ TableD _ en >
 * < BUFR _ 22_0_1 _ TableD _ en >
 * < No > 5874 < / No >
 * < Category > 15 < / Category >
 * < CategoryOfSequences _ en > Oceanographic report sequences < / CategoryOfSequences _ en >
 * < FXY1 > 315004 < / FXY1 >
 * < Title _ en > ( XBT temperature profile data sequence ) < / Title _ en >
 * < FXY2 > 025061 < / FXY2 >
 * < ElementName _ en > Software identification and version number < / ElementName _ en >
 * < Status > Operational < / Status >
 * < / BUFR _ 22_0_1 _ TableD _ en > */
static void readWmoXmlTableD ( InputStream ios , TableD tableD ) throws IOException { } }

implementation: org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; doc = builder . build ( ios ) ; } catch ( JDOMException e ) { throw new IOException ( e . getMessage ( ) ) ; } int currSeqno = - 1 ; TableD . Descriptor currDesc = null ; Element root = doc . getRootElement ( ) ; String [ ] elems = null ; for ( Version v : Version . values ( ) ) { elems = v . getElemNamesD ( ) ; List < Element > featList = root . getChildren ( elems [ 0 ] ) ; if ( featList != null && featList . size ( ) > 0 ) { break ; } } if ( elems == null ) { elems = Version . BUFR_WMO . getElemNamesD ( ) ; } List < Element > featList = root . getChildren ( ) ; for ( Element elem : featList ) { Element ce = elem . getChild ( elems [ 1 ] ) ; if ( ce == null ) continue ; String seqs = elem . getChildTextNormalize ( "FXY1" ) ; int seq = Integer . parseInt ( seqs ) ; if ( currSeqno != seq ) { int y = seq % 1000 ; int w = seq / 1000 ; int x = w % 100 ; String seqName = Util . cleanName ( elem . getChildTextNormalize ( elems [ 1 ] ) ) ; currDesc = tableD . addDescriptor ( ( short ) x , ( short ) y , seqName , new ArrayList < Short > ( ) ) ; currSeqno = seq ; } String fnos = elem . getChildTextNormalize ( "FXY2" ) ; int fno = Integer . parseInt ( fnos ) ; int y = fno % 1000 ; int w = fno / 1000 ; int x = w % 100 ; int f = w / 100 ; int fxy = ( f << 14 ) + ( x << 8 ) + y ; currDesc . addFeature ( ( short ) fxy ) ; } ios . close ( ) ;


signature:
public class GribCollectionWriter { /** * message Gds {
 * bytes gds = 1 ; / / raw gds : Grib1SectionGridDefinition or Grib2SectionGridDefinition
 * uint32 predefinedGridDefinition = 2 ; / / only grib1 ; instead of gds raw bytes ; need center , subcenter to interpret */
static GribCollectionProto . Gds writeGdsProto ( byte [ ] rawGds , int predefinedGridDefinition ) { } }

implementation: GribCollectionProto . Gds . Builder b = GribCollectionProto . Gds . newBuilder ( ) ; if ( predefinedGridDefinition >= 0 ) b . setPredefinedGridDefinition ( predefinedGridDefinition ) ; else { b . setGds ( ByteString . copyFrom ( rawGds ) ) ; } return b . build ( ) ;


signature:
public class GribCollectionWriter { /** * message Coord {
 * GribAxisType axisType = 1;
 * int32 code = 2 ; / / time unit ; level type
 * string unit = 3;
 * repeated float values = 4;
 * repeated float bound = 5 ; / / only used if interval , then = ( value , bound )
 * repeated int64 msecs = 6 ; / / calendar date */
GribCollectionProto . Coord writeCoordProto ( CoordinateRuntime coord ) { } }

implementation: GribCollectionProto . Coord . Builder b = GribCollectionProto . Coord . newBuilder ( ) ; b . setAxisType ( convertAxisType ( coord . getType ( ) ) ) ; b . setCode ( coord . getCode ( ) ) ; if ( coord . getUnit ( ) != null ) b . setUnit ( coord . getUnit ( ) ) ; for ( int idx = 0 ; idx < coord . getSize ( ) ; idx ++ ) { long runtime = coord . getRuntime ( idx ) ; b . addMsecs ( runtime ) ; } return b . build ( ) ;


signature:
public class GribCollectionWriter { /** * / * not currently used
 * protected GribCollectionProto . FcConfig writeConfig ( FeatureCollectionConfig config ) throws IOException {
 * GribCollectionProto . FcConfig . Builder b = GribCollectionProto . FcConfig . newBuilder ( ) ;
 * b . setName ( config . collectionName ) ;
 * b . setCollectionSpec ( config . spec ) ;
 * b . setPartitionType ( config . ptype . toString ( ) ) ;
 * if ( config . dateFormatMark ! = null )
 * b . setDateFormatMark ( config . dateFormatMark ) ;
 * FeatureCollectionConfig . GribConfig gribConfig = config . gribConfig ;
 * if ( gribConfig . gdsHash ! = null ) {
 * for ( Map . Entry < Integer , Integer > entry : gribConfig . gdsHash . entrySet ( ) ) {
 * GribCollectionProto . IntMap . Builder bIntMap = GribCollectionProto . IntMap . newBuilder ( ) ;
 * bIntMap . setFrom ( entry . getKey ( ) ) ;
 * bIntMap . setTo ( entry . getValue ( ) ) ;
 * b . addGdsConvert ( bIntMap ) ;
 * b . setPdsUseGenType ( gribConfig . useGenType ) ;
 * b . setPdsUseTableVersion ( gribConfig . useTableVersion ) ;
 * b . setPdsIntvMerge ( gribConfig . intvMerge ) ;
 * b . setPdsUseCenter ( gribConfig . useCenter ) ;
 * if ( gribConfig . intvFilter ! = null ) {
 * b . setIntvExcludeZero ( gribConfig . intvFilter . isZeroExcluded ( ) ) ;
 * for ( FeatureCollectionConfig . GribIntvFilterParam intvFilter : gribConfig . intvFilter . filterList ) {
 * GribCollectionProto . IntvFilter . Builder bIntv = GribCollectionProto . IntvFilter . newBuilder ( ) ;
 * bIntv . setVariableId ( intvFilter . id ) ;
 * bIntv . setIntvLength ( intvFilter . intvLength ) ;
 * bIntv . setIntvProb ( intvFilter . prob ) ;
 * b . addIntvFilter ( bIntv ) ;
 * time unit convert
 * if ( gribConfig . tuc ! = null ) {
 * for ( Map . Entry < Integer , Integer > entry : gribConfig . tuc . map . entrySet ( ) ) {
 * GribCollectionProto . IntMap . Builder bIntMap = GribCollectionProto . IntMap . newBuilder ( ) ;
 * bIntMap . setFrom ( entry . getKey ( ) ) ;
 * bIntMap . setTo ( entry . getValue ( ) ) ;
 * b . addTimeUnitConvert ( bIntMap ) ;
 * if ( gribConfig . userTimeUnit ! = null )
 * b . setUserTimeUnit ( gribConfig . userTimeUnit . toString ( ) ) ;
 * return b . build ( ) ;
 * protected FeatureCollectionConfig readConfig ( boolean isGrib1 , GribCollectionProto . FcConfig pconfig ) throws IOException {
 * FeatureCollectionConfig config = new FeatureCollectionConfig ( ) ;
 * config . name = pconfig . getName ( ) ;
 * config . collectionName = pconfig . getName ( ) ;
 * config . type = isGrib1 ? FeatureCollectionType . GRIB1 : FeatureCollectionType . GRIB2;
 * config . spec = pconfig . getCollectionSpec ( ) ;
 * config . ptype = FeatureCollectionConfig . PartitionType . valueOf ( pconfig . getPartitionType ( ) ) ;
 * if ( pconfig . getDateFormatMark ( ) . length ( ) > 0)
 * config . dateFormatMark = pconfig . getDateFormatMark ( ) ;
 * if ( pconfig . getGdsConvertCount ( ) > 0 ) {
 * config . gribConfig . gdsHash = new HashMap < > ( ) ;
 * for ( GribCollectionProto . IntMap pIntMap : pconfig . getGdsConvertList ( ) ) {
 * config . gribConfig . gdsHash . put ( pIntMap . getFrom ( ) , pIntMap . getTo ( ) ) ;
 * config . gribConfig . useGenType = pconfig . getPdsUseGenType ( ) ;
 * config . gribConfig . useTableVersion = pconfig . getPdsUseTableVersion ( ) ;
 * config . gribConfig . intvMerge = pconfig . getPdsIntvMerge ( ) ;
 * config . gribConfig . useCenter = pconfig . getPdsUseCenter ( ) ;
 * boolean isZeroExcluded = pconfig . getIntvExcludeZero ( ) ;
 * if ( isZeroExcluded | | pconfig . getIntvFilterCount ( ) > 0 ) {
 * config . gribConfig . intvFilter = new FeatureCollectionConfig . GribIntvFilter ( ) ;
 * config . gribConfig . intvFilter . isZeroExcluded = isZeroExcluded ;
 * config . gribConfig . intvFilter . filterList = new ArrayList < > ( ) ;
 * for ( GribCollectionProto . IntvFilter pi : pconfig . getIntvFilterList ( ) ) {
 * int prob = pi . getIntvProb ( ) ;
 * config . gribConfig . intvFilter . filterList . add ( new FeatureCollectionConfig . GribIntvFilterParam ( pi . getVariableId ( ) , pi . getIntvLength ( ) , prob ) ) ;
 * if ( pconfig . getTimeUnitConvertCount ( ) > 0 ) {
 * config . gribConfig . tuc = new FeatureCollectionConfig . TimeUnitConverterHash ( ) ;
 * for ( GribCollectionProto . IntMap pIntMap : pconfig . getTimeUnitConvertList ( ) ) {
 * config . gribConfig . tuc . map . put ( pIntMap . getFrom ( ) , pIntMap . getTo ( ) ) ;
 * if ( pconfig . getDateFormatMark ( ) . length ( ) > 0)
 * config . gribConfig . setUserTimeUnit ( pconfig . getDateFormatMark ( ) ) ;
 * return config ; */
public static GribCollectionProto . GribAxisType convertAxisType ( Coordinate . Type type ) { } }

implementation: switch ( type ) { case runtime : return GribCollectionProto . GribAxisType . runtime ; case time : return GribCollectionProto . GribAxisType . time ; case time2D : return GribCollectionProto . GribAxisType . time2D ; case timeIntv : return GribCollectionProto . GribAxisType . timeIntv ; case ens : return GribCollectionProto . GribAxisType . ens ; case vert : return GribCollectionProto . GribAxisType . vert ; } throw new IllegalStateException ( "illegal axis type " + type ) ;


signature:
public class Universal { /** * Selected consult or iterator overrides for efficiency */
@ Override public boolean references ( DapNode node ) { } }

implementation: switch ( node . getSort ( ) ) { case DIMENSION : case ENUMERATION : case VARIABLE : case GROUP : case DATASET : return true ; default : break ; } return false ;


signature:
public class UnitFormatImpl { /** * Parses a unit specification . This method is thread - safe .
 * @ param spec
 * The unit specification ( e . g . " m / s " ) ;
 * @ return The unit corresponding to the specification .
 * @ throws NoSuchUnitException
 * A unit in the specification couldn ' t be found ( e . g . the " m "
 * in the example ) .
 * @ throws UnitParseException
 * The specification is grammatically incorrect .
 * @ throws SpecificationException
 * The specification is incorrect somehow .
 * @ throws UnitDBException
 * Problem with the unit database .
 * @ throws PrefixDBException
 * Problem with the unit - prefix database .
 * @ throws UnitSystemException
 * Problem with the system of units . */
public final Unit parse ( final String spec ) throws NoSuchUnitException , UnitParseException , SpecificationException , UnitDBException , PrefixDBException , UnitSystemException { } }

implementation: synchronized ( MUTEX ) { return parse ( spec , UnitDBManager . instance ( ) ) ; }


signature:
public class SigmetVolumeScan { /** * Sort Ray objects in the same sweep according to the ascended azimuth ( from 0 to 360)
 * and time .
 * @ param r the array of Ray objects in a sweep . Its length = number _ rays */
void checkSort ( Ray [ ] r ) { } }

implementation:
int j = 0 , n = 0 , n1 = 0 , n2 = 0 ; short time1 = 0 , time2 = 0 ; int [ ] k1 = new int [ 300 ] ; int [ ] k2 = new int [ 300 ] ; // define the groups of rays with the same " time " . For ex . :
// group1 - ray [ 0 ] = { time = 1 , az = 344 } , ray [ 1 ] = { time = 1 , az = 345 } , . . . ray [ 11 ] = { time = 1 , az = 359}
// group2 - ray [ 12 ] = { time = 1 , az = 0 } , ray [ 13 ] = { time = 1 , az = 1 } , . . . ray [ 15 ] = { time = 1 , az = 5}
// k1 - array of begin indx ( 0,12 ) , k2 - array of end indx ( 11,15)
for ( int i = 0 ; i < r . length - 1 ; i ++ ) { time1 = r [ i ] . getTime ( ) ; time2 = r [ i + 1 ] . getTime ( ) ; if ( time1 != time2 ) { k2 [ j ] = i ; j = j + 1 ; k1 [ j ] = i + 1 ; } } if ( k2 [ j ] < r . length - 1 ) { k1 [ j ] = k2 [ j - 1 ] + 1 ; k2 [ j ] = r . length - 1 ; n = j + 1 ; } // if different groups have the same value of " time " ( may be 2 and more groups ) -
// it1 = indx of " k1 " of 1st group , it2 = indx of " k2 " of last group
int it1 = 0 , it2 = 0 ; for ( int ii = 0 ; ii < j + 1 ; ii ++ ) { n1 = k1 [ ii ] ; for ( int i = 0 ; i < j + 1 ; i ++ ) { if ( i != ii ) { n2 = k1 [ i ] ; if ( r [ n1 ] . getTime ( ) == r [ n2 ] . getTime ( ) ) { it1 = ii ; it2 = i ; } } } } n1 = k1 [ it1 ] ; n2 = k1 [ it2 ] ; int s1 = k2 [ it1 ] - k1 [ it1 ] + 1 ; int s2 = k2 [ it2 ] - k1 [ it2 ] + 1 ; float [ ] t0 = new float [ s1 ] ; float [ ] t00 = new float [ s2 ] ; for ( int i = 0 ; i < s1 ; i ++ ) { t0 [ i ] = r [ n1 + i ] . getAz ( ) ; } for ( int i = 0 ; i < s2 ; i ++ ) { t00 [ i ] = r [ n2 + i ] . getAz ( ) ; } float mx0 = t0 [ 0 ] ; for ( int i = 0 ; i < s1 ; i ++ ) { if ( mx0 < t0 [ i ] ) mx0 = t0 [ i ] ; } float mx00 = t00 [ 0 ] ; for ( int i = 0 ; i < s2 ; i ++ ) { if ( mx00 < t00 [ i ] ) mx00 = t00 [ i ] ; } if ( ( mx0 > 330.0f & mx00 < 50.0f ) ) { for ( int i = 0 ; i < s1 ; i ++ ) { float q = r [ n1 + i ] . getAz ( ) ; r [ n1 + i ] . setAz ( q - 360.0f ) ; } } Arrays . sort ( r , new RayComparator ( ) ) ; for ( int i = 0 ; i < r . length ; i ++ ) { float a = r [ i ] . getAz ( ) ; if ( a < 0 & a > - 361.0f ) { float qa = r [ i ] . getAz ( ) ; r [ i ] . setAz ( qa + 360.0f ) ; } }


signature:
public class Tools { /** * Show me lots of stuff about the passed in object */
public static void probeObject ( Object o ) { } }

implementation: Class c = o . getClass ( ) ; Class interfaces [ ] = c . getInterfaces ( ) ; Class parent = c . getSuperclass ( ) ; Method m [ ] = c . getMethods ( ) ; System . out . println ( "********* OBJECT PROBE *********" ) ; System . out . println ( "Class Name:  " + c . getName ( ) ) ; System . out . println ( "Super Class: " + parent . getName ( ) ) ; System . out . println ( "Interfaces: " ) ; for ( int i = 0 ; i < interfaces . length ; i ++ ) { System . out . println ( "    " + interfaces [ i ] . getName ( ) ) ; } System . out . println ( "Methods:" ) ; for ( int i = 0 ; i < m . length ; i ++ ) { Class params [ ] = m [ i ] . getParameterTypes ( ) ; Class excepts [ ] = m [ i ] . getExceptionTypes ( ) ; Class ret = m [ i ] . getReturnType ( ) ; System . out . print ( "    " + ret . getName ( ) + "  " + m [ i ] . getName ( ) + "(" ) ; for ( int j = 0 ; j < params . length ; j ++ ) { if ( j > 0 ) System . out . print ( ", " ) ; System . out . print ( params [ j ] . getName ( ) ) ; } System . out . print ( ")  throws " ) ; for ( int j = 0 ; j < excepts . length ; j ++ ) { if ( j > 0 ) System . out . print ( ", " ) ; System . out . print ( excepts [ j ] . getName ( ) ) ; } System . out . println ( "" ) ; } System . out . println ( "******************" ) ;


signature:
public class AggregationTiled { /** * a variable is tiled if any of its dimensions are tiled */
private boolean isTiled ( Variable v ) { } }

implementation: for ( Dimension d : v . getDimensions ( ) ) { for ( Range r : section . getRanges ( ) ) { if ( d . getShortName ( ) . equals ( r . getName ( ) ) ) return true ; } } return false ;


signature:
public class CoordinateTimeAbstract { /** * Implements coverting a " complete best " to a " monotonic best " .
 * The reftime is not allowed to decrease
 * @ return " monotonic best " CoordinateTimeAbstract , based on this one , which is a " complete best " */
public CoordinateTimeAbstract makeBestFromComplete ( ) { } }

implementation: int [ ] best = new int [ time2runtime . length ] ; int last = - 1 ; int count = 0 ; for ( int i = 0 ; i < time2runtime . length ; i ++ ) { int time = time2runtime [ i ] ; if ( time >= last ) { last = time ; best [ i ] = time ; count ++ ; } else { best [ i ] = - 1 ; } } return makeBestFromComplete ( best , count ) ;


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

implementation: result . setLocation ( LatLonPointImpl . lonNormal ( latlon . getLongitude ( ) , centerLon ) , latlon . getLatitude ( ) ) ; return result ;


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

implementation: result . setLongitude ( world . getX ( ) ) ; result . setLatitude ( world . getY ( ) ) ; return result ;


signature:
public class LatLonProjection { /** * Convert projection coordinates to lat / lon coordinate .
 * @ param from array of projection coordinates : from [ 2 ] [ n ] , where
 * ( from [ 0 ] [ i ] , from [ 1 ] [ i ] ) is the ( x , y ) coordinate
 * of the ith point
 * @ param to resulting array of lat / lon coordinates : to [ 2 ] [ n ] where
 * ( to [ 0 ] [ i ] , to [ 1 ] [ i ] ) is the ( lat , lon ) coordinate of
 * the ith point
 * @ return the " to " array */
public float [ ] [ ] projToLatLon ( float [ ] [ ] from , float [ ] [ ] to ) { } }

implementation: float [ ] fromX = from [ INDEX_X ] ; float [ ] fromY = from [ INDEX_Y ] ; to [ INDEX_LAT ] = fromY ; to [ INDEX_LON ] = fromX ; return to ;


signature:
public class LatLonProjection { /** * Convert lat / lon coordinates to projection coordinates .
 * @ param from array of lat / lon coordinates : from [ 2 ] [ n ] , where
 * ( from [ latIndex ] [ i ] , from [ lonIndex ] [ i ] ) is the ( lat , lon )
 * coordinate of the ith point
 * @ param to resulting array of projection coordinates : to [ 2 ] [ n ]
 * where ( to [ 0 ] [ i ] , to [ 1 ] [ i ] ) is the ( x , y ) coordinate of
 * the ith point
 * @ param latIndex index of lat coordinate ; must be 0 or 1
 * @ param lonIndex index of lon coordinate ; must be 0 or 1
 * @ return the " to " array */
public double [ ] [ ] latLonToProj ( double [ ] [ ] from , double [ ] [ ] to , int latIndex , int lonIndex ) { } }

implementation: int cnt = from [ 0 ] . length ; double [ ] toX = to [ INDEX_X ] ; double [ ] toY = to [ INDEX_Y ] ; double [ ] fromLat = from [ latIndex ] ; double [ ] fromLon = from [ lonIndex ] ; double lat , lon ; for ( int i = 0 ; i < cnt ; i ++ ) { lat = fromLat [ i ] ; lon = centerLon + Math . IEEEremainder ( fromLon [ i ] - centerLon , 360.0 ) ; toX [ i ] = lon ; toY [ i ] = lat ; } return to ;


signature:
public class LatLonProjection { /** * Does the line between these two points cross the projection " seam " .
 * @ param pt1 the line goes between these two points
 * @ param pt2 the line goes between these two points
 * @ return false if there is no seam */
public boolean crossSeam ( ProjectionPoint pt1 , ProjectionPoint pt2 ) { } }

implementation: return Math . abs ( pt1 . getX ( ) - pt2 . getX ( ) ) > 270.0 ; // ? ? LOOK : do I believe this


signature:
public class LatLonProjection { /** * Split a latlon rectangle to the equivalent ProjectionRect
 * using this LatLonProjection to split it at the seam if needed .
 * @ param latlonR the latlon rectangle to transform
 * @ return 1 or 2 ProjectionRect . If it doesnt cross the seam ,
 * the second rectangle is null . */
public ProjectionRect [ ] latLonToProjRect ( LatLonRect latlonR ) { } }

implementation: double lat0 = latlonR . getLowerLeftPoint ( ) . getLatitude ( ) ; double height = Math . abs ( latlonR . getUpperRightPoint ( ) . getLatitude ( ) - lat0 ) ; double width = latlonR . getWidth ( ) ; double lon0 = LatLonPointImpl . lonNormal ( latlonR . getLowerLeftPoint ( ) . getLongitude ( ) , centerLon ) ; double lon1 = LatLonPointImpl . lonNormal ( latlonR . getUpperRightPoint ( ) . getLongitude ( ) , centerLon ) ; ProjectionRect [ ] rects = new ProjectionRect [ ] { new ProjectionRect ( ) , new ProjectionRect ( ) } ; if ( lon0 < lon1 ) { rects [ 0 ] . setRect ( lon0 , lat0 , width , height ) ; rects [ 1 ] = null ; } else { double y = centerLon + 180 - lon0 ; rects [ 0 ] . setRect ( lon0 , lat0 , y , height ) ; rects [ 1 ] . setRect ( lon1 - width + y , lat0 , width - y , height ) ; } return rects ;


signature:
public class LatLonProjection { /** * Create a latlon rectangle and split it into the equivalent
 * ProjectionRect using this LatLonProjection . The latlon rect is
 * constructed from 2 lat / lon points . The lon values are considered
 * coords in the latlonProjection , and so do not have to be + / - 180.
 * @ param lat0 lat of point 1
 * @ param lon0 lon of point 1
 * @ param lat1 lat of point 1
 * @ param lon1 lon of point 1
 * @ return 1 or 2 ProjectionRect . If it doesnt cross the seam ,
 * the second rectangle is null . */
public ProjectionRect [ ] latLonToProjRect ( double lat0 , double lon0 , double lat1 , double lon1 ) { } }

implementation:
double height = Math . abs ( lat1 - lat0 ) ; lat0 = Math . min ( lat1 , lat0 ) ; double width = lon1 - lon0 ; if ( width < 1.0e-8 ) { width = 360.0 ; // assume its the whole thing
} lon0 = LatLonPointImpl . lonNormal ( lon0 , centerLon ) ; lon1 = LatLonPointImpl . lonNormal ( lon1 , centerLon ) ; ProjectionRect [ ] rects = new ProjectionRect [ ] { new ProjectionRect ( ) , new ProjectionRect ( ) } ; if ( width >= 360.0 ) { rects [ 0 ] . setRect ( centerLon - 180.0 , lat0 , 360.0 , height ) ; rects [ 1 ] = null ; } else if ( lon0 < lon1 ) { rects [ 0 ] . setRect ( lon0 , lat0 , width , height ) ; rects [ 1 ] = null ; } else { double y = centerLon + 180 - lon0 ; rects [ 0 ] . setRect ( lon0 , lat0 , y , height ) ; rects [ 1 ] . setRect ( lon1 - width + y , lat0 , width - y , height ) ; } return rects ;


signature:
public class AdminDebugController { /** * LOOK change to ResponseEntity < String > */
@ RequestMapping ( method = RequestMethod . GET ) protected void showDebugPage ( HttpServletRequest request , HttpServletResponse response ) throws IOException { } }

implementation:
response . setContentType ( ContentType . html . getContentHeader ( ) ) ; response . setHeader ( "Content-Description" , "thredds_debug" ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; PrintStream pw = new PrintStream ( bos , false , CDM . UTF8 ) ; pw . println ( htmlu . getHtmlDoctypeAndOpenTag ( ) ) ; pw . println ( "" ) ; pw . println ( "<title>THREDDS Debug</title>" ) ; pw . println ( "<meta http-equiv=\"Content-Type\" content=\"text/html\">" ) ; pw . println ( htmlu . getTdsPageCssLink ( ) ) ; pw . println ( htmlu . getGoogleTrackingContent ( ) ) ; pw . println ( "" ) ; pw . println ( "" ) ; pw . println ( htmlu . getOldStyleHeader ( ) ) ; pw . println ( "
Show TDS Logs" ) ; pw . println ( "
Show TDM Logs" ) ; pw . println ( "
Show Tomcat Logs" ) ; pw . println ( "
Show Config Catalogs" ) ; pw . println ( "
Show Spring Controllers" ) ; pw . println ( "
Debug Actions
" ) ; pw . println ( "
" ) ; String cmds = request . getQueryString ( ) ; if ( ( cmds == null ) || ( cmds . length ( ) == 0 ) ) { showDebugActions ( request , pw ) ; } else { StringTokenizer tz = new StringTokenizer ( cmds , ";" ) ; while ( tz . hasMoreTokens ( ) ) { String cmd = tz . nextToken ( ) ; String target = null ; pw . println ( "Cmd= " + cmd ) ; int pos = cmd . indexOf ( '/' ) ; String dhName = "General" ; if ( pos > 0 ) { dhName = cmd . substring ( 0 , pos ) ; cmd = cmd . substring ( pos + 1 ) ; } pos = cmd . indexOf ( '=' ) ; if ( pos >= 0 ) { target = cmd . substring ( pos + 1 ) ; cmd = cmd . substring ( 0 , pos ) ; } DebugCommands . Category dh = debugCommands . findCategory ( dhName ) ; if ( dh == null ) { pw . println ( " Unknown Debug Category=" + dhName + "=" ) ; } else { DebugCommands . Action action = dh . actions . get ( cmd ) ; if ( action == null ) pw . println ( " Unknown action=" + cmd + "=" ) ; else action . doAction ( new DebugCommands . Event ( request , response , pw , bos , target ) ) ; } } } pw . println ( "
" ) ; response . setStatus ( HttpServletResponse . SC_OK ) ; // send it out
PrintWriter responsePS = response . getWriter ( ) ; responsePS . write ( bos . toString ( CDM . UTF8 ) ) ; responsePS . flush ( ) ;


signature:
public class Index5D { /** * experimental : should be package private */
int setDirect ( int v0 , int v1 , int v2 , int v3 , int v4 ) { } }

implementation: return offset + v0 * stride0 + v1 * stride1 + v2 * stride2 + v3 * stride3 + v4 * stride4 ;


signature:
public class AccessLogTable { /** * construct the TImeSeries plot for the list of logs passed in */
private void showTimeSeriesAll ( java . util . List < LogReader . Log > logs ) { } }

implementation:
TimeSeries bytesSentData = new TimeSeries ( "Bytes Sent" , Minute . class ) ; TimeSeries timeTookData = new TimeSeries ( "Average Latency" , Minute . class ) ; TimeSeries nreqData = new TimeSeries ( "Number of Requests" , Minute . class ) ; String intervalS = "5 minute" ; // interval . getText ( ) . trim ( ) ;
// if ( intervalS . length ( ) = = 0 ) intervalS = " 5 minute " ;
long period = 1000 * 60 * 5 ; try { TimeDuration tu = new TimeDuration ( intervalS ) ; period = ( long ) ( 1000 * tu . getValueInSeconds ( ) ) ; } catch ( Exception e ) { System . out . printf ( "Illegal Time interval=%s %n" , intervalS ) ; } long current = 0 ; long bytes = 0 ; long timeTook = 0 ; long total_count = 0 ; long count = 0 ; for ( LogReader . Log log : logs ) { long msecs = log . date ; if ( msecs - current > period ) { if ( current > 0 ) { total_count += count ; addPoint ( bytesSentData , timeTookData , nreqData , new Date ( current ) , bytes , count , timeTook ) ; } bytes = 0 ; count = 0 ; timeTook = 0 ; current = msecs ; } bytes += log . getBytes ( ) ; timeTook += log . getMsecs ( ) ; count ++ ; } if ( count > 0 ) addPoint ( bytesSentData , timeTookData , nreqData , new Date ( current ) , bytes , count , timeTook ) ; total_count += count ; System . out . printf ( "showTimeSeriesAll: total_count = %d logs = %d%n" , total_count , logs . size ( ) ) ; MultipleAxisChart mc = new MultipleAxisChart ( "Access Logs" , intervalS + " average" , "Mbytes Sent" , bytesSentData ) ; mc . addSeries ( "Number of Requests" , nreqData ) ; mc . addSeries ( "Average Latency (secs)" , timeTookData ) ; mc . finish ( new java . awt . Dimension ( 1000 , 1000 ) ) ; // MultipleAxisChart mc = new MultipleAxisChart ( " Bytes Sent " , " 5 min average " , " Mbytes / sec " , bytesSentData ) ;
// Chart c2 = new Chart ( " Average Latency " , " 5 min average " , " Millisecs " , timeTookData ) ;
// Chart c3 = new Chart ( " Number of Requests / sec " , " 5 min average " , " " , nreqData ) ;
timeSeriesPanel . removeAll ( ) ; timeSeriesPanel . add ( mc ) ;


signature:
public class Attribute { /** * Turn a list into a map
 * @ param atts list of attributes
 * @ return map of attributes by name */
static public Map < String , Attribute > makeMap ( List < Attribute > atts ) { } }

implementation: int size = ( atts == null ) ? 1 : atts . size ( ) ; Map < String , Attribute > result = new HashMap < > ( size ) ; if ( atts == null ) return result ; for ( Attribute att : atts ) result . put ( att . getShortName ( ) , att ) ; return result ;


signature:
public class Attribute { /** * Get the value as an Array .
 * @ return Array of values . */
public Array getValues ( ) { } }

implementation: if ( values == null && svalue != null ) { values = Array . factory ( DataType . STRING , new int [ ] { 1 } ) ; values . setObject ( values . getIndex ( ) , svalue ) ; } return values ;


signature:
public class Attribute { /** * Retrieve String value ; only call if isString ( ) is true .
 * @ return String if this is a String valued attribute , else null .
 * @ see Attribute # isString */
public String getStringValue ( ) { } }

implementation: if ( dataType != DataType . STRING ) return null ; return ( svalue != null ) ? svalue : _getStringValue ( 0 ) ;


signature:
public class Attribute { /** * Retrieve a numeric value by index . If it ' s a String , it will try to parse it as a double .
 * @ param index the index into the value array .
 * @ return Number < code > value [ index ] < / code > , or null if its a non - parseable String or
 * the index is out of range . */
public Number getNumericValue ( int index ) { } }

implementation:
if ( ( index < 0 ) || ( index >= nelems ) ) return null ; // LOOK can attributes be enum valued ? for now , no
switch ( dataType ) { case STRING : try { return new Double ( getStringValue ( index ) ) ; } catch ( NumberFormatException e ) { return null ; } case BYTE : case UBYTE : return values . getByte ( index ) ; case SHORT : case USHORT : return values . getShort ( index ) ; case INT : case UINT : return values . getInt ( index ) ; case FLOAT : return values . getFloat ( index ) ; case DOUBLE : return values . getDouble ( index ) ; case LONG : case ULONG : return values . getLong ( index ) ; } return null ;


signature:
public class Attribute { /** * Write CDL representation into f
 * @ param f write into this
 * @ param strict if true , create strict CDL , escaping names */
protected void writeCDL ( Formatter f , boolean strict , String parentname ) { } }

implementation:
if ( strict && ( isString ( ) || this . getEnumType ( ) != null ) ) // Force type explicitly for string .
f . format ( "string " ) ; // note lower case and trailing blank
if ( strict && parentname != null ) f . format ( NetcdfFile . makeValidCDLName ( parentname ) ) ; f . format ( ":" ) ; f . format ( "%s" , strict ? NetcdfFile . makeValidCDLName ( getShortName ( ) ) : getShortName ( ) ) ; if ( isString ( ) ) { f . format ( " = " ) ; for ( int i = 0 ; i < getLength ( ) ; i ++ ) { if ( i != 0 ) f . format ( ", " ) ; String val = getStringValue ( i ) ; if ( val != null ) f . format ( "\"%s\"" , encodeString ( val ) ) ; } } else if ( getEnumType ( ) != null ) { f . format ( " = " ) ; for ( int i = 0 ; i < getLength ( ) ; i ++ ) { if ( i != 0 ) f . format ( ", " ) ; EnumTypedef en = getEnumType ( ) ; String econst = getStringValue ( i ) ; Integer ecint = en . lookupEnumInt ( econst ) ; if ( ecint == null ) throw new ForbiddenConversionException ( "Illegal enum constant: " + econst ) ; f . format ( "\"%s\"" , encodeString ( econst ) ) ; } } else { f . format ( " = " ) ; for ( int i = 0 ; i < getLength ( ) ; i ++ ) { if ( i != 0 ) f . format ( ", " ) ; Number number = getNumericValue ( i ) ; if ( dataType . isUnsigned ( ) ) { // ' number ' is unsigned , but will be treated as signed when we print it below , because Java only has signed
// types . If it is large enough ( > = 2 ^ ( BIT _ WIDTH - 1 ) ) , its most - significant bit will be interpreted as the
// sign bit , which will result in an invalid ( negative ) value being printed . To prevent that , we ' re going
// to widen the number before printing it .
number = DataType . widenNumber ( number ) ; } f . format ( "%s" , number ) ; if ( dataType . isUnsigned ( ) ) { f . format ( "U" ) ; } if ( dataType == DataType . FLOAT ) f . format ( "f" ) ; else if ( dataType == DataType . SHORT || dataType == DataType . USHORT ) { f . format ( "S" ) ; } else if ( dataType == DataType . BYTE || dataType == DataType . UBYTE ) { f . format ( "B" ) ; } else if ( dataType == DataType . LONG || dataType == DataType . ULONG ) { f . format ( "L" ) ; } } }


signature:
public class Attribute { /** * set the value as a String , trimming trailing zeroes
 * @ param val value of Attribute */
private void setStringValue ( String val ) { } }

implementation:
if ( val == null ) throw new IllegalArgumentException ( "Attribute value cannot be null" ) ; // get rid of trailing nul characters
int len = val . length ( ) ; while ( ( len > 0 ) && ( val . charAt ( len - 1 ) == 0 ) ) len -- ; if ( len != val . length ( ) ) val = val . substring ( 0 , len ) ; this . svalue = val ; this . nelems = 1 ; this . dataType = DataType . STRING ; // values = Array . factory ( String . class , new int [ ] { 1 } ) ;
// values . setObject ( values . getIndex ( ) , val ) ;
// setValues ( values ) ;


signature:
public class Attribute { /** * set the values from a list
 * @ param values */
public void setValues ( List values ) { } }

implementation: if ( values == null || values . size ( ) == 0 ) throw new IllegalArgumentException ( "Cannot determine attribute's type" ) ; int n = values . size ( ) ; Class c = values . get ( 0 ) . getClass ( ) ; Object pa ; if ( c == String . class ) { String [ ] va = new String [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( String ) values . get ( i ) ; } else if ( c == Integer . class ) { int [ ] va = new int [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Integer ) values . get ( i ) ; } else if ( c == Double . class ) { double [ ] va = new double [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Double ) values . get ( i ) ; } else if ( c == Float . class ) { float [ ] va = new float [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Float ) values . get ( i ) ; } else if ( c == Short . class ) { short [ ] va = new short [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Short ) values . get ( i ) ; } else if ( c == Byte . class ) { byte [ ] va = new byte [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Byte ) values . get ( i ) ; } else if ( c == Long . class ) { long [ ] va = new long [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Long ) values . get ( i ) ; } else { throw new IllegalArgumentException ( "Unknown type for Attribute = " + c . getName ( ) ) ; } setValues ( Array . factory ( this . dataType , new int [ ] { n } , pa ) ) ;


signature:
public class Attribute { /** * set the values from an Array
 * @ param arr value of Attribute */
public void setValues ( Array arr ) { } }

implementation:
if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( arr == null ) { dataType = DataType . STRING ; return ; } if ( arr . getElementType ( ) == char . class ) { // turn CHAR into STRING
ArrayChar carr = ( ArrayChar ) arr ; if ( carr . getRank ( ) == 1 ) { // common case
svalue = carr . getString ( ) ; this . nelems = 1 ; this . dataType = DataType . STRING ; return ; } // otherwise its an array of Strings
arr = carr . make1DStringArray ( ) ; } // this should be a utility somewhere
if ( arr . getElementType ( ) == ByteBuffer . class ) { // turn OPAQUE into BYTE
int totalLen = 0 ; arr . resetLocalIterator ( ) ; while ( arr . hasNext ( ) ) { ByteBuffer bb = ( ByteBuffer ) arr . next ( ) ; totalLen += bb . limit ( ) ; } byte [ ] ba = new byte [ totalLen ] ; int pos = 0 ; arr . resetLocalIterator ( ) ; while ( arr . hasNext ( ) ) { ByteBuffer bb = ( ByteBuffer ) arr . next ( ) ; System . arraycopy ( bb . array ( ) , 0 , ba , pos , bb . limit ( ) ) ; pos += bb . limit ( ) ; } arr = Array . factory ( DataType . BYTE , new int [ ] { totalLen } , ba ) ; } if ( DataType . getType ( arr ) == DataType . OBJECT ) throw new IllegalArgumentException ( "Cant set Attribute with type " + arr . getElementType ( ) ) ; if ( arr . getRank ( ) > 1 ) arr = arr . reshape ( new int [ ] { ( int ) arr . getSize ( ) } ) ; // make sure 1D
this . values = arr ; this . nelems = ( int ) arr . getSize ( ) ; this . dataType = DataType . getType ( arr ) ;


signature:
public class CollectionLevelScanner { /** * Scan the collection and gather information on contained datasets .
 * @ throws IOException if an I / O error occurs while locating the contained datasets . */
public void scan ( ) throws IOException { } }

implementation:
if ( state == 1 ) throw new IllegalStateException ( "Scan already underway." ) ; if ( state >= 2 ) throw new IllegalStateException ( "Scan has already been generated." ) ; state = 1 ; // Make sure proxyDsHandlers Map is not null .
if ( proxyDsHandlers == null ) proxyDsHandlers = Collections . EMPTY_MAP ; // Create a skeleton catalog .
genCatalog = createSkeletonCatalog ( currentLevel ) ; InvDatasetImpl topInvDs = ( InvDatasetImpl ) genCatalog . getDatasets ( ) . get ( 0 ) ; // Get the datasets in this collection .
List crDsList = currentLevel . listDatasets ( this . filter ) ; // Sort the datasets in this collection .
// @ todo Should we move sort to end of this method ? As is , we can ' t use naming or enhancements to determine sort order .
if ( sorter != null ) sorter . sort ( crDsList ) ; // Add the datasets to the catalog .
for ( int i = 0 ; i < crDsList . size ( ) ; i ++ ) // for ( Iterator it = crDsList . iterator ( ) ; it . hasNext ( ) ; )
{ CrawlableDataset curCrDs = ( CrawlableDataset ) crDsList . get ( i ) ; InvDatasetImpl curInvDs = ( InvDatasetImpl ) createInvDatasetFromCrawlableDataset ( curCrDs , topInvDs , null ) ; // Add dataset info to appropriate lists .
InvCrawlablePair dsInfo = new InvCrawlablePair ( curCrDs , curInvDs ) ; // allDsInfo . add ( dsInfo ) ;
if ( curCrDs . isCollection ( ) ) catRefInfo . add ( dsInfo ) ; else atomicDsInfo . add ( dsInfo ) ; // Add current InvDataset to top dataset .
topInvDs . addDataset ( curInvDs ) ; } // Tie up any loose ends in catalog with finish ( ) .
( ( InvCatalogImpl ) genCatalog ) . finish ( ) ; // Add proxy datasets to list ( only if some atomic datasets in this collection ) .
if ( atomicDsInfo . size ( ) > 0 ) { boolean anyProxiesAdded = false ; for ( Iterator it = proxyDsHandlers . values ( ) . iterator ( ) ; it . hasNext ( ) ; ) { // Get current
ProxyDatasetHandler curProxy = ( ProxyDatasetHandler ) it . next ( ) ; InvService proxyService = curProxy . getProxyDatasetService ( currentLevel ) ; if ( proxyService != null ) { // Create proxy CrawlableDataset and corresponding InvDataset
CrawlableDataset crDsToAdd = curProxy . createProxyDataset ( currentLevel ) ; InvDatasetImpl invDsToAdd = createInvDatasetFromCrawlableDataset ( crDsToAdd , topInvDs , proxyService ) ; // Add dataset info to appropriate lists .
InvCrawlablePair dsInfo = new InvCrawlablePair ( crDsToAdd , invDsToAdd ) ; proxyDsInfo . add ( dsInfo ) ; // Add dataset to catalog
int index = curProxy . getProxyDatasetLocation ( currentLevel , topInvDs . getDatasets ( ) . size ( ) ) ; topInvDs . addDataset ( index , ( InvDatasetImpl ) invDsToAdd ) ; genCatalog . addService ( proxyService ) ; anyProxiesAdded = true ; } } // Tie up any proxy dataset loose ends .
if ( anyProxiesAdded ) ( ( InvCatalogImpl ) genCatalog ) . finish ( ) ; } // Add any top - level metadata .
this . addTopLevelMetadata ( genCatalog , true ) ; state = 2 ; return ;


signature:
public class CollectionLevelScanner { /** * Generate the catalog for a resolver request of the given ProxyDatasetHandler .
 * @ param pdh the ProxyDatasetHandler corresponding to the resolver request .
 * @ return the catalog for a resolver request of the given proxy dataset .
 * @ throws IllegalStateException if this collection has not yet been scanned .
 * @ throws IllegalArgumentException if the given ProxyDatasetHandler is not known by this CollectionLevelScanner . */
public InvCatalogImpl generateProxyDsResolverCatalog ( ProxyDatasetHandler pdh ) { } }

implementation:
if ( state != 2 ) throw new IllegalStateException ( "Scan has not been performed." ) ; if ( ! proxyDsHandlers . containsValue ( pdh ) ) throw new IllegalArgumentException ( "Unknown ProxyDatasetHandler." ) ; // Create a skeleton catalog .
InvCatalogImpl catalog = createSkeletonCatalog ( currentLevel ) ; InvDatasetImpl topDs = ( InvDatasetImpl ) catalog . getDatasets ( ) . get ( 0 ) ; // Find actual dataset in the list of atomic dataset InvCrawlablePairs .
InvCrawlablePair actualDsInfo = pdh . getActualDataset ( atomicDsInfo ) ; if ( actualDsInfo == null ) return catalog ; // TODO Test this case in TestDataRootHandler .
InvDatasetImpl actualInvDs = ( InvDatasetImpl ) actualDsInfo . getInvDataset ( ) ; actualInvDs . setName ( pdh . getActualDatasetName ( actualDsInfo , topDs . getName ( ) ) ) ; // Add current InvDataset to top dataset .
catalog . removeDataset ( topDs ) ; catalog . addDataset ( actualInvDs ) ; // topDs . addDataset ( actualInvDs ) ;
// Finish catalog .
catalog . finish ( ) ; // Add any top - level metadata .
this . addTopLevelMetadata ( catalog , false ) ; return catalog ;


signature:
public class CollectionLevelScanner { /** * - baseID + " / " + node . getPath ( ) . substring ( collectionLevel . length ) [ when ID added at catalog construction using node info ] */
private String getID ( CrawlableDataset dataset ) { } }

implementation: if ( dataset == null ) return null ; if ( collectionId == null ) return null ; int i = collectionLevel . getPath ( ) . length ( ) ; String id = dataset . getPath ( ) . substring ( i ) ; if ( id . startsWith ( "/" ) ) id = id . substring ( 1 ) ; if ( collectionId . equals ( "" ) ) { if ( id . equals ( "" ) ) return null ; return id ; } if ( id . equals ( "" ) ) return collectionId ; return ( collectionId + "/" + id ) ;


signature:
public class CollectionLevelScanner { /** * - collectionPath + " / " + node . getPath ( ) . substring ( collectionLevel . length ) [ when service is absolute ( i . e . , relative to collection ) ] */
private String getUrlPath ( CrawlableDataset dataset , InvService service ) { } }

implementation:
InvService serviceForThisDs = service != null ? service : this . service ; if ( serviceForThisDs . getBase ( ) . equals ( "" ) && ! serviceForThisDs . getServiceType ( ) . equals ( ServiceType . COMPOUND ) ) { // Service is relative to the catalog URL .
String urlPath = dataset . getPath ( ) . substring ( catalogLevel . getPath ( ) . length ( ) ) ; if ( urlPath . startsWith ( "/" ) ) urlPath = urlPath . substring ( 1 ) ; return urlPath ; } else { if ( serviceForThisDs . isRelativeBase ( ) ) { // Service is relative to the collection root .
String relPath = dataset . getPath ( ) . substring ( collectionLevel . getPath ( ) . length ( ) ) ; if ( relPath . startsWith ( "/" ) ) relPath = relPath . substring ( 1 ) ; return ( ( collectionPath . equals ( "" ) ? "" : collectionPath + "/" ) + relPath ) ; } else { // Service base URI is Absolute so don ' t use collectionPath .
String relPath = dataset . getPath ( ) . substring ( collectionLevel . getPath ( ) . length ( ) ) ; if ( relPath . startsWith ( "/" ) ) relPath = relPath . substring ( 1 ) ; return relPath ; } }


signature:
public class CollectionLevelScanner { /** * - node . getPath ( ) . substring ( catalogLevel . length ) + " / catalog . xml " */
private String getXlinkHref ( CrawlableDataset dataset ) { } }

implementation:
// @ todo Remove alias until sure how to handle things like " . scour * " being a regular file .
// if ( ! CrawlableDatasetAlias . isAlias ( catalogLevel . getPath ( ) ) )
String path = dataset . getPath ( ) . substring ( catalogLevel . getPath ( ) . length ( ) ) ; if ( path . startsWith ( "/" ) ) path = path . substring ( 1 ) ; if ( path . endsWith ( "/" ) ) path += "catalog.xml" ; else path += "/catalog.xml" ; return CatalogUtils . escapePathForURL ( path ) ; // else
// / / @ todo Move this functionality into CrawlableDatasetAlias
// String path = dataset . getPath ( ) ;
// int curIndex = path . length ( ) ;
// int numSegments = catalogLevel . getName ( ) . split ( " / " ) . length ;
// for ( int i = 0 ; i < numSegments ; i + + )
// curIndex = dataset . getPath ( ) . lastIndexOf ( " / " , curIndex - 1 ) ;
// return ( dataset . getPath ( ) . substring ( curIndex + 1 ) + " / catalog . xml " ) ;


signature:
public class PointStream { /** * Caller must iter . finish ( ) and out . close ( ) . */
public static int write ( OutputStream out , PointFeatureIterator pointFeatIter , String name , String timeUnitString , String altUnits ) throws IOException { } }

implementation: int numWritten = 0 ; while ( pointFeatIter . hasNext ( ) ) { try { PointFeature pointFeat = pointFeatIter . next ( ) ; if ( numWritten == 0 ) { PointStreamProto . PointFeatureCollection protoPfc = PointStream . encodePointFeatureCollection ( name , timeUnitString , altUnits , pointFeat ) ; byte [ ] data = protoPfc . toByteArray ( ) ; PointStream . writeMagic ( out , MessageType . PointFeatureCollection ) ; NcStream . writeVInt ( out , data . length ) ; out . write ( data ) ; } PointStreamProto . PointFeature protoPointFeat = PointStream . encodePointFeature ( pointFeat ) ; byte [ ] data = protoPointFeat . toByteArray ( ) ; PointStream . writeMagic ( out , MessageType . PointFeature ) ; NcStream . writeVInt ( out , data . length ) ; out . write ( data ) ; ++ numWritten ; } catch ( Throwable t ) { NcStreamProto . Error protoError = NcStream . encodeErrorMessage ( t . getMessage ( ) != null ? t . getMessage ( ) : t . getClass ( ) . getName ( ) ) ; byte [ ] data = protoError . toByteArray ( ) ; PointStream . writeMagic ( out , PointStream . MessageType . Error ) ; NcStream . writeVInt ( out , data . length ) ; out . write ( data ) ; throw new IOException ( t ) ; } } PointStream . writeMagic ( out , PointStream . MessageType . End ) ; return numWritten ;


signature:
public class MessageWriter { /** * put a message on the queue , schedule writing if not already scheduled . */
void scheduleWrite ( Message m ) { } }

implementation: q . add ( m ) ; if ( ! isScheduled . getAndSet ( true ) ) { executor . submit ( this ) ; }


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

implementation: if ( _Debug ) System . out . println ( "asciiGrid.toASCII(" + addName + ",'" + rootName + "')  getName(): " + getEncodedName ( ) ) ; if ( rootName != null ) rootName += "." + getEncodedName ( ) ; else rootName = getEncodedName ( ) ; boolean firstPass = true ; Enumeration e = getVariables ( ) ; while ( e . hasMoreElements ( ) ) { toASCII ta = ( toASCII ) e . nextElement ( ) ; if ( ! newLine && ! firstPass ) pw . print ( ", " ) ; ta . toASCII ( pw , addName , rootName , newLine ) ; firstPass = false ; } if ( newLine ) pw . print ( "\n" ) ;


signature:
public class ToolsUI { /** * deferred creation of components to minimize startup */
public void makeComponent ( JTabbedPane parent , final String title ) { } }

implementation:
if ( parent == null ) { parent = tabbedPane ; } // find the correct index
int n = parent . getTabCount ( ) ; int idx ; for ( idx = 0 ; idx < n ; idx ++ ) { String cTitle = parent . getTitleAt ( idx ) ; if ( cTitle . equals ( title ) ) break ; } if ( idx >= n ) { log . debug ( "Cant find {} in {}" , title , parent ) ; return ; } Component c ; switch ( title ) { case "Aggregation" : aggPanel = new AggPanel ( ( PreferencesExt ) mainPrefs . node ( "NcMLAggregation" ) ) ; c = aggPanel ; break ; case "BUFR" : bufrPanel = new BufrPanel ( ( PreferencesExt ) mainPrefs . node ( "bufr" ) ) ; c = bufrPanel ; break ; case "BUFRTableB" : bufrTableBPanel = new BufrTableBPanel ( ( PreferencesExt ) mainPrefs . node ( "bufr2" ) ) ; c = bufrTableBPanel ; break ; case "BUFRTableD" : bufrTableDPanel = new BufrTableDPanel ( ( PreferencesExt ) mainPrefs . node ( "bufrD" ) ) ; c = bufrTableDPanel ; break ; case "BufrReports" : { PreferencesExt prefs = ( PreferencesExt ) mainPrefs . node ( "bufrReports" ) ; ReportPanel rp = new BufrReportPanel ( prefs ) ; bufrReportPanel = new ReportOpPanel ( prefs , rp ) ; c = bufrReportPanel ; break ; } case "BUFR-CODES" : bufrCodePanel = new BufrCodePanel ( ( PreferencesExt ) mainPrefs . node ( "bufr-codes" ) ) ; c = bufrCodePanel ; break ; case "CdmrFeature" : cdmremotePanel = new CdmrFeatureOpPanel ( ( PreferencesExt ) mainPrefs . node ( "CdmrFeature" ) ) ; c = cdmremotePanel ; break ; case "CollectionSpec" : fcPanel = new CollectionSpecPanel ( ( PreferencesExt ) mainPrefs . node ( "collSpec" ) ) ; c = fcPanel ; break ; case "DirectoryPartition" : dirPartPanel = new DirectoryPartitionPanel ( ( PreferencesExt ) mainPrefs . node ( "dirPartition" ) ) ; c = dirPartPanel ; break ; case "NcStream" : ncStreamPanel = new NcStreamOpPanel ( ( PreferencesExt ) mainPrefs . node ( "NcStream" ) ) ; c = ncStreamPanel ; break ; case "GRIB1collection" : grib1CollectionPanel = new Grib1CollectionOpPanel ( ( PreferencesExt ) mainPrefs . node ( "grib1raw" ) ) ; c = grib1CollectionPanel ; break ; case "GRIB1data" : grib1DataPanel = new Grib1DataOpPanel ( ( PreferencesExt ) mainPrefs . node ( "grib1Data" ) ) ; c = grib1DataPanel ; break ; case "GRIB-FILES" : gribFilesPanel = new GribFilesOpPanel ( ( PreferencesExt ) mainPrefs . node ( "gribFiles" ) ) ; c = gribFilesPanel ; break ; case "GRIB2collection" : grib2CollectionPanel = new Grib2CollectionOpPanel ( ( PreferencesExt ) mainPrefs . node ( "gribNew" ) ) ; c = grib2CollectionPanel ; break ; case "GRIB2data" : grib2DataPanel = new Grib2DataOpPanel ( ( PreferencesExt ) mainPrefs . node ( "grib2Data" ) ) ; c = grib2DataPanel ; break ; case "BufrCdmIndex" : bufrCdmIndexPanel = new BufrCdmIndexOpPanel ( ( PreferencesExt ) mainPrefs . node ( "bufrCdmIdx" ) ) ; c = bufrCdmIndexPanel ; /* } else if ( title . equals ( " CdmIndex " ) ) {
 gribCdmIndexPanel = new GribCdmIndexPanel ( ( PreferencesExt ) mainPrefs . node ( " cdmIdx " ) ) ;
 c = gribCdmIndexPanel ; */
break ; case "CdmIndex4" : cdmIndexPanel = new CdmIndexOpPanel ( ( PreferencesExt ) mainPrefs . node ( "cdmIdx3" ) ) ; c = cdmIndexPanel ; break ; case "CdmIndexReport" : { PreferencesExt prefs = ( PreferencesExt ) mainPrefs . node ( "CdmIndexReport" ) ; ReportPanel rp = new CdmIndexReportPanel ( prefs ) ; cdmIndexReportPanel = new ReportOpPanel ( prefs , rp ) ; c = cdmIndexReportPanel ; break ; } case "GribIndex" : gribIdxPanel = new GribIndexOpPanel ( ( PreferencesExt ) mainPrefs . node ( "gribIdx" ) ) ; c = gribIdxPanel ; break ; case "GRIB1-REPORT" : { PreferencesExt prefs = ( PreferencesExt ) mainPrefs . node ( "grib1Report" ) ; ReportPanel rp = new Grib1ReportPanel ( prefs ) ; grib1ReportPanel = new ReportOpPanel ( prefs , rp ) ; c = grib1ReportPanel ; break ; } case "GRIB2-REPORT" : { PreferencesExt prefs = ( PreferencesExt ) mainPrefs . node ( "gribReport" ) ; ReportPanel rp = new Grib2ReportPanel ( prefs ) ; grib2ReportPanel = new ReportOpPanel ( prefs , rp ) ; c = grib2ReportPanel ; break ; } case "WMO-COMMON" : wmoCommonCodePanel = new WmoCCPanel ( ( PreferencesExt ) mainPrefs . node ( "wmo-common" ) ) ; c = wmoCommonCodePanel ; break ; case "WMO-CODES" : gribCodePanel = new GribCodePanel ( ( PreferencesExt ) mainPrefs . node ( "wmo-codes" ) ) ; c = gribCodePanel ; break ; case "WMO-TEMPLATES" : gribTemplatePanel = new GribTemplatePanel ( ( PreferencesExt ) mainPrefs . node ( "wmo-templates" ) ) ; c = gribTemplatePanel ; break ; case "GRIB1-TABLES" : grib1TablePanel = new Grib1TablePanel ( ( PreferencesExt ) mainPrefs . node ( "grib1-tables" ) ) ; c = grib1TablePanel ; break ; case "GRIB2-TABLES" : grib2TablePanel = new Grib2TablePanel ( ( PreferencesExt ) mainPrefs . node ( "grib2-tables" ) ) ; c = grib2TablePanel ; break ; case "GRIB-Rewrite" : gribRewritePanel = new GribRewriteOpPanel ( ( PreferencesExt ) mainPrefs . node ( "grib-rewrite" ) ) ; c = gribRewritePanel ; break ; case "CoordSys" : coordSysPanel = new CoordSysPanel ( ( PreferencesExt ) mainPrefs . node ( "CoordSys" ) ) ; c = coordSysPanel ; break ; case "FeatureScan" : ftPanel = new FeatureScanPanel ( ( PreferencesExt ) mainPrefs . node ( "ftPanel" ) ) ; c = ftPanel ; break ; case "GeoTiff" : geotiffPanel = new GeotiffPanel ( ( PreferencesExt ) mainPrefs . node ( "WCS" ) ) ; c = geotiffPanel ; break ; case "Grids" : gridPanel = new GeoGridPanel ( ( PreferencesExt ) mainPrefs . node ( "grid" ) ) ; c = gridPanel ; break ; case "SimpleGeometry" : simpleGeomPanel = new SimpleGeomPanel ( ( PreferencesExt ) mainPrefs . node ( "simpleGeom" ) ) ; c = simpleGeomPanel ; break ; case "Coverages" : coveragePanel = new CoveragePanel ( ( PreferencesExt ) mainPrefs . node ( "coverage2" ) ) ; c = coveragePanel ; break ; case "HDF5-Objects" : hdf5ObjectPanel = new Hdf5ObjectPanel ( ( PreferencesExt ) mainPrefs . node ( "hdf5" ) ) ; c = hdf5ObjectPanel ; break ; case "HDF5-Data" : hdf5DataPanel = new Hdf5DataPanel ( ( PreferencesExt ) mainPrefs . node ( "hdf5data" ) ) ; c = hdf5DataPanel ; break ; case "Netcdf4-JNI" : nc4viewer = new DatasetViewerPanel ( ( PreferencesExt ) mainPrefs . node ( "nc4viewer" ) , true ) ; c = nc4viewer ; break ; case "HDF4" : hdf4Panel = new Hdf4Panel ( ( PreferencesExt ) mainPrefs . node ( "hdf4" ) ) ; c = hdf4Panel ; break ; case "Images" : imagePanel = new ImagePanel ( ( PreferencesExt ) mainPrefs . node ( "images" ) ) ; c = imagePanel ; break ; case "Fmrc" : fmrcPanel = new FmrcPanel ( ( PreferencesExt ) mainPrefs . node ( "fmrc2" ) ) ; c = fmrcPanel ; break ; case "Collections" : fmrcCollectionPanel = new FmrcCollectionPanel ( ( PreferencesExt ) mainPrefs . node ( "collections" ) ) ; c = fmrcCollectionPanel ; break ; case "NCDump" : ncdumpPanel = new NCdumpPanel ( ( PreferencesExt ) mainPrefs . node ( "NCDump" ) ) ; c = ncdumpPanel ; break ; case "NcmlEditor" : ncmlEditorPanel = new NcmlEditorPanel ( ( PreferencesExt ) mainPrefs . node ( "NcmlEditor" ) ) ; c = ncmlEditorPanel ; break ; case "PointFeature" : pointFeaturePanel = new PointFeaturePanel ( ( PreferencesExt ) mainPrefs . node ( "pointFeature" ) ) ; c = pointFeaturePanel ; break ; case "Radial" : radialPanel = new RadialPanel ( ( PreferencesExt ) mainPrefs . node ( "radial" ) ) ; c = radialPanel ; break ; case "StationRadial" : stationRadialPanel = new StationRadialPanel ( ( PreferencesExt ) mainPrefs . node ( "stationRadar" ) ) ; c = stationRadialPanel ; break ; case "THREDDS" : threddsUI = new ThreddsUI ( parentFrame , ( PreferencesExt ) mainPrefs . node ( "thredds" ) ) ; threddsUI . addPropertyChangeListener ( new PropertyChangeListener ( ) { public void propertyChange ( PropertyChangeEvent e ) { if ( e . getPropertyName ( ) . equals ( "InvAccess" ) ) { thredds . client . catalog . Access access = ( thredds . client . catalog . Access ) e . getNewValue ( ) ; jumptoThreddsDatatype ( access ) ; } if ( e . getPropertyName ( ) . equals ( "Dataset" ) || e . getPropertyName ( ) . equals ( "CoordSys" ) || e . getPropertyName ( ) . equals ( "File" ) ) { thredds . client . catalog . Dataset ds = ( thredds . client . catalog . Dataset ) e . getNewValue ( ) ; setThreddsDatatype ( ds , e . getPropertyName ( ) ) ; } } } ) ; c = threddsUI ; break ; case "Units" : unitsPanel = new UnitsPanel ( ( PreferencesExt ) mainPrefs . node ( "units" ) ) ; c = unitsPanel ; break ; case "URLdump" : urlPanel = new URLDumpPane ( ( PreferencesExt ) mainPrefs . node ( "urlDump" ) ) ; c = urlPanel ; break ; case "Viewer" : c = viewerPanel ; break ; case "Writer" : writerPanel = new DatasetWriterPanel ( ( PreferencesExt ) mainPrefs . node ( "writer" ) ) ; c = writerPanel ; break ; case "WMS" : wmsPanel = new WmsPanel ( ( PreferencesExt ) mainPrefs . node ( "wms" ) ) ; c = wmsPanel ; break ; default : log . warn ( "tabbedPane unknown component {}" , title ) ; return ; } parent . setComponentAt ( idx , c ) ; log . trace ( "tabbedPane changed {} added " , title ) ;


signature:
public class ToolsUI { /** * Jump to the appropriate tab based on datatype of InvDataset */
private void setThreddsDatatype ( thredds . client . catalog . Dataset invDataset , String wants ) { } }

implementation:
if ( invDataset == null ) return ; boolean wantsViewer = wants . equals ( "File" ) ; boolean wantsCoordSys = wants . equals ( "CoordSys" ) ; try { // just open as a NetcdfDataset
if ( wantsViewer ) { openNetcdfFile ( threddsDataFactory . openDataset ( invDataset , true , null , null ) ) ; return ; } if ( wantsCoordSys ) { NetcdfDataset ncd = threddsDataFactory . openDataset ( invDataset , true , null , null ) ; ncd . enhance ( ) ; // make sure its enhanced
openCoordSystems ( ncd ) ; return ; } // otherwise do the datatype thing
DataFactory . Result threddsData = threddsDataFactory . openFeatureDataset ( invDataset , null ) ; if ( threddsData . fatalError ) { JOptionPane . showMessageDialog ( null , "Failed to open err=" + threddsData . errLog ) ; return ; } jumptoThreddsDatatype ( threddsData ) ; } catch ( IOException ioe ) { JOptionPane . showMessageDialog ( null , "Error on setThreddsDatatype = " + ioe . getMessage ( ) ) ; ioe . printStackTrace ( ) ; }


signature:
public class ToolsUI { /** * jump to the appropriate tab based on datatype of InvAccess */
private void jumptoThreddsDatatype ( thredds . client . catalog . Access invAccess ) { } }

implementation:
if ( invAccess == null ) { return ; } thredds . client . catalog . Service s = invAccess . getService ( ) ; if ( s . getType ( ) == ServiceType . HTTPServer ) { downloadFile ( invAccess . getStandardUrlName ( ) ) ; return ; } if ( s . getType ( ) == ServiceType . WMS ) { openWMSDataset ( invAccess . getStandardUrlName ( ) ) ; return ; } if ( s . getType ( ) == ServiceType . CdmrFeature ) { openCoverageDataset ( invAccess . getWrappedUrlName ( ) ) ; return ; } thredds . client . catalog . Dataset ds = invAccess . getDataset ( ) ; if ( ds . getFeatureType ( ) == null ) { // if no feature type , just open as a NetcdfDataset
try { openNetcdfFile ( threddsDataFactory . openDataset ( invAccess , true , null , null ) ) ; } catch ( IOException ioe ) { JOptionPane . showMessageDialog ( null , "Error on setThreddsDatatype = " + ioe . getMessage ( ) ) ; } return ; } DataFactory . Result threddsData = null ; try { threddsData = threddsDataFactory . openFeatureDataset ( invAccess , null ) ; if ( threddsData . fatalError ) { JOptionPane . showMessageDialog ( null , "Failed to open err=" + threddsData . errLog ) ; return ; } jumptoThreddsDatatype ( threddsData ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; JOptionPane . showMessageDialog ( null , "Error on setThreddsDatatype = " + ioe . getMessage ( ) ) ; if ( threddsData != null ) { try { threddsData . close ( ) ; } catch ( IOException ioe2 ) { // Okay to fall through ?
} } }


signature:
public class ToolsUI { /** * Jump to the appropriate tab based on datatype of threddsData */
private void jumptoThreddsDatatype ( DataFactory . Result threddsData ) { } }

implementation: if ( threddsData . fatalError ) { JOptionPane . showMessageDialog ( this , "Cant open dataset=" + threddsData . errLog ) ; try { threddsData . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return ; } if ( threddsData . featureType . isCoverageFeatureType ( ) ) { if ( threddsData . featureDataset instanceof FeatureDatasetCoverage ) { makeComponent ( ftTabPane , "Coverages" ) ; coveragePanel . setDataset ( threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( coveragePanel ) ; } else if ( threddsData . featureDataset instanceof GridDataset ) { makeComponent ( ftTabPane , "Grids" ) ; gridPanel . setDataset ( ( GridDataset ) threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( gridPanel ) ; } } else if ( threddsData . featureType == FeatureType . IMAGE ) { makeComponent ( ftTabPane , "Images" ) ; imagePanel . setImageLocation ( threddsData . imageURL ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( imagePanel ) ; } else if ( threddsData . featureType == FeatureType . RADIAL ) { makeComponent ( ftTabPane , "Radial" ) ; radialPanel . setDataset ( ( RadialDatasetSweep ) threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( radialPanel ) ; } else if ( threddsData . featureType . isPointFeatureType ( ) ) { makeComponent ( ftTabPane , "PointFeature" ) ; pointFeaturePanel . setPointFeatureDataset ( ( PointDatasetImpl ) threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( pointFeaturePanel ) ; } else if ( threddsData . featureType == FeatureType . STATION_RADIAL ) { makeComponent ( ftTabPane , "StationRadial" ) ; stationRadialPanel . setStationRadialDataset ( threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( stationRadialPanel ) ; }


signature:
public class ToolsUI { /** * Handle messages . */
private static void setDataset ( ) { } }

implementation:
// do it in the swing event thread
SwingUtilities . invokeLater ( ( ) -> { int pos = wantDataset . indexOf ( '#' ) ; if ( pos > 0 ) { final String catName = wantDataset . substring ( 0 , pos ) ; // { catalog } # { dataset }
if ( catName . endsWith ( ".xml" ) ) { ui . makeComponent ( null , "THREDDS" ) ; ui . threddsUI . setDataset ( wantDataset ) ; ui . tabbedPane . setSelectedComponent ( ui . threddsUI ) ; } return ; } // default
ui . openNetcdfFile ( wantDataset ) ; } ) ;


signature:
public class ToolsUI { /** * Set look - and - feel . */
private static void prepareGui ( ) { } }

implementation:
final String osName = System . getProperty ( "os.name" ) . toLowerCase ( ) ; final boolean isMacOs = osName . startsWith ( "mac os x" ) ; if ( isMacOs ) { System . setProperty ( "apple.laf.useScreenMenuBar" , "true" ) ; // fixes the case on macOS where users use the system menu option to quit rather than
// closing a window using the ' x ' button .
Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ) { @ Override public void run ( ) { doSavePrefsAndUI ( ) ; } } ) ; } else { // Not macOS , so try applying Nimbus L & F , if available .
try { for ( UIManager . LookAndFeelInfo info : UIManager . getInstalledLookAndFeels ( ) ) { if ( "Nimbus" . equals ( info . getName ( ) ) ) { UIManager . setLookAndFeel ( info . getClassName ( ) ) ; break ; } } } catch ( Exception exc ) { log . warn ( "Unable to apply Nimbus look-and-feel due to {}" , exc . toString ( ) ) ; if ( log . isTraceEnabled ( ) ) { exc . printStackTrace ( ) ; } } } // misc Gui initialization ( s )
BAMutil . setResourcePath ( "/resources/nj22/ui/icons/" ) ; // Setting up a font metrics object triggers one of the most time - wasting steps of GUI set up .
// We do it now before trying to create the splash or tools interface .
SwingUtilities . invokeLater ( ( ) -> { final Toolkit tk = Toolkit . getDefaultToolkit ( ) ; final Font f = new Font ( "SansSerif" , Font . PLAIN , 12 ) ; @ SuppressWarnings ( "deprecation" ) final FontMetrics fm = tk . getFontMetrics ( f ) ; } ) ;


signature:
public class ToolsUI { /** * Must call this method on the event thread . */
private static void createToolsFrame ( ) { } }

implementation:
// put UI in a JFrame
frame = new JFrame ( "NetCDF (" + DIALOG_VERSION + ") Tools" ) ; ui = new ToolsUI ( prefs , frame ) ; frame . setIconImage ( BAMutil . getImage ( "netcdfUI" ) ) ; frame . addWindowListener ( new WindowAdapter ( ) { @ Override public void windowActivated ( final WindowEvent e ) { ToolsSplashScreen . getSharedInstance ( ) . setVisible ( false ) ; } @ Override public void windowClosing ( final WindowEvent e ) { if ( ! done ) { exit ( ) ; } } } ) ; frame . getContentPane ( ) . add ( ui ) ; final Rectangle have = frame . getGraphicsConfiguration ( ) . getBounds ( ) ; final Rectangle def = new Rectangle ( 50 , 50 , 800 , 800 ) ; Rectangle want = ( Rectangle ) prefs . getBean ( FRAME_SIZE , def ) ; if ( want . getX ( ) > have . getWidth ( ) - 25 ) { // may be off screen when switcing between 2 monitor system
want = def ; } frame . setBounds ( want ) ; frame . pack ( ) ; frame . setBounds ( want ) ; // in case a dataset was on the command line
if ( wantDataset != null ) { setDataset ( ) ; }


signature:
public class DodsDirDatasetSource { /** * Build an unnamed InvCatalog for this DatasetSource and return the
 * top - level InvDataset . The ResultService for this DatasetSource is
 * used to create the InvService for the new InvCatalog . Each InvDataset
 * in the catalog is named with the location of the object they represent
 * on the dataset source .
 * @ return the top - level dataset of the newly constructed InvCatalog .
 * @ throws java . io . IOException if top - level dataset does not exist or is not a collection dataset . */
protected InvCatalog createSkeletonCatalog ( String prefixUrlPath ) throws IOException { } }

implementation:
String aphString = this . getResultService ( ) . getAccessPointHeader ( ) ; String apString = this . getAccessPoint ( ) ; // Check that accessPoint URL starts with accessPointHeader .
if ( ! apString . startsWith ( aphString ) ) throw new IOException ( "The accessPoint <" + apString + "> must start with the accessPointHeader <" + aphString + ">." ) ; // Check that accessPoint URL ends with a slash ( " / " ) .
if ( ! apString . endsWith ( "/" ) ) throw new IOException ( "The accessPoint URL must end with a \"/\" <" + apString + ">." ) ; // Check that accessPoint URL is an OPeNDAP server URL .
String apVersionString = apString + "version" ; String apVersionResultContent = null ; try { apVersionResultContent = urlExtractor . getTextContent ( apVersionString ) ; } catch ( java . io . IOException e ) { String tmpMsg = "The accessPoint URL is not an OPeNDAP server URL (no version info) <" + apVersionString + ">" ; log . error ( "expandThisType(): " + tmpMsg , e ) ; IOException myE = new IOException ( tmpMsg + e . getMessage ( ) ) ; myE . initCause ( e ) ; throw ( myE ) ; } if ( apVersionResultContent . indexOf ( "DODS" ) == - 1 && apVersionResultContent . indexOf ( "OPeNDAP" ) == - 1 && apVersionResultContent . indexOf ( "DAP" ) == - 1 ) { String tmpMsg = "The accessPoint URL version info is not valid <" + apVersionResultContent + ">" ; log . error ( "expandThisType(): " + tmpMsg ) ; throw new IOException ( tmpMsg ) ; } // Some setup stuff
try { accessPointHeaderUri = new URI ( aphString ) ; } catch ( URISyntaxException e ) { throw new IOException ( "The accessPointHeader URL failed to map to a URI <" + aphString + ">." ) ; } // Create catalog .
InvCatalogImpl catalog = new InvCatalogImpl ( null , null , null ) ; // this . getName ( ) , null , null ) ;
// Create service .
InvService service = new InvService ( this . getResultService ( ) . getName ( ) , this . getResultService ( ) . getServiceType ( ) . toString ( ) , this . getResultService ( ) . getBase ( ) , this . getResultService ( ) . getSuffix ( ) , this . getResultService ( ) . getDescription ( ) ) ; for ( Iterator it = this . getResultService ( ) . getProperties ( ) . iterator ( ) ; it . hasNext ( ) ; ) { service . addProperty ( ( InvProperty ) it . next ( ) ) ; } for ( Iterator it = this . getResultService ( ) . getServices ( ) . iterator ( ) ; it . hasNext ( ) ; ) { service . addService ( ( InvService ) it . next ( ) ) ; } // Add service to catalog .
catalog . addService ( service ) ; // Create top - level dataset .
DodsDirInvDataset topDs = null ; try { topDs = new DodsDirInvDataset ( null , new URI ( apString ) ) ; } catch ( URISyntaxException e ) { throw new IOException ( "The accessPoint URL failed to map to a URI <" + apString + ">." ) ; } // Set the serviceName ( inherited by all datasets ) in top - level dataset .
ThreddsMetadata tm = new ThreddsMetadata ( false ) ; tm . setServiceName ( service . getName ( ) ) ; InvMetadata md = new InvMetadata ( topDs , null , XMLEntityResolver . CATALOG_NAMESPACE_10 , "" , true , true , null , tm ) ; ThreddsMetadata tm2 = new ThreddsMetadata ( false ) ; tm2 . addMetadata ( md ) ; topDs . setLocalMetadata ( tm2 ) ; // Add top - level dataset to catalog .
catalog . addDataset ( topDs ) ; // Tie up any loose ends in catalog with finish ( ) .
( ( InvCatalogImpl ) catalog ) . finish ( ) ; return ( catalog ) ;