signature:
public class BufrCdmIndex { /** * MAGIC _ START
 * version
 * sizeIndex
 * BufrCdmIndexProto ( sizeIndex bytes ) */
private boolean writeIndex2 ( String bufrFilename , BufrConfig config , File indexFile ) throws IOException { } }

implementation:
if ( indexFile . exists ( ) ) { if ( ! indexFile . delete ( ) ) log . warn ( " BufrCdmIndex cant delete index file {}" , indexFile . getPath ( ) ) ; } log . debug ( " createIndex for {}" , indexFile . getPath ( ) ) ; try ( RandomAccessFile raf = new RandomAccessFile ( indexFile . getPath ( ) , "rw" ) ) { raf . order ( RandomAccessFile . BIG_ENDIAN ) ; // / / header message
raf . write ( MAGIC_START . getBytes ( CDM . utf8Charset ) ) ; raf . writeInt ( version ) ; // build it
BufrCdmIndexProto . BufrIndex . Builder indexBuilder = BufrCdmIndexProto . BufrIndex . newBuilder ( ) ; indexBuilder . setFilename ( bufrFilename ) ; root = buildField ( config . getRootConverter ( ) ) ; indexBuilder . setRoot ( root ) ; indexBuilder . setStart ( config . getStart ( ) ) ; indexBuilder . setEnd ( config . getEnd ( ) ) ; indexBuilder . setNobs ( config . getNobs ( ) ) ; Map < String , BufrConfig . BufrStation > smaps = config . getStationMap ( ) ; if ( smaps != null ) { List < BufrConfig . BufrStation > stations = new ArrayList < BufrConfig . BufrStation > ( smaps . values ( ) ) ; Collections . sort ( stations ) ; for ( BufrConfig . BufrStation s : stations ) { indexBuilder . addStations ( buildStation ( s ) ) ; } } // write it
BufrCdmIndexProto . BufrIndex index = indexBuilder . build ( ) ; byte [ ] b = index . toByteArray ( ) ; NcStream . writeVInt ( raf , b . length ) ; // message size
raf . write ( b ) ; // message - all in one gulp
log . debug ( "  file size =  %d bytes" , raf . length ( ) ) ; return true ; }


signature:
public class ArrayDouble { /** * / * Create new ArrayDouble with given indexImpl and backing store .
 * Should be private .
 * @ param index use this Index
 * @ param stor . use this storage . if null , allocate .
 * @ return . new ArrayDouble . D < rank > or ArrayDouble object . */
static ArrayDouble factory ( Index index , double [ ] storage ) { } }

implementation: if ( index instanceof Index0D ) { return new ArrayDouble . D0 ( index , storage ) ; } else if ( index instanceof Index1D ) { return new ArrayDouble . D1 ( index , storage ) ; } else if ( index instanceof Index2D ) { return new ArrayDouble . D2 ( index , storage ) ; } else if ( index instanceof Index3D ) { return new ArrayDouble . D3 ( index , storage ) ; } else if ( index instanceof Index4D ) { return new ArrayDouble . D4 ( index , storage ) ; } else if ( index instanceof Index5D ) { return new ArrayDouble . D5 ( index , storage ) ; } else if ( index instanceof Index6D ) { return new ArrayDouble . D6 ( index , storage ) ; } else if ( index instanceof Index7D ) { return new ArrayDouble . D7 ( index , storage ) ; } else { return new ArrayDouble ( index , storage ) ; }


signature:
public class ArrayDouble { /** * copy from javaArray to storage using the iterator : used by factory ( Object ) ; */
protected void copyFrom1DJavaArray ( IndexIterator iter , Object javaArray ) { } }

implementation: double [ ] ja = ( double [ ] ) javaArray ; for ( double aJa : ja ) iter . setDoubleNext ( aJa ) ;


signature:
public class RecordDatasetHelper { /** * Set extra information used by station obs datasets .
 * Use stnIdVName or stnIndexVName .
 * @ param stnIdVName the obs variable that is used to find the station in the stnHash ; may be type int or a String ( char ) .
 * @ param stnDescVName optional station var containing station description */
public void setStationInfo ( String stnIdVName , String stnDescVName , String stnIndexVName , StationHelper stationHelper ) { } }

implementation: this . stnIdVName = stnIdVName ; this . stnDescVName = stnDescVName ; this . stnIndexVName = stnIndexVName ; this . stationHelper = stationHelper ; if ( stnIdVName != null ) { Variable stationVar = ncfile . findVariable ( stnIdVName ) ; stationIdType = stationVar . getDataType ( ) ; }


signature:
public class RecordDatasetHelper { /** * access it members */
public void setShortNames ( String latVName , String lonVName , String altVName , String obsTimeVName , String nomTimeVName ) { } }

implementation: this . latVName = latVName ; this . lonVName = lonVName ; this . zcoordVName = altVName ; this . obsTimeVName = obsTimeVName ; this . nomTimeVName = nomTimeVName ;


signature: public class RecordDatasetHelper { public PointFeature factory ( StationImpl s , StructureData sdata , int recno ) { } }

implementation: if ( s == null ) return new RecordPointObs ( sdata , recno ) ; else return new RecordStationObs ( s , sdata , recno ) ;


signature:
public class SDList { /** * Prints the value of the variable , with its declaration . This
 * function is primarily intended for debugging OPeNDAP applications and
 * text - based clients such as geturl .
 * < h2 > Important Note < / h2 >
 * This method overrides the BaseType method of the same name and
 * type signature and it significantly changes the behavior for all versions
 * of < code > printVal ( ) < / code > for this type :
 * < b > < i > All the various versions of printVal ( ) will only
 * print a value , or a value with declaration , if the variable is
 * in the projection . < / i > < / b >
 * < br >
 * < br > In other words , if a call to
 * < code > isProject ( ) < / code > for a particular variable returns
 * < code > true < / code > then < code > printVal ( ) < / code > will print a value
 * ( or a declaration and a value ) .
 * < br >
 * < br > If < code > isProject ( ) < / code > for a particular variable returns
 * < code > false < / code > then < code > printVal ( ) < / code > is basically a No - Op .
 * < br >
 * < br >
 * @ param os the < code > PrintWriter < / code > on which to print the value .
 * @ param space this value is passed to the < code > printDecl < / code > method ,
 * and controls the leading spaces of the output .
 * @ param print _ decl _ p a boolean value controlling whether the
 * variable declaration is printed as well as the value .
 * @ see BaseType # printVal ( PrintWriter , String , boolean )
 * @ see ServerMethods # isProject ( ) */
public void printVal ( PrintWriter os , String space , boolean print_decl_p ) { } }

implementation:
if ( ! isProject ( ) ) return ; PrimitiveVector pv = getPrimitiveVector ( ) ; if ( pv instanceof BaseTypePrimitiveVector ) { BaseTypePrimitiveVector vals = ( BaseTypePrimitiveVector ) pv ; if ( print_decl_p ) { printDecl ( os , space , false , true ) ; os . print ( " = " ) ; } os . print ( "{ " ) ; // vals . printVal ( os , " " ) ;
ServerMethods sm ; int len = vals . getLength ( ) ; for ( int i = 0 ; i < len - 1 ; i ++ ) { sm = ( ServerMethods ) vals . getValue ( i ) ; if ( sm . isProject ( ) ) { ( ( BaseType ) sm ) . printVal ( os , "" , false ) ; os . print ( ", " ) ; } } // print last value , if any , without trailing comma
if ( len > 0 ) { sm = ( ServerMethods ) vals . getValue ( len - 1 ) ; if ( sm . isProject ( ) ) { ( ( BaseType ) sm ) . printVal ( os , "" , false ) ; } } os . print ( "}" ) ; if ( print_decl_p ) os . println ( ";" ) ; } else { super . printVal ( os , space , print_decl_p ) ; }


signature:
public class NcepMnemonic { /** * Read NCEP mnemonic BUFR tables .
 * @ return boolean
 * @ throws IOException */
public static boolean read ( InputStream ios , BufrTables . Tables tables ) throws IOException { } }

implementation:
if ( ios == null ) return false ; if ( tables . b == null ) tables . b = new TableB ( "fake" , "fake" ) ; if ( tables . d == null ) tables . d = new TableD ( "fake" , "fake" ) ; HashMap < String , String > number = new HashMap < > ( ) ; // key = mnemonic value = fxy
HashMap < String , String > desc = new HashMap < > ( ) ; // key = mnemonic value = description
HashMap < String , String > mnseq = new HashMap < > ( ) ; try { BufferedReader dataIS = new BufferedReader ( new InputStreamReader ( ios , CDM . utf8Charset ) ) ; // read mnemonic table
Matcher m ; // read header info and disregard
while ( true ) { String line = dataIS . readLine ( ) ; if ( line == null ) throw new RuntimeException ( "Bad NCEP mnemonic BUFR table " ) ; if ( line . contains ( "MNEMONIC" ) ) break ; } // read mnemonic , number , and description
// | HEADR | 362001 | TABLE D ENTRY - PROFILE COORDINATES |
while ( true ) { String line = dataIS . readLine ( ) ; if ( line == null ) break ; if ( line . contains ( "MNEMONIC" ) ) break ; if ( line . contains ( "----" ) ) continue ; if ( line . startsWith ( "*" ) ) continue ; if ( line . startsWith ( "|       " ) ) continue ; m = fields3 . matcher ( line ) ; if ( m . find ( ) ) { String mnu = m . group ( 1 ) . trim ( ) ; String fxy = m . group ( 2 ) . trim ( ) ; if ( fxy . startsWith ( "3" ) ) { number . put ( mnu , fxy ) ; desc . put ( mnu , m . group ( 3 ) . replace ( "TABLE D ENTRY - " , "" ) . trim ( ) ) ; } else if ( fxy . startsWith ( "0" ) ) { number . put ( mnu , fxy ) ; desc . put ( mnu , m . group ( 3 ) . replace ( "TABLE B ENTRY - " , "" ) . trim ( ) ) ; } else if ( fxy . startsWith ( "A" ) ) { number . put ( mnu , fxy ) ; desc . put ( mnu , m . group ( 3 ) . replace ( "TABLE A ENTRY - " , "" ) . trim ( ) ) ; } } else if ( debugTable ) { System . out . println ( "bad mnemonic, number, and description: " + line ) ; } } // read in sequences using mnemonics
// | ETACLS1 | HEADR { PROFILE } SURF FLUX HYDR D10M { SLYR } XTRA |
while ( true ) { String line = dataIS . readLine ( ) ; if ( line == null ) break ; if ( line . contains ( "MNEMONIC" ) ) break ; if ( line . contains ( "----" ) ) continue ; if ( line . startsWith ( "|       " ) ) continue ; if ( line . startsWith ( "*" ) ) continue ; m = fields2 . matcher ( line ) ; if ( m . find ( ) ) { String mnu = m . group ( 1 ) . trim ( ) ; if ( mnseq . containsKey ( mnu ) ) { // concat lines with same mnu
String value = mnseq . get ( mnu ) ; value = value + " " + m . group ( 2 ) ; mnseq . put ( mnu , value ) ; } else { mnseq . put ( mnu , m . group ( 2 ) ) ; } } else if ( debugTable ) { System . out . println ( "bad sequence mnemonic: " + line ) ; } } // create sequences , replacing mnemonics with numbers
for ( Map . Entry < String , String > ent : mnseq . entrySet ( ) ) { String seq = ent . getValue ( ) ; seq = seq . replaceAll ( "\\<" , "1-1-0 0-31-0 " ) ; seq = seq . replaceAll ( "\\>" , "" ) ; seq = seq . replaceAll ( "\\{" , "1-1-0 0-31-1 " ) ; seq = seq . replaceAll ( "\\}" , "" ) ; seq = seq . replaceAll ( "\\(" , "1-1-0 0-31-2 " ) ; seq = seq . replaceAll ( "\\)" , "" ) ; StringTokenizer stoke = new StringTokenizer ( seq , " " ) ; List < Short > list = new ArrayList < > ( ) ; while ( stoke . hasMoreTokens ( ) ) { String mn = stoke . nextToken ( ) ; if ( mn . charAt ( 1 ) == '-' ) { list . add ( Descriptor . getFxy ( mn ) ) ; continue ; } // element descriptor needs hyphens
m = ints6 . matcher ( mn ) ; if ( m . find ( ) ) { String F = mn . substring ( 0 , 1 ) ; String X = removeLeading0 ( mn . substring ( 1 , 3 ) ) ; String Y = removeLeading0 ( mn . substring ( 3 ) ) ; list . add ( Descriptor . getFxy ( F + "-" + X + "-" + Y ) ) ; continue ; } if ( mn . startsWith ( "\"" ) ) { int idx = mn . lastIndexOf ( '"' ) ; String count = mn . substring ( idx + 1 ) ; list . add ( Descriptor . getFxy ( "1-1-" + count ) ) ; mn = mn . substring ( 1 , idx ) ; } if ( mn . startsWith ( "." ) ) { String des = mn . substring ( mn . length ( ) - 4 ) ; mn = mn . replace ( des , "...." ) ; } String fxy = number . get ( mn ) ; String F = fxy . substring ( 0 , 1 ) ; String X = removeLeading0 ( fxy . substring ( 1 , 3 ) ) ; String Y = removeLeading0 ( fxy . substring ( 3 ) ) ; list . add ( Descriptor . getFxy ( F + "-" + X + "-" + Y ) ) ; } String fxy = number . get ( ent . getKey ( ) ) ; String X = removeLeading0 ( fxy . substring ( 1 , 3 ) ) ; String Y = removeLeading0 ( fxy . substring ( 3 ) ) ; // these are in latest tables
if ( XlocalCutoff > Integer . parseInt ( X ) && YlocalCutoff > Integer . parseInt ( Y ) ) continue ; // key = F + " - " + X + " - " + Y ;
short seqX = Short . parseShort ( X . trim ( ) ) ; short seqY = Short . parseShort ( Y . trim ( ) ) ; tables . d . addDescriptor ( seqX , seqY , ent . getKey ( ) , list ) ; // short id = Descriptor . getFxy ( key ) ;
// sequences . put ( Short . valueOf ( id ) , tableD ) ;
} // add some static repetition sequences
// LOOK why ?
List < Short > list = new ArrayList < > ( ) ; // 16 bit delayed repetition
list . add ( Descriptor . getFxy ( "1-1-0" ) ) ; list . add ( Descriptor . getFxy ( "0-31-2" ) ) ; tables . d . addDescriptor ( ( short ) 60 , ( short ) 1 , "" , list ) ; // tableD = new DescriptorTableD ( " " , " 3-60-1 " , list , false ) ;
// tableD . put ( " 3-60-1 " , d ) ;
// short id = Descriptor . getFxy ( " 3-60-1 " ) ;
// sequences . put ( Short . valueOf ( id ) , tableD ) ;
list = new ArrayList < > ( ) ; // 8 bit delayed repetition
list . add ( Descriptor . getFxy ( "1-1-0" ) ) ; list . add ( Descriptor . getFxy ( "0-31-1" ) ) ; tables . d . addDescriptor ( ( short ) 60 , ( short ) 2 , "" , list ) ; // tableD = new DescriptorTableD ( " " , " 3-60-2 " , list , false ) ;
// tableD . put ( " 3-60-2 " , d ) ;
// id = Descriptor . getFxy ( " 3-60-2 " ) ;
// sequences . put ( Short . valueOf ( id ) , tableD ) ;
list = new ArrayList < > ( ) ; // 8 bit delayed repetition
list . add ( Descriptor . getFxy ( "1-1-0" ) ) ; list . add ( Descriptor . getFxy ( "0-31-1" ) ) ; tables . d . addDescriptor ( ( short ) 60 , ( short ) 3 , "" , list ) ; // tableD = new DescriptorTableD ( " " , " 3-60-3 " , list , false ) ;
// tableD . put ( " 3-60-3 " , d ) ;
// id = Descriptor . getFxy ( " 3-60-3 " ) ;
// sequences . put ( Short . valueOf ( id ) , tableD ) ;
list = new ArrayList < > ( ) ; // 1 bit delayed repetition
list . add ( Descriptor . getFxy ( "1-1-0" ) ) ; list . add ( Descriptor . getFxy ( "0-31-0" ) ) ; tables . d . addDescriptor ( ( short ) 60 , ( short ) 4 , "" , list ) ; // tableD = new DescriptorTableD ( " " , " 3-60-4 " , list , false ) ;
// tableD . put ( " 3-60-4 " , d ) ;
// id = Descriptor . getFxy ( " 3-60-4 " ) ;
// sequences . put ( Short . valueOf ( id ) , tableD ) ;
// add in element descriptors
// MNEMONIC | SCAL | REFERENCE | BIT | UNITS
// | FTIM | 0 | 0 | 24 | SECONDS | - - - - - |
// tableB = new TableB ( tablename , tablename ) ;
while ( true ) { String line = dataIS . readLine ( ) ; if ( line == null ) break ; if ( line . contains ( "MNEMONIC" ) ) break ; if ( line . startsWith ( "|       " ) ) continue ; if ( line . startsWith ( "*" ) ) continue ; m = fields5 . matcher ( line ) ; if ( m . find ( ) ) { if ( m . group ( 1 ) . equals ( "" ) ) { continue ; } else if ( number . containsKey ( m . group ( 1 ) . trim ( ) ) ) { // add descriptor to tableB
String fxy = number . get ( m . group ( 1 ) . trim ( ) ) ; String X = fxy . substring ( 1 , 3 ) ; String Y = fxy . substring ( 3 ) ; String mnu = m . group ( 1 ) . trim ( ) ; String descr = desc . get ( mnu ) ; short x = Short . parseShort ( X . trim ( ) ) ; short y = Short . parseShort ( Y . trim ( ) ) ; // these are in latest tables so skip LOOK WHY
if ( XlocalCutoff > x && YlocalCutoff > y ) continue ; int scale = Integer . parseInt ( m . group ( 2 ) . trim ( ) ) ; int refVal = Integer . parseInt ( m . group ( 3 ) . trim ( ) ) ; int width = Integer . parseInt ( m . group ( 4 ) . trim ( ) ) ; String units = m . group ( 5 ) . trim ( ) ; tables . b . addDescriptor ( x , y , scale , refVal , width , mnu , units , descr ) ; } else if ( debugTable ) { System . out . println ( "bad element descriptors: " + line ) ; } } } } finally { ios . close ( ) ; } // LOOK why ?
// default for NCEP
// 0 ; 63 ; 0 ; 0 ; 0 ; 16 ; Numeric ; Byte count
tables . b . addDescriptor ( ( short ) 63 , ( short ) 0 , 0 , 0 , 16 , "Byte count" , "Numeric" , null ) ; return true ;


signature:
public class NcepMnemonic { /** * Read NCEP mnemonic BUFR tables . */
private static void readSubCategories ( String fileIn , PrintStream out , String token ) throws IOException { } }

implementation:
System . out . printf ( "%s%n" , fileIn ) ; try ( FileInputStream in = new FileInputStream ( fileIn ) ) { BufferedReader dataIS = new BufferedReader ( new InputStreamReader ( in , CDM . utf8Charset ) ) ; while ( true ) { String line = dataIS . readLine ( ) ; if ( line == null ) break ; int posb = line . indexOf ( "DISCONTINUED" ) ; if ( posb > 0 ) continue ; posb = line . indexOf ( "NO LONGER" ) ; if ( posb > 0 ) continue ; posb = line . indexOf ( "WAS REPLACED" ) ; if ( posb > 0 ) continue ; int pos = line . indexOf ( token ) ; if ( pos < 0 ) continue ; System . out . printf ( "%s%n" , line ) ; boolean is31 = token . equals ( "031-" ) ; String subline = is31 ? line . substring ( pos ) : line . substring ( pos + token . length ( ) ) ; // if ( is31 ) System . out . printf ( " ' % s ' % n " , subline ) ;
int pos2 = subline . indexOf ( ' ' ) ; String catS = subline . substring ( 0 , pos2 ) ; String desc = subline . substring ( pos2 + 1 ) ; // System . out . printf ( " cat = ' % s ' % n " , catS ) ;
// System . out . printf ( " desc = ' % s ' % n " , desc ) ;
int cat = Integer . parseInt ( catS . substring ( 0 , 3 ) ) ; int subcat = Integer . parseInt ( catS . substring ( 4 , 7 ) ) ; desc = StringUtil2 . remove ( desc , '|' ) . trim ( ) ; // System . out . printf ( " cat = % d subcat = % d % n " , cat , subcat ) ;
// System . out . printf ( " desc = ' % s ' % n " , desc ) ;
// System . out . printf ( " % d , % d , % s % n " , cat , subcat , desc ) ;
out . printf ( "%d; %d; %s%n" , cat , subcat , desc ) ; } }


signature:
public class HTTPFormBuilder { /** * Field construction */
public HTTPFormBuilder add ( String fieldname , String text ) throws HTTPException { } }

implementation: if ( fieldname == null || text == null || fieldname . length ( ) == 0 ) throw new IllegalArgumentException ( ) ; Field f = new Field ( Sort . TEXT , fieldname , text , null ) ; parts . put ( fieldname , f ) ; return this ;


signature:
public class FeatureCollectionConfigBuilder { /** * input is xml file with just the < featureCollection > */
public FeatureCollectionConfig readConfigFromFile ( String filename ) { } }

implementation: org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; doc = builder . build ( filename ) ; } catch ( Exception e ) { System . out . printf ( "Error parsing featureCollection %s err = %s" , filename , e . getMessage ( ) ) ; return null ; } return readConfig ( doc . getRootElement ( ) ) ;


signature:
public class FeatureCollectionConfigBuilder { /** * Read a catalog and extract a FeatureCollectionConfig from it
 * @ param catalogAndPath catalog filename , or catalog # featureName
 * @ return FeatureCollectionConfig or null */
public FeatureCollectionConfig readConfigFromCatalog ( String catalogAndPath ) { } }

implementation: String catFilename ; String fcName = null ; int pos = catalogAndPath . indexOf ( "#" ) ; if ( pos > 0 ) { catFilename = catalogAndPath . substring ( 0 , pos ) ; fcName = catalogAndPath . substring ( pos + 1 ) ; } else { catFilename = catalogAndPath ; } File cat = new File ( catFilename ) ; org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; doc = builder . build ( cat ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return null ; } try { List < Element > fcElems = new ArrayList < > ( ) ; findFeatureCollection ( doc . getRootElement ( ) , fcName , fcElems ) ; if ( fcElems . size ( ) > 0 ) return readConfig ( fcElems . get ( 0 ) ) ; } catch ( IllegalStateException e ) { e . printStackTrace ( ) ; } return null ;


signature:
public class DapGroup { /** * Add single declaration */
public void addDecl ( DapNode newdecl ) throws DapException { } }

implementation:
DapSort newsort = newdecl . getSort ( ) ; String newname = newdecl . getShortName ( ) ; boolean suppress = false ; // Look for name conflicts ( ignore anonymous dimensions )
if ( newsort != DapSort . DIMENSION || newname != null ) { for ( DapNode decl : decls ) { if ( newsort == decl . getSort ( ) && newname . equals ( decl . getShortName ( ) ) ) throw new DapException ( "DapGroup: attempt to add duplicate decl: " + newname ) ; } } else { // Anonymous
DapDimension anon = ( DapDimension ) newdecl ; assert ( newsort == DapSort . DIMENSION && newname == null ) ; // Search for matching anonymous dimension
boolean found = false ; for ( DapDimension dim : dimensions ) { if ( ! dim . isShared ( ) && dim . getSize ( ) == anon . getSize ( ) ) { found = true ; break ; } } // Define the anondecl in root group
if ( ! found && ! isTopLevel ( ) ) getDataset ( ) . addDecl ( anon ) ; suppress = found || ! isTopLevel ( ) ; } if ( ! suppress ) { decls . add ( newdecl ) ; newdecl . setParent ( this ) ; // Cross link
} switch ( newdecl . getSort ( ) ) { case ATTRIBUTE : case ATTRIBUTESET : case OTHERXML : super . addAttribute ( ( DapAttribute ) newdecl ) ; break ; case DIMENSION : if ( ! suppress ) dimensions . add ( ( DapDimension ) newdecl ) ; break ; case ENUMERATION : enums . add ( ( DapEnumeration ) newdecl ) ; break ; case ATOMICTYPE : break ; // do nothing
case STRUCTURE : case SEQUENCE : compounds . add ( ( DapStructure ) newdecl ) ; break ; case VARIABLE : variables . add ( ( DapVariable ) newdecl ) ; break ; case GROUP : case DATASET : if ( this != ( DapGroup ) newdecl ) groups . add ( ( DapGroup ) newdecl ) ; break ; default : throw new ClassCastException ( newdecl . getShortName ( ) ) ; }


signature:
public class DapGroup { /** * We will need to re - order the groups */
void updateGroups ( List < DapGroup > groups ) { } }

implementation:
// Verify that the incoming groups are all and only in the list of groups .
assert ( groups . size ( ) == this . groups . size ( ) ) : "Update groups: not same size" ; for ( DapGroup g : groups ) { if ( ! this . groups . contains ( g ) ) assert ( false ) : "Update groups: attempt to add new group" ; }


signature:
public class DapGroup { /** * Parse an FQN and use it to trace to a specific
 * object in a dataset . Absolute FQN paths are passed
 * to DapDataset . findByFQN ( ) . Relative FQNs are assumed
 * to be WRT to the FQN of this node
 * @ param fqn the fully qualified name
 * @ param sortset the kinds of object we are looking for
 * @ return the matching Dap Node or null if not found */
public DapNode findByFQN ( String fqn , DapSort ... sortset ) throws DapException { } }

implementation: fqn = fqn . trim ( ) ; if ( fqn == null ) return null ; if ( fqn . charAt ( 0 ) != '/' ) { String prefix = this . getFQN ( ) ; fqn = prefix + '/' + fqn ; } return getDataset ( ) . lookup ( fqn , sortset ) ;


signature:
public class DapGroup { /** * Locate a variable in this group
 * @ param name the variable ' s name
 * @ return the matching Dap Node or null if not found */
public DapVariable findVariable ( String name ) { } }

implementation: DapNode var = findInGroup ( name , DapSort . VARIABLE ) ; return ( DapVariable ) var ;


signature:
public class CompareNetcdf2 { /** * / * private boolean compare ( List < Dimension > dims1 , List < Dimension > dims2 ) {
 * if ( dims1 . size ( ) ! = dims2 . size ( ) ) return false ;
 * for ( int i = 0 ; i < dims1 . size ( ) ; i + + ) {
 * Dimension dim1 = dims1 . get ( i ) ;
 * Dimension dim2 = dims2 . get ( i ) ;
 * if ( ! dim1 . getName ( ) . equals ( dim2 . getName ( ) ) ) return false ;
 * if ( dim1 . getLength ( ) ! = dim2 . getLength ( ) ) return false ;
 * return true ; */
private boolean compareGroups ( Group org , Group copy , ObjFilter filter ) { } }

implementation:
if ( showCompare ) f . format ( "compare Group %s to %s %n" , org . getShortName ( ) , copy . getShortName ( ) ) ; boolean ok = true ; if ( ! org . getShortName ( ) . equals ( copy . getShortName ( ) ) ) { f . format ( " ** names are different %s != %s %n" , org . getShortName ( ) , copy . getShortName ( ) ) ; ok = false ; } // dimensions
ok &= checkDimensions ( org . getDimensions ( ) , copy . getDimensions ( ) ) ; ok &= checkDimensions ( copy . getDimensions ( ) , org . getDimensions ( ) ) ; // attributes
ok &= checkAttributes ( null , org . getAttributes ( ) , copy . getAttributes ( ) , filter ) ; // enums
ok &= checkEnums ( org , copy ) ; // variables
// cant use object equality , just match on short name
for ( Variable orgV : org . getVariables ( ) ) { Variable copyVar = copy . findVariable ( orgV . getShortName ( ) ) ; if ( copyVar == null ) { f . format ( " ** cant find variable %s in 2nd file%n" , orgV . getFullName ( ) ) ; ok = false ; } else { ok &= compareVariables ( orgV , copyVar , filter , compareData , true ) ; } } for ( Variable copyV : copy . getVariables ( ) ) { Variable orgV = org . findVariable ( copyV . getShortName ( ) ) ; if ( orgV == null ) { f . format ( " ** cant find variable %s in 1st file%n" , copyV . getFullName ( ) ) ; ok = false ; } } // nested groups
List groups = new ArrayList ( ) ; String name = org . isRoot ( ) ? "root" : org . getFullName ( ) ; ok &= checkAll ( name , org . getGroups ( ) , copy . getGroups ( ) , groups ) ; for ( int i = 0 ; i < groups . size ( ) ; i += 2 ) { Group orgGroup = ( Group ) groups . get ( i ) ; Group copyGroup = ( Group ) groups . get ( i + 1 ) ; ok &= compareGroups ( orgGroup , copyGroup , filter ) ; } return ok ;


signature:
public class CompareNetcdf2 { /** * return an arrayList of paired objects . */
private boolean checkAttributes ( Variable v , List < Attribute > list1 , List < Attribute > list2 , ObjFilter filter ) { } }

implementation: boolean ok = true ; String name = v == null ? "global" : "variable " + v . getFullName ( ) ; for ( Attribute att1 : list1 ) { if ( filter == null || filter . attCheckOk ( v , att1 ) ) ok &= checkEach ( name , att1 , "file1" , list1 , "file2" , list2 , null ) ; } for ( Attribute att2 : list2 ) { if ( filter == null || filter . attCheckOk ( v , att2 ) ) ok &= checkEach ( name , att2 , "file2" , list2 , "file1" , list1 , null ) ; } return ok ;


signature:
public class CompareNetcdf2 { /** * return an arrayList of paired objects . */
private boolean checkEnums ( Group org , Group copy ) { } }

implementation: boolean ok = true ; for ( EnumTypedef enum1 : org . getEnumTypedefs ( ) ) { if ( showCompare ) f . format ( "compare Enum %s%n" , enum1 . getShortName ( ) ) ; EnumTypedef enum2 = copy . findEnumeration ( enum1 . getShortName ( ) ) ; if ( enum2 == null ) { f . format ( "  ** Enum %s not in file2 %n" , enum1 . getShortName ( ) ) ; ok = false ; continue ; } if ( ! enum1 . equals ( enum2 ) ) { f . format ( "  ** Enum %s not equal%n  %s%n  %s%n" , enum1 . getShortName ( ) , enum1 , enum2 ) ; ok = false ; } } for ( EnumTypedef enum2 : copy . getEnumTypedefs ( ) ) { EnumTypedef enum1 = org . findEnumeration ( enum2 . getShortName ( ) ) ; if ( enum1 == null ) { f . format ( "  ** Enum %s not in file1 %n" , enum2 . getShortName ( ) ) ; ok = false ; } } return ok ;


signature:
public class CompareNetcdf2 { /** * return an arrayList of paired objects . */
private boolean checkAll ( String what , List list1 , List list2 , List result ) { } }

implementation: boolean ok = true ; for ( Object aList1 : list1 ) { ok &= checkEach ( what , aList1 , "file1" , list1 , "file2" , list2 , result ) ; } for ( Object aList2 : list2 ) { ok &= checkEach ( what , aList2 , "file2" , list2 , "file1" , list1 , null ) ; } return ok ;


signature:
public class CompareNetcdf2 { /** * check that want is in both list1 and list2 , using object . equals ( ) */
private boolean checkEach ( String what , Object want1 , String name1 , List list1 , String name2 , List list2 , List result ) { } }

implementation:
boolean ok = true ; try { int index2 = list2 . indexOf ( want1 ) ; if ( index2 < 0 ) { f . format ( "  ** %s: %s 0x%x (%s) not in %s %n" , what , want1 , want1 . hashCode ( ) , name1 , name2 ) ; ok = false ; } else { // found it in second list
Object want2 = list2 . get ( index2 ) ; int index1 = list1 . indexOf ( want2 ) ; if ( index1 < 0 ) { // can this happen ? ?
f . format ( "  ** %s: %s 0x%x (%s) not in %s %n" , what , want2 , want2 . hashCode ( ) , name2 , name1 ) ; ok = false ; } else { // found it in both lists
Object want = list1 . get ( index1 ) ; if ( ! want . equals ( want1 ) ) { f . format ( "  ** %s: %s 0x%x (%s) not equal to %s 0x%x (%s) %n" , what , want1 , want1 . hashCode ( ) , name1 , want2 , want2 . hashCode ( ) , name2 ) ; ok = false ; } else { if ( showEach ) f . format ( "  OK <%s> equals <%s>%n" , want1 , want2 ) ; if ( result != null ) { result . add ( want1 ) ; result . add ( want2 ) ; } } } } } catch ( Throwable t ) { t . printStackTrace ( ) ; f . format ( " *** Throwable= %s %n" , t . getMessage ( ) ) ; } return ok ;


signature:
public class COARDSConvention { /** * The COARDS standard offers limited support for climatological time . For compatibility with COARDS , time coordinates should also be
 * recognised as climatological if they have a units attribute of time - units relative to midnight on 1 January in year 0
 * i . e . since 0-1-1 in udunits syntax , and provided they refer to the real - world calendar . We do not recommend this convention because
 * ( a ) it does not provide any information about the intervals used to compute the climatology , and
 * ( b ) there is no standard for how dates since year 1 will be encoded with units having a reference time in year 0,
 * since this year does not exist ; consequently there may be inconsistencies among software packages in the interpretation of the
 * time coordinates . Year 0 may be a valid year in non - real - world calendars , and therefore cannot be used to signal climatological
 * time in such cases . */
public static boolean isMine ( String hasName ) { } }

implementation: if ( hasName . equalsIgnoreCase ( "COARDS" ) ) return true ; List < String > names = breakupConventionNames ( hasName ) ; for ( String name : names ) { if ( name . equalsIgnoreCase ( "COARDS" ) ) return true ; } return false ;


signature:
public class COARDSConvention { /** * we assume that coordinate axes get identified by being coordinate variables */
protected AxisType getAxisType ( NetcdfDataset ncDataset , VariableEnhanced v ) { } }

implementation:
String unit = v . getUnitsString ( ) ; if ( unit == null ) return null ; unit = unit . trim ( ) ; if ( unit . equalsIgnoreCase ( "degrees_east" ) || unit . equalsIgnoreCase ( "degrees_E" ) || unit . equalsIgnoreCase ( "degreesE" ) || unit . equalsIgnoreCase ( "degree_east" ) || unit . equalsIgnoreCase ( "degree_E" ) || unit . equalsIgnoreCase ( "degreeE" ) ) return AxisType . Lon ; if ( unit . equalsIgnoreCase ( "degrees_north" ) || unit . equalsIgnoreCase ( "degrees_N" ) || unit . equalsIgnoreCase ( "degreesN" ) || unit . equalsIgnoreCase ( "degree_north" ) || unit . equalsIgnoreCase ( "degree_N" ) || unit . equalsIgnoreCase ( "degreeN" ) ) return AxisType . Lat ; if ( SimpleUnit . isDateUnit ( unit ) ) { return AxisType . Time ; } // look for other z coordinate
if ( SimpleUnit . isCompatible ( "mbar" , unit ) ) return AxisType . Pressure ; if ( unit . equalsIgnoreCase ( "level" ) || unit . equalsIgnoreCase ( "layer" ) || unit . equalsIgnoreCase ( "sigma_level" ) ) return AxisType . GeoZ ; String positive = ncDataset . findAttValueIgnoreCase ( ( Variable ) v , CF . POSITIVE , null ) ; if ( positive != null ) { if ( SimpleUnit . isCompatible ( "m" , unit ) ) return AxisType . Height ; else return AxisType . GeoZ ; } // a bad idea , but CDC SST relies on it :
// : Source = " NOAA / National Climatic Data Center " ;
// : Contact = " Dick Reynolds , email : Richard . W . Reynolds @ noaa . gov & Chunying Liu , email : Chunying . liu @ noaa . gov " ;
// : netcdf _ Convention = " COARDS " ;
// if ( checkForMeter & & SimpleUnit . isCompatible ( " m " , unit ) )
// return AxisType . Height ;
return null ;


signature:
public class Grib1WmoTimeType { /** * The time unit statistical type , derived from code table 5)
 * @ return time unit statistical type , or null if unknown . */
@ Nullable public static GribStatType getStatType ( int timeRangeIndicator ) { } }

implementation: switch ( timeRangeIndicator ) { case 3 : case 6 : case 7 : case 51 : case 113 : case 115 : case 117 : case 120 : case 123 : return GribStatType . Average ; case 4 : case 114 : case 116 : case 124 : return GribStatType . Accumulation ; case 5 : return GribStatType . DifferenceFromEnd ; case 118 : return GribStatType . Covariance ; case 119 : case 125 : return GribStatType . StandardDeviation ; default : return null ; }


signature: public class HorizCoordSys { public Optional < HorizCoordSys > subset ( SubsetParams params ) { } }

implementation:
LatLonRect llbb = ( LatLonRect ) params . get ( SubsetParams . latlonBB ) ; ProjectionRect projbb = ( ProjectionRect ) params . get ( SubsetParams . projBB ) ; LatLonPoint latlon = ( LatLonPoint ) params . get ( SubsetParams . latlonPoint ) ; Integer horizStride = ( Integer ) params . get ( SubsetParams . horizStride ) ; if ( horizStride == null || horizStride < 1 ) horizStride = 1 ; CoverageCoordAxis1D xaxisSubset = null , yaxisSubset = null ; CoverageCoordAxis lataxisSubset = null , lonaxisSubset = null ; Optional < CoverageCoordAxis > opt ; Optional < CoverageCoordAxisBuilder > optb ; Formatter errMessages = new Formatter ( ) ; try { if ( latlon != null ) { // overrides other horiz subset params
if ( isProjection ) { CoordAxisHelper xhelper = new CoordAxisHelper ( xAxis ) ; CoordAxisHelper yhelper = new CoordAxisHelper ( yAxis ) ; // we have to transform latlon to projection coordinates
ProjectionImpl proj = transform . getProjection ( ) ; ProjectionPoint pp = proj . latLonToProj ( latlon ) ; optb = xhelper . subsetContaining ( pp . getX ( ) ) ; if ( optb . isPresent ( ) ) xaxisSubset = new CoverageCoordAxis1D ( optb . get ( ) ) ; else errMessages . format ( "xaxis: %s;%n" , optb . getErrorMessage ( ) ) ; optb = yhelper . subsetContaining ( pp . getY ( ) ) ; if ( optb . isPresent ( ) ) yaxisSubset = new CoverageCoordAxis1D ( optb . get ( ) ) ; else errMessages . format ( "yaxis: %s;%n" , optb . getErrorMessage ( ) ) ; } else { CoordAxisHelper xhelper = new CoordAxisHelper ( lonAxis ) ; CoordAxisHelper yhelper = new CoordAxisHelper ( latAxis ) ; double lonNormal = LatLonPointImpl . lonNormalFrom ( latlon . getLongitude ( ) , lonAxis . getStartValue ( ) ) ; optb = xhelper . subsetContaining ( lonNormal ) ; if ( optb . isPresent ( ) ) lonaxisSubset = new CoverageCoordAxis1D ( optb . get ( ) ) ; else errMessages . format ( "lonaxis: %s;%n" , optb . getErrorMessage ( ) ) ; optb = yhelper . subsetContaining ( latlon . getLatitude ( ) ) ; if ( optb . isPresent ( ) ) lataxisSubset = new CoverageCoordAxis1D ( optb . get ( ) ) ; else errMessages . format ( "lataxis: %s;%n" , optb . getErrorMessage ( ) ) ; } } else if ( projbb != null ) { if ( isProjection ) { opt = xAxis . subset ( projbb . getMinX ( ) , projbb . getMaxX ( ) , horizStride ) ; if ( opt . isPresent ( ) ) xaxisSubset = ( CoverageCoordAxis1D ) opt . get ( ) ; else errMessages . format ( "xaxis: %s;%n" , opt . getErrorMessage ( ) ) ; opt = yAxis . subset ( projbb . getMinY ( ) , projbb . getMaxY ( ) , horizStride ) ; if ( opt . isPresent ( ) ) yaxisSubset = ( CoverageCoordAxis1D ) opt . get ( ) ; else errMessages . format ( "yaxis: %s;%n" , opt . getErrorMessage ( ) ) ; } /* else { / / WTF projbb on non Projection ?
 ProjectionImpl proj = transform . getProjection ( ) ;
 LatLonRect llrect = proj . projToLatLonBB ( projbb ) ;
 opt = lonaxis . subset ( llrect . getLonMin ( ) , llrect . getLonMax ( ) , horizStride ) ;
 if ( opt . isPresent ( ) ) lonaxisSubset = opt . get ( ) ;
 else errMessages . format ( " lonaxis : % s ; % n " , opt . getErrorMessage ( ) ) ;
 opt = lataxis . subset ( llrect . getLatMin ( ) , llrect . getLatMax ( ) , horizStride ) ;
 if ( opt . isPresent ( ) ) lataxisSubset = opt . get ( ) ;
 else errMessages . format ( " lataxis : % s ; % n " , opt . getErrorMessage ( ) ) ; */
} else if ( llbb != null ) { LatLonRect full = calcLatLonBoundingBox ( ) ; assert full != null ; if ( ! full . containedIn ( llbb ) ) { // if request contains entire bb , then no subsetting needed
if ( isProjection ) { // we have to transform latlon to projection coordinates
ProjectionImpl proj = transform . getProjection ( ) ; ProjectionRect prect = proj . latLonToProjBB ( llbb ) ; // allow projection to override
opt = xAxis . subset ( prect . getMinX ( ) , prect . getMaxX ( ) , horizStride ) ; if ( opt . isPresent ( ) ) xaxisSubset = ( CoverageCoordAxis1D ) opt . get ( ) ; else errMessages . format ( "xaxis: %s;%n" , opt . getErrorMessage ( ) ) ; opt = yAxis . subset ( prect . getMinY ( ) , prect . getMaxY ( ) , horizStride ) ; if ( opt . isPresent ( ) ) yaxisSubset = ( CoverageCoordAxis1D ) opt . get ( ) ; else errMessages . format ( "yaxis: %s;%n" , opt . getErrorMessage ( ) ) ; } else { opt = subsetLon ( llbb , horizStride ) ; if ( opt . isPresent ( ) ) lonaxisSubset = opt . get ( ) ; else errMessages . format ( "lonaxis: %s;%n" , opt . getErrorMessage ( ) ) ; opt = latAxis . subset ( llbb . getLatMin ( ) , llbb . getLatMax ( ) , horizStride ) ; if ( opt . isPresent ( ) ) lataxisSubset = opt . get ( ) ; else errMessages . format ( "lataxis: %s;%n" , opt . getErrorMessage ( ) ) ; } } } else if ( horizStride > 1 ) { // no bounding box , just horiz stride
if ( isProjection ) { opt = xAxis . subsetByIndex ( xAxis . getRange ( ) . setStride ( horizStride ) ) ; if ( opt . isPresent ( ) ) xaxisSubset = ( CoverageCoordAxis1D ) opt . get ( ) ; else errMessages . format ( "xaxis: %s;%n" , opt . getErrorMessage ( ) ) ; opt = yAxis . subsetByIndex ( yAxis . getRange ( ) . setStride ( horizStride ) ) ; if ( opt . isPresent ( ) ) yaxisSubset = ( CoverageCoordAxis1D ) opt . get ( ) ; else errMessages . format ( "yaxis: %s;%n" , opt . getErrorMessage ( ) ) ; } else { opt = lonAxis . subsetByIndex ( lonAxis . getRange ( ) . setStride ( horizStride ) ) ; if ( opt . isPresent ( ) ) lonaxisSubset = opt . get ( ) ; else errMessages . format ( "lonaxis: %s;%n" , opt . getErrorMessage ( ) ) ; opt = latAxis . subsetByIndex ( latAxis . getRange ( ) . setStride ( horizStride ) ) ; if ( opt . isPresent ( ) ) lataxisSubset = opt . get ( ) ; else errMessages . format ( "lataxis: %s;%n" , opt . getErrorMessage ( ) ) ; } } } catch ( InvalidRangeException e ) { errMessages . format ( "%s;%n" , e . getMessage ( ) ) ; } String errs = errMessages . toString ( ) ; if ( errs . length ( ) > 0 ) return Optional . empty ( errs ) ; // makes a copy of the axis
if ( xaxisSubset == null && xAxis != null ) xaxisSubset = ( CoverageCoordAxis1D ) xAxis . copy ( ) ; if ( yaxisSubset == null && yAxis != null ) yaxisSubset = ( CoverageCoordAxis1D ) yAxis . copy ( ) ; if ( lataxisSubset == null && latAxis != null ) lataxisSubset = latAxis . copy ( ) ; if ( lonaxisSubset == null && lonAxis != null ) lonaxisSubset = lonAxis . copy ( ) ; return Optional . of ( new HorizCoordSys ( xaxisSubset , yaxisSubset , lataxisSubset , lonaxisSubset , transform ) ) ;


signature:
public class HorizCoordSys { /** * here ' s where to deal with crossing seam */
private Optional < CoverageCoordAxis > subsetLon ( LatLonRect llbb , int stride ) throws InvalidRangeException { } }

implementation:
double wantMin = LatLonPointImpl . lonNormalFrom ( llbb . getLonMin ( ) , lonAxis . getStartValue ( ) ) ; double wantMax = LatLonPointImpl . lonNormalFrom ( llbb . getLonMax ( ) , lonAxis . getStartValue ( ) ) ; double start = lonAxis . getStartValue ( ) ; double end = lonAxis . getEndValue ( ) ; // use MAMath . MinMax as a container for two values , min and max
List < MAMath . MinMax > lonIntvs = subsetLonIntervals ( wantMin , wantMax , start , end ) ; if ( lonIntvs . size ( ) == 0 ) return Optional . empty ( String . format ( "longitude want [%f,%f] does not intersect lon axis [%f,%f]" , wantMin , wantMax , start , end ) ) ; if ( lonIntvs . size ( ) == 1 ) { MAMath . MinMax lonIntv = lonIntvs . get ( 0 ) ; return lonAxis . subset ( lonIntv . min , lonIntv . max , stride ) ; } // this is the seam crossing case
return lonAxis . subsetByIntervals ( lonIntvs , stride ) ;


signature:
public class HorizCoordSys { /** * longitude subset , after normalizing to start
 * draw a circle , representing longitude values from start to start + 360.
 * all values are on this circle and are > start .
 * put start at bottom of circle , end > start , data has values from start , counterclockwise to end .
 * wantMin , wantMax can be anywhere , want goes from wantMin counterclockwise to wantMax .
 * wantMin may be less than or greater than wantMax .
 * cases :
 * A . wantMin < wantMax
 * 1 wantMin , wantMax > end : empty
 * 2 wantMin , wantMax < end : [ wantMin , wantMax ]
 * 3 wantMin < end , wantMax > end : [ wantMin , end ]
 * B . wantMin > wantMax
 * 1 wantMin , wantMax > end : all [ start , end ]
 * 2 wantMin , wantMax < end : 2 pieces : [ wantMin , end ] + [ start , max ]
 * 3 wantMin < end , wantMax > end : [ wantMin , end ] */
private List < MAMath . MinMax > subsetLonIntervals ( double wantMin , double wantMax , double start , double end ) { } }

implementation:
if ( wantMin <= wantMax ) { if ( wantMin > end && wantMax > end ) // none A . 1
return Collections . EMPTY_LIST ; if ( wantMin < end && wantMax < end ) // A . 2
return Lists . newArrayList ( new MAMath . MinMax ( wantMin , wantMax ) ) ; if ( wantMin < end && wantMax > end ) // A . 3
return Lists . newArrayList ( new MAMath . MinMax ( wantMin , end ) ) ; } else { if ( wantMin > end && wantMax > end ) // all B . 1
return Lists . newArrayList ( new MAMath . MinMax ( start , end ) ) ; if ( wantMin < end && wantMax < end ) { // B . 2
return Lists . newArrayList ( new MAMath . MinMax ( wantMin , end ) , new MAMath . MinMax ( start , wantMax ) ) ; } if ( wantMin < end && wantMax > end ) // B . 3
return Lists . newArrayList ( new MAMath . MinMax ( wantMin , end ) ) ; } // otherwise shouldnt get to this
logger . error ( "longitude want [%f,%f] does not intersect axis [%f,%f]" , wantMin , wantMax , start , end ) ; return Collections . EMPTY_LIST ;


signature:
public class HorizCoordSys { /** * return y , x range */
public List < RangeIterator > getRanges ( ) { } }

implementation:
List < RangeIterator > result = new ArrayList < > ( ) ; result . add ( getYAxis ( ) . getRange ( ) ) ; RangeIterator lonRange = getXAxis ( ) . getRangeIterator ( ) ; if ( lonRange == null ) lonRange = getXAxis ( ) . getRange ( ) ; // clumsy
result . add ( lonRange ) ; return result ;


signature:
public class HorizCoordSys { /** * Calculates the bounding box of this coordinate reference system , in projection coordinates . If this CRS
 * { @ link # isProjection isn ' t a projection } , than { @ code null } is returned .
 * @ return the bounding box of this CRS , in projection coordinates . */
public ProjectionRect calcProjectionBoundingBox ( ) { } }

implementation: if ( ! isProjection ) return null ; double minX = Math . min ( xAxis . getCoordEdgeFirst ( ) , xAxis . getCoordEdgeLast ( ) ) ; double minY = Math . min ( yAxis . getCoordEdgeFirst ( ) , yAxis . getCoordEdgeLast ( ) ) ; double width = Math . abs ( xAxis . getCoordEdgeLast ( ) - xAxis . getCoordEdgeFirst ( ) ) ; double height = Math . abs ( yAxis . getCoordEdgeLast ( ) - yAxis . getCoordEdgeFirst ( ) ) ; return new ProjectionRect ( new ProjectionPointImpl ( minX , minY ) , width , height ) ;


signature:
public class HorizCoordSys { /** * Calculates the bounding box of this coordinate reference system , in latitude / longitude . This method properly
 * handles coverages that straddle the international date line by deriving its bounding box from the
 * { @ link # calcConnectedLatLonBoundaryPoints ( int , int ) connected latitude / longitude boundary } .
 * If this CRS { @ link # isProjection is a projection } , its lat / lon boundary is computed by converting each point
 * in its { @ link # calcProjectionBoundaryPoints ( ) projection boundary } to latitude / longitude using the
 * { @ link Projection projection } .
 * @ return the bounding box of this CRS , in latitude / longitude . */
public LatLonRect calcLatLonBoundingBox ( ) { } }

implementation: double minLat = Double . MAX_VALUE ; double minLon = Double . MAX_VALUE ; double maxLat = - Double . MAX_VALUE ; double maxLon = - Double . MAX_VALUE ; for ( LatLonPointNoNormalize boundaryPoint : calcConnectedLatLonBoundaryPoints ( ) ) { minLat = Math . min ( minLat , boundaryPoint . getLatitude ( ) ) ; minLon = Math . min ( minLon , boundaryPoint . getLongitude ( ) ) ; maxLat = Math . max ( maxLat , boundaryPoint . getLatitude ( ) ) ; maxLon = Math . max ( maxLon , boundaryPoint . getLongitude ( ) ) ; } return new LatLonRect ( new LatLonPointImpl ( minLat , minLon ) , new LatLonPointImpl ( maxLat , maxLon ) ) ;


signature:
public class HorizCoordSys { /** * Calculates the latitude / longitude boundary of this coordinate reference system . The boundary starts at the lower
 * left corner of the coverage - - i . e . { @ code ( y [ 0 ] , x [ 0 ] ) } - - and consists of the points that lie along the bottom ,
 * right , top , and left edges , in that order .
 * The { @ code maxPointsInYEdge } parameter establishes a limit on the number of boundary points that ' ll be included
 * from the right and left edges . { @ code maxPointsInXEdge } establishes a similar limit for the bottom and top edges .
 * The size of the returned list will be { @ code ≤ 2 * maxPointsInYEdge + 2 * maxPointsInXEdge } . Note that the corners
 * are always included , regardless of the arguments . If you wish to include ALL of the points along the edges in
 * the boundary , simply choose values for the parameters that are greater than the lengths of the corresponding
 * axes in the CRS . { @ link Integer # MAX _ VALUE } works great . In that case , the size of the returned list will be
 * { @ code 2 * numXcoords + 2 * numYcoords } .
 * If this CRS { @ link # isProjection is a projection } , the lat / lon boundary is computed by converting each point
 * in its { @ link # calcProjectionBoundaryPoints ( ) projection boundary } to latitude / longitude using the
 * { @ link Projection projection } .
 * Points in the boundary will be { @ link # connectLatLonPoints connected } . This facilitates proper interpretation of
 * the boundary if it ' s rendered as a georeferenced polygon , particularly when the boundary crosses the international
 * date line .
 * @ param maxPointsInYEdge the maximum number of boundary points to include from the right and left edges .
 * @ param maxPointsInXEdge the maximum number of boundary points to include from the bottom and top edges .
 * @ return the connected latitude / longitude boundary of this CRS . */
public List < LatLonPointNoNormalize > calcConnectedLatLonBoundaryPoints ( int maxPointsInYEdge , int maxPointsInXEdge ) { } }

implementation: List < LatLonPoint > points ; if ( isProjection ) { points = calcLatLonBoundaryPointsFromProjection ( maxPointsInYEdge , maxPointsInXEdge ) ; } else if ( isLatLon1D ) { points = calcLatLon1DBoundaryPoints ( maxPointsInYEdge , maxPointsInXEdge ) ; } else if ( isLatLon2D ) { points = calcLatLon2DBoundaryPoints ( maxPointsInYEdge , maxPointsInXEdge ) ; } else { throw new AssertionError ( "HorizCoordSys was not a projection, latLon1D, or latLon2D." ) ; } return connectLatLonPoints ( points ) ;


signature:
public class HorizCoordSys { /** * Calculates the boundary of this coordinate reference system , in projection coordinates . The boundary starts at the
 * lower left corner of the coverage - - i . e . { @ code ( y [ 0 ] , x [ 0 ] ) } - - and consists of the points that lie along the bottom ,
 * right , top , and left edges , in that order .
 * The { @ code maxPointsInYEdge } parameter establishes a limit on the number of boundary points that ' ll be included
 * from the right and left edges . { @ code maxPointsInXEdge } establishes a similar limit for the bottom and top edges .
 * The size of the returned list will be { @ code ≤ 2 * maxPointsInYEdge + 2 * maxPointsInXEdge } . Note that the corners
 * are always included , regardless of the arguments . If you wish to include ALL of the points along the edges in
 * the boundary , simply choose values for the parameters that are greater than the lengths of the corresponding
 * axes in the CRS . { @ link Integer # MAX _ VALUE } works great . In that case , the size of the returned list will be
 * { @ code 2 * numXcoords + 2 * numYcoords } .
 * @ param maxPointsInYEdge the maximum number of boundary points to include from the right and left edges .
 * @ param maxPointsInXEdge the maximum number of boundary points to include from the bottom and top edges .
 * @ return the boundary of this coordinate reference system , in projection coordinates .
 * @ throws UnsupportedOperationException if this CRS is not a projection . */
public List < ProjectionPoint > calcProjectionBoundaryPoints ( int maxPointsInYEdge , int maxPointsInXEdge ) { } }

implementation:
if ( ! isProjection ) { throw new UnsupportedOperationException ( "Coordinate system is not a projection." ) ; } checkMaxPointsInEdges ( maxPointsInYEdge , maxPointsInXEdge ) ; int numYtotal = yAxis . getNcoords ( ) ; int numXtotal = xAxis . getNcoords ( ) ; int strideY = calcStride ( numYtotal , maxPointsInYEdge ) ; int strideX = calcStride ( numXtotal , maxPointsInXEdge ) ; List < ProjectionPoint > points = new LinkedList < > ( ) ; // Bottom boundary points
for ( int i = 0 ; i < numXtotal ; i += strideX ) { points . add ( new ProjectionPointImpl ( xAxis . getCoordEdge1 ( i ) , yAxis . getCoordEdgeFirst ( ) ) ) ; } // Right boundary points
for ( int j = 0 ; j < numYtotal ; j += strideY ) { points . add ( new ProjectionPointImpl ( xAxis . getCoordEdgeLast ( ) , yAxis . getCoordEdge1 ( j ) ) ) ; } // Top boundary points
for ( int i = numXtotal - 1 ; i >= 0 ; i -= strideX ) { points . add ( new ProjectionPointImpl ( xAxis . getCoordEdge2 ( i ) , yAxis . getCoordEdgeLast ( ) ) ) ; } // Left boundary points
for ( int j = numYtotal - 1 ; j >= 0 ; j -= strideY ) { points . add ( new ProjectionPointImpl ( xAxis . getCoordEdgeFirst ( ) , yAxis . getCoordEdge2 ( j ) ) ) ; } assertNotExceedingMaxBoundaryPoints ( points . size ( ) , maxPointsInYEdge , maxPointsInXEdge ) ; return points ;


signature:
public class HorizCoordSys { /** * Returns a list of points that is equivalent to the input list , but with longitude values adjusted to ensure that
 * adjacent elements are " connected " .
 * Two points are " connected " if the absolute difference of their { @ link LatLonPointImpl # lonNormal normalized
 * longitudes } is { @ code ≤ 180 } . For example , the longitudes { @ code 112 } and { @ code 124 } are connected . So are
 * { @ code 15 } and { @ code - 27 } .
 * Two points may be " disconnected " if they lie on opposite sides of the international date line . For example ,
 * the longitudes { @ code 175 } and { @ code - 175 } are disconnected because their absolute difference is { @ code 350 } ,
 * which is { @ code > 180 } . To connect the two points , we adjust the second longitude to an equivalent value
 * in the range { @ code [ firstLon ± 180 ] } by adding or subtracting { @ code 360 } . So , { @ code - 175 } would become
 * { @ code 185 } . We perform this adjustment for each pair of adjacent elements in the list .
 * Performing the above adjustment will result in longitudes that lie outside of the normalized range of
 * ( { @ code [ - 180 , 180 ] } ) . To be precise , if adjustments are necessary , all of the longitudes in the returned list
 * will be in either { @ code [ - 360 , 0 ] } or { @ code [ 0 , 360 ] } . Consequently , adjusted points cannot be returned as
 * { @ link LatLonPoint } s ; they are returned as { @ link LatLonPointNoNormalize } objects instead .
 * Longitudes { @ code lon1 } and { @ code lon2 } are considered equivalent if { @ code lon1 = = lon2 + 360 * i } , for some
 * integer { @ code i } .
 * @ param points a sequence of normalized lat / lon points that potentially crosses the international date line .
 * @ return an equivalent sequence of points that has been adjusted to be " connected " . */
public static List < LatLonPointNoNormalize > connectLatLonPoints ( List < LatLonPoint > points ) { } }

implementation: LinkedList < LatLonPointNoNormalize > connectedPoints = new LinkedList < > ( ) ; for ( LatLonPoint point : points ) { double curLat = point . getLatitude ( ) ; double curLon = point . getLongitude ( ) ; if ( ! connectedPoints . isEmpty ( ) ) { double prevLon = connectedPoints . getLast ( ) . getLongitude ( ) ; curLon = LatLonPointImpl . lonNormal ( curLon , prevLon ) ; } connectedPoints . add ( new LatLonPointNoNormalize ( curLat , curLon ) ) ; } return connectedPoints ;


signature:
public class HorizCoordSys { /** * Returns the { @ link # calcConnectedLatLonBoundaryPoints ( int , int ) latitude / longitude boundary } of this coordinate
 * reference system as a polygon in WKT . It is used in the OpenLayers map in NCSS , as well as the
 * " datasetBoundaries " endpoint .
 * @ param maxPointsInYEdge the maximum number of boundary points to include from the right and left edges .
 * @ param maxPointsInXEdge the maximum number of boundary points to include from the bottom and top edges .
 * @ return the latitude / longitude boundary of this CRS as a polygon in WKT . */
public String getLatLonBoundaryAsWKT ( int maxPointsInYEdge , int maxPointsInXEdge ) { } }

implementation:
List < LatLonPointNoNormalize > points = calcConnectedLatLonBoundaryPoints ( maxPointsInYEdge , maxPointsInXEdge ) ; StringBuilder sb = new StringBuilder ( "POLYGON((" ) ; for ( LatLonPointNoNormalize point : points ) { sb . append ( String . format ( "%.3f %.3f, " , point . getLongitude ( ) , point . getLatitude ( ) ) ) ; } sb . delete ( sb . length ( ) - 2 , sb . length ( ) ) ; // Nuke trailing comma and space .
sb . append ( "))" ) ; return sb . toString ( ) ;


signature:
public class HTTPSession { /** * Provide defaults for a settings map */
static synchronized protected void setDefaults ( Map < Prop , Object > props ) { } }

implementation:
if ( false ) { // turn off for now
props . put ( Prop . HANDLE_AUTHENTICATION , Boolean . TRUE ) ; } props . put ( Prop . HANDLE_REDIRECTS , Boolean . TRUE ) ; props . put ( Prop . ALLOW_CIRCULAR_REDIRECTS , Boolean . TRUE ) ; props . put ( Prop . MAX_REDIRECTS , ( Integer ) DFALTREDIRECTS ) ; props . put ( Prop . SO_TIMEOUT , ( Integer ) DFALTSOTIMEOUT ) ; props . put ( Prop . CONN_TIMEOUT , ( Integer ) DFALTCONNTIMEOUT ) ; props . put ( Prop . CONN_REQ_TIMEOUT , ( Integer ) DFALTCONNREQTIMEOUT ) ; props . put ( Prop . USER_AGENT , DFALTUSERAGENT ) ;


signature:
public class HTTPSession { /** * Timeouts */
static synchronized public void setGlobalConnectionTimeout ( int timeout ) { } }

implementation: if ( timeout >= 0 ) { globalsettings . put ( Prop . CONN_TIMEOUT , ( Integer ) timeout ) ; globalsettings . put ( Prop . CONN_REQ_TIMEOUT , ( Integer ) timeout ) ; }


signature:
public class HTTPSession { /** * Compression */
static synchronized public void setGlobalCompression ( String compressors ) { } }

implementation: if ( globalsettings . get ( Prop . COMPRESSION ) != null ) removeGlobalCompression ( ) ; String compresslist = checkCompressors ( compressors ) ; if ( HTTPUtil . nullify ( compresslist ) == null ) throw new IllegalArgumentException ( "Bad compressors: " + compressors ) ; globalsettings . put ( Prop . COMPRESSION , compresslist ) ; HttpResponseInterceptor hrsi ; if ( compresslist . contains ( "gzip" ) ) { hrsi = new GZIPResponseInterceptor ( ) ; rspintercepts . add ( hrsi ) ; } if ( compresslist . contains ( "deflate" ) ) { hrsi = new DeflateResponseInterceptor ( ) ; rspintercepts . add ( hrsi ) ; }


signature:
public class HTTPSession { /** * It is convenient to be able to directly set the Credentials
 * ( not the provider ) when those credentials are fixed .
 * @ param creds
 * @ param scope where to use it ( i . e . on what host )
 * @ throws HTTPException */
static public void setGlobalCredentials ( Credentials creds , AuthScope scope ) throws HTTPException { } }

implementation: assert ( creds != null ) ; if ( scope == null ) scope = AuthScope . ANY ; CredentialsProvider provider = new BasicCredentialsProvider ( ) ; provider . setCredentials ( scope , creds ) ; setGlobalCredentialsProvider ( provider , scope ) ;


signature:
public class HTTPSession { /** * Interceptors : Only supported at global level */
static protected void setInterceptors ( HttpClientBuilder cb ) { } }

implementation:
for ( HttpRequestInterceptor hrq : reqintercepts ) { cb . addInterceptorLast ( hrq ) ; } for ( HttpResponseInterceptor hrs : rspintercepts ) { cb . addInterceptorLast ( hrs ) ; } // Add debug interceptors
for ( HttpRequestInterceptor hrq : dbgreq ) { cb . addInterceptorFirst ( hrq ) ; } for ( HttpResponseInterceptor hrs : dbgrsp ) { cb . addInterceptorFirst ( hrs ) ; } // Hack : add Content - Encoding suppressor
cb . addInterceptorFirst ( CEKILL ) ;


signature:
public class HTTPSession { /** * Extract the sessionid cookie value
 * @ return sessionid string */
public String getSessionID ( ) { } }

implementation: String sid = null ; String jsid = null ; List < Cookie > cookies = this . sessioncontext . getCookieStore ( ) . getCookies ( ) ; for ( Cookie cookie : cookies ) { if ( cookie . getName ( ) . equalsIgnoreCase ( "sessionid" ) ) sid = cookie . getValue ( ) ; if ( cookie . getName ( ) . equalsIgnoreCase ( "jsessionid" ) ) jsid = cookie . getValue ( ) ; } return ( sid == null ? jsid : sid ) ;


signature:
public class HTTPSession { /** * Set the max number of redirects to follow
 * @ param n */
public HTTPSession setMaxRedirects ( int n ) { } }

implementation:
if ( n < 0 ) // validate
throw new IllegalArgumentException ( "setMaxRedirects" ) ; localsettings . put ( Prop . MAX_REDIRECTS , n ) ; this . cachevalid = false ; return this ;


signature:
public class HTTPSession { /** * Enable / disable redirection following
 * Default is yes . */
public HTTPSession setFollowRedirects ( boolean tf ) { } }

implementation: localsettings . put ( Prop . HANDLE_REDIRECTS , ( Boolean ) tf ) ; this . cachevalid = false ; return this ;


signature:
public class HTTPSession { /** * Should we use sessionid ' s ?
 * @ param tf */
public HTTPSession setUseSessions ( boolean tf ) { } }

implementation: localsettings . put ( Prop . USESESSIONS , ( Boolean ) tf ) ; this . cachevalid = false ; return this ;


signature:
public class HTTPSession { /** * Close the session . This implies closing
 * any open methods . */
synchronized public void close ( ) { } }

implementation:
if ( this . closed ) return ; // multiple calls ok
closed = true ; for ( HTTPMethod m : this . methods ) { m . close ( ) ; // forcibly close ; will invoke removemethod ( ) .
} methods . clear ( ) ;


signature:
public class HTTPSession { /** * This is the most general case
 * @ param provider the credentials provider
 * @ param scope where to use it ( i . e . on what host + port )
 * @ throws HTTPException */
public HTTPSession setCredentialsProvider ( CredentialsProvider provider , AuthScope scope ) throws HTTPException { } }

implementation: if ( provider == null ) throw new NullPointerException ( this . getClass ( ) . getName ( ) ) ; if ( scope == null ) scope = AuthScope . ANY ; localcreds . put ( scope , provider ) ; return this ;


signature:
public class HTTPSession { /** * It is convenient to be able to directly set the Credentials
 * ( not the provider ) when those credentials are fixed .
 * @ param creds
 * @ param scope where to use it ( i . e . on what host )
 * @ throws HTTPException */
public HTTPSession setCredentials ( Credentials creds , AuthScope scope ) throws HTTPException { } }

implementation: assert ( creds != null ) ; if ( scope == null ) scope = AuthScope . ANY ; CredentialsProvider provider = new BasicCredentialsProvider ( ) ; provider . setCredentials ( scope , creds ) ; setCredentialsProvider ( provider , scope ) ; return this ;


signature:
public class HTTPSession { /** * Handle authentication and Proxy ' ing
 * @ param cb
 * @ throws HTTPException */
synchronized protected void setAuthenticationAndProxy ( HttpClientBuilder cb ) throws HTTPException { } }

implementation:
// First , setup the ssl factory
cb . setSSLSocketFactory ( ( SSLConnectionSocketFactory ) authcontrols . get ( AuthProp . SSLFACTORY ) ) ; // Second , Construct a CredentialsProvider that is
// the union of the Proxy credentials plus
// either the global or local credentials ; local overrides global
// Unfortunately , we cannot either clone or extract the contents
// of the client supplied provider , so we are forced ( for now )
// to modify the client supplied provider .
// Look in the local credentials first for for best scope match
AuthScope bestMatch = HTTPAuthUtil . bestmatch ( scope , localcreds . keySet ( ) ) ; CredentialsProvider cp = null ; if ( bestMatch != null ) { cp = localcreds . get ( bestMatch ) ; } else { bestMatch = HTTPAuthUtil . bestmatch ( scope , globalcredfactories . keySet ( ) ) ; if ( bestMatch != null ) { HTTPProviderFactory factory = globalcredfactories . get ( bestMatch ) ; cp = factory . getProvider ( bestMatch ) ; } } // Build the proxy credentials and AuthScope
Credentials proxycreds = null ; AuthScope proxyscope = null ; String user = ( String ) authcontrols . get ( AuthProp . PROXYUSER ) ; String pwd = ( String ) authcontrols . get ( AuthProp . PROXYPWD ) ; HttpHost httpproxy = ( HttpHost ) authcontrols . get ( AuthProp . HTTPPROXY ) ; HttpHost httpsproxy = ( HttpHost ) authcontrols . get ( AuthProp . HTTPSPROXY ) ; if ( user != null && ( httpproxy != null || httpsproxy != null ) ) { if ( httpproxy != null ) proxyscope = HTTPAuthUtil . hostToAuthScope ( httpproxy ) ; else // httpsproxy ! = null
proxyscope = HTTPAuthUtil . hostToAuthScope ( httpsproxy ) ; proxycreds = new UsernamePasswordCredentials ( user , pwd ) ; } if ( cp == null && proxycreds != null && proxyscope != null ) { // If client provider is null and proxycreds are not ,
// then use proxycreds alone
cp = new BasicCredentialsProvider ( ) ; cp . setCredentials ( proxyscope , proxycreds ) ; } else if ( cp != null && proxycreds != null && proxyscope != null ) { // If client provider is not null and proxycreds are not ,
// then add proxycreds to the client provider
cp . setCredentials ( proxyscope , proxycreds ) ; } if ( cp != null ) this . sessioncontext . setCredentialsProvider ( cp ) ;


signature:
public class HTTPSession { /** * / * package scope */
public Map < Prop , Object > mergedSettings ( ) { } }

implementation:
Map < Prop , Object > merged ; synchronized ( this ) { // keep coverity happy
// Merge Settings ;
merged = HTTPUtil . merge ( globalsettings , localsettings ) ; } return Collections . unmodifiableMap ( merged ) ;


signature:
public class HTTPSession { /** * Utilities */
static String getCanonicalURL ( String legalurl ) { } }

implementation:
if ( legalurl == null ) return null ; int index = legalurl . indexOf ( '?' ) ; if ( index >= 0 ) legalurl = legalurl . substring ( 0 , index ) ; // remove any trailing extension
// index = legalurl . lastIndexOf ( ' . ' ) ;
// if ( index > = 0 ) legalurl = legalurl . substring ( 0 , index ) ;
return HTTPUtil . canonicalpath ( legalurl ) ;


signature:
public class HTTPSession { /** * If we are testing , then track the sessions for kill */
static protected synchronized void track ( HTTPSession session ) { } }

implementation: if ( ! TESTING ) throw new UnsupportedOperationException ( ) ; if ( sessionList == null ) sessionList = new ConcurrentSkipListSet < HTTPSession > ( ) ; sessionList . add ( session ) ;


signature:
public class HTTPSession { /** * / * Only allow if debugging */
static public void clearkeystore ( ) { } }

implementation: if ( ! TESTING ) throw new UnsupportedOperationException ( ) ; authcontrols . setReadOnly ( false ) ; authcontrols . remove ( AuthProp . KEYSTORE ) ; authcontrols . remove ( AuthProp . KEYPASSWORD ) ; authcontrols . remove ( AuthProp . TRUSTSTORE ) ; authcontrols . remove ( AuthProp . TRUSTPASSWORD ) ; authcontrols . setReadOnly ( true ) ;


signature:
public class HTTPSession { /** * / * Only allow if debugging */
static public void rebuildkeystore ( String path , String pwd ) { } }

implementation: if ( ! TESTING ) throw new UnsupportedOperationException ( ) ; KeyStore newks = buildkeystore ( path , pwd ) ; authcontrols . setReadOnly ( false ) ; authcontrols . put ( AuthProp . KEYSTORE , newks ) ; authcontrols . setReadOnly ( true ) ;


signature:
public class HTTPSession { /** * Deprecated , but here for back compatibility */
@ Deprecated static public void setGlobalCredentialsProvider ( AuthScope scope , CredentialsProvider provider ) throws HTTPException { } }

implementation: setGlobalCredentialsProvider ( provider , scope ) ;


signature:
public class HTTPSession { /** * obsolete */
static protected synchronized void kill ( ) { } }

implementation: if ( sessionList != null ) { for ( HTTPSession session : sessionList ) { session . close ( ) ; } sessionList . clear ( ) ; connmgr . close ( ) ; }


signature:
public class HTTPSession { /** * This is the most general case
 * @ param provider the credentials provider
 * @ param scope where to use it ( i . e . on what host )
 * @ throws HTTPException */
@ Deprecated static public void setGlobalCredentialsProvider ( CredentialsProvider provider , AuthScope scope ) throws HTTPException { } }

implementation: HTTPProviderFactory factory = new SingleProviderFactory ( provider ) ; setCredentialsProviderFactory ( factory , scope ) ;


signature:
public class TextGetPutPane { /** * private DqcFactory dqcFactory = null ; */
void validate ( String urlString ) { } }

implementation:
if ( urlString == null ) return ; URI uri ; try { uri = new URI ( urlString ) ; } catch ( URISyntaxException e ) { javax . swing . JOptionPane . showMessageDialog ( null , "URISyntaxException on URL (" + urlString + ") " + e . getMessage ( ) + "\n" ) ; return ; } String contents = getText ( ) ; // boolean isCatalog = contents . indexOf ( " queryCapability " ) < 0;
ByteArrayInputStream is = new ByteArrayInputStream ( contents . getBytes ( CDM . utf8Charset ) ) ; try { CatalogBuilder catFactory = new CatalogBuilder ( ) ; Catalog cat = catFactory . buildFromLocation ( urlString , null ) ; boolean isValid = ! catFactory . hasFatalError ( ) ; javax . swing . JOptionPane . showMessageDialog ( this , "Catalog Validation = " + isValid + "\n" + catFactory . getErrorMessage ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; }


signature:
public class Index { /** * Generate a subclass of Index optimized for this array ' s rank
 * @ param shape use this shape
 * @ return a subclass of Index optimized for this array ' s rank */
static public Index factory ( int [ ] shape ) { } }

implementation: int rank = shape . length ; switch ( rank ) { case 0 : return new Index0D ( ) ; case 1 : return new Index1D ( shape ) ; case 2 : return new Index2D ( shape ) ; case 3 : return new Index3D ( shape ) ; case 4 : return new Index4D ( shape ) ; case 5 : return new Index5D ( shape ) ; case 6 : return new Index6D ( shape ) ; case 7 : return new Index7D ( shape ) ; default : return new Index ( shape ) ; }


signature:
public class Index { /** * Compute standard strides based on array ' s shape .
 * Ignore vlen
 * @ param shape length of array in each dimension .
 * @ param stride put result here
 * @ return standard strides based on array ' s shape . */
static private long computeStrides ( int [ ] shape , int [ ] stride ) { } }

implementation:
long product = 1 ; for ( int ii = shape . length - 1 ; ii >= 0 ; ii -- ) { final int thisDim = shape [ ii ] ; if ( thisDim < 0 ) continue ; // ignore vlen
stride [ ii ] = ( int ) product ; product *= thisDim ; } return product ;


signature:
public class Index { /** * Create a new Index based on current one , except
 * flip the index so that it runs from shape [ index ] - 1 to 0.
 * Leave rightmost vlen alone .
 * @ param index dimension to flip
 * @ return new index with flipped dimension */
Index flip ( int index ) { } }

implementation:
if ( ( index < 0 ) || ( index >= rank ) ) throw new IllegalArgumentException ( ) ; Index i = ( Index ) this . clone ( ) ; if ( shape [ index ] >= 0 ) { // ! vlen case
i . offset += stride [ index ] * ( shape [ index ] - 1 ) ; i . stride [ index ] = - stride [ index ] ; } i . fastIterator = false ; i . precalc ( ) ; // any subclass - specific optimizations
return i ;


signature:
public class Index { /** * create a new Index based on a subsection of this one , with rank reduction if
 * dimension length = = 1.
 * @ param ranges array of Ranges that specify the array subset .
 * Must be same rank as original Array .
 * A particular Range : 1 ) may be a subset ; 2 ) may be null , meaning use entire Range .
 * @ return new Index , with same or smaller rank as original .
 * @ throws InvalidRangeException if ranges dont match current shape */
Index section ( List < Range > ranges ) throws InvalidRangeException { } }

implementation:
// check ranges are valid
if ( ranges . size ( ) != rank ) throw new InvalidRangeException ( "Bad ranges [] length" ) ; for ( int ii = 0 ; ii < rank ; ii ++ ) { Range r = ranges . get ( ii ) ; if ( r == null ) continue ; if ( r == Range . VLEN ) continue ; if ( ( r . first ( ) < 0 ) || ( r . first ( ) >= shape [ ii ] ) ) throw new InvalidRangeException ( "Bad range starting value at index " + ii + " == " + r . first ( ) ) ; if ( ( r . last ( ) < 0 ) || ( r . last ( ) >= shape [ ii ] ) ) throw new InvalidRangeException ( "Bad range ending value at index " + ii + " == " + r . last ( ) ) ; } int reducedRank = rank ; for ( Range r : ranges ) { if ( ( r != null ) && ( r . length ( ) == 1 ) ) reducedRank -- ; } Index newindex = Index . factory ( reducedRank ) ; newindex . offset = offset ; // calc shape , size , and index transformations
// calc strides into original ( backing ) store
int newDim = 0 ; for ( int ii = 0 ; ii < rank ; ii ++ ) { Range r = ranges . get ( ii ) ; if ( r == null ) { // null range means use the whole original dimension
newindex . shape [ newDim ] = shape [ ii ] ; newindex . stride [ newDim ] = stride [ ii ] ; // if ( name ! = null ) newindex . name [ newDim ] = name [ ii ] ;
newDim ++ ; } else if ( r . length ( ) != 1 ) { newindex . shape [ newDim ] = r . length ( ) ; newindex . stride [ newDim ] = stride [ ii ] * r . stride ( ) ; newindex . offset += stride [ ii ] * r . first ( ) ; // if ( name ! = null ) newindex . name [ newDim ] = name [ ii ] ;
newDim ++ ; } else { newindex . offset += stride [ ii ] * r . first ( ) ; // constant due to rank reduction
} } newindex . size = computeSize ( newindex . shape ) ; newindex . fastIterator = fastIterator && ( newindex . size == size ) ; // if equal , then its not a real subset , so can still use fastIterator
newindex . precalc ( ) ; // any subclass - specific optimizations
return newindex ;


signature:
public class Index { /** * Create a new Index based on current one by
 * eliminating any dimensions with length one .
 * @ return the new Index */
Index reduce ( ) { } }

implementation:
Index c = this ; for ( int ii = 0 ; ii < rank ; ii ++ ) if ( shape [ ii ] == 1 ) { // do this on the first one you find
Index newc = c . reduce ( ii ) ; return newc . reduce ( ) ; // any more to do ?
} return c ;


signature:
public class Index { /** * Create a new Index based on current one by
 * eliminating the specified dimension ;
 * @ param dim : dimension to eliminate : must be of length one , else IllegalArgumentException
 * @ return the new Index */
Index reduce ( int dim ) { } }

implementation:
if ( ( dim < 0 ) || ( dim >= rank ) ) throw new IllegalArgumentException ( "illegal reduce dim " + dim ) ; if ( shape [ dim ] != 1 ) throw new IllegalArgumentException ( "illegal reduce dim " + dim + " : length != 1" ) ; Index newindex = Index . factory ( rank - 1 ) ; newindex . offset = offset ; int count = 0 ; for ( int ii = 0 ; ii < rank ; ii ++ ) { if ( ii != dim ) { newindex . shape [ count ] = shape [ ii ] ; newindex . stride [ count ] = stride [ ii ] ; // if ( name ! = null ) newindex . name [ count ] = name [ ii ] ;
count ++ ; } } newindex . size = computeSize ( newindex . shape ) ; newindex . fastIterator = fastIterator ; newindex . precalc ( ) ; // any subclass - specific optimizations
return newindex ;


signature:
public class Index { /** * create a new Index based on current one , except
 * transpose two of the indices .
 * @ param index1 transpose these two indices
 * @ param index2 transpose these two indices
 * @ return new Index with transposed indices */
Index transpose ( int index1 , int index2 ) { } }

implementation:
if ( ( index1 < 0 ) || ( index1 >= rank ) ) throw new IllegalArgumentException ( ) ; if ( ( index2 < 0 ) || ( index2 >= rank ) ) throw new IllegalArgumentException ( ) ; Index newIndex = ( Index ) this . clone ( ) ; newIndex . stride [ index1 ] = stride [ index2 ] ; newIndex . stride [ index2 ] = stride [ index1 ] ; newIndex . shape [ index1 ] = shape [ index2 ] ; newIndex . shape [ index2 ] = shape [ index1 ] ; /* if ( name ! = null ) {
 newIndex . name [ index1 ] = name [ index2 ] ;
 newIndex . name [ index2 ] = name [ index1 ] ; */
newIndex . fastIterator = false ; newIndex . precalc ( ) ; // any subclass - specific optimizations
return newIndex ;


signature:
public class Index { /** * create a new Index based on a permutation of the current indices ; vlen fails .
 * @ param dims : the old index dim [ k ] becomes the new kth index .
 * @ return new Index with permuted indices */
Index permute ( int [ ] dims ) { } }

implementation:
if ( dims . length != shape . length ) throw new IllegalArgumentException ( ) ; for ( int dim : dims ) if ( ( dim < 0 ) || ( dim >= rank ) ) throw new IllegalArgumentException ( ) ; boolean isPermuted = false ; Index newIndex = ( Index ) this . clone ( ) ; for ( int i = 0 ; i < dims . length ; i ++ ) { newIndex . stride [ i ] = stride [ dims [ i ] ] ; newIndex . shape [ i ] = shape [ dims [ i ] ] ; // if ( name ! = null ) newIndex . name [ i ] = name [ dims [ i ] ] ;
if ( i != dims [ i ] ) isPermuted = true ; } newIndex . fastIterator = fastIterator && ! isPermuted ; // useful optimization
newIndex . precalc ( ) ; // any subclass - specific optimizations
return newIndex ;


signature:
public class Index { /** * Get an index iterator for traversing the array in canonical order .
 * @ param maa the array to iterate through
 * @ return an index iterator for traversing the array in canonical order .
 * @ see IndexIterator */
IndexIterator getIndexIterator ( Array maa ) { } }

implementation: if ( fastIterator ) return new IteratorFast ( size , maa ) ; else return new IteratorImpl ( maa ) ;


signature:
public class Index { /** * Get the current element ' s index into the 1D backing array .
 * VLEN stops processing .
 * @ return the current element ' s index into the 1D backing array . */
public int currentElement ( ) { } }

implementation:
int value = offset ; // NB : dont have to check each index again
for ( int ii = 0 ; ii < rank ; ii ++ ) { // general rank
if ( shape [ ii ] < 0 ) break ; // vlen
value += current [ ii ] * stride [ ii ] ; } return value ;


signature:
public class Index { /** * Set the current counter from the 1D " current element "
 * currElement = offset + stride [ 0 ] * current [ 0 ] + . . .
 * @ param currElement set to this value */
public void setCurrentCounter ( int currElement ) { } }

implementation:
currElement -= offset ; for ( int ii = 0 ; ii < rank ; ii ++ ) { // general rank
if ( shape [ ii ] < 0 ) { current [ ii ] = - 1 ; break ; } current [ ii ] = currElement / stride [ ii ] ; currElement -= current [ ii ] * stride [ ii ] ; } set ( current ) ; // transfer to subclass fields


signature:
public class Index { /** * Set the current element ' s index . General - rank case .
 * @ param index set current value to these values
 * @ return this , so you can use A . get ( i . set ( i ) )
 * @ throws ArrayIndexOutOfBoundsException if index . length ! = rank . */
public Index set ( int [ ] index ) { } }

implementation: if ( index . length != rank ) throw new ArrayIndexOutOfBoundsException ( ) ; if ( rank == 0 ) return this ; int prefixrank = ( hasvlen ? rank : rank - 1 ) ; System . arraycopy ( index , 0 , current , 0 , prefixrank ) ; if ( hasvlen ) current [ prefixrank ] = - 1 ; return this ;


signature:
public class Index { /** * set current element at dimension dim to v
 * @ param dim set this dimension
 * @ param value to this value */
public void setDim ( int dim , int value ) { } }

implementation:
if ( value < 0 || value >= shape [ dim ] ) // check index here
throw new ArrayIndexOutOfBoundsException ( ) ; if ( shape [ dim ] >= 0 ) // ! vlen
current [ dim ] = value ;


signature:
public class Index { /** * set current element at dimension 0,1,2 to v0 , v1 , v2
 * @ param v0 set dimension 0 index to this value
 * @ param v1 set dimension 1 index to this value
 * @ param v2 set dimension 2 index to this value
 * @ return this , so you can use A . get ( i . set ( i , j , k ) ) */
public Index set ( int v0 , int v1 , int v2 ) { } }

implementation: setDim ( 0 , v0 ) ; setDim ( 1 , v1 ) ; setDim ( 2 , v2 ) ; return this ;


signature:
public class Index { /** * String representation
 * @ return String representation */
public String toStringDebug ( ) { } }

implementation:
StringBuilder sbuff = new StringBuilder ( 100 ) ; sbuff . setLength ( 0 ) ; sbuff . append ( " shape= " ) ; for ( int ii = 0 ; ii < rank ; ii ++ ) { sbuff . append ( shape [ ii ] ) ; sbuff . append ( " " ) ; } sbuff . append ( " stride= " ) ; for ( int ii = 0 ; ii < rank ; ii ++ ) { sbuff . append ( stride [ ii ] ) ; sbuff . append ( " " ) ; } /* if ( name ! = null ) {
 sbuff . append ( " names = " ) ;
 for ( int ii = 0 ; ii < rank ; ii + + ) {
 sbuff . append ( name [ ii ] ) ;
 sbuff . append ( " " ) ; */
sbuff . append ( " offset= " ) . append ( offset ) ; sbuff . append ( " rank= " ) . append ( rank ) ; sbuff . append ( " size= " ) . append ( size ) ; sbuff . append ( " current= " ) ; for ( int ii = 0 ; ii < rank ; ii ++ ) { sbuff . append ( current [ ii ] ) ; sbuff . append ( " " ) ; } return sbuff . toString ( ) ;


signature:
public class CoordinateTimeIntv { /** * Check if we all time intervals have the same length .
 * @ return time interval name or MIXED _ INTERVALS */
public String getTimeIntervalName ( ) { } }

implementation:
// are they the same length ?
int firstValue = - 1 ; for ( TimeCoordIntvValue tinv : timeIntervals ) { int value = ( tinv . getBounds2 ( ) - tinv . getBounds1 ( ) ) ; if ( firstValue < 0 ) firstValue = value ; else if ( value != firstValue ) return MIXED_INTERVALS ; } firstValue = ( firstValue * timeUnit . getValue ( ) ) ; return firstValue + "_" + timeUnit . getField ( ) . toString ( ) ;


signature:
public class CoordinateTimeIntv { /** * Make calendar date range , using the first and last ending bounds
 * @ param cal optional calendar , may be null
 * @ return calendar date range */
@ Override public CalendarDateRange makeCalendarDateRange ( ucar . nc2 . time . Calendar cal ) { } }

implementation: CalendarDateUnit cdu = CalendarDateUnit . of ( cal , timeUnit . getField ( ) , refDate ) ; CalendarDate start = cdu . makeCalendarDate ( timeUnit . getValue ( ) * timeIntervals . get ( 0 ) . getBounds2 ( ) ) ; CalendarDate end = cdu . makeCalendarDate ( timeUnit . getValue ( ) * timeIntervals . get ( getSize ( ) - 1 ) . getBounds2 ( ) ) ; return CalendarDateRange . of ( start , end ) ;


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

implementation:
// Trace . startTrace ( ) ;
if ( ! super . init ( fullCheck ) ) { return false ; } if ( ( dmLabel . kftype != MFSN ) && ( dmLabel . kftype != MFSF ) ) { logError ( "not a point data file " ) ; return false ; } return true ;


signature:
public class AbstractGempakStationFileReader { /** * Read in the stations and times . Subclasses should
 * call this during init ( )
 * @ param uniqueTimes make a set of unique times
 * @ return true if stations and times were read okay . */
protected boolean readStationsAndTimes ( boolean uniqueTimes ) { } }

implementation:
for ( DMPart apart : parts ) { List < GempakParameter > params = makeParams ( apart ) ; partParamMap . put ( apart . kprtnm , params ) ; } // get the date / time keys
dateTimeKeys = getDateTimeKeys ( ) ; if ( ( dateTimeKeys == null ) || dateTimeKeys . isEmpty ( ) ) { return false ; } // get the station info
stationKeys = findStationKeys ( ) ; if ( ( stationKeys == null ) || stationKeys . isEmpty ( ) ) { return false ; } stations = getStationList ( ) ; makeFileSubType ( ) ; // null out the old cached list
dates = null ; dateList = makeDateList ( uniqueTimes ) ; return true ;


signature:
public class AbstractGempakStationFileReader { /** * Get the date / time information
 * @ return the list of date / time keys */
private List < Key > getDateTimeKeys ( ) { } }

implementation: Key date = findKey ( DATE ) ; Key time = findKey ( TIME ) ; if ( ( date == null ) || ( time == null ) || ! date . type . equals ( time . type ) ) { return null ; } List < Key > dt = new ArrayList < > ( 2 ) ; dt . add ( date ) ; dt . add ( time ) ; return dt ;


signature:
public class AbstractGempakStationFileReader { /** * Get the list of dates
 * @ param unique true for unique list
 * @ return the list of dates */
protected List < String > makeDateList ( boolean unique ) { } }

implementation:
Key date = dateTimeKeys . get ( 0 ) ; Key time = dateTimeKeys . get ( 1 ) ; List < int [ ] > toCheck ; if ( date . type . equals ( ROW ) ) { toCheck = headers . rowHeaders ; } else { toCheck = headers . colHeaders ; } List < String > fileDates = new ArrayList < > ( ) ; for ( int [ ] header : toCheck ) { if ( header [ 0 ] != IMISSD ) { // convert to GEMPAK date / time
int idate = header [ date . loc + 1 ] ; int itime = header [ time . loc + 1 ] ; // TODO : Add in the century
String dateTime = GempakUtil . TI_CDTM ( idate , itime ) ; fileDates . add ( dateTime ) ; } } if ( unique && ! fileDates . isEmpty ( ) ) { SortedSet < String > uniqueTimes = Collections . synchronizedSortedSet ( new TreeSet < String > ( ) ) ; uniqueTimes . addAll ( fileDates ) ; fileDates . clear ( ) ; fileDates . addAll ( uniqueTimes ) ; } return fileDates ;


signature:
public class AbstractGempakStationFileReader { /** * Make GempakParameters from the list of
 * @ param part the part to use
 * @ return parameters from the info in that part . */
private List < GempakParameter > makeParams ( DMPart part ) { } }

implementation:
List < GempakParameter > gemparms = new ArrayList < > ( part . kparms ) ; for ( DMParam param : part . params ) { String name = param . kprmnm ; GempakParameter parm = GempakParameters . getParameter ( name ) ; if ( parm == null ) { // System . out . println ( " couldn ' t find " + name
// + " in params table " ) ;
parm = new GempakParameter ( 1 , name , name , "" , 0 ) ; } gemparms . add ( parm ) ; } return gemparms ;


signature:
public class AbstractGempakStationFileReader { /** * Get the station list
 * @ return the list of stations */
private List < GempakStation > getStationList ( ) { } }

implementation: Key slat = findKey ( GempakStation . SLAT ) ; if ( slat == null ) { return null ; } List < int [ ] > toCheck ; if ( slat . type . equals ( ROW ) ) { toCheck = headers . rowHeaders ; } else { toCheck = headers . colHeaders ; } List < GempakStation > fileStations = new ArrayList < > ( ) ; int i = 0 ; for ( int [ ] header : toCheck ) { if ( header [ 0 ] != IMISSD ) { GempakStation station = makeStation ( header ) ; if ( station != null ) { station . setIndex ( i + 1 ) ; fileStations . add ( station ) ; } } i ++ ; } return fileStations ;


signature:
public class AbstractGempakStationFileReader { /** * Make a station from the header info
 * @ param header the station header
 * @ return the corresponding station */
private GempakStation makeStation ( int [ ] header ) { } }

implementation: if ( ( stationKeys == null ) || stationKeys . isEmpty ( ) ) { return null ; } GempakStation newStation = new GempakStation ( ) ; for ( Key key : stationKeys ) { int loc = key . loc + 1 ; switch ( key . name ) { case GempakStation . STID : newStation . setSTID ( GempakUtil . ST_ITOC ( header [ loc ] ) . trim ( ) ) ; break ; case GempakStation . STNM : newStation . setSTNM ( header [ loc ] ) ; break ; case GempakStation . SLAT : newStation . setSLAT ( header [ loc ] ) ; break ; case GempakStation . SLON : newStation . setSLON ( header [ loc ] ) ; break ; case GempakStation . SELV : newStation . setSELV ( header [ loc ] ) ; break ; case GempakStation . SPRI : newStation . setSPRI ( header [ loc ] ) ; break ; case GempakStation . STAT : newStation . setSTAT ( GempakUtil . ST_ITOC ( header [ loc ] ) . trim ( ) ) ; break ; case GempakStation . COUN : newStation . setCOUN ( GempakUtil . ST_ITOC ( header [ loc ] ) . trim ( ) ) ; break ; case GempakStation . SWFO : newStation . setSWFO ( GempakUtil . ST_ITOC ( header [ loc ] ) . trim ( ) ) ; break ; case GempakStation . WFO2 : newStation . setWFO2 ( GempakUtil . ST_ITOC ( header [ loc ] ) . trim ( ) ) ; break ; case GempakStation . STD2 : newStation . setSTD2 ( GempakUtil . ST_ITOC ( header [ loc ] ) . trim ( ) ) ; break ; } } return newStation ;


signature:
public class AbstractGempakStationFileReader { /** * Get the station key names
 * @ return the list of station key names */
public List < String > getStationKeyNames ( ) { } }

implementation: List < String > keys = new ArrayList < > ( ) ; if ( ( stationKeys != null ) && ! stationKeys . isEmpty ( ) ) { for ( Key key : stationKeys ) { keys . add ( key . name ) ; } } return keys ;


signature:
public class AbstractGempakStationFileReader { /** * Get the station keys
 * @ return the list of station keys */
private List < Key > findStationKeys ( ) { } }

implementation:
Key stid = findKey ( GempakStation . STID ) ; Key stnm = findKey ( GempakStation . STNM ) ; Key slat = findKey ( GempakStation . SLAT ) ; Key slon = findKey ( GempakStation . SLON ) ; Key selv = findKey ( GempakStation . SELV ) ; Key stat = findKey ( GempakStation . STAT ) ; Key coun = findKey ( GempakStation . COUN ) ; Key std2 = findKey ( GempakStation . STD2 ) ; Key spri = findKey ( GempakStation . SPRI ) ; Key swfo = findKey ( GempakStation . SWFO ) ; Key wfo2 = findKey ( GempakStation . WFO2 ) ; if ( ( slat == null ) || ( slon == null ) || ! slat . type . equals ( slon . type ) ) { return null ; } String tslat = slat . type ; // check to make sure they are all in the same set of keys
List < Key > stKeys = new ArrayList < > ( ) ; stKeys . add ( slat ) ; stKeys . add ( slon ) ; if ( ( stid != null ) && ! stid . type . equals ( tslat ) ) { return null ; } else if ( ( stnm != null ) && ! stnm . type . equals ( tslat ) ) { return null ; } else if ( ( selv != null ) && ! selv . type . equals ( tslat ) ) { return null ; } else if ( ( stat != null ) && ! stat . type . equals ( tslat ) ) { return null ; } else if ( ( coun != null ) && ! coun . type . equals ( tslat ) ) { return null ; } else if ( ( std2 != null ) && ! std2 . type . equals ( tslat ) ) { return null ; } else if ( ( spri != null ) && ! spri . type . equals ( tslat ) ) { return null ; } else if ( ( swfo != null ) && ! swfo . type . equals ( tslat ) ) { return null ; } else if ( ( wfo2 != null ) && ! wfo2 . type . equals ( tslat ) ) { return null ; } if ( stid != null ) { stKeys . add ( stid ) ; } if ( stnm != null ) { stKeys . add ( stnm ) ; } if ( selv != null ) { stKeys . add ( selv ) ; } if ( stat != null ) { stKeys . add ( stat ) ; } if ( coun != null ) { stKeys . add ( coun ) ; } if ( std2 != null ) { stKeys . add ( std2 ) ; } if ( spri != null ) { stKeys . add ( spri ) ; } if ( swfo != null ) { stKeys . add ( swfo ) ; } if ( wfo2 != null ) { stKeys . add ( wfo2 ) ; } return stKeys ;


signature:
public class AbstractGempakStationFileReader { /** * Get the list of dates in this file .
 * @ return list of dates . */
public List < Date > getDates ( ) { } }

implementation:
if ( ( dates == null || dates . isEmpty ( ) ) && ! dateList . isEmpty ( ) ) { dates = new ArrayList < > ( dateList . size ( ) ) ; dateFmt . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; for ( String dateString : dateList ) { Date d = dateFmt . parse ( dateString , new ParsePosition ( 0 ) ) ; // DateFromString . getDateUsingSimpleDateFormat ( dateString ,
// DATE _ FORMAT ) ;
dates . add ( d ) ; } } return dates ;


signature:
public class AbstractGempakStationFileReader { /** * Print the list of dates in the file */
public void printDates ( ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; builder . append ( "\nDates:\n" ) ; for ( String date : dateList ) { builder . append ( "\t" ) ; builder . append ( date ) ; builder . append ( "\n" ) ; } System . out . println ( builder . toString ( ) ) ;


signature:
public class AbstractGempakStationFileReader { /** * Print the list of dates in the file
 * @ param list true to list each station , false to list summary */
public void printStations ( boolean list ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; builder . append ( "\nStations:\n" ) ; if ( list ) { for ( GempakStation station : getStations ( ) ) { builder . append ( station ) ; builder . append ( "\n" ) ; } } else { builder . append ( "\t" ) ; builder . append ( getStations ( ) . size ( ) ) ; } System . out . println ( builder . toString ( ) ) ;


signature:
public class AbstractGempakStationFileReader { /** * Find the station index for the specified station id .
 * @ param id station id ( case sensitive )
 * @ return index or - 1 if not found . */
public int findStationIndex ( String id ) { } }

implementation: for ( GempakStation station : getStations ( ) ) { if ( station . getSTID ( ) . equals ( id ) ) { return station . getIndex ( ) ; } } return - 1 ;


signature:
public class AbstractGempakStationFileReader { /** * Get the type for this file
 * @ return file type */
public String getFileType ( ) { } }

implementation: String type = "Unknown" ; switch ( dmLabel . kftype ) { case MFSN : type = "Sounding" ; break ; case MFSF : type = "Surface" ; break ; default : } if ( ! subType . equals ( "" ) ) { type = type + " (" + subType + ")" ; } return type ;


signature:
public class IndentWriter { /** * Set depth + = n
 * @ param n depth increment / decrement ( if neg ) */
public void indent ( int n ) { } }

implementation: depth += n ; if ( depth < 0 ) depth = 0 ; else if ( depth > MAXDEPTH ) depth = MAXDEPTH ;


signature:
public class IndentWriter { /** * Set depth = n
 * @ param n absolute depth */
public void setIndent ( int n ) { } }

implementation: depth = n ; if ( depth < 0 ) depth = 0 ; else if ( depth > MAXDEPTH ) depth = MAXDEPTH ;


signature:
public class AST { /** * / * Only call on the root node */
public void init ( CEEvaluator ceEval , BaseTypeFactory factory , ClauseFactory clauseFactory , ServerDDS sdds , List < AST > nodes ) { } }

implementation: this . ceEval = ceEval ; this . clauseFactory = clauseFactory ; this . factory = factory ; this . sdds = sdds ; this . root = this ; for ( AST node : nodes ) node . setRoot ( this ) ;


signature:
public class ASTconstraint { /** * public String toString ( )
 * StringBuilder buf = new StringBuilder ( ) ;
 * boolean first = true ;
 * if ( projections ! = null )
 * for ( ASTprojection p : projections ) {
 * buf . append ( ( first ? " " : " , " ) + p . toString ( ) ) ;
 * first = false ;
 * first = true ;
 * if ( selections ! = null )
 * for ( ASTclause c : selections ) {
 * buf . append ( c . toString ( ) ) ;
 * first = false ;
 * return buf . toString ( ) ; */
public void walkConstraint ( ) throws DAP2ServerSideException , DAP2Exception { } }

implementation: if ( projections != null ) for ( ASTprojection proj : projections ) { proj . walk ( ceEval ) ; } else getCeEval ( ) . markAll ( true ) ; if ( selections != null ) for ( ASTclause cl : selections ) { getCeEval ( ) . appendClause ( cl . translate ( ) ) ; }


signature:
public class ASTprojection { /** * public String toString ( )
 * if ( var ! = null )
 * return var . toString ( ) ;
 * else
 * return fcn . toString ( ) ; */
void walk ( CEEvaluator ceEval ) throws DAP2ServerSideException , DAP2Exception , NoSuchFunctionException , NoSuchVariableException { } }

implementation: if ( fcn != null ) { SubClause subclause = fcn . translate ( ) ; getCeEval ( ) . appendClause ( subclause ) ; } else { Stack components = new Stack ( ) ; components = var . collect ( components ) ; markStackedVariables ( components ) ; }


signature:
public class ASTfcn { /** * public String toString ( )
 * StringBuilder buf = new StringBuilder ( ) ;
 * boolean first = true ;
 * buf . append ( fcnname ) ;
 * buf . append ( " ( " ) ;
 * if ( args ! = null )
 * for ( ASTvalue arg : args ) {
 * if ( ! first ) buf . append ( " , " ) ; else { first = false ; }
 * buf . append ( arg . toString ( ) ) ;
 * buf . append ( " ) " ) ;
 * return buf . toString ( ) ; */
SubClause translate ( ) throws DAP2ServerSideException , DAP2Exception , NoSuchFunctionException , NoSuchVariableException { } }

implementation: SubClause subclause = null ; Vector < SubClause > cvtargs = new Vector < SubClause > ( ) ; if ( args != null ) for ( ASTvalue arg : args ) cvtargs . addElement ( arg . translate ( ) ) ; subclause = getClauseFactory ( ) . newBTFunctionClause ( fcnname , cvtargs ) ; return subclause ;


signature:
public class ASTvar { /** * public String toString ( )
 * StringBuilder buf = new StringBuilder ( ) ;
 * boolean first = true ;
 * for ( ASTsegment seg : segments ) {
 * buf . append ( ( first ? " " : " . " ) + seg . toString ( ) ) ;
 * first = false ;
 * return buf . toString ( ) ; */
Stack collect ( Stack components ) throws DAP2ServerSideException , DAP2Exception , NoSuchFunctionException , NoSuchVariableException { } }

implementation: for ( ASTsegment segment : segments ) { components = segment . collect ( components ) ; } return components ;


signature:
public class ASTsegment { /** * public String toString ( )
 * StringBuilder buf = new StringBuilder ( ) ;
 * buf . append ( name ) ;
 * if ( slices ! = null )
 * for ( ASTslice slice : slices ) {
 * buf . append ( slice . toString ( ) ) ;
 * return buf . toString ( ) ; */
Stack collect ( Stack components ) throws DAP2ServerSideException , DAP2Exception , NoSuchFunctionException , NoSuchVariableException { } }

implementation:
BaseType bt = null ; ServerArrayMethods sam = null ; components = getSdds ( ) . search ( name , components ) ; if ( slices != null && slices . size ( ) > 0 ) { try { bt = ( BaseType ) components . peek ( ) ; } catch ( ClassCastException cce ) { String msg = "Attempt to treat the variable `" + name + "' as if it is an array." ; throw new DAP2Exception ( DAP2Exception . MALFORMED_EXPR , msg ) ; } if ( bt instanceof DGrid ) { // project the grid and the coordinate variable
DGrid grid = ( ( DGrid ) bt ) ; bt = grid . getArray ( ) ; sam = ( ServerArrayMethods ) bt ; for ( int i = 0 ; i < slices . size ( ) ; i ++ ) { ASTslice slice = slices . get ( i ) ; slice . walk ( sam , i ) ; } // walk the coordinate variables also
for ( int i = 0 ; i < slices . size ( ) ; i ++ ) { ASTslice slice = slices . get ( i ) ; bt = grid . getVar ( i + 1 ) ; sam = ( ServerArrayMethods ) bt ; slice . walk ( sam , 0 ) ; } } else if ( bt instanceof ServerArrayMethods ) { sam = ( ServerArrayMethods ) bt ; for ( int i = 0 ; i < slices . size ( ) ; i ++ ) { ASTslice slice = slices . get ( i ) ; slice . walk ( sam , i ) ; } } } return components ;


signature:
public class ASTslice { /** * public String toString ( )
 * if ( stride = = 1 ) {
 * if ( first = = last )
 * return String . format ( " [ % d ] " , first ) ;
 * else
 * return String . format ( " [ % d : % d ] " , first , last ) ;
 * } else
 * return String . format ( " [ % d : % d : % d ] " , first , stride , last ) ; */
void walk ( ServerArrayMethods sam , int index ) throws InvalidDimensionException , SBHException { } }

implementation: sam . setProjection ( index , ( int ) start , ( int ) stride , ( int ) stop ) ;


signature:
public class ASTvalue { /** * public String toString ( )
 * StringBuilder buf = new StringBuilder ( ) ;
 * if ( constant ! = null )
 * buf . append ( constant . toString ( ) ) ;
 * else if ( var ! = null )
 * buf . append ( var . toString ( ) ) ;
 * else if ( fcn ! = null )
 * buf . append ( fcn . toString ( ) ) ;
 * else
 * assert ( false ) ;
 * return buf . toString ( ) ; */
SubClause translate ( ) throws DAP2ServerSideException , DAP2Exception , NoSuchFunctionException , NoSuchVariableException { } }

implementation: SubClause subclause = null ; if ( constant != null ) { subclause = constant . translate ( ) ; } else if ( var != null ) { Stack components = new Stack ( ) ; components = var . collect ( components ) ; subclause = getClauseFactory ( ) . newValueClause ( ( BaseType ) components . pop ( ) , false ) ; } else if ( fcn != null ) { subclause = fcn . translate ( ) ; } else assert ( false ) ; return subclause ;


signature:
public class ASTconstant { /** * public String toString ( )
 * StringBuilder buf = new StringBuilder ( ) ;
 * switch ( tag ) {
 * case STRINGCONST :
 * buf . append ( String . format ( " \ " % s \ " " , text ) ) ;
 * break ;
 * case INTCONST :
 * buf . append ( String . format ( " % d " , intvalue ) ) ;
 * break ;
 * case FLOATCONST :
 * buf . append ( String . format ( " % . 1f " , floatvalue ) ) ;
 * break ;
 * default :
 * assert ( false ) ;
 * return buf . toString ( ) ; */
SubClause translate ( ) throws DAP2ServerSideException , DAP2Exception , NoSuchFunctionException , NoSuchVariableException { } }

implementation: SubClause subclause = null ; switch ( tag ) { case ExprParserConstants . INTCONST : { String s = String . format ( "%d" , intvalue ) ; DInt32 i = getFactory ( ) . newDInt32 ( s ) ; i . setValue ( ( int ) intvalue ) ; ( ( ServerMethods ) i ) . setRead ( true ) ; ( ( ServerMethods ) i ) . setProject ( true ) ; subclause = getClauseFactory ( ) . newValueClause ( i , false ) ; } break ; case ExprParserConstants . FLOATCONST : { String s = String . format ( "%.1f" , floatvalue ) ; DFloat64 f = getFactory ( ) . newDFloat64 ( s ) ; f . setValue ( floatvalue ) ; subclause = getClauseFactory ( ) . newValueClause ( f , false ) ; } break ; case ExprParserConstants . STRINGCONST : { DString s = getFactory ( ) . newDString ( text ) ; s . setValue ( text ) ; ( ( ServerMethods ) s ) . setRead ( true ) ; ( ( ServerMethods ) s ) . setProject ( true ) ; subclause = getClauseFactory ( ) . newValueClause ( s , false ) ; } break ; default : assert ( false ) ; } return subclause ;