signature:
public class GradsDimension { /** * Make the level values from the specifications
 * @ return the level values */
protected double [ ] makeLevelValues ( ) { } }

implementation:
if ( levels == null ) { return null ; } if ( levels . size ( ) != size ) { // do someting
} double [ ] vals = new double [ size ] ; if ( mapping . equalsIgnoreCase ( LEVELS ) ) { for ( int i = 0 ; i < vals . length ; i ++ ) { vals [ i ] = Double . parseDouble ( levels . get ( i ) ) ; } } else if ( mapping . equalsIgnoreCase ( LINEAR ) ) { double start = 0 ; double inc = 0 ; start = Double . parseDouble ( levels . get ( 0 ) ) ; inc = Double . parseDouble ( levels . get ( 1 ) ) ; for ( int i = 0 ; i < size ; i ++ ) { vals [ i ] = start + i * inc ; } // TODO : figure out a better way to do this in case they don ' t start with gaus ( e . g . MOM32)
} else if ( mapping . toLowerCase ( ) . startsWith ( "gaus" ) ) { vals = GradsUtil . getGaussianLatitudes ( mapping , ( int ) Double . parseDouble ( levels . get ( 0 ) ) , size ) ; } // sanity check on z units
if ( name . equals ( GradsDataDescriptorFile . ZDEF ) ) { for ( int i = 0 ; i < vals . length ; i ++ ) { double val = vals [ i ] ; if ( val > 1050 ) { unitName = "Pa" ; break ; } else if ( val < 10 ) { // sometimes it ' s just a level number
// probably should be something else , but dimensionless
unitName = "" ; break ; } } } return vals ;


signature:
public class CEParserImpl { /** * Parser primary actions */
@ Override CEAST constraint ( CEAST . NodeList clauses ) throws ParseException { } }

implementation:
CEAST node = new CEAST ( CEAST . Sort . CONSTRAINT ) ; node . clauses = clauses ; node . dimdefs = dimdefs ; // save for constructing the DMR
this . constraint = node ; return node ;


signature:
public class CEParserImpl { /** * Selection actions */
@ Override CEAST selection ( CEAST projection , CEAST filter ) throws ParseException { } }

implementation: CEAST node = new CEAST ( CEAST . Sort . SELECTION ) ; node . projection = projection ; node . filter = filter ; return node ;


signature:
public class CEParserImpl { /** * Parser list support */
@ Override CEAST . NodeList nodelist ( CEAST . NodeList list , CEAST ast ) { } }

implementation: if ( list == null ) list = new CEAST . NodeList ( ) ; if ( ast != null ) list . add ( ast ) ; return list ;


signature:
public class BufrIdentificationSection { /** * return record header time as a CalendarDate
 * @ return referenceTime */
public final CalendarDate getReferenceTime ( ) { } }

implementation: int sec = ( second < 0 || second > 59 ) ? 0 : second ; return CalendarDate . of ( null , year , month , day , hour , minute , sec ) ;


signature:
public class ArrayStructureBBsection { /** * Make a section of an ArrayStructureBB
 * @ param org the original
 * @ param section of the whole
 * @ return original , if section is empty or the same saze as the original , else a section of the original */
static public ArrayStructureBB factory ( ArrayStructureBB org , Section section ) { } }

implementation: if ( section == null || section . computeSize ( ) == org . getSize ( ) ) return org ; return new ArrayStructureBBsection ( org . getStructureMembers ( ) , org . getShape ( ) , org . getByteBuffer ( ) , section ) ;


signature:
public class LuceneIndexer { /** * Makes a document for a File .
 * The document has three fields :
 * < ul >
 * < li > < code > path < / code > - - containing the pathname of the file , as a stored ,
 * untokenized field ;
 * < li > < code > modified < / code > - - containing the last modified date of the file as
 * a field as created by < a
 * href = " lucene . document . DateTools . html " > DateTools < / a > ; and
 * < li > < code > contents < / code > - - containing the full contents of the file , as a
 * Reader field ; */
public Document makeDocument ( File f ) throws java . io . FileNotFoundException { } }

implementation:
// make a new , empty document
Document doc = new Document ( ) ; // Add the path of the file as a field named " path " . Use a field that is
// indexed ( i . e . searchable ) , but don ' t tokenize the field into words .
doc . add ( new Field ( "path" , f . getPath ( ) , Field . Store . YES , Field . Index . UN_TOKENIZED ) ) ; // Add the last modified date of the file a field named " modified " . Use
// a field that is indexed ( i . e . searchable ) , but don ' t tokenize the field
// into words .
doc . add ( new Field ( "modified" , DateTools . timeToString ( f . lastModified ( ) , DateTools . Resolution . MINUTE ) , Field . Store . YES , Field . Index . UN_TOKENIZED ) ) ; // Add the contents of the file to a field named " contents " . Specify a Reader ,
// so that the text of the file is tokenized and indexed , but not stored .
// Note that FileReader expects the file to be in the system ' s default encoding .
// If that ' s not the case searching for special characters will fail .
// doc . add ( new Field ( " contents " , new FileReader ( f ) ) ) ;
// return the document
return doc ;


signature:
public class LuceneIndexer { /** * Index all text files under a directory . */
public static void main1 ( String [ ] args ) { } }

implementation: if ( INDEX_DIR . exists ( ) ) { System . out . println ( "Cannot save index to '" + INDEX_DIR + "' directory, please delete it first" ) ; System . exit ( 1 ) ; } LuceneIndexer indexer = new LuceneIndexer ( ) ; Date start = new Date ( ) ; try { IndexWriter writer = new IndexWriter ( INDEX_DIR , new StandardAnalyzer ( ) , true ) ; System . out . println ( "Indexing to directory '" + INDEX_DIR + "'..." ) ; indexer . indexDocs ( writer , DOC_DIR ) ; System . out . println ( "Optimizing..." ) ; writer . optimize ( ) ; writer . close ( ) ; Date end = new Date ( ) ; System . out . println ( end . getTime ( ) - start . getTime ( ) + " total milliseconds" ) ; } catch ( IOException e ) { System . out . println ( " caught a " + e . getClass ( ) + "\n with message: " + e . getMessage ( ) ) ; }


signature:
public class Grib1Index { /** * deserialize the Grib1Record object */
private Grib1Record readRecord ( Grib1IndexProto . Grib1Record p ) { } }

implementation: Grib1SectionIndicator is = new Grib1SectionIndicator ( p . getGribMessageStart ( ) , p . getGribMessageLength ( ) ) ; Grib1SectionProductDefinition pds = new Grib1SectionProductDefinition ( p . getPds ( ) . toByteArray ( ) ) ; Grib1SectionGridDefinition gds = pds . gdsExists ( ) ? gdsList . get ( p . getGdsIdx ( ) ) : new Grib1SectionGridDefinition ( pds ) ; Grib1SectionBitMap bms = pds . bmsExists ( ) ? new Grib1SectionBitMap ( p . getBmsPos ( ) ) : null ; Grib1SectionBinaryData dataSection = new Grib1SectionBinaryData ( p . getDataPos ( ) , p . getDataLen ( ) ) ; return new Grib1Record ( p . getHeader ( ) . toByteArray ( ) , is , gds , pds , bms , dataSection ) ;


signature:
public class Grib1Index { /** * LOOK what about extending an index ? ? */
public boolean makeIndex ( String filename , RandomAccessFile dataRaf ) throws IOException { } }

implementation:
String idxPath = filename ; if ( ! idxPath . endsWith ( GBX9_IDX ) ) idxPath += GBX9_IDX ; File idxFile = GribIndexCache . getFileOrCache ( idxPath ) ; File idxFileTmp = GribIndexCache . getFileOrCache ( idxPath + ".tmp" ) ; RandomAccessFile raf = null ; try ( FileOutputStream fout = new FileOutputStream ( idxFileTmp ) ) { // / / header message
fout . write ( MAGIC_START . getBytes ( CDM . utf8Charset ) ) ; NcStream . writeVInt ( fout , version ) ; Map < Long , Integer > gdsMap = new HashMap < > ( ) ; gdsList = new ArrayList < > ( ) ; records = new ArrayList < > ( 200 ) ; Grib1IndexProto . Grib1Index . Builder rootBuilder = Grib1IndexProto . Grib1Index . newBuilder ( ) ; rootBuilder . setFilename ( filename ) ; if ( dataRaf == null ) { // open if dataRaf not already open
raf = RandomAccessFile . acquire ( filename ) ; dataRaf = raf ; } Grib1RecordScanner scan = new Grib1RecordScanner ( dataRaf ) ; while ( scan . hasNext ( ) ) { Grib1Record r = scan . next ( ) ; if ( r == null ) break ; // done
records . add ( r ) ; Grib1SectionGridDefinition gdss = r . getGDSsection ( ) ; Integer index = gdsMap . get ( gdss . calcCRC ( ) ) ; if ( gdss . getPredefinedGridDefinition ( ) >= 0 ) // skip predefined gds - they dont have raw bytes
index = 0 ; else if ( index == null ) { gdsList . add ( gdss ) ; index = gdsList . size ( ) - 1 ; gdsMap . put ( gdss . calcCRC ( ) , index ) ; rootBuilder . addGdsList ( makeGdsProto ( gdss ) ) ; } rootBuilder . addRecords ( makeRecordProto ( r , index ) ) ; } if ( records . isEmpty ( ) ) throw new RuntimeException ( "No GRIB1 records found in " + dataRaf . getLocation ( ) ) ; ucar . nc2 . grib . grib1 . Grib1IndexProto . Grib1Index index = rootBuilder . build ( ) ; byte [ ] b = index . toByteArray ( ) ; NcStream . writeVInt ( fout , b . length ) ; // message size
fout . write ( b ) ; // message - all in one gulp
logger . debug ( "  made gbx9 index for {} size={}" , filename , b . length ) ; return true ; } finally { if ( raf != null ) raf . close ( ) ; // only close if it was opened here
// now switch
RandomAccessFile . eject ( idxFile . getPath ( ) ) ; boolean deleteOk = ! idxFile . exists ( ) || idxFile . delete ( ) ; boolean renameOk = idxFileTmp . renameTo ( idxFile ) ; if ( ! deleteOk ) logger . error ( "  could not delete Grib1Index= {}" , idxFile . getPath ( ) ) ; if ( ! renameOk ) logger . error ( "  could not rename Grib1Index= {}" , idxFile . getPath ( ) ) ; }


signature:
public class ChainedFileSource { /** * This implementation requires a relative path . The relative path may
 * not start with " . . / " or once " normalized " start with " . . / " . Here
 * " normalized " means that " . / " and " path / . . " segments are removed ,
 * e . g . , " dir1 / . . / . . / dir2 " once normalized would be " . . / dir2 " .
 * @ param path the relative path to the desired File .
 * @ return the File represented by the given relative path or null if the path is null or the File it represents does not exist . */
public File getFile ( String path ) { } }

implementation: File file ; for ( DescendantFileSource curLocator : chain ) { file = curLocator . getFile ( path ) ; if ( file != null ) return file ; } return null ;


signature:
public class M3IOConvention { /** * Do we think this is a M3IO file .
 * @ param ncfile the NetcdfFile to test
 * @ return true if we think this is a M3IO file . */
public static boolean isMine ( NetcdfFile ncfile ) { } }

implementation:
return ( null != ncfile . findGlobalAttribute ( "XORIG" ) ) && ( null != ncfile . findGlobalAttribute ( "YORIG" ) ) && ( null != ncfile . findGlobalAttribute ( "XCELL" ) ) && ( null != ncfile . findGlobalAttribute ( "YCELL" ) ) && ( null != ncfile . findGlobalAttribute ( "NCOLS" ) ) && ( null != ncfile . findGlobalAttribute ( "NROWS" ) ) ; // M3IOVGGridConvention - is this true for this class ? ?
// return ncFile . findGlobalAttribute ( " VGLVLS " ) ! = null & & isValidM3IOFile _ ( ncFile ) ;


signature: public class M3IOConvention { protected AxisType getAxisType ( NetcdfDataset ds , VariableEnhanced ve ) { } }

implementation: Variable v = ( Variable ) ve ; String vname = v . getShortName ( ) ; if ( vname . equalsIgnoreCase ( "x" ) ) return AxisType . GeoX ; if ( vname . equalsIgnoreCase ( "y" ) ) return AxisType . GeoY ; if ( vname . equalsIgnoreCase ( "lat" ) ) return AxisType . Lat ; if ( vname . equalsIgnoreCase ( "lon" ) ) return AxisType . Lon ; if ( vname . equalsIgnoreCase ( "time" ) ) return AxisType . Time ; if ( vname . equalsIgnoreCase ( "level" ) ) return AxisType . GeoZ ; return null ;


signature:
public class AreaServiceProvider { /** * Open the service provider for reading .
 * @ param raf file to read from
 * @ param ncfile netCDF file we are writing to ( memory )
 * @ param cancelTask task for cancelling
 * @ throws IOException problem reading file */
public void open ( RandomAccessFile raf , NetcdfFile ncfile , CancelTask cancelTask ) throws IOException { } }

implementation:
super . open ( raf , ncfile , cancelTask ) ; if ( areaReader == null ) areaReader = new AreaReader ( ) ; try { areaReader . init ( raf . getLocation ( ) , ncfile ) ; } catch ( Throwable e ) { close ( ) ; // try not to leak files
throw new IOException ( e ) ; } finally { raf . close ( ) ; // avoid leaks
}


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

implementation: return areaReader . readVariable ( v2 , section ) ;


signature:
public class AreaServiceProvider { /** * reacquire any resources like file handles */
public void reacquire ( ) throws IOException { } }

implementation: try { areaReader . af = new AreaFile ( location ) ; } catch ( Throwable e ) { throw new IOException ( e ) ; }


signature:
public class DateType { /** * Is this date before the given date . if isPresent , always false .
 * @ param d test against this date
 * @ return true if this date before the given date */
public boolean before ( Date d ) { } }

implementation: if ( isPresent ( ) ) return false ; return date . isBefore ( CalendarDate . of ( d ) ) ;


signature:
public class DateType { /** * Is this date before the given date . if d . isPresent , always true , else if this . isPresent , false .
 * @ param d test against this date
 * @ return true if this date before the given date */
public boolean before ( DateType d ) { } }

implementation: if ( d . isPresent ( ) ) return true ; if ( isPresent ( ) ) return false ; return date . isBefore ( d . getCalendarDate ( ) ) ;


signature:
public class DateType { /** * Is this date after the given date . if isPresent , always true .
 * @ param d test against this date
 * @ return true if this date after the given date */
public boolean after ( Date d ) { } }

implementation: if ( isPresent ( ) ) return true ; return date . isAfter ( CalendarDate . of ( d ) ) ;


signature:
public class DateType { /** * test */
private static void doOne ( String s ) { } }

implementation: try { System . out . println ( "\nString = (" + s + ")" ) ; DateType d = new DateType ( s , null , null ) ; System . out . println ( "DateType = (" + d . toString ( ) + ")" ) ; System . out . println ( "Date = (" + d . getDate ( ) + ")" ) ; } catch ( java . text . ParseException e ) { e . printStackTrace ( ) ; }


signature:
public class CatalogScan { /** * when we have a real catalog ( filename ! = CATSCAN ) */
public ConfigCatalog getCatalog ( File baseDir , String matchRemaining , String filename , CatalogReader reader ) throws IOException { } }

implementation: String relLocation = ( matchRemaining . length ( ) >= 1 ) ? location + "/" + matchRemaining : location ; File absLocation = new File ( baseDir , relLocation ) ; ConfigCatalog cc = reader . getFromAbsolutePath ( absLocation + "/" + filename ) ; if ( cc == null ) logger . warn ( "Cant find catalog from scan: " + absLocation + "/" + filename ) ; return cc ;


signature:
public class CatalogScan { /** * when we have a catalog built from a directory ( filename = = CATSCAN ) */
public CatalogBuilder makeCatalogFromDirectory ( File baseDir , String matchRemaining , URI baseURI ) throws IOException { } }

implementation:
String relLocation = ( matchRemaining . length ( ) >= 1 ) ? location + "/" + matchRemaining : location ; String name = ( matchRemaining . length ( ) >= 1 ) ? getName ( ) + "/" + matchRemaining : getName ( ) ; File absLocation = new File ( baseDir , relLocation ) ; // it must be a directory
Path wantDir = absLocation . toPath ( ) ; if ( ! Files . exists ( wantDir ) ) throw new FileNotFoundException ( "Requested catalog does not exist =" + absLocation ) ; if ( ! Files . isDirectory ( wantDir ) ) throw new FileNotFoundException ( "Not a directory =" + absLocation ) ; // Setup and create catalog builder .
CatalogBuilder catBuilder = new CatalogBuilder ( ) ; catBuilder . setBaseURI ( baseURI ) ; assert this . getParentCatalog ( ) != null ; DatasetBuilder top = new DatasetBuilder ( null ) ; top . transferMetadata ( this , true ) ; top . setName ( name ) ; top . put ( Dataset . Id , null ) ; // no id for top
catBuilder . addDataset ( top ) ; // first look for catalogs
try ( DirectoryStream < Path > ds = Files . newDirectoryStream ( wantDir , "*.xml" ) ) { for ( Path p : ds ) { if ( ! Files . isDirectory ( p ) ) { String pfilename = p . getFileName ( ) . toString ( ) ; String urlPath = pfilename ; // String path = dataDirComplete . length ( ) = = 0 ? filename : dataDirComplete + " / " + filename ; / / reletive starting from current directory
CatalogRefBuilder catref = new CatalogRefBuilder ( top ) ; catref . setTitle ( urlPath ) ; catref . setHref ( urlPath ) ; top . addDataset ( catref ) ; } } } // now look for directories
try ( DirectoryStream < Path > ds = Files . newDirectoryStream ( wantDir ) ) { for ( Path dir : ds ) { if ( Files . isDirectory ( dir ) ) { String dfilename = dir . getFileName ( ) . toString ( ) ; String urlPath = ( matchRemaining . length ( ) >= 1 ) ? dfilename + "/" + matchRemaining : dfilename ; CatalogRefBuilder catref = new CatalogRefBuilder ( top ) ; catref . setTitle ( urlPath ) ; catref . setHref ( urlPath + "/" + CATSCAN ) ; catref . addToList ( Dataset . Properties , new Property ( "CatalogScan" , "true" ) ) ; top . addDataset ( catref ) ; } } } return catBuilder ;


signature:
public class CollectionType { /** * Return the known CollectionType that matches the given name ( ignoring case )
 * or null if the name is unknown .
 * @ param name name of the desired CollectionType .
 * @ return CollectionType or null if no match . */
public static CollectionType findType ( String name ) { } }

implementation: if ( name == null ) return null ; for ( CollectionType m : members ) { if ( m . name . equalsIgnoreCase ( name ) ) return m ; } return null ;


signature:
public class CollectionType { /** * Return a CollectionType that matches the given name by either matching
 * a known type ( ignoring case ) or creating an unknown type .
 * @ param name name of the desired CollectionType
 * @ return the named CollectionType or null if given name is null . */
public static CollectionType getType ( String name ) { } }

implementation: if ( name == null ) return null ; CollectionType type = findType ( name ) ; return type != null ? type : new CollectionType ( name , false ) ;


signature:
public class BaseTypePrimitiveVector { /** * Set the i ' th value of the array .
 * @ param i the index of the value to set .
 * @ param newVal the new value . */
public final void setValue ( int i , BaseType newVal ) { } }

implementation: vals [ i ] = newVal ; BaseType parent = ( BaseType ) getTemplate ( ) . getParent ( ) ; vals [ i ] . setParent ( parent ) ;


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

implementation:
for ( int i = 0 ; i < vals . length ; i ++ ) { // create new variable from template
vals [ i ] = ( BaseType ) getTemplate ( ) . clone ( ) ; ( ( ClientIO ) vals [ i ] ) . deserialize ( source , sv , statusUI ) ; if ( statusUI != null && statusUI . userCancelled ( ) ) throw new DataReadException ( "User cancelled" ) ; }


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

implementation:
for ( int i = 0 ; i < vals . length ; i ++ ) { // LogStream . out . println ( " \ t \ t \ tI AM THE WALRUS ! " ) ;
( ( ClientIO ) vals [ i ] ) . externalize ( sink ) ; }


signature:
public class EnhancementsImpl { /** * Add a CoordinateSystem to the dataset . */
public void addCoordinateSystem ( CoordinateSystem cs ) { } }

implementation: if ( cs == null ) throw new RuntimeException ( "Attempted to add null CoordinateSystem to var " + forVar . getFullName ( ) ) ; if ( coordSys == null ) coordSys = new ArrayList < > ( 5 ) ; coordSys . add ( cs ) ;


signature:
public class EnhancementsImpl { /** * Get the description of the Variable .
 * Default is to look for attributes in this order : CDM . LONG _ NAME , " description " , " title " , " standard _ name " . */
public String getDescription ( ) { } }

implementation: if ( ( desc == null ) && ( forVar != null ) ) { Attribute att = forVar . findAttributeIgnoreCase ( CDM . LONG_NAME ) ; if ( ( att != null ) && att . isString ( ) ) desc = att . getStringValue ( ) ; if ( desc == null ) { att = forVar . findAttributeIgnoreCase ( "description" ) ; if ( ( att != null ) && att . isString ( ) ) desc = att . getStringValue ( ) ; } if ( desc == null ) { att = forVar . findAttributeIgnoreCase ( CDM . TITLE ) ; if ( ( att != null ) && att . isString ( ) ) desc = att . getStringValue ( ) ; } if ( desc == null ) { att = forVar . findAttributeIgnoreCase ( CF . STANDARD_NAME ) ; if ( ( att != null ) && att . isString ( ) ) desc = att . getStringValue ( ) ; } } return ( desc == null ) ? null : desc . trim ( ) ;


signature:
public class EnhancementsImpl { /** * Set the Unit String for this Variable . Default is to use the CDM . UNITS attribute .
 * @ param units unit string */
public void setUnitsString ( String units ) { } }

implementation: this . units = units ; forVar . addAttribute ( new Attribute ( CDM . UNITS , units ) ) ;


signature:
public class EnhancementsImpl { /** * Get the Unit String for the Variable . May be set explicitly , else look for attribute CDM . UNITS .
 * @ return the Unit String for the Variable , or null if none . */
public String getUnitsString ( ) { } }

implementation: String result = units ; if ( ( result == null ) && ( forVar != null ) ) { Attribute att = forVar . findAttribute ( CDM . UNITS ) ; if ( att == null ) att = forVar . findAttributeIgnoreCase ( CDM . UNITS ) ; if ( ( att != null ) && att . isString ( ) ) result = att . getStringValue ( ) ; } return ( result == null ) ? null : result . trim ( ) ;


signature:
public class ConfigCatalogInitialization { /** * called from TdsInit on spring - managed auto - wired bean */
public synchronized void init ( ReadMode readMode , PreferencesExt prefs ) { } }

implementation: if ( readMode == null ) readMode = defaultReadMode ; this . prefs = prefs ; trackerNumber = prefs . getLong ( "trackerNumber" , 1 ) ; numberCatalogs = prefs . getInt ( "numberCatalogs" , 10 ) ; nextCatId = prefs . getLong ( "nextCatId" , 1 ) ; makeDebugActions ( ) ; this . contentRootPath = this . tdsContext . getThreddsDirectory ( ) ; this . contextPath = tdsContext . getContextPath ( ) ; reread ( readMode , true ) ;


signature:
public class ConfigCatalogInitialization { /** * called from init ( ) and from trigger controller */
public synchronized boolean reread ( ReadMode readMode , boolean isStartup ) { } }

implementation:
readNow = System . currentTimeMillis ( ) ; logCatalogInit . info ( "=========================================================================================\n" + "ConfigCatalogInitialization readMode={} isStartup={}" , readMode , isStartup ) ; catPathMap = new HashSet < > ( ) ; fcNameMap = new HashMap < > ( ) ; if ( ccc != null ) ccc . invalidateAll ( ) ; // remove anything in cache
if ( fcCache != null ) fcCache . invalidateAll ( ) ; // remove anything in cache
if ( ! isStartup && readMode == ReadMode . always ) trackerNumber ++ ; // must write a new database if TDS is already running and rereading all
if ( ! isDebugMode || this . datasetTracker == null ) this . datasetTracker = new DatasetTrackerChronicle ( trackerDir , maxDatasets , trackerNumber ) ; boolean databaseAlreadyExists = datasetTracker . exists ( ) ; // detect if tracker database exists
if ( ! databaseAlreadyExists ) { readMode = ReadMode . always ; logCatalogInit . info ( "ConfigCatalogInitializion datasetTracker database does not exist, set readMode to=" + readMode ) ; } if ( this . callback == null ) this . callback = new StatCallback ( readMode ) ; // going to reread global services
allowedServices . clearGlobalServices ( ) ; switch ( readMode ) { case always : // if the database already exists , we need to close it
// before we reinit
if ( databaseAlreadyExists ) { logCatalogInit . info ( "ConfigCatalogInitializion datasetTracker database already exists - closing it before reinitialization." ) ; try { this . datasetTracker . close ( ) ; } catch ( IOException e ) { logCatalogInit . error ( "There was an error closing the datasetTracker database." , e ) ; } this . datasetTracker . reinit ( ) ; } this . catalogTracker = new CatalogTracker ( trackerDir , true , numberCatalogs , nextCatId ) ; this . dataRootTracker = new DataRootTracker ( trackerDir , true , callback ) ; this . dataRootPathMatcher = new DataRootPathMatcher ( ccc , dataRootTracker ) ; // starting over
readRootCatalogs ( readMode ) ; break ; case check : this . catalogTracker = new CatalogTracker ( trackerDir , false , numberCatalogs , nextCatId ) ; // use existing catalog list
this . dataRootTracker = new DataRootTracker ( trackerDir , false , callback ) ; // use existing data roots
this . dataRootPathMatcher = new DataRootPathMatcher ( ccc , dataRootTracker ) ; readRootCatalogs ( readMode ) ; // read just roots to get global services
checkExistingCatalogs ( readMode ) ; break ; case triggerOnly : this . catalogTracker = new CatalogTracker ( trackerDir , false , numberCatalogs , nextCatId ) ; // use existing catalog list
this . dataRootTracker = new DataRootTracker ( trackerDir , false , callback ) ; // use existing data roots
this . dataRootPathMatcher = new DataRootPathMatcher ( ccc , dataRootTracker ) ; readRootCatalogs ( readMode ) ; // read just roots to get global services
break ; } numberCatalogs = catalogTracker . size ( ) ; nextCatId = catalogTracker . getNextCatId ( ) ; if ( prefs != null ) { prefs . putLong ( "trackerNumber" , trackerNumber ) ; prefs . putLong ( "nextCatId" , nextCatId ) ; prefs . putInt ( "numberCatalogs" , numberCatalogs ) ; } callback . finish ( ) ; logCatalogInit . info ( "\nConfigCatalogInitializion stats\n" + callback ) ; try { datasetTracker . save ( ) ; catalogTracker . save ( ) ; dataRootTracker . save ( ) ; } catch ( IOException e ) { // e . printStackTrace ( ) ;
logCatalogInit . error ( "datasetTracker.save() failed" , e ) ; } // heres where we may be doing a switcheroo in a running TDS
if ( dataRootManager != null ) dataRootManager . setDataRootPathMatcher ( dataRootPathMatcher ) ; if ( datasetManager != null ) datasetManager . setDatasetTracker ( datasetTracker ) ; // cleanup old version of the database
if ( ! isStartup && readMode == ReadMode . always ) { DatasetTrackerChronicle . cleanupBefore ( trackerDir , trackerNumber ) ; } long took = System . currentTimeMillis ( ) - readNow ; logCatalogInit . info ( "ConfigCatalogInitializion finished took={} msecs" , took ) ; // cleanup
catPathMap = null ; fcNameMap = null ; catalogTracker = null ; return true ; // ok


signature:
public class ConfigCatalogInitialization { /** * catalogRelpath must be relative to rootDir */
private void checkCatalogToRead ( ReadMode readMode , String catalogRelPath , boolean isRoot , long lastRead ) throws IOException { } }

implementation:
if ( exceedLimit ) return ; catalogRelPath = StringUtils . cleanPath ( catalogRelPath ) ; File catalogFile = new File ( this . contentRootPath , catalogRelPath ) ; if ( ! catalogFile . exists ( ) ) { catalogTracker . removeCatalog ( catalogRelPath ) ; logCatalogInit . error ( ERROR + "initCatalog(): Catalog [" + catalogRelPath + "] does not exist." ) ; return ; } long lastModified = catalogFile . lastModified ( ) ; if ( ! isRoot && readMode != ReadMode . always && lastModified < lastRead ) return ; // skip catalogs that havent changed
if ( ! isRoot && readMode == ReadMode . triggerOnly ) return ; // skip non - root catalogs for trigger only
if ( show ) System . out . printf ( "initCatalog %s%n" , catalogRelPath ) ; // make sure we havent already read it
if ( catPathMap . contains ( catalogRelPath ) ) { logCatalogInit . error ( ERROR + "initCatalog(): Catalog [" + catalogRelPath + "] already seen, possible loop (skip)." ) ; return ; } catPathMap . add ( catalogRelPath ) ; Set < String > idSet = new HashSet < > ( ) ; // look for unique ids
// if ( logCatalogInit . isDebugEnabled ( ) ) logCatalogInit . debug ( " initCatalog { } - > { } " , path , f . getAbsolutePath ( ) ) ;
// read it
ConfigCatalog cat = readCatalog ( catalogRelPath , catalogFile . getPath ( ) ) ; if ( cat == null ) { logCatalogInit . error ( ERROR + "initCatalog(): failed to read catalog <" + catalogFile . getPath ( ) + ">." ) ; return ; } long catId = catalogTracker . put ( new CatalogExt ( 0 , catalogRelPath , isRoot , readNow ) ) ; if ( isRoot ) { if ( ccc != null ) ccc . put ( catalogRelPath , cat ) ; allowedServices . addGlobalServices ( cat . getServices ( ) ) ; if ( readMode == ReadMode . triggerOnly ) return ; // thats all we need
} if ( callback != null ) callback . hasCatalogRef ( cat ) ; // look for datasetRoots
for ( DatasetRootConfig p : cat . getDatasetRoots ( ) ) dataRootPathMatcher . addRoot ( p , catalogRelPath , readMode == ReadMode . always ) ; // check for duplicates on complete reread
if ( callback == null ) { // LOOK WTF ?
List < String > disallowedServices = allowedServices . getDisallowedServices ( cat . getServices ( ) ) ; if ( ! disallowedServices . isEmpty ( ) ) { allowedServices . getDisallowedServices ( cat . getServices ( ) ) ; logCatalogInit . error ( ERROR + "initCatalog(): declared services: " + Arrays . toString ( disallowedServices . toArray ( ) ) + " in catalog: " + catalogFile . getPath ( ) + " are disallowed in threddsConfig file" ) ; } } // look for dataRoots in datasetScans and featureCollections
dataRootPathMatcher . extractDataRoots ( catalogRelPath , cat . getDatasetsLocal ( ) , readMode == ReadMode . always , fcNameMap ) ; // get the directory path , reletive to the rootDir
int pos = catalogRelPath . lastIndexOf ( "/" ) ; String dirPath = ( pos > 0 ) ? catalogRelPath . substring ( 0 , pos + 1 ) : "" ; processDatasets ( catId , readMode , dirPath , cat . getDatasetsLocal ( ) , idSet ) ; // recurse
// look for catalogScans
for ( CatalogScan catScan : cat . getCatalogScans ( ) ) { if ( exceedLimit ) return ; Path relLocation = Paths . get ( dirPath , catScan . getLocation ( ) ) ; Path absLocation = Paths . get ( catalogFile . getParent ( ) , catScan . getLocation ( ) ) ; // if ( catalogWatcher ! = null ) catalogWatcher . registerAll ( absLocation ) ;
readCatsInDirectory ( readMode , relLocation . toString ( ) , absLocation ) ; }


signature:
public class ConfigCatalogInitialization { /** * Does the actual work of reading a catalog .
 * @ param catalogRelPath reletive path starting from content root
 * @ param catalogFullPath absolute location on disk
 * @ return the Catalog , or null if failure */
private ConfigCatalog readCatalog ( String catalogRelPath , String catalogFullPath ) { } }

implementation:
URI uri ; try { // uri = new URI ( " file : " + StringUtil2 . escape ( catalogFullPath , " / : - _ . " ) ) ; / / needed ?
uri = new URI ( this . contextPath + "/catalog/" + catalogRelPath ) ; } catch ( URISyntaxException e ) { logCatalogInit . error ( ERROR + "readCatalog(): URISyntaxException=" + e . getMessage ( ) ) ; return null ; } ConfigCatalogBuilder builder = new ConfigCatalogBuilder ( ) ; try { // read the catalog
logCatalogInit . info ( "-------readCatalog(): path=" + catalogRelPath ) ; ConfigCatalog cat = ( ConfigCatalog ) builder . buildFromLocation ( catalogFullPath , uri ) ; if ( builder . hasFatalError ( ) ) { logCatalogInit . error ( ERROR + "   invalid catalog -- " + builder . getErrorMessage ( ) ) ; return null ; } if ( builder . getErrorMessage ( ) . length ( ) > 0 ) logCatalogInit . debug ( builder . getErrorMessage ( ) ) ; return cat ; } catch ( Throwable t ) { logCatalogInit . error ( ERROR + "  Exception on catalog=" + catalogFullPath + " " + t . getMessage ( ) + "\n log=" + builder . getErrorMessage ( ) , t ) ; return null ; }


signature:
public class ConfigCatalogInitialization { /** * dirPath = the directory path , reletive to the rootDir */
private void processDatasets ( long catId , ReadMode readMode , String dirPath , List < Dataset > datasets , Set < String > idMap ) throws IOException { } }

implementation:
if ( exceedLimit ) return ; for ( Dataset ds : datasets ) { if ( datasetTracker . trackDataset ( catId , ds , callback ) ) countDatasets ++ ; if ( maxDatasetsProcess > 0 && countDatasets > maxDatasetsProcess ) exceedLimit = true ; // look for duplicate ids
String id = ds . getID ( ) ; if ( id != null ) { if ( idMap . contains ( id ) ) { logCatalogInit . error ( ERROR + "Duplicate id on  '" + ds . getName ( ) + "' id= '" + id + "'" ) ; } else { idMap . add ( id ) ; } } if ( ( ds instanceof DatasetScan ) || ( ds instanceof FeatureCollectionRef ) ) continue ; if ( ds instanceof CatalogScan ) continue ; if ( ds instanceof CatalogRef ) { // follow catalog refs
CatalogRef catref = ( CatalogRef ) ds ; String href = catref . getXlinkHref ( ) ; // if ( logCatalogInit . isDebugEnabled ( ) ) logCatalogInit . debug ( " catref . getXlinkHref = " + href ) ;
// Check that catRef is relative
if ( ! href . startsWith ( "http:" ) ) { // Clean up relative URLs that start with " . / "
if ( href . startsWith ( "./" ) ) { href = href . substring ( 2 ) ; } String path ; String contextPathPlus = this . contextPath + "/" ; if ( href . startsWith ( contextPathPlus ) ) { path = href . substring ( contextPathPlus . length ( ) ) ; // absolute starting from content root
} else if ( href . startsWith ( "/" ) ) { // Drop the catRef because it points to a non - TDS served catalog .
logCatalogInit . error ( ERROR + "Skipping catalogRef <xlink:href=" + href + ">. Reference is relative to the server outside the context path [" + contextPathPlus + "]. " + "Parent catalog info: Name=\"" + catref . getParentCatalog ( ) . getName ( ) + "\"; Base URI=\"" + catref . getParentCatalog ( ) . getUriString ( ) + "\"; dirPath=\"" + dirPath + "\"." ) ; continue ; } else { path = dirPath + href ; // reletive starting from current directory
} CatalogExt ext = catalogTracker . get ( path ) ; long lastRead = ( ext == null ) ? 0 : ext . getLastRead ( ) ; checkCatalogToRead ( readMode , path , false , lastRead ) ; } } else { // recurse through nested datasets
processDatasets ( catId , readMode , dirPath , ds . getDatasetsLocal ( ) , idMap ) ; } }


signature:
public class ConfigCatalogInitialization { /** * dirPath is the directory relative to rootDir , directory is absolute */
private void readCatsInDirectory ( ReadMode readMode , String dirPath , Path directory ) throws IOException { } }

implementation:
if ( exceedLimit ) return ; // do any catalogs first
try ( DirectoryStream < Path > ds = Files . newDirectoryStream ( directory , "*.xml" ) ) { for ( Path p : ds ) { if ( ! Files . isDirectory ( p ) ) { // path must be relative to rootDir
String filename = p . getFileName ( ) . toString ( ) ; String path = dirPath . length ( ) == 0 ? filename : dirPath + "/" + filename ; // reletive starting from current directory
CatalogExt ext = catalogTracker . get ( path ) ; long lastRead = ( ext == null ) ? 0 : ext . getLastRead ( ) ; checkCatalogToRead ( readMode , path , false , lastRead ) ; } } } // now recurse into the directory
try ( DirectoryStream < Path > ds = Files . newDirectoryStream ( directory ) ) { for ( Path dir : ds ) { if ( Files . isDirectory ( dir ) ) { String dirPathChild = dirPath + "/" + dir . getFileName ( ) . toString ( ) ; // reletive starting from current directory
readCatsInDirectory ( readMode , dirPathChild , dir ) ; } } }


signature: public class ConfigCatalogInitialization { public void makeDebugActions ( ) { } }

implementation:
DebugCommands . Category debugHandler = debugCommands . findCategory ( "Catalogs" ) ; DebugCommands . Action act ; act = new DebugCommands . Action ( "showCatalogExt" , "Show known catalogs" ) { public void doAction ( DebugCommands . Event e ) { e . pw . printf ( "numberCatalogs=%d nextCatId=%d%n" , numberCatalogs , nextCatId ) ; e . pw . printf ( "%nid  root  lastRead     path%n" ) ; CatalogTracker catalogTracker = new CatalogTracker ( trackerDir , false , numberCatalogs , 0 ) ; for ( CatalogExt cat : catalogTracker . getCatalogs ( ) ) { e . pw . printf ( "%3d: %5s %s %s%n" , cat . getCatId ( ) , cat . isRoot ( ) , CalendarDate . of ( cat . getLastRead ( ) ) , cat . getCatRelLocation ( ) ) ; } } } ; debugHandler . addAction ( act ) ; act = new DebugCommands . Action ( "showRoots" , "Show root catalogs" ) { public void doAction ( DebugCommands . Event e ) { StringBuilder sbuff = new StringBuilder ( ) ; synchronized ( ConfigCatalogInitialization . this ) { for ( String catPath : rootCatalogKeys ) { sbuff . append ( " catalog= " ) . append ( catPath ) . append ( "\n" ) ; // String filename = StringUtil2 . unescape ( cat . getUriString ( ) ) ;
// sbuff . append ( " from = " ) . append ( filename ) . append ( " \ n " ) ;
} } e . pw . println ( ) ; e . pw . println ( Escape . html ( sbuff . toString ( ) ) ) ; } } ; debugHandler . addAction ( act ) ; act = new DebugCommands . Action ( "showStats" , "Show catalog initialization stats" ) { public void doAction ( DebugCommands . Event e ) { if ( callback != null ) e . pw . printf ( "%n%s%n" , Escape . html ( callback . toString ( ) ) ) ; else e . pw . printf ( "N/A%n" ) ; } } ; debugHandler . addAction ( act ) ;


signature:
public class LatLonPointImpl { /** * Test if point lies between two longitudes , deal with wrapping .
 * @ param lon point to test
 * @ param lonBeg beginning longitude
 * @ param lonEnd ending longitude
 * @ return true if lon is between lonBeg and lonEnd .
 * @ deprecated */
static public boolean betweenLon ( double lon , double lonBeg , double lonEnd ) { } }

implementation: lonBeg = lonNormal ( lonBeg , lon ) ; lonEnd = lonNormal ( lonEnd , lon ) ; return ( lon >= lonBeg ) && ( lon <= lonEnd ) ;


signature:
public class LatLonPointImpl { /** * put longitude into the range [ start , start + 360 ] deg
 * @ param lon lon to normalize
 * @ param start starting point
 * @ return longitude into the [ start , start + 360 ] deg */
static public double lonNormalFrom ( double lon , double start ) { } }

implementation: while ( lon < start ) lon += 360 ; while ( lon > start + 360 ) lon -= 360 ; return lon ;


signature:
public class LatLonPointImpl { /** * Make a nicely formatted representation of a latitude , eg 40.34N or 12.9S .
 * @ param lat the latitude .
 * @ param ndec number of digits to right of decimal point
 * @ return String representation . */
static public String latToString ( double lat , int ndec ) { } }

implementation: boolean is_north = ( lat >= 0.0 ) ; if ( ! is_north ) lat = - lat ; String f = "%." + ndec + "f" ; Formatter latBuff = new Formatter ( ) ; latBuff . format ( f , lat ) ; latBuff . format ( "%s" , is_north ? "N" : "S" ) ; return latBuff . toString ( ) ;


signature:
public class LatLonPointImpl { /** * Make a nicely formatted representation of a longitude , eg 120.3W or 99.99E .
 * @ param lon the longitude .
 * @ param ndec number of digits to right of decimal point
 * @ return String representation . */
static public String lonToString ( double lon , int ndec ) { } }

implementation: double wlon = lonNormal ( lon ) ; boolean is_east = ( wlon >= 0.0 ) ; if ( ! is_east ) wlon = - wlon ; String f = "%." + ndec + "f" ; Formatter latBuff = new Formatter ( ) ; latBuff . format ( f , wlon ) ; latBuff . format ( "%s" , is_east ? "E" : "W" ) ; return latBuff . toString ( ) ;


signature:
public class BaseQuantity { /** * Compares this base quantity to another base quantity .
 * @ param that
 * The BaseQuantity to compare against .
 * @ return An integer that is negative , zero , or positive depending on
 * whether this BaseQuantity is less than , equal to , or greater than
 * < code > that < / code > . */
public int compareTo ( final BaseQuantity that ) { } }

implementation: int comp ; if ( this == that ) { comp = 0 ; } else { comp = getName ( ) . compareToIgnoreCase ( that . getName ( ) ) ; if ( comp == 0 && getSymbol ( ) != null ) { comp = getSymbol ( ) . compareTo ( that . getSymbol ( ) ) ; } } return comp ;


signature:
public class BaseQuantity { /** * Tests this class . */
public static void main ( final String [ ] args ) { } }

implementation: System . out . println ( "AMOUNT_OF_SUBSTANCE.getName() = " + AMOUNT_OF_SUBSTANCE . getName ( ) ) ; System . out . println ( "LUMINOUS_INTENSITY.getSymbol() = " + LUMINOUS_INTENSITY . getSymbol ( ) ) ; System . out . println ( "PLANE_ANGLE.getSymbol() = " + PLANE_ANGLE . getSymbol ( ) ) ; System . out . println ( "LENGTH.equals(LENGTH) = " + LENGTH . equals ( LENGTH ) ) ; System . out . println ( "LENGTH.equals(MASS) = " + LENGTH . equals ( MASS ) ) ; System . out . println ( "LENGTH.equals(PLANE_ANGLE) = " + LENGTH . equals ( PLANE_ANGLE ) ) ; System . out . println ( "PLANE_ANGLE.equals(PLANE_ANGLE) = " + PLANE_ANGLE . equals ( PLANE_ANGLE ) ) ; System . out . println ( "PLANE_ANGLE.equals(SOLID_ANGLE) = " + PLANE_ANGLE . equals ( SOLID_ANGLE ) ) ; System . out . println ( "LENGTH.compareTo(LENGTH) = " + LENGTH . compareTo ( LENGTH ) ) ; System . out . println ( "LENGTH.compareTo(MASS) = " + LENGTH . compareTo ( MASS ) ) ; System . out . println ( "LENGTH.compareTo(PLANE_ANGLE) = " + LENGTH . compareTo ( PLANE_ANGLE ) ) ; System . out . println ( "PLANE_ANGLE.compareTo(PLANE_ANGLE) = " + PLANE_ANGLE . compareTo ( PLANE_ANGLE ) ) ; System . out . println ( "PLANE_ANGLE.compareTo(SOLID_ANGLE) = " + PLANE_ANGLE . compareTo ( SOLID_ANGLE ) ) ;


signature:
public class CatalogTreeView { /** * Get the currently selected InvDataset .
 * @ return selected InvDataset , or null if none . */
public DatasetNode getSelectedDataset ( ) { } }

implementation: InvCatalogTreeNode tnode = getSelectedNode ( ) ; return tnode == null ? null : tnode . ds ;


signature:
public class CatalogTreeView { /** * Set the currently selected InvDataset .
 * @ param ds select this InvDataset , must be already in the tree .
 * LOOK does this work ? ? doesnt throw event */
public void setSelectedDataset ( Dataset ds ) { } }

implementation: if ( ds == null ) return ; TreePath path = makePath ( ds ) ; if ( path == null ) return ; tree . setSelectionPath ( path ) ; tree . scrollPathToVisible ( path ) ;


signature:
public class CatalogTreeView { /** * Create the TreePath corresponding to the given TreeNode .
 * @ param node the TreeNode ; already in the Tree .
 * @ return the corresponding TreePath . */
TreePath makeTreePath ( TreeNode node ) { } }

implementation: ArrayList < TreeNode > path = new ArrayList < > ( ) ; path . add ( node ) ; TreeNode parent = node . getParent ( ) ; while ( parent != null ) { path . add ( 0 , parent ) ; parent = parent . getParent ( ) ; } Object [ ] paths = path . toArray ( ) ; return new TreePath ( paths ) ;


signature:
public class CatalogTreeView { /** * Open all nodes of the tree .
 * @ param includeCatref open catrefs ? */
public void openAll ( boolean includeCatref ) { } }

implementation: if ( catalog == null ) return ; open ( ( InvCatalogTreeNode ) model . getRoot ( ) , includeCatref ) ; tree . repaint ( ) ;


signature:
public class CatalogTreeView { /** * Set the InvCatalog to display .
 * The catalog is read asynchronously and displayed if successfully read .
 * You must use a PropertyChangeEventListener to be notified if successful .
 * @ param location The URL of the InvCatalog . */
public void setCatalog ( String location ) { } }

implementation: CatalogBuilder builder = new CatalogBuilder ( ) ; try { Catalog cat = builder . buildFromLocation ( location , null ) ; setCatalog ( cat ) ; } catch ( Exception ioe ) { JOptionPane . showMessageDialog ( this , "Error opening catalog location " + location + " err=" + builder . getErrorMessage ( ) ) ; }


signature:
public class CatalogTreeView { /** * Set the catalog to be displayed . If ok , then a " Catalog " PropertyChangeEvent is sent .
 * @ param catalog to be displayed */
public void setCatalog ( Catalog catalog ) { } }

implementation:
if ( catalog == null ) return ; String catalogName = catalog . getBaseURI ( ) . toString ( ) ; this . catalog = catalog ; // send catalog event
setCatalogURL ( catalogName ) ; // display tree
// this sends TreeNode events
model = new InvCatalogTreeModel ( catalog ) ; tree . setModel ( model ) ; // debug
if ( debugTree ) { System . out . println ( "*** catalog/showJTree =" ) ; showNode ( tree . getModel ( ) , tree . getModel ( ) . getRoot ( ) ) ; System . out . println ( "*** " ) ; } // look for a specific dataset
int pos = catalogName . indexOf ( '#' ) ; if ( pos >= 0 ) { String id = catalogName . substring ( pos + 1 ) ; Dataset dataset = catalog . findDatasetByID ( id ) ; if ( dataset != null ) { setSelectedDataset ( dataset ) ; firePropertyChangeEvent ( new PropertyChangeEvent ( this , "Selection" , null , dataset ) ) ; } } // send catalog event
firePropertyChangeEvent ( new PropertyChangeEvent ( this , "Catalog" , null , catalogName ) ) ;


signature:
public class CatalogTreeView { /** * debug */
private void showNode ( TreeModel tree , Object node ) { } }

implementation: if ( node == null ) return ; InvCatalogTreeNode tnode = ( InvCatalogTreeNode ) node ; DatasetNode cp = tnode . ds ; System . out . println ( " node= " + cp . getName ( ) + " leaf= " + tree . isLeaf ( node ) ) ; for ( int i = 0 ; i < tree . getChildCount ( node ) ; i ++ ) showNode ( tree , tree . getChild ( node , i ) ) ;


signature:
public class Grib1Rectilyser { /** * debugging only */
public void showInfo ( Formatter f , Grib1Customizer cust1 ) { } }

implementation:
// f . format ( " % nVariables % n " ) ;
// f . format ( " % n % 3s % 3s % 3s % n " , " time " , " vert " , " ens " ) ;
GribRecordStats all = new GribRecordStats ( ) ; for ( VariableBag vb : gribvars ) { f . format ( "Variable %s (%d)%n" , Grib1Iosp . makeVariableName ( cust , gribConfig , vb . first . getPDSsection ( ) ) , vb . hashCode ( ) ) ; vb . coordND . showInfo ( f , all ) ; // f . format ( " % 3d % 3d % 3d % s records = % d density = % f hash = % d " , vb . timeCoordIndex , vb . vertCoordIndex , vb . ensCoordIndex ,
// vname , vb . atomList . size ( ) , vb . recordMap . density ( ) , vb . cdmHash ) ;
f . format ( "%n" ) ; } f . format ( "%n all= %s" , all . show ( ) ) ;


signature:
public class GDVConvention { /** * look for aliases . */
@ Override protected void findCoordinateAxes ( NetcdfDataset ds ) { } }

implementation:
for ( VarProcess vp : varList ) { if ( vp . isCoordinateVariable ) continue ; Variable ncvar = vp . v ; if ( ! ( ncvar instanceof VariableDS ) ) continue ; // cant be a structure
String dimName = findAlias ( ds , ncvar ) ; if ( dimName . length ( ) == 0 ) // none
continue ; Dimension dim = ds . findDimension ( dimName ) ; if ( null != dim ) { vp . isCoordinateAxis = true ; parseInfo . format ( " Coordinate Axis added (GDV alias) = %s for dimension %s%n" , vp . v . getFullName ( ) , dimName ) ; } } super . findCoordinateAxes ( ds ) ; // desperado
findCoordinateAxesForce ( ds ) ;


signature:
public class GDVConvention { /** * look for an coord _ axis or coord _ alias attribute */
private String findAlias ( NetcdfDataset ds , Variable v ) { } }

implementation: String alias = ds . findAttValueIgnoreCase ( v , "coord_axis" , null ) ; if ( alias == null ) alias = ds . findAttValueIgnoreCase ( v , "coord_alias" , "" ) ; return alias ;


signature:
public class VlenIO { /** * bigendian */
public final void writeInt ( int v ) throws IOException { } }

implementation: write ( int3 ( v ) ) ; write ( int2 ( v ) ) ; write ( int1 ( v ) ) ; write ( int0 ( v ) ) ;


signature:
public class VlenIO { /** * Writes an int in a variable - length format . Writes between one and five
 * bytes . Smaller values take fewer bytes . Negative numbers are not
 * supported . */
public int writeVInt ( int i ) throws IOException { } }

implementation: int count = 0 ; while ( ( i & ~ 0x7F ) != 0 ) { writeByte ( ( byte ) ( ( i & 0x7f ) | 0x80 ) ) ; i >>>= 7 ; count ++ ; } writeByte ( ( byte ) i ) ; return count + 1 ;


signature:
public class VlenIO { /** * Writes an long in a variable - length format . Writes between one and nine ( ? )
 * bytes . Smaller values take fewer bytes . Negative numbers are not
 * supported . */
public int writeVLong ( long i ) throws IOException { } }


signature:
public class VlenIO { /** * Writes a string .
 * ( vlen ) [ char ] */
public int writeString ( String s ) throws IOException { } }

implementation: int length = s . length ( ) ; int count = writeVInt ( length ) ; count += writeChars ( s , 0 , length ) ; return count ;


signature:
public class VlenIO { /** * Writes a sequence of UTF - 8 encoded characters from a string .
 * @ param s the source of the characters
 * @ param start the first character in the sequence
 * @ param length the number of characters in the sequence */
public int writeChars ( String s , int start , int length ) throws IOException { } }

implementation: final int end = start + length ; int count = 0 ; for ( int i = start ; i < end ; i ++ ) { final int code = ( int ) s . charAt ( i ) ; if ( code >= 0x01 && code <= 0x7F ) { writeByte ( ( byte ) code ) ; count ++ ; } else if ( ( ( code >= 0x80 ) && ( code <= 0x7FF ) ) || code == 0 ) { writeByte ( ( byte ) ( 0xC0 | ( code >> 6 ) ) ) ; writeByte ( ( byte ) ( 0x80 | ( code & 0x3F ) ) ) ; count += 2 ; } else { writeByte ( ( byte ) ( 0xE0 | ( code >>> 12 ) ) ) ; writeByte ( ( byte ) ( 0x80 | ( ( code >> 6 ) & 0x3F ) ) ) ; writeByte ( ( byte ) ( 0x80 | ( code & 0x3F ) ) ) ; count += 3 ; } } return count ;


signature:
public class VlenIO { /** * private char [ ] chars ; */
public String readString ( ) throws IOException { } }

implementation:
int length = readVInt ( ) ; // if ( chars = = null | | length > chars . length )
char [ ] chars = new char [ length ] ; readChars ( chars , 0 , length ) ; return new String ( chars , 0 , length ) ;


signature:
public class VlenIO { /** * Reads UTF - 8 encoded characters into an array .
 * @ param buffer the array to read characters into
 * @ param start the offset in the array to start storing characters
 * @ param length the number of characters to read */
public void readChars ( char [ ] buffer , int start , int length ) throws IOException { } }

implementation: final int end = start + length ; for ( int i = start ; i < end ; i ++ ) { byte b = readByte ( ) ; if ( ( b & 0x80 ) == 0 ) buffer [ i ] = ( char ) ( b & 0x7F ) ; else if ( ( b & 0xE0 ) != 0xE0 ) { buffer [ i ] = ( char ) ( ( ( b & 0x1F ) << 6 ) | ( readByte ( ) & 0x3F ) ) ; } else buffer [ i ] = ( char ) ( ( ( b & 0x0F ) << 12 ) | ( ( readByte ( ) & 0x3F ) << 6 ) | ( readByte ( ) & 0x3F ) ) ; }


signature:
public class Ray { /** * Read data from this record .
 * @ param raf read from this file
 * @ param gateRange handles the possible subset of data to return
 * @ param ii put the data here
 * @ throws java . io . IOException on read error */
public void readData ( RandomAccessFile raf , Range gateRange , IndexIterator ii ) throws IOException { } }

implementation:
final int REC_SIZE = 6144 ; raf . seek ( offset ) ; byte [ ] data = new byte [ bins ] ; float [ ] dd = new float [ bins ] ; byte d ; int nb = 0 ; short a00 ; // raf . readFully ( data ) ;
if ( dataRead > 0 ) { raf . seek ( offset ) ; for ( int i = 0 ; i < dataRead ; i ++ ) { d = raf . readByte ( ) ; dd [ i ] = SigmetIOServiceProvider . calcData ( SigmetIOServiceProvider . recHdr , getDataType ( ) , d ) ; nb ++ ; } } // System . out . println ( " this is az " + getAz ( ) ) ;
raf . seek ( offset1 ) ; int cur_len = offset1 ; while ( nb < ( int ) bins ) { // - - - Check if the code = 1 ( " 1 " means an end of a ray )
a00 = raf . readShort ( ) ; cur_len = cur_len + 2 ; if ( a00 == ( short ) 1 ) { for ( int uk = 0 ; uk < ( int ) bins ; uk ++ ) { dd [ uk ] = - 999.99f ; } break ; } if ( a00 < 0 ) { // - - This is data
int nwords = a00 & 0x7fff ; int dataRead1 = nwords * 2 ; int pos = 0 ; if ( cur_len % REC_SIZE == 0 ) { pos = 0 ; break ; } raf . seek ( cur_len ) ; for ( int i = 0 ; i < dataRead1 ; i ++ ) { d = raf . readByte ( ) ; dd [ nb ] = SigmetIOServiceProvider . calcData ( SigmetIOServiceProvider . recHdr , getDataType ( ) , d ) ; nb = nb + 1 ; cur_len = cur_len + 1 ; if ( nb % REC_SIZE == 0 ) { pos = i + 1 ; break ; } } if ( pos > 0 ) { break ; } } else if ( a00 > 0 & a00 != 1 ) { int num_zero = a00 * 2 ; int dataRead1 = num_zero ; for ( int k = 0 ; k < dataRead1 ; k ++ ) { dd [ nb + k ] = SigmetIOServiceProvider . calcData ( SigmetIOServiceProvider . recHdr , getDataType ( ) , ( byte ) 0 ) ; } nb = nb + dataRead1 ; if ( cur_len % REC_SIZE == 0 ) { break ; } } } // - - - - - end of while for num _ bins - - - - -
for ( int gateIdx : gateRange ) { if ( gateIdx >= bins ) ii . setFloatNext ( Float . NaN ) ; else ii . setFloatNext ( dd [ gateIdx ] ) ; }


signature:
public class Grib { /** * we are running with only ncx index files , no data */
public static void setDebugFlags ( ucar . nc2 . util . DebugFlags debugFlag ) { } }

implementation: debugRead = debugFlag . isSet ( "Grib/showRead" ) ; debugIndexOnly = debugFlag . isSet ( "Grib/indexOnly" ) ; debugIndexOnlyShow = debugFlag . isSet ( "Grib/indexOnlyShow" ) ; debugGbxIndexOnly = debugFlag . isSet ( "Grib/debugGbxIndexOnly" ) ;


signature:
public class NdbcCoards { /** * < ! - - C : / data / dt2 / station / ndbc . nc - - >
 * < stationFeature >
 * < stationId > " : station " < / stationId >
 * < stationDesc > " : description " < / stationDesc >
 * < coordAxis type = " lat " > lat < / coordAxis >
 * < coordAxis type = " lon " > lon < / coordAxis >
 * < coordAxis type = " height " > 0 < / coordAxis >
 * < table dim = " time " >
 * < coordAxis type = " time " > time < / coordAxis >
 * < / table >
 * < / stationFeature > */
public TableConfig getConfig ( FeatureType wantFeatureType , NetcdfDataset ds , Formatter errlog ) { } }

implementation:
Dimension obsDim = ds . getUnlimitedDimension ( ) ; if ( obsDim == null ) { CoordinateAxis axis = CoordSysEvaluator . findCoordByType ( ds , AxisType . Time ) ; if ( ( axis != null ) && axis . isScalar ( ) ) obsDim = axis . getDimension ( 0 ) ; } if ( obsDim == null ) { errlog . format ( "Must have an Observation dimension: unlimited dimension, or from Time Coordinate" ) ; return null ; } boolean hasStruct = Evaluator . hasNetcdf3RecordStructure ( ds ) ; // wants a Point
if ( ( wantFeatureType == FeatureType . POINT ) ) { TableConfig nt = new TableConfig ( Table . Type . Structure , hasStruct ? "record" : obsDim . getShortName ( ) ) ; nt . structName = "record" ; nt . structureType = hasStruct ? TableConfig . StructureType . Structure : TableConfig . StructureType . PsuedoStructure ; nt . featureType = FeatureType . POINT ; CoordSysEvaluator . findCoords ( nt , ds , null ) ; return nt ; } // otherwise , make it a Station
TableConfig nt = new TableConfig ( Table . Type . Top , "station" ) ; nt . featureType = FeatureType . STATION ; nt . lat = CoordSysEvaluator . findCoordNameByType ( ds , AxisType . Lat ) ; nt . lon = CoordSysEvaluator . findCoordNameByType ( ds , AxisType . Lon ) ; nt . stnId = ds . findAttValueIgnoreCase ( null , "station" , null ) ; nt . stnDesc = ds . findAttValueIgnoreCase ( null , "description" , null ) ; if ( nt . stnDesc == null ) nt . stnDesc = ds . findAttValueIgnoreCase ( null , "comment" , null ) ; TableConfig obs = new TableConfig ( Table . Type . Structure , hasStruct ? "record" : obsDim . getShortName ( ) ) ; obs . structName = "record" ; obs . structureType = hasStruct ? TableConfig . StructureType . Structure : TableConfig . StructureType . PsuedoStructure ; obs . dimName = obsDim . getShortName ( ) ; obs . time = CoordSysEvaluator . findCoordNameByType ( ds , AxisType . Time ) ; nt . addChild ( obs ) ; return nt ;


signature:
public class AtmosSigma { /** * Get the 3D vertical coordinate array for this time step .
 * @ param timeIndex the time index . Ignored if ! isTimeDependent ( ) .
 * @ return vertical coordinate array
 * @ throws IOException problem reading data
 * @ throws InvalidRangeException _ more _ */
public ArrayDouble . D3 getCoordinateArray ( int timeIndex ) throws IOException , InvalidRangeException { } }

implementation: Array ps = readArray ( psVar , timeIndex ) ; Index psIndex = ps . getIndex ( ) ; int nz = sigma . length ; int [ ] shape2D = ps . getShape ( ) ; int ny = shape2D [ 0 ] ; int nx = shape2D [ 1 ] ; ArrayDouble . D3 result = new ArrayDouble . D3 ( nz , ny , nx ) ; for ( int y = 0 ; y < ny ; y ++ ) { for ( int x = 0 ; x < nx ; x ++ ) { double psVal = ps . getDouble ( psIndex . set ( y , x ) ) ; for ( int z = 0 ; z < nz ; z ++ ) { result . set ( z , y , x , ptop + sigma [ z ] * ( psVal - ptop ) ) ; } } } return result ;


signature:
public class AtmosSigma { /** * Get the 1D vertical coordinate array for this time step and point
 * ( needds test ! ! ! )
 * @ param timeIndex the time index . Ignored if ! isTimeDependent ( ) .
 * @ param xIndex the x index
 * @ param yIndex the y index
 * @ return vertical coordinate array
 * @ throws java . io . IOException problem reading data
 * @ throws ucar . ma2 . InvalidRangeException _ more _ */
public D1 getCoordinateArray1D ( int timeIndex , int xIndex , int yIndex ) throws IOException , InvalidRangeException { } }

implementation: Array ps = readArray ( psVar , timeIndex ) ; Index psIndex = ps . getIndex ( ) ; int nz = sigma . length ; ArrayDouble . D1 result = new ArrayDouble . D1 ( nz ) ; double psVal = ps . getDouble ( psIndex . set ( yIndex , xIndex ) ) ; for ( int z = 0 ; z < nz ; z ++ ) { result . set ( z , ptop + sigma [ z ] * ( psVal - ptop ) ) ; } return result ;


signature:
public class StructureMembers { /** * Add a member .
 * @ param m member to add */
public void addMember ( Member m ) { } }

implementation: members . add ( m ) ; if ( memberHash != null ) memberHash . put ( m . getName ( ) , m ) ;


signature:
public class StructureMembers { /** * Remove the given member
 * @ param m member
 * @ return position that it used to occupy , or - 1 if not found */
public int hideMember ( Member m ) { } }

implementation: if ( m == null ) return - 1 ; int index = members . indexOf ( m ) ; members . remove ( m ) ; if ( memberHash != null ) memberHash . remove ( m . getName ( ) ) ; return index ;


signature:
public class StructureMembers { /** * Get the names of the members .
 * @ return List of type String . */
public java . util . List < String > getMemberNames ( ) { } }

implementation: List < String > memberNames = new ArrayList < > ( ) ; for ( Member m : members ) { memberNames . add ( m . getName ( ) ) ; } return memberNames ;


signature:
public class StructureMembers { /** * Find the member by its name .
 * @ param memberName find by this name
 * @ return Member matching the name , or null if not found */
public Member findMember ( String memberName ) { } }

implementation:
if ( memberName == null ) return null ; if ( memberHash == null ) { // delay making the hash table until needed
int initial_capacity = ( int ) ( members . size ( ) / .75 ) + 1 ; memberHash = new HashMap < > ( initial_capacity ) ; for ( Member m : members ) memberHash . put ( m . getName ( ) , m ) ; } return memberHash . get ( memberName ) ;


signature:
public class Grib1SectionBitMap { /** * Read the bitmap array when needed , return null if none . */
@ Nullable public byte [ ] getBitmap ( RandomAccessFile raf ) throws IOException { } }

implementation:
if ( startingPosition <= 0 ) { throw new IllegalStateException ( "Grib1 Bit map has bad starting position" ) ; } raf . seek ( startingPosition ) ; // octet 1-3 ( length of section )
int length = GribNumbers . uint3 ( raf ) ; // octet 4 unused bits
raf . read ( ) ; // unused
// octets 5-6
int bm = raf . readShort ( ) ; if ( bm != 0 ) { logger . warn ( "Grib1 Bit map section pre-defined (provided by center) bitmap number = {}" , bm ) ; return null ; } // not sure if length is set correctly when pre - define bitmap is used , so wait until that to test
// seeing a - 1 , bail out
if ( length <= 6 || length > 10e6 ) { // look max ? ?
return null ; } // read the bits as integers
int n = length - 6 ; byte [ ] data = new byte [ n ] ; raf . readFully ( data ) ; return data ;


signature:
public class JTreeTableSorted { /** * Set the state from the last saved in the PreferencesExt .
 * @ param store ok if null or empty */
public void restoreState ( PreferencesExt store ) { } }

implementation:
if ( store == null ) return ; int ncols = table . getColumnCount ( ) ; // stored column order
int [ ] modelIndex = ( int [ ] ) store . getBean ( "ColumnOrder" , null ) ; if ( ( modelIndex != null ) && ( modelIndex . length == ncols ) ) { // what about invisible ? ?
// make invisible any not stored
boolean [ ] visible = new boolean [ ncols ] ; for ( int aModelIndex : modelIndex ) if ( aModelIndex < ncols ) visible [ aModelIndex ] = true ; // modify popup menu
for ( int i = 0 ; i < ncols ; i ++ ) if ( ! visible [ i ] ) { // System . out . println ( colName [ i ] + " hide " + i ) ;
acts [ i ] . hideColumn ( ) ; acts [ i ] . putValue ( BAMutil . STATE , new Boolean ( false ) ) ; } // now set the header order
TableColumnModel tcm = table . getColumnModel ( ) ; int n = Math . min ( modelIndex . length , table . getColumnCount ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { TableColumn tc = tcm . getColumn ( i ) ; tc . setModelIndex ( modelIndex [ i ] ) ; String name = model . getColumnName ( modelIndex [ i ] ) ; tc . setHeaderValue ( name ) ; tc . setIdentifier ( name ) ; if ( useThreads && ( modelIndex [ i ] == threadCol ) ) { threadHeaderRenderer = new ThreadHeaderRenderer ( threadCol ) ; tc . setHeaderRenderer ( threadHeaderRenderer ) ; } else tc . setHeaderRenderer ( new SortedHeaderRenderer ( name , modelIndex [ i ] ) ) ; } } // set the column widths
Object colWidths = store . getBean ( "ColumnWidths" , null ) ; if ( colWidths == null ) return ; int [ ] size = ( int [ ] ) colWidths ; setColumnWidths ( size ) ; if ( debug ) { System . out . println ( " read widths = " ) ; for ( int aSize : size ) System . out . print ( " " + aSize ) ; System . out . println ( ) ; } boolean isThreadsOn = store . getBoolean ( "isThreadsOn" , false ) ; if ( useThreads ) { model . setThreadsOn ( isThreadsOn ) ; threadHeaderRenderer . setOn ( isThreadsOn ) ; } int colNo = store . getInt ( "SortOnCol" , 0 ) ; boolean reverse = store . getBoolean ( "SortReverse" , false ) ; model . setSortCol ( colNo ) ; model . setReverse ( reverse ) ; setSortCol ( colNo , reverse ) ; model . sort ( ) ; table . fireDataChanged ( ) ; } private void setColumnWidths ( int [ ] sizes ) { TableColumnModel tcm = table . getColumnModel ( ) ; for ( int i = 0 ; i < table . getColumnCount ( ) ; i ++ ) { TableColumn tc = tcm . getColumn ( i ) ; int maxw = ( ( sizes == null ) || ( i >= sizes . length ) ) ? 10 : sizes [ i ] ; // model . getPreferredWidthForColumn ( tc ) : sizes [ i ] ;
tc . setPreferredWidth ( maxw ) ; } // table . sizeColumnsToFit ( 0 ) ; / / must be called due to a JTable bug
} public void setColOn ( int colno , boolean state , int pos ) { // System . out . println ( " setColOn " + colno + " " + state + " " + pos ) ;
acts [ colno ] . putValue ( BAMutil . STATE , new Boolean ( state ) ) ; if ( state ) acts [ colno ] . addAtPos ( pos ) ; else acts [ colno ] . hideColumn ( ) ;


signature:
public class JTreeTableSorted { /** * Save state to the PreferencesExt . */
public void saveState ( PreferencesExt store ) { } }

implementation: if ( store == null ) return ; int ncols = table . getColumnCount ( ) ; int [ ] size = new int [ ncols ] ; int [ ] modelIndex = new int [ ncols ] ; TableColumnModel tcm = table . getColumnModel ( ) ; for ( int i = 0 ; i < ncols ; i ++ ) { TableColumn tc = tcm . getColumn ( i ) ; size [ i ] = tc . getWidth ( ) ; modelIndex [ i ] = tc . getModelIndex ( ) ; } store . putBeanObject ( "ColumnWidths" , size ) ; store . putBeanObject ( "ColumnOrder" , modelIndex ) ; store . putInt ( "SortOnCol" , model . getSortCol ( ) ) ; store . putBoolean ( "SortReverse" , model . getReverse ( ) ) ; store . putBoolean ( "isThreadsOn" , model . isThreadsOn ( ) ) ; if ( debug ) { System . out . println ( " store widths = " ) ; for ( int aSize : size ) System . out . print ( " " + aSize ) ; System . out . println ( ) ; }


signature:
public class JTreeTableSorted { /** * Get the currently selected rows .
 * @ return an Iterator whose objects are TableRow */
public Iterator getSelectedRows ( ) { } }

implementation: TreePath [ ] paths = table . getSelectionPaths ( ) ; if ( ( paths == null ) || ( paths . length < 1 ) ) return null ; HashSet set = new HashSet ( 2 * paths . length ) ; for ( TreePath path : paths ) { model . addRowsToSetFromPath ( table . getTree ( ) , path , set ) ; } return set . iterator ( ) ;


signature:
public class JTreeTableSorted { /** * Set the current selection to this row .
 * @ param rowno index into rowList */
public void setSelectedRow ( int rowno ) { } }

implementation:
if ( ( rowno < 0 ) || ( rowno >= model . getRowCount ( ) ) ) return ; if ( debugSetPath ) System . out . println ( "TreeTableSorted setSelected " + rowno ) ; selectedRow = model . getRow ( rowno ) ; TreePath path = model . getPath ( selectedRow ) ; if ( path != null ) table . setSelectionPath ( path ) ; // for mysterious reasons , gotta do it again later
invokeSetPath ( ) ; ensureRowIsVisible ( rowno ) ;


signature:
public class JTreeTableSorted { /** * this array translates the column index to the model index */
public int [ ] getModelIndex ( ) { } }

implementation:
int [ ] modelIndex = new int [ model . getColumnCount ( ) ] ; try { TableColumnModel tcm = table . getColumnModel ( ) ; for ( int i = 0 ; i < model . getColumnCount ( ) ; i ++ ) { TableColumn tc = tcm . getColumn ( i ) ; modelIndex [ i ] = tc . getModelIndex ( ) ; } } catch ( java . lang . ArrayIndexOutOfBoundsException e ) { // can happen when model size increases
} return modelIndex ;


signature: public class JTreeTableSorted { private void ensureRowIsVisible ( int nRow ) { } }

implementation: Rectangle visibleRect = table . getCellRect ( nRow , 0 , true ) ; if ( debugSetPath ) System . out . println ( "----ensureRowIsVisible = " + visibleRect ) ; if ( visibleRect != null ) { visibleRect . x = scrollPane . getViewport ( ) . getViewPosition ( ) . x ; table . scrollRectToVisible ( visibleRect ) ; table . repaint ( ) ; }


signature:
public class StructureDataW { /** * / * Copy constructor .
 * This makes a local copy of all the data in the from StrucureData .
 * @ param from copy from here
 * public StructureDataW ( StructureData from ) {
 * this ( from . getStructureMembers ( ) ) ;
 * List < StructureMembers . Member > members = getMembers ( ) ;
 * for ( StructureMembers . Member m : members ) {
 * Array data = from . getArray ( m ) ;
 * setMemberData ( m , data . copy ( ) ) ; / / LOOK wont work for StructureData */
public void setMemberData ( StructureMembers . Member m , Array data ) { } }

implementation: if ( data == null ) throw new IllegalArgumentException ( "data cant be null" ) ; memberData . put ( m , data ) ;


signature:
public class StructureDataW { /** * Get member data array of any type as an Array .
 * @ param m get data from this StructureMembers . Member .
 * @ return Array values . */
public Array getArray ( StructureMembers . Member m ) { } }

implementation: if ( m == null ) throw new IllegalArgumentException ( "member is null" ) ; return memberData . get ( m ) ;


signature:
public class StructureDataW { /** * Get member data of type double .
 * @ param m get data from this StructureMembers . Member . Must be of type double .
 * @ return scalar double value */
public double getScalarDouble ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return data . getDouble ( Index . scalarIndexImmutable ) ;


signature:
public class StructureDataW { /** * Get java double array for a member of type double .
 * @ param m get data from this StructureMembers . Member . Must be of type double .
 * @ return 1D java array of doubles */
public double [ ] getJavaArrayDouble ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return ( double [ ] ) data . getStorage ( ) ;


signature:
public class StructureDataW { /** * Get member data of type float .
 * @ param m get data from this StructureMembers . Member . Must be of type float .
 * @ return scalar double value */
public float getScalarFloat ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return data . getFloat ( Index . scalarIndexImmutable ) ;


signature:
public class StructureDataW { /** * Get java float array for a member of type float .
 * @ param m get data from this StructureMembers . Member . Must be of type float .
 * @ return 1D java array of floats */
public float [ ] getJavaArrayFloat ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return ( float [ ] ) data . getStorage ( ) ;


signature:
public class StructureDataW { /** * Get member data of type byte .
 * @ param m get data from this StructureMembers . Member . Must be of type byte .
 * @ return scalar byte value */
public byte getScalarByte ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return data . getByte ( Index . scalarIndexImmutable ) ;


signature:
public class StructureDataW { /** * Get java byte array for a member of type byte .
 * @ param m get data from this StructureMembers . Member . Must be of type byte .
 * @ return 1D java array of bytes */
public byte [ ] getJavaArrayByte ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return ( byte [ ] ) data . getStorage ( ) ;


signature:
public class StructureDataW { /** * Get member data of type int .
 * @ param m get data from this StructureMembers . Member . Must be of type int .
 * @ return scalar int value */
public int getScalarInt ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return data . getInt ( Index . scalarIndexImmutable ) ;


signature:
public class StructureDataW { /** * Get java int array for a member of type int .
 * @ param m get data from this StructureMembers . Member . Must be of type int .
 * @ return 1D java array of ints */
public int [ ] getJavaArrayInt ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return ( int [ ] ) data . getStorage ( ) ;


signature:
public class StructureDataW { /** * Get member data of type short .
 * @ param m get data from this StructureMembers . Member . Must be of type short .
 * @ return scalar short value */
public short getScalarShort ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return data . getShort ( Index . scalarIndexImmutable ) ;


signature:
public class StructureDataW { /** * Get java short array for a member of type short .
 * @ param m get data from this StructureMembers . Member . Must be of type short .
 * @ return 1D java array of shorts */
public short [ ] getJavaArrayShort ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return ( short [ ] ) data . getStorage ( ) ;


signature:
public class StructureDataW { /** * Get member data of type long .
 * @ param m get data from this StructureMembers . Member . Must be of type long .
 * @ return scalar long value */
public long getScalarLong ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return data . getLong ( Index . scalarIndexImmutable ) ;


signature:
public class StructureDataW { /** * Get java long array for a member of type long .
 * @ param m get data from this StructureMembers . Member . Must be of type long .
 * @ return 1D java array of longs */
public long [ ] getJavaArrayLong ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return ( long [ ] ) data . getStorage ( ) ;


signature:
public class StructureDataW { /** * Get member data of type char .
 * @ param m get data from this StructureMembers . Member . Must be of type char .
 * @ return scalar char value */
public char getScalarChar ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return data . getChar ( Index . scalarIndexImmutable ) ;


signature:
public class StructureDataW { /** * Get java char array for a member of type char .
 * @ param m get data from this StructureMembers . Member . Must be of type char .
 * @ return 1D java array of chars */
public char [ ] getJavaArrayChar ( StructureMembers . Member m ) { } }

implementation: Array data = getArray ( m ) ; return ( char [ ] ) data . getStorage ( ) ;


signature:
public class StructureDataW { /** * Get String value , from rank 0 String or rank 1 char member array .
 * @ param m get data from this StructureMembers . Member . Must be of type char or String . */
public String getScalarString ( StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) == DataType . STRING ) { Array data = getArray ( m ) ; if ( data == null ) data = getArray ( m ) ; return ( String ) data . getObject ( 0 ) ; } else { char [ ] ba = getJavaArrayChar ( m ) ; int count = 0 ; while ( count < ba . length ) { if ( 0 == ba [ count ] ) break ; count ++ ; } return new String ( ba , 0 , count ) ; }


signature:
public class StructureDataW { /** * Get member data of type Structure .
 * @ param m get data from this StructureMembers . Member . Must be of type Structure .
 * @ return StructureData */
public StructureData getScalarStructure ( StructureMembers . Member m ) { } }

implementation: ArrayStructure data = ( ArrayStructure ) getArray ( m ) ; return data . getStructureData ( 0 ) ;


signature:
public class DIFWriter { /** * Write all harvestable datasets to DIF records that have at least the minimum metadata .
 * Call isDatasetUseable ( ) to find out .
 * @ param cat harvest the datasets starting from here
 * @ param fileDir write records to this directory . The dataset id is used as the filename , appending " dif . xml "
 * @ param mess status messages are appended here */
public void writeDatasetEntries ( InvCatalogImpl cat , String fileDir , StringBuilder mess ) { } }

implementation: this . fileDir = fileDir ; this . messBuffer = mess ; File dir = new File ( fileDir ) ; if ( ! dir . exists ( ) ) { boolean ret = dir . mkdirs ( ) ; assert ret ; } CatalogCrawler . Listener listener = new CatalogCrawler . Listener ( ) { public void getDataset ( InvDataset ds , Object context ) { doOneDataset ( ds ) ; } public boolean getCatalogRef ( InvCatalogRef dd , Object context ) { return true ; } } ; ByteArrayOutputStream bis = new ByteArrayOutputStream ( ) ; PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( bis , CDM . utf8Charset ) ) ; CatalogCrawler crawler = new CatalogCrawler ( CatalogCrawler . USE_ALL , true , listener ) ; crawler . crawl ( cat , null , pw , null ) ; mess . append ( "\n*********************\n" ) ; mess . append ( new String ( bis . toByteArray ( ) , CDM . utf8Charset ) ) ;


signature:
public class DIFWriter { /** * Write a DIF record for a specific dataset
 * @ param ds use this dataset */
public void doOneDataset ( InvDataset ds ) { } }

implementation:
if ( debug ) System . out . println ( "doDataset " + ds . getName ( ) ) ; if ( isDatasetUseable ( ds , messBuffer ) ) { String id = StringUtil2 . replace ( ds . getID ( ) , "/" , "-" ) ; String fileOutName = fileDir + "/" + id + ".dif.xml" ; try { OutputStream out = new BufferedOutputStream ( new FileOutputStream ( fileOutName ) ) ; // writeOneEntry ( ds , System . out , mess ) ;
writeOneEntry ( ds , out , messBuffer ) ; out . close ( ) ; messBuffer . append ( " OK on Write\n" ) ; } catch ( IOException ioe ) { messBuffer . append ( "DIFWriter failed on write " + ioe . getMessage ( ) + "\n" ) ; log . error ( "DIFWriter failed on write " + ioe . getMessage ( ) , ioe ) ; } }


signature:
public class DIFWriter { /** * See if a dataset is harvestable to a DIF record .
 * @ param ds check this dataset .
 * @ param sbuff put status messages here .
 * @ return true if a DIF record can be written */
public boolean isDatasetUseable ( InvDataset ds , StringBuilder sbuff ) { } }

implementation: boolean ok = true ; sbuff . append ( "Dataset " + ds . getName ( ) + " id = " + ds . getID ( ) + ": " ) ; if ( ! ds . isHarvest ( ) ) { ok = false ; sbuff . append ( "Dataset " + ds . getName ( ) + " id = " + ds . getID ( ) + " has harvest = false\n" ) ; } if ( ds . getName ( ) == null ) { ok = false ; sbuff . append ( " missing Name field\n" ) ; } if ( ds . getUniqueID ( ) == null ) { ok = false ; sbuff . append ( " missing ID field\n" ) ; } ThreddsMetadata . Variables vs = ds . getVariables ( "DIF" ) ; if ( ( vs == null ) || ( vs . getVariableList ( ) . size ( ) == 0 ) ) vs = ds . getVariables ( "GRIB-1" ) ; if ( ( vs == null ) || ( vs . getVariableList ( ) . size ( ) == 0 ) ) vs = ds . getVariables ( "GRIB-2" ) ; if ( ( vs == null ) || ( vs . getVariableList ( ) . size ( ) == 0 ) ) { ok = false ; sbuff . append ( " missing Variables with DIF or GRIB compatible vocabulary\n" ) ; } List list = ds . getPublishers ( ) ; if ( ( list == null ) || ( list . size ( ) == 0 ) ) { ok = false ; sbuff . append ( " must have publisher element that defines the data center\n" ) ; } String summary = ds . getDocumentation ( "summary" ) ; if ( summary == null ) { ok = false ; sbuff . append ( " must have documentation element of type summary\n" ) ; } sbuff . append ( " useable= " + ok + "\n" ) ; return ok ;


signature:
public class DatasetBuilder { /** * Utility routine to keep list of objects small .
 * add fldValue to the fldName list in flds .
 * fldValue may be a list or an object .
 * if no list , just keep the object without creating a list ( common case ) .
 * otherwise add it to the existing list . */
public static void addToList ( Map < String , Object > flds , String fldName , Object fldValue ) { } }

implementation: if ( fldValue == null ) return ; Object prevVal = flds . get ( fldName ) ; if ( prevVal == null ) { flds . put ( fldName , fldValue ) ; return ; } List prevList ; if ( prevVal instanceof List ) { prevList = ( List ) prevVal ; } else { prevList = new ArrayList ( 5 ) ; prevList . add ( prevVal ) ; flds . put ( fldName , prevList ) ; } if ( fldValue instanceof List ) { prevList . addAll ( ( List ) fldValue ) ; } else { prevList . add ( fldValue ) ; }


signature:
public class DatasetBuilder { /** * make an immutable copy without changin DatasetBuilder */
public Dataset copyDataset ( DatasetNode parent ) { } }

implementation: return new Dataset ( parent , name , flds , accessBuilders , datasetBuilders ) ;


signature:
public class DatasetBuilder { /** * transfer all metadata , optionally also inheritable metadata from parents */
public void transferMetadata ( DatasetNode from , boolean parentsAlso ) { } }

implementation:
if ( parentsAlso ) { ThreddsMetadata inherit = getInheritableMetadata ( ) ; // make sure exists
inheritMetadata ( from , inherit . getFlds ( ) ) ; } // local metadata
for ( Map . Entry < String , Object > entry : from . getFldIterator ( ) ) { if ( parentsAlso && entry . getKey ( ) . equals ( Dataset . ThreddsMetadataInheritable ) ) continue ; // already did this
if ( Dataset . listFlds . contains ( entry . getKey ( ) ) ) addToNewList ( flds , entry . getKey ( ) , entry . getValue ( ) ) ; else flds . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } // tmi must be mutable , transfer if not
ThreddsMetadata tmiOld = ( ThreddsMetadata ) get ( Dataset . ThreddsMetadataInheritable ) ; if ( tmiOld != null && tmiOld . isImmutable ( ) ) { ThreddsMetadata tmiNew = new ThreddsMetadata ( tmiOld ) ; flds . put ( Dataset . ThreddsMetadataInheritable , tmiNew ) ; }


signature:
public class DatasetBuilder { /** * place directly into flds ( not in this . tmi ) LOOK why not into tmi ? ? LOOK put into tmi , see what breaks ! */
public void transferInheritedMetadata ( DatasetNode from ) { } }

implementation: ThreddsMetadata tmi = getInheritableMetadata ( ) ; inheritMetadata ( from , tmi . getFlds ( ) ) ;


signature:
public class DatasetBuilder { /** * get the inheritable ThreddsMetadata object . If doesnt exist , create new , empty one */
public ThreddsMetadata getInheritableMetadata ( ) { } }

implementation: ThreddsMetadata tmi = ( ThreddsMetadata ) get ( Dataset . ThreddsMetadataInheritable ) ; if ( tmi == null ) { tmi = new ThreddsMetadata ( ) ; put ( Dataset . ThreddsMetadataInheritable , tmi ) ; } return tmi ;


signature:
public class GridVariable { /** * Add in a new product
 * @ param record grid to add */
void addProduct ( GridRecord record ) { } }

implementation: records . add ( record ) ; if ( firstRecord == null ) { firstRecord = record ; }


signature:
public class GridVariable { /** * is this a time interval variable
 * @ return true if uses time intervals
 * boolean isInterval ( ) {
 * if ( firstRecord instanceof GribGridRecord ) {
 * GribGridRecord ggr = ( GribGridRecord ) firstRecord ;
 * return ggr . isInterval ( ) ;
 * return false ;
 * String getIntervalTypeName ( ) {
 * if ( firstRecord instanceof GribGridRecord ) {
 * GribGridRecord ggr = ( GribGridRecord ) firstRecord ;
 * return ggr . getStatisticalProcessTypeName ( ) ;
 * return null ; */
protected void addExtraAttributes ( GridParameter param , Variable v ) { } }

implementation: int icf = hcs . getGds ( ) . getInt ( GridDefRecord . VECTOR_COMPONENT_FLAG ) ; String flag = GridCF . VectorComponentFlag . of ( icf ) ; v . addAttribute ( new Attribute ( GridDefRecord . VECTOR_COMPONENT_FLAG , flag ) ) ;


signature:
public class GridVariable { /** * Make the netcdf variable . If vname is not already set , use useName as name
 * @ param ncfile netCDF file
 * @ param g group
 * @ param useName use this as the variable name
 * @ param raf read from here
 * @ return the netcdf variable */
Variable makeVariable ( NetcdfFile ncfile , Group g , String useName , RandomAccessFile raf ) { } }

implementation:
assert records . size ( ) > 0 : "no records for this variable" ; this . nlevels = getVertNlevels ( ) ; this . ntimes = tcs . getNTimes ( ) ; if ( vname == null ) { useName = StringUtil2 . replace ( useName , ' ' , "_" ) ; this . vname = useName ; } Variable v = new Variable ( ncfile , g , null , vname ) ; v . setDataType ( DataType . FLOAT ) ; Formatter dims = new Formatter ( ) ; if ( hasEnsemble ( ) ) { dims . format ( "ens " ) ; } dims . format ( "%s " , tcs . getName ( ) ) ; if ( getVertIsUsed ( ) ) { dims . format ( "%s " , getVertName ( ) ) ; hasVert = true ; } if ( hcs . isLatLon ( ) ) { dims . format ( "lat lon" ) ; } else { dims . format ( "y x" ) ; } v . setDimensions ( dims . toString ( ) ) ; // add attributes
GridParameter param = lookup . getParameter ( firstRecord ) ; if ( param == null ) return null ; String unit = param . getUnit ( ) ; if ( unit == null ) unit = "" ; v . addAttribute ( new Attribute ( "units" , unit ) ) ; v . addAttribute ( new Attribute ( "long_name" , makeLongName ( ) ) ) ; v . addAttribute ( new Attribute ( "missing_value" , lookup . getFirstMissingValue ( ) ) ) ; if ( ! hcs . isLatLon ( ) ) { if ( GridServiceProvider . addLatLon ) v . addAttribute ( new Attribute ( "coordinates" , "lat lon" ) ) ; v . addAttribute ( new Attribute ( "grid_mapping" , hcs . getGridName ( ) ) ) ; } addExtraAttributes ( param , v ) ; v . setSPobject ( this ) ; int nrecs = ntimes * nlevels ; if ( hasEnsemble ( ) ) nrecs *= ecs . getNEnsembles ( ) ; recordTracker = new GridRecord [ nrecs ] ; if ( log . isDebugEnabled ( ) ) log . debug ( "Record Assignment for Variable " + getName ( ) ) ; boolean oneSent = false ; for ( GridRecord p : records ) { int level = getVertIndex ( p ) ; if ( ! getVertIsUsed ( ) && ( level > 0 ) ) { log . warn ( "inconsistent level encoding=" + level ) ; level = 0 ; // inconsistent level encoding ? ?
} int time = tcs . findIndex ( p ) ; // System . out . println ( " time = " + time + " level = " + level ) ;
if ( level < 0 ) { log . warn ( "LEVEL NOT FOUND record; level=" + level + " time= " + time + " for " + getName ( ) + " file=" + ncfile . getLocation ( ) + "\n" + "   " + getVertLevelName ( ) + " (type=" + p . getLevelType1 ( ) + "," + p . getLevelType2 ( ) + ")  value=" + p . getLevel1 ( ) + "," + p . getLevel2 ( ) + "\n" ) ; getVertIndex ( p ) ; // allow breakpoint
continue ; } if ( time < 0 ) { log . warn ( "TIME NOT FOUND record; level=" + level + " time= " + time + " for " + getName ( ) + " file=" + ncfile . getLocation ( ) + "\n" + " validTime= " + p . getValidTime ( ) + "\n" ) ; tcs . findIndex ( p ) ; // allow breakpoint
continue ; } oneSent = trackRecords ( time , level , p , raf , oneSent ) ; } // let all references to Index go , to reduce retained size LOOK
records . clear ( ) ; return v ;


signature:
public class GridVariable { /** * debugging */
public void showRecord ( int recnum , Formatter f ) { } }

implementation:
if ( ( recnum < 0 ) || ( recnum > recordTracker . length - 1 ) ) { f . format ( "%d out of range [0,%d]%n" , recnum , recordTracker . length - 1 ) ; return ; } GridRecord gr = recordTracker [ recnum ] ; if ( hasEnsemble ( ) ) { // recnum = ens * ( ntimes * nlevels ) + ( time * nlevels ) + level
int ens = recnum / ( nlevels * ntimes ) ; int tmp = recnum - ens * ( nlevels * ntimes ) ; int time = tmp / nlevels ; int level = tmp % nlevels ; f . format ( "recnum=%d (record hash=%d) ens=%d time=%s(%d) level=%f(%d)%n" , recnum , gr . hashCode ( ) , ens , tcs . getCoord ( time ) , time , vc . getCoord ( level ) , level ) ; } else { int time = recnum / nlevels ; int level = recnum % nlevels ; f . format ( "recnum=%d (record hash=%d) time=%s(%d) level=%f(%d)%n" , recnum , gr . hashCode ( ) , tcs . getCoord ( time ) , time , vc . getCoord ( level ) , level ) ; }


signature:
public class GridVariable { /** * Dump out the missing data
 * @ param f write to this */
public void showMissing ( Formatter f ) { } }

implementation:
// System . out . println ( " " + name + " ntimes ( across ) = " + ntimes + " nlevs ( down ) = " + nlevels + " : " ) ;
int count = 0 , total = 0 ; f . format ( "  %s%n" , name ) ; for ( int j = 0 ; j < nlevels ; j ++ ) { f . format ( "   " ) ; for ( int i = 0 ; i < ntimes ; i ++ ) { boolean missing = recordTracker [ i * nlevels + j ] == null ; f . format ( "%s" , missing ? "-" : "X" ) ; if ( missing ) count ++ ; total ++ ; } f . format ( "%n" ) ; } f . format ( "  MISSING= %d / %d for %s%n" , count , total , name ) ;


signature:
public class GridVariable { /** * Dump out the missing data as a summary
 * @ param f write to this
 * @ return number of missing levels */
public int showMissingSummary ( Formatter f ) { } }

implementation: int count = 0 ; int total = recordTracker . length ; for ( int i = 0 ; i < total ; i ++ ) { if ( recordTracker [ i ] == null ) count ++ ; } f . format ( "  MISSING= %d / %d for %s%n" , count , total , name ) ; return count ;


signature:
public class GridVariable { /** * Find the grid record for the time and level indices
 * Canonical ordering is ens , time , level
 * @ param ens ensemble index
 * @ param time time index
 * @ param level level index
 * @ return the record or null */
public GridRecord findRecord ( int ens , int time , int level ) { } }

implementation: if ( hasEnsemble ( ) ) { return recordTracker [ ens * ( ntimes * nlevels ) + ( time * nlevels ) + level ] ; } else { return recordTracker [ time * nlevels + level ] ; }


signature:
public class GridVariable { /** * Dump this variable
 * @ return the variable */
public String dump ( ) { } }

implementation: DateFormatter formatter = new DateFormatter ( ) ; Formatter sbuff = new Formatter ( ) ; sbuff . format ( "%s %d %n" , name , records . size ( ) ) ; for ( GridRecord record : records ) { sbuff . format ( " level = %d %f" , record . getLevelType1 ( ) , record . getLevel1 ( ) ) ; if ( null != record . getValidTime ( ) ) sbuff . format ( " time = %s" , formatter . toDateTimeString ( record . getValidTime ( ) ) ) ; sbuff . format ( "%n" ) ; } return sbuff . toString ( ) ;


signature:
public class GridVariable { /** * Make a long name for the variable
 * @ return long variable name */
protected String makeLongName ( ) { } }

implementation: Formatter f = new Formatter ( ) ; GridParameter param = lookup . getParameter ( firstRecord ) ; if ( param == null ) return null ; f . format ( "%s" , param . getDescription ( ) ) ; String levelName = makeLevelName ( firstRecord , lookup ) ; if ( levelName . length ( ) != 0 ) f . format ( " @ %s" , levelName ) ; return f . toString ( ) ;


signature:
public class TypedDatasetFactory { /** * Register a class that implements a TypedDatasetFactoryIF .
 * @ param className name of class that implements TypedDatasetFactoryIF .
 * @ param datatype scientific data type
 * @ throws ClassNotFoundException if loading error */
static public void registerFactory ( FeatureType datatype , String className ) throws ClassNotFoundException { } }

implementation: Class c = Class . forName ( className ) ; registerFactory ( datatype , c ) ;


signature:
public class TypedDatasetFactory { /** * Register a class that implements a TypedDatasetFactoryIF .
 * @ param datatype scientific data type
 * @ param c class that implements TypedDatasetFactoryIF . */
static public void registerFactory ( FeatureType datatype , Class c ) { } }

implementation:
if ( ! ( TypedDatasetFactoryIF . class . isAssignableFrom ( c ) ) ) throw new IllegalArgumentException ( "Class " + c . getName ( ) + " must implement TypedDatasetFactoryIF" ) ; // fail fast - check newInstance works
Object instance ; try { instance = c . newInstance ( ) ; } catch ( InstantiationException e ) { throw new IllegalArgumentException ( "CoordTransBuilderIF Class " + c . getName ( ) + " cannot instantiate, probably need default Constructor" ) ; } catch ( IllegalAccessException e ) { throw new IllegalArgumentException ( "CoordTransBuilderIF Class " + c . getName ( ) + " is not accessible" ) ; } // user stuff gets put at top
if ( userMode ) transformList . add ( 0 , new Factory ( datatype , c , ( TypedDatasetFactoryIF ) instance ) ) ; else transformList . add ( new Factory ( datatype , c , ( TypedDatasetFactoryIF ) instance ) ) ;


signature:
public class TypedDatasetFactory { /** * Open a dataset as a TypedDataset .
 * @ param datatype open this kind of Typed Dataset ; may be null , which means search all factories .
 * If datatype is not null , only return correct TypedDataset ( eg PointObsDataset for DataType . POINT ) .
 * @ param location URL or file location of the dataset
 * @ param task user may cancel
 * @ param errlog place errors here , may not be null
 * @ return a subclass of TypedDataset
 * @ throws java . io . IOException on io error */
static public TypedDataset open ( FeatureType datatype , String location , ucar . nc2 . util . CancelTask task , StringBuilder errlog ) throws IOException { } }

implementation: DatasetUrl durl = DatasetUrl . findDatasetUrl ( location ) ; NetcdfDataset ncd = NetcdfDataset . acquireDataset ( durl , true , task ) ; return open ( datatype , ncd , task , errlog ) ;


signature:
public class TypedDatasetFactory { /** * Open a dataset as a TypedDataset .
 * @ param datatype open this kind of Typed Dataset ; may be null , which means search all factories .
 * If datatype is not null , only return correct TypedDataset ( eg PointObsDataset for DataType . POINT ) .
 * @ param ncd the NetcdfDataset to wrap in a TypedDataset
 * @ param task user may cancel
 * @ param errlog place errors here , may not be null
 * @ return a subclass of TypedDataset , or null if cant find
 * @ throws java . io . IOException on io error */
static public TypedDataset open ( FeatureType datatype , NetcdfDataset ncd , ucar . nc2 . util . CancelTask task , StringBuilder errlog ) throws IOException { } }

implementation:
// look for a Factory that claims this dataset
Class useClass = null ; for ( Factory fac : transformList ) { if ( ( datatype != null ) && ( datatype != fac . datatype ) ) continue ; if ( fac . instance . isMine ( ncd ) ) { useClass = fac . c ; break ; } } // Factory not found
if ( null == useClass ) { // POINT is also a STATION
if ( datatype == FeatureType . POINT ) { return open ( FeatureType . STATION , ncd , task , errlog ) ; } // if explicitly requested , give em a GridDataset even if no Grids
if ( datatype == FeatureType . GRID ) { return null ; // new ucar . nc2 . dt . grid . GridDataset ( ncd ) ; LOOK have to copy old GridDataset to archive
} if ( null == datatype ) { // if no datatype was requested , give em a GridDataset only if some Grids are found .
ucar . nc2 . dt . grid . GridDataset gds = new ucar . nc2 . dt . grid . GridDataset ( ncd ) ; if ( gds . getGrids ( ) . size ( ) > 0 ) return null ; // gds ; LOOK have to copy old GridDataset to archive
} errlog . append ( "**Failed to find Datatype Factory for= " ) . append ( ncd . getLocation ( ) ) . append ( " datatype= " ) . append ( datatype ) . append ( "\n" ) ; return null ; } // get a new instance of the Factory class , for thread safety
TypedDatasetFactoryIF builder = null ; try { builder = ( TypedDatasetFactoryIF ) useClass . newInstance ( ) ; } catch ( InstantiationException e ) { errlog . append ( e . getMessage ( ) ) . append ( "\n" ) ; } catch ( IllegalAccessException e ) { errlog . append ( e . getMessage ( ) ) . append ( "\n" ) ; } if ( null == builder ) { errlog . append ( "**Error on TypedDatasetFactory object from class= " ) . append ( useClass . getName ( ) ) . append ( "\n" ) ; return null ; } return builder . open ( ncd , task , errlog ) ;


signature:
public class NcTVPDefaultMetadataPropertyType { /** * wml2 : defaultPointMetadata */
public static TVPDefaultMetadataPropertyType initDefaultPointMetadata ( TVPDefaultMetadataPropertyType defaultPointMetadata , VariableSimpleIF dataVar ) { } }

implementation:
// wml2 : DefaultTVPMeasurementMetadata
DefaultTVPMeasurementMetadataDocument defaultTVPMeasurementMetadataDoc = DefaultTVPMeasurementMetadataDocument . Factory . newInstance ( ) ; NcTVPMeasurementMetadataType . initDefaultTVPMeasurementMetadata ( defaultTVPMeasurementMetadataDoc . addNewDefaultTVPMeasurementMetadata ( ) , dataVar ) ; defaultPointMetadata . set ( defaultTVPMeasurementMetadataDoc ) ; return defaultPointMetadata ;


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

implementation:
// throw away first three bytes ( padding )
byte unused ; for ( int i = 0 ; i < 3 ; i ++ ) { unused = source . readByte ( ) ; } // read fourth byte
val = source . readByte ( ) ; if ( statusUI != null ) statusUI . incrementByteCount ( 4 ) ;


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

implementation:
// print three null bytes ( padding )
for ( int i = 0 ; i < 3 ; i ++ ) { sink . writeByte ( 0 ) ; } sink . writeByte ( val ) ;


signature:
public class CoverageCoordAxis1D { /** * Spacing */
public boolean isAscending ( ) { } }

implementation: loadValuesIfNeeded ( ) ; switch ( spacing ) { case regularInterval : case regularPoint : return getResolution ( ) > 0 ; case irregularPoint : return values [ 0 ] <= values [ ncoords - 1 ] ; case contiguousInterval : return values [ 0 ] <= values [ ncoords ] ; case discontiguousInterval : return values [ 0 ] <= values [ 2 * ncoords - 1 ] ; } throw new IllegalStateException ( "unknown spacing" + spacing ) ;


signature:
public class CoverageCoordAxis1D { /** * CalendarDate , double [ 2 ] , or Double */
public Object getCoordObject ( int index ) { } }

implementation: if ( axisType == AxisType . RunTime ) return makeDate ( getCoordMidpoint ( index ) ) ; if ( isInterval ( ) ) return new double [ ] { getCoordEdge1 ( index ) , getCoordEdge2 ( index ) } ; return getCoordMidpoint ( index ) ;