signature:
public class Grib2Index { /** * message GribIdSection {
 * required uint32 center _ id = 1;
 * required uint32 subcenter _ id = 2;
 * required uint32 master _ table _ version = 3;
 * required uint32 local _ table _ version = 4;
 * required uint32 significanceOfRT = 5;
 * repeated uint32 refDate = 6 [ packed = true ] ; / / year , month , day , hour , minute , second ;
 * required uint32 productionStatus = 7;
 * required uint32 processedDataType = 8; */
private Grib2IndexProto . GribIdSection makeIdProto ( Grib2SectionIdentification id ) { } }

implementation: Grib2IndexProto . GribIdSection . Builder b = Grib2IndexProto . GribIdSection . newBuilder ( ) ; b . setCenterId ( id . getCenter_id ( ) ) ; b . setSubcenterId ( id . getSubcenter_id ( ) ) ; b . setMasterTableVersion ( id . getMaster_table_version ( ) ) ; b . setLocalTableVersion ( id . getLocal_table_version ( ) ) ; b . setSignificanceOfRT ( id . getSignificanceOfRT ( ) ) ; b . addRefDate ( id . getYear ( ) ) ; b . addRefDate ( id . getMonth ( ) ) ; b . addRefDate ( id . getDay ( ) ) ; b . addRefDate ( id . getHour ( ) ) ; b . addRefDate ( id . getMinute ( ) ) ; b . addRefDate ( id . getSecond ( ) ) ; b . setProductionStatus ( id . getProductionStatus ( ) ) ; b . setProcessedDataType ( id . getTypeOfProcessedData ( ) ) ; return b . build ( ) ;


signature:
public class GeotiffWriter { /** * Write GridDatatype data to the geotiff file .
 * @ param dataset grid in contained in this dataset
 * @ param grid data is in this grid
 * @ param data 2D array in YX order
 * @ param greyScale if true , write greyScale image , else dataSample .
 * @ throws IOException on i / o error */
public void writeGrid ( GridDataset dataset , GridDatatype grid , Array data , boolean greyScale ) throws IOException { } }

implementation:
GridCoordSystem gcs = grid . getCoordinateSystem ( ) ; if ( ! gcs . isRegularSpatial ( ) ) { throw new IllegalArgumentException ( "Must have 1D x and y axes for " + grid . getFullName ( ) ) ; } CoordinateAxis1D xaxis = ( CoordinateAxis1D ) gcs . getXHorizAxis ( ) ; CoordinateAxis1D yaxis = ( CoordinateAxis1D ) gcs . getYHorizAxis ( ) ; // units may need to be scaled to meters
double scaler = ( xaxis . getUnitsString ( ) . equalsIgnoreCase ( "km" ) ) ? 1000.0 : 1.0 ; // data must go from top to bottom
double xStart = xaxis . getCoordEdge ( 0 ) * scaler ; double yStart = yaxis . getCoordEdge ( 0 ) * scaler ; double xInc = xaxis . getIncrement ( ) * scaler ; double yInc = Math . abs ( yaxis . getIncrement ( ) ) * scaler ; if ( yaxis . getCoordValue ( 0 ) < yaxis . getCoordValue ( 1 ) ) { data = data . flip ( 0 ) ; yStart = yaxis . getCoordEdge ( ( int ) yaxis . getSize ( ) ) * scaler ; } if ( ! xaxis . isRegular ( ) || ! yaxis . isRegular ( ) ) { throw new IllegalArgumentException ( "Must be evenly spaced grid = " + grid . getFullName ( ) ) ; } if ( pageNumber > 1 ) { geotiff . initTags ( ) ; } // write it out
writeGrid ( grid , data , greyScale , xStart , yStart , xInc , yInc , pageNumber ) ; pageNumber ++ ;


signature:
public class GeotiffWriter { /** * Write Grid data to the geotiff file .
 * Grid currently must :
 * < ol >
 * < li > have a 1D X and Y coordinate axes .
 * < li > be lat / lon or Lambert Conformal Projection
 * < li > be equally spaced
 * < / ol >
 * @ param grid original grid
 * @ param data 2D array in YX order
 * @ param greyScale if true , write greyScale image , else dataSample .
 * @ param xStart
 * @ param yStart
 * @ param xInc
 * @ param yInc
 * @ param imageNumber
 * @ throws IOException on i / o error
 * @ throws IllegalArgumentException if above assumptions not valid */
protected void writeGrid ( GridDatatype grid , Array data , boolean greyScale , double xStart , double yStart , double xInc , double yInc , int imageNumber ) throws IOException { } }

implementation:
int nextStart = 0 ; GridCoordSystem gcs = grid . getCoordinateSystem ( ) ; // get rid of this when all projections are implemented
if ( ! gcs . isLatLon ( ) && ! ( gcs . getProjection ( ) instanceof LambertConformal ) && ! ( gcs . getProjection ( ) instanceof Stereographic ) && ! ( gcs . getProjection ( ) instanceof Mercator ) // & & ! ( gcs . getProjection ( ) instanceof TransverseMercator ) LOOK broken ? ?
&& ! ( gcs . getProjection ( ) instanceof AlbersEqualAreaEllipse ) && ! ( gcs . getProjection ( ) instanceof AlbersEqualArea ) ) { throw new IllegalArgumentException ( "Unsupported projection = " + gcs . getProjection ( ) . getClass ( ) . getName ( ) ) ; } // write the data first
MAMath . MinMax dataMinMax = grid . getMinMaxSkipMissingData ( data ) ; if ( greyScale ) { ArrayByte result = replaceMissingValuesAndScale ( grid , data , dataMinMax ) ; nextStart = geotiff . writeData ( ( byte [ ] ) result . getStorage ( ) , imageNumber ) ; } else { ArrayFloat result = replaceMissingValues ( grid , data , dataMinMax ) ; nextStart = geotiff . writeData ( ( float [ ] ) result . getStorage ( ) , imageNumber ) ; } // set the width and the height
int height = data . getShape ( ) [ 0 ] ; int width = data . getShape ( ) [ 1 ] ; writeMetadata ( greyScale , xStart , yStart , xInc , yInc , height , width , imageNumber , nextStart , dataMinMax , gcs . getProjection ( ) ) ;


signature:
public class GeotiffWriter { /** * Replace missing values with dataMinMax . min - 1.0 ; return a floating point data array .
 * @ param grid GridDatatype
 * @ param data input data array
 * @ return floating point data array with missing values replaced . */
private ArrayFloat replaceMissingValues ( IsMissingEvaluator grid , Array data , MAMath . MinMax dataMinMax ) { } }

implementation: float minValue = ( float ) ( dataMinMax . min - 1.0 ) ; ArrayFloat floatArray = ( ArrayFloat ) Array . factory ( DataType . FLOAT , data . getShape ( ) ) ; IndexIterator dataIter = data . getIndexIterator ( ) ; IndexIterator floatIter = floatArray . getIndexIterator ( ) ; while ( dataIter . hasNext ( ) ) { float v = dataIter . getFloatNext ( ) ; if ( grid . isMissing ( ( double ) v ) ) { v = minValue ; } floatIter . setFloatNext ( v ) ; } return floatArray ;


signature:
public class GeotiffWriter { /** * Replace missing values with 0 ; scale other values between 1 and 255 , return a byte data array .
 * @ param grid GridDatatype
 * @ param data input data array
 * @ return byte data array with missing values replaced and data scaled from 1 - 255. */
private ArrayByte replaceMissingValuesAndScale ( IsMissingEvaluator grid , Array data , MAMath . MinMax dataMinMax ) { } }

implementation: double scale = 254.0 / ( dataMinMax . max - dataMinMax . min ) ; ArrayByte byteArray = ( ArrayByte ) Array . factory ( DataType . BYTE , data . getShape ( ) ) ; IndexIterator dataIter = data . getIndexIterator ( ) ; IndexIterator resultIter = byteArray . getIndexIterator ( ) ; byte bv ; while ( dataIter . hasNext ( ) ) { double v = dataIter . getDoubleNext ( ) ; if ( grid . isMissing ( v ) ) { bv = 0 ; } else { int iv = ( int ) ( ( v - dataMinMax . min ) * scale + 1 ) ; bv = ( byte ) ( iv & 0xff ) ; } resultIter . setByteNext ( bv ) ; } return byteArray ;


signature:
public class GeotiffWriter { /** * LOOK WTF ? ? is this the seam crossing ? ? */
private double geoShiftGetXstart ( Array lon , double inc ) { } }

implementation: Index ilon = lon . getIndex ( ) ; int [ ] lonShape = lon . getShape ( ) ; IndexIterator lonIter = lon . getIndexIterator ( ) ; double xlon = 0.0 ; LatLonPoint p0 = new LatLonPointImpl ( 0 , lon . getFloat ( ilon . set ( 0 ) ) ) ; LatLonPoint pN = new LatLonPointImpl ( 0 , lon . getFloat ( ilon . set ( lonShape [ 0 ] - 1 ) ) ) ; xlon = p0 . getLongitude ( ) ; while ( lonIter . hasNext ( ) ) { float l = lonIter . getFloatNext ( ) ; LatLonPoint pn = new LatLonPointImpl ( 0 , l ) ; if ( pn . getLongitude ( ) < xlon ) { xlon = pn . getLongitude ( ) ; } } if ( p0 . getLongitude ( ) == pN . getLongitude ( ) ) { xlon = xlon - inc ; } return xlon ;


signature:
public class GeotiffWriter { /** * Write GridCoverage data to the geotiff file .
 * @ param array GeoReferencedArray array in YX order
 * @ param greyScale if true , write greyScale image , else dataSample .
 * @ throws IOException on i / o error */
public void writeGrid ( GeoReferencedArray array , boolean greyScale ) throws IOException { } }

implementation:
CoverageCoordSys gcs = array . getCoordSysForData ( ) ; if ( ! gcs . isRegularSpatial ( ) ) throw new IllegalArgumentException ( "Must have 1D x and y axes for " + array . getCoverageName ( ) ) ; Projection proj = gcs . getProjection ( ) ; CoverageCoordAxis1D xaxis = ( CoverageCoordAxis1D ) gcs . getXAxis ( ) ; CoverageCoordAxis1D yaxis = ( CoverageCoordAxis1D ) gcs . getYAxis ( ) ; // latlon coord does not need to be scaled
double scaler = ( xaxis . getUnits ( ) . equalsIgnoreCase ( "km" ) ) ? 1000.0 : 1.0 ; // data must go from top to bottom
double xStart = xaxis . getCoordEdge1 ( 0 ) * scaler ; double yStart = yaxis . getCoordEdge1 ( 0 ) * scaler ; double xInc = xaxis . getResolution ( ) * scaler ; double yInc = Math . abs ( yaxis . getResolution ( ) ) * scaler ; Array data = array . getData ( ) . reduce ( ) ; if ( yaxis . getCoordMidpoint ( 0 ) < yaxis . getCoordMidpoint ( 1 ) ) { data = data . flip ( 0 ) ; yStart = yaxis . getCoordEdgeLast ( ) ; } /* remove - i think unneeded , monotonic lon handled in CoordinateAxis1D . JC 3/18/2013
 if ( gcs . isLatLon ( ) ) {
 Array lon = xaxis . read ( ) ;
 data = geoShiftDataAtLon ( data , lon ) ;
 xStart = geoShiftGetXstart ( lon , xInc ) ;
 / / xStart = - 180.0; */
if ( pageNumber > 1 ) { geotiff . initTags ( ) ; } // write the data first
int nextStart = 0 ; MAMath . MinMax dataMinMax = MAMath . getMinMaxSkipMissingData ( data , array ) ; if ( greyScale ) { ArrayByte result = replaceMissingValuesAndScale ( array , data , dataMinMax ) ; nextStart = geotiff . writeData ( ( byte [ ] ) result . getStorage ( ) , pageNumber ) ; } else { ArrayFloat result = replaceMissingValues ( array , data , dataMinMax ) ; nextStart = geotiff . writeData ( ( float [ ] ) result . getStorage ( ) , pageNumber ) ; } // set the width and the height
int height = data . getShape ( ) [ 0 ] ; int width = data . getShape ( ) [ 1 ] ; writeMetadata ( greyScale , xStart , yStart , xInc , yInc , height , width , pageNumber , nextStart , dataMinMax , proj ) ; pageNumber ++ ;


signature:
public class NUWGConvention { /** * Search for an aliased coord that may have multiple variables
 * : dimName = alias1 , alias2;
 * Variable alias1 ( dim ) ;
 * Variable alias2 ( dim ) ;
 * @ param ds search in this dataset
 * @ param dim : look for this dimension name
 * @ return Collection of nectdf variables , or null if none */
private List < Variable > searchAliasedDimension ( NetcdfDataset ds , Dimension dim ) { } }

implementation: String dimName = dim . getShortName ( ) ; String alias = ds . findAttValueIgnoreCase ( null , dimName , null ) ; if ( alias == null ) return null ; List < Variable > vars = new ArrayList < > ( ) ; StringTokenizer parser = new StringTokenizer ( alias , " ," ) ; while ( parser . hasMoreTokens ( ) ) { String token = parser . nextToken ( ) ; Variable ncvar = ds . findVariable ( token ) ; if ( ncvar == null ) continue ; if ( ncvar . getRank ( ) != 1 ) continue ; Iterator dimIter = ncvar . getDimensions ( ) . iterator ( ) ; Dimension dim2 = ( Dimension ) dimIter . next ( ) ; if ( dimName . equals ( dim2 . getShortName ( ) ) ) { vars . add ( ncvar ) ; if ( debug ) System . out . print ( " " + token ) ; } } if ( debug ) System . out . println ( ) ; return vars ;


signature:
public class WFSExceptionWriter { /** * Given the information on construction , writes the necessary exception information .
 * @ param hsr the Servlet Response to write to
 * @ throws IOException */
public void write ( HttpServletResponse hsr ) throws IOException { } }

implementation: PrintWriter xmlResponse = hsr . getWriter ( ) ; xmlResponse . append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ) ; xmlResponse . append ( "<ows:ExceptionReport xml:lang=\"en-US\" xsi:schemaLocation=\"http://www.opengis.net/ows/1.1" + " http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd\" version=\"2.0.0\" xmlns:ows=\"http://www.opengis.net/ows/1.1\"" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" ) ; xmlResponse . append ( "<ows:Exception " ) ; if ( locator != null ) xmlResponse . append ( "locator=\"" + locator + "\" " ) ; xmlResponse . append ( "exceptionCode=\"" + ExceptionCode + "\">" ) ; xmlResponse . append ( "<ows:ExceptionText>" + text + "</ows:ExceptionText>" ) ; xmlResponse . append ( "</ows:Exception>" ) ; xmlResponse . append ( "</ows:ExceptionReport>" ) ;


signature:
public class ArrayInt { /** * package private . use Array . factory ( ) */
static ArrayInt factory ( Index index , boolean isUnsigned ) { } }

implementation: return ArrayInt . factory ( index , isUnsigned , null ) ;


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

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


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

implementation: int [ ] ja = ( int [ ] ) javaArray ; for ( int aJa : ja ) iter . setIntNext ( aJa ) ;


signature:
public class ArrayInt { /** * package private : mostly for iterators */
public double getDouble ( int index ) { } }

implementation: int val = storage [ index ] ; return ( double ) ( isUnsigned ( ) ? DataType . unsignedIntToLong ( val ) : val ) ;


signature:
public class Nc4wrapper { /** * Begin API Override */
@ Override public synchronized String nc_inq_libvers ( ) { } }

implementation: String ret ; try { ce ( ) ; ret = nc4 . nc_inq_libvers ( ) ; if ( TRACE ) trace ( ret , "nc_inq_libvers" , "-" ) ; } finally { cx ( ) ; } return ret ;


signature:
public class GribCdmIndex { /** * open GribCollectionImmutable from an existing index file . return null on failure */
static GribCollectionImmutable acquireGribCollection ( FileFactory factory , Object hashKey , String location , int buffer_size , CancelTask cancelTask , Object spiObject ) throws IOException { } }

implementation:
FileCacheable result ; DatasetUrl durl = new DatasetUrl ( null , location ) ; if ( gribCollectionCache != null ) { // FileFactory factory , Object hashKey , String location , int buffer _ size , CancelTask cancelTask , Object spiObject
result = GribCdmIndex . gribCollectionCache . acquire ( factory , hashKey , durl , buffer_size , cancelTask , spiObject ) ; } else { // String location , int buffer _ size , ucar . nc2 . util . CancelTask cancelTask , Object iospMessage
result = factory . open ( durl , buffer_size , cancelTask , spiObject ) ; } return ( GribCollectionImmutable ) result ;


signature: public class GribCdmIndex { public static File getTopIndexFileFromConfig ( FeatureCollectionConfig config ) { } }

implementation: File indexFile = makeTopIndexFileFromConfig ( config ) ; return GribIndexCache . getExistingFileOrCache ( indexFile . getPath ( ) ) ;


signature:
public class GribCdmIndex { /** * This is only used for the top level GribCollection .
 * @ param config use this FeatureCollectionConfig
 * @ return index File */
private static File makeTopIndexFileFromConfig ( FeatureCollectionConfig config ) { } }

implementation:
Formatter errlog = new Formatter ( ) ; CollectionSpecParser specp = config . getCollectionSpecParser ( errlog ) ; String name = StringUtil2 . replace ( config . collectionName , '\\' , "/" ) ; // String cname = DirectoryCollection . makeCollectionName ( name , Paths . get ( specp . getRootDir ( ) ) ) ;
return makeIndexFile ( name , new File ( specp . getRootDir ( ) ) ) ;


signature:
public class GribCdmIndex { /** * Find out what kind of index this is
 * @ param raf open RAF
 * @ return GribCollectionType
 * @ throws IOException on read error */
public static GribCollectionType getType ( RandomAccessFile raf ) throws IOException { } }

implementation: String magic ; raf . seek ( 0 ) ; magic = raf . readString ( Grib2CollectionWriter . MAGIC_START . getBytes ( CDM . utf8Charset ) . length ) ; switch ( magic ) { case Grib2CollectionWriter . MAGIC_START : return GribCollectionType . GRIB2 ; case Grib1CollectionWriter . MAGIC_START : return GribCollectionType . GRIB1 ; case Grib2PartitionBuilder . MAGIC_START : return GribCollectionType . Partition2 ; case Grib1PartitionBuilder . MAGIC_START : return GribCollectionType . Partition1 ; } return GribCollectionType . none ;


signature:
public class GribCdmIndex { /** * open GribCollectionImmutable from an existing index file . return null on failure */
@ Nullable public static GribCollectionImmutable openCdmIndex ( String indexFilename , FeatureCollectionConfig config , boolean useCache , Logger logger ) throws IOException { } }

implementation: File indexFileInCache = useCache ? GribIndexCache . getExistingFileOrCache ( indexFilename ) : new File ( indexFilename ) ; if ( indexFileInCache == null ) return null ; String indexFilenameInCache = indexFileInCache . getPath ( ) ; String name = makeNameFromIndexFilename ( indexFilename ) ; GribCollectionImmutable result = null ; try ( RandomAccessFile raf = RandomAccessFile . acquire ( indexFilenameInCache ) ) { GribCollectionType type = getType ( raf ) ; switch ( type ) { case GRIB2 : result = Grib2CollectionBuilderFromIndex . readFromIndex ( name , raf , config , logger ) ; break ; case Partition2 : result = Grib2PartitionBuilderFromIndex . createTimePartitionFromIndex ( name , raf , config , logger ) ; break ; case GRIB1 : result = Grib1CollectionBuilderFromIndex . readFromIndex ( name , raf , config , logger ) ; break ; case Partition1 : result = Grib1PartitionBuilderFromIndex . createTimePartitionFromIndex ( name , raf , config , logger ) ; break ; default : logger . warn ( "GribCdmIndex.openCdmIndex failed on {} type={}" , indexFilenameInCache , type ) ; } } catch ( FileNotFoundException ioe ) { throw ioe ; } catch ( Throwable t ) { logger . warn ( "GribCdmIndex.openCdmIndex failed on " + indexFilenameInCache , t ) ; RandomAccessFile . eject ( indexFilenameInCache ) ; if ( ! indexFileInCache . delete ( ) ) logger . warn ( "failed to delete {}" , indexFileInCache . getPath ( ) ) ; } return result ;


signature:
public class GribCdmIndex { /** * open GribCollectionImmutable from an existing index file . return null on failure */
@ Nullable public static GribCollectionMutable openMutableGCFromIndex ( String indexFilename , FeatureCollectionConfig config , boolean dataOnly , boolean useCache , Logger logger ) { } }

implementation: File indexFileInCache = useCache ? GribIndexCache . getExistingFileOrCache ( indexFilename ) : new File ( indexFilename ) ; if ( indexFileInCache == null ) { return null ; } String indexFilenameInCache = indexFileInCache . getPath ( ) ; String name = makeNameFromIndexFilename ( indexFilename ) ; GribCollectionMutable result = null ; try ( RandomAccessFile raf = RandomAccessFile . acquire ( indexFilenameInCache ) ) { GribCollectionType type = getType ( raf ) ; switch ( type ) { case GRIB2 : result = Grib2CollectionBuilderFromIndex . openMutableGCFromIndex ( name , raf , config , logger ) ; break ; case Partition2 : result = Grib2PartitionBuilderFromIndex . openMutablePCFromIndex ( name , raf , config , logger ) ; break ; case GRIB1 : result = Grib1CollectionBuilderFromIndex . openMutableGCFromIndex ( name , raf , config , logger ) ; break ; case Partition1 : result = Grib1PartitionBuilderFromIndex . openMutablePCFromIndex ( name , raf , config , logger ) ; break ; default : logger . warn ( "GribCdmIndex.openMutableGCFromIndex failed on {} type={}" , indexFilenameInCache , type ) ; } if ( result != null ) { result . lastModified = raf . getLastModified ( ) ; result . fileSize = raf . length ( ) ; } } catch ( Throwable t ) { logger . warn ( "GribCdmIndex.openMutableGCFromIndex failed on " + indexFilenameInCache , t ) ; } if ( result == null ) { RandomAccessFile . eject ( indexFilenameInCache ) ; if ( ! indexFileInCache . delete ( ) ) logger . warn ( "failed to delete {}" , indexFileInCache . getPath ( ) ) ; } return result ;


signature:
public class GribCdmIndex { /** * used ( only ) by GribCollectionBuilder */
public static boolean updateGribCollectionFromPCollection ( boolean isGrib1 , PartitionManager dcm , CollectionUpdateType updateType , Formatter errlog , org . slf4j . Logger logger ) throws IOException { } }

implementation:
if ( updateType == CollectionUpdateType . never || dcm instanceof CollectionSingleIndexFile ) { // LOOK would isIndexFile ( ) be better ?
// then just open the existing index file
return false ; } boolean changed = updatePartition ( isGrib1 , dcm , updateType , logger , errlog ) ; if ( errlog != null ) errlog . format ( "PartitionCollection %s was recreated %s%n" , dcm . getCollectionName ( ) , changed ) ; return changed ;


signature:
public class GribCdmIndex { /** * Update Grib Collection if needed
 * @ return true if the collection was updated */
public static boolean updateGribCollection ( FeatureCollectionConfig config , CollectionUpdateType updateType , Logger logger ) throws IOException { } }

implementation:
if ( logger == null ) logger = classLogger ; long start = System . currentTimeMillis ( ) ; Formatter errlog = new Formatter ( ) ; CollectionSpecParser specp = config . getCollectionSpecParser ( errlog ) ; Path rootPath = Paths . get ( specp . getRootDir ( ) ) ; boolean isGrib1 = config . type == FeatureCollectionType . GRIB1 ; boolean changed ; if ( config . ptype == FeatureCollectionConfig . PartitionType . none || config . ptype == FeatureCollectionConfig . PartitionType . all ) { try ( CollectionAbstract dcm = new CollectionPathMatcher ( config , specp , logger ) ) { changed = updateGribCollection ( isGrib1 , dcm , updateType , FeatureCollectionConfig . PartitionType . none , logger , errlog ) ; } } else if ( config . ptype == FeatureCollectionConfig . PartitionType . timePeriod ) { try ( TimePartition tp = new TimePartition ( config , specp , logger ) ) { changed = updateTimePartition ( isGrib1 , tp , updateType , logger ) ; } } else { // LOOK assume wantSubdirs makes it into a Partition . Isnt there something better ? ?
if ( specp . wantSubdirs ( ) ) { // its a partition
try ( DirectoryPartition dpart = new DirectoryPartition ( config , rootPath , true , new GribCdmIndex ( logger ) , NCX_SUFFIX , logger ) ) { dpart . putAuxInfo ( FeatureCollectionConfig . AUX_CONFIG , config ) ; changed = updateDirectoryCollectionRecurse ( isGrib1 , dpart , config , updateType , logger ) ; } } else { // otherwise its a leaf directory
changed = updateLeafCollection ( isGrib1 , config , updateType , true , logger , rootPath ) ; } } long took = System . currentTimeMillis ( ) - start ; logger . info ( "updateGribCollection {} changed {} took {} msecs" , config . collectionName , changed , took ) ; return changed ;


signature:
public class GribCdmIndex { /** * return true if changed , exception on failure */
public static boolean updateGribCollection ( boolean isGrib1 , MCollection dcm , CollectionUpdateType updateType , FeatureCollectionConfig . PartitionType ptype , Logger logger , Formatter errlog ) throws IOException { } }

implementation:
logger . debug ( "GribCdmIndex.updateGribCollection %s %s%n" , dcm . getCollectionName ( ) , updateType ) ; if ( ! isUpdateNeeded ( dcm . getIndexFilename ( NCX_SUFFIX ) , updateType , ( isGrib1 ? GribCollectionType . GRIB1 : GribCollectionType . GRIB2 ) , logger ) ) return false ; boolean changed ; if ( isGrib1 ) { // existing case handles correctly - make seperate index for each runtime ( OR ) partition = = runtime
Grib1CollectionBuilder builder = new Grib1CollectionBuilder ( dcm . getCollectionName ( ) , dcm , logger ) ; changed = builder . updateNeeded ( updateType ) && builder . createIndex ( ptype , errlog ) ; } else { Grib2CollectionBuilder builder = new Grib2CollectionBuilder ( dcm . getCollectionName ( ) , dcm , logger ) ; changed = builder . updateNeeded ( updateType ) && builder . createIndex ( ptype , errlog ) ; } return changed ;


signature:
public class GribCdmIndex { /** * return true if changed , exception on failure */
private static boolean updatePartition ( boolean isGrib1 , PartitionManager dcm , CollectionUpdateType updateType , Logger logger , Formatter errlog ) throws IOException { } }

implementation: boolean changed ; if ( isGrib1 ) { Grib1PartitionBuilder builder = new Grib1PartitionBuilder ( dcm . getCollectionName ( ) , new File ( dcm . getRoot ( ) ) , dcm , logger ) ; changed = builder . updateNeeded ( updateType ) && builder . createPartitionedIndex ( updateType , errlog ) ; } else { Grib2PartitionBuilder builder = new Grib2PartitionBuilder ( dcm . getCollectionName ( ) , new File ( dcm . getRoot ( ) ) , dcm , logger ) ; changed = builder . updateNeeded ( updateType ) && builder . createPartitionedIndex ( updateType , errlog ) ; } return changed ;


signature:
public class GribCdmIndex { /** * Update all the gbx indices in one directory , and the ncx index for that directory
 * @ param config FeatureCollectionConfig
 * @ param dirPath directory path
 * @ return true if collection was rewritten , exception on failure */
private static boolean updateLeafCollection ( boolean isGrib1 , FeatureCollectionConfig config , CollectionUpdateType updateType , boolean isTop , Logger logger , Path dirPath ) throws IOException { } }

implementation: if ( config . ptype == FeatureCollectionConfig . PartitionType . file ) { return updateFilePartition ( isGrib1 , config , updateType , isTop , logger , dirPath ) ; } else { Formatter errlog = new Formatter ( ) ; CollectionSpecParser specp = config . getCollectionSpecParser ( errlog ) ; try ( DirectoryCollection dcm = new DirectoryCollection ( config . collectionName , dirPath , isTop , config . olderThan , logger ) ) { dcm . putAuxInfo ( FeatureCollectionConfig . AUX_CONFIG , config ) ; if ( specp . getFilter ( ) != null ) dcm . setStreamFilter ( new StreamFilter ( specp . getFilter ( ) , specp . getFilterOnName ( ) ) ) ; boolean changed = updateGribCollection ( isGrib1 , dcm , updateType , FeatureCollectionConfig . PartitionType . directory , logger , errlog ) ; logger . debug ( "  GribCdmIndex.updateDirectoryPartition was updated=%s on %s%n" , changed , dirPath ) ; return changed ; } }


signature:
public class GribCdmIndex { /** * File Partition : each File is a collection of Grib records , and the collection of all files in the directory is a PartitionCollection .
 * Rewrite the PartitionCollection and optionally its children
 * @ param config FeatureCollectionConfig
 * @ param updateType always , test , nocheck , never
 * @ return true if partition was rewritten , exception on failure */
private static boolean updateFilePartition ( final boolean isGrib1 , final FeatureCollectionConfig config , final CollectionUpdateType updateType , boolean isTop , final Logger logger , Path dirPath ) throws IOException { } }

implementation:
long start = System . currentTimeMillis ( ) ; final Formatter errlog = new Formatter ( ) ; CollectionSpecParser specp = config . getCollectionSpecParser ( errlog ) ; try ( FilePartition partition = new FilePartition ( config . collectionName , dirPath , isTop , config . olderThan , logger ) ) { partition . putAuxInfo ( FeatureCollectionConfig . AUX_CONFIG , config ) ; if ( specp . getFilter ( ) != null ) partition . setStreamFilter ( new StreamFilter ( specp . getFilter ( ) , specp . getFilterOnName ( ) ) ) ; logger . debug ( "GribCdmIndex.updateFilePartition %s %s%n" , partition . getCollectionName ( ) , updateType ) ; if ( ! isUpdateNeeded ( partition . getIndexFilename ( NCX_SUFFIX ) , updateType , ( isGrib1 ? GribCollectionType . Partition1 : GribCollectionType . Partition2 ) , logger ) ) return false ; final AtomicBoolean anyChange = new AtomicBoolean ( false ) ; // just need a mutable boolean we can declare final
// redo the children here
if ( updateType != CollectionUpdateType . testIndexOnly ) { // skip children on testIndexOnly
partition . iterateOverMFileCollection ( mfile -> { MCollection part = new CollectionSingleFile ( mfile , logger ) ; part . putAuxInfo ( FeatureCollectionConfig . AUX_CONFIG , config ) ; try { boolean changed = updateGribCollection ( isGrib1 , part , updateType , FeatureCollectionConfig . PartitionType . file , logger , errlog ) ; if ( changed ) anyChange . set ( true ) ; } catch ( IllegalStateException t ) { logger . warn ( "Error making partition {} '{}'" , part . getRoot ( ) , t . getMessage ( ) ) ; partition . removePartition ( part ) ; // keep on truckin ; can happen if directory is empty
} catch ( Throwable t ) { logger . error ( "Error making partition " + part . getRoot ( ) , t ) ; partition . removePartition ( part ) ; } } ) ; } // LOOK what if theres only one file ?
try { // redo partition index if needed , will detect if children have changed
boolean recreated = updatePartition ( isGrib1 , partition , updateType , logger , errlog ) ; long took = System . currentTimeMillis ( ) - start ; if ( recreated ) logger . info ( "RewriteFilePartition {} took {} msecs" , partition . getCollectionName ( ) , took ) ; return recreated ; } catch ( IllegalStateException t ) { logger . warn ( "Error making partition {} '{}'" , partition . getRoot ( ) , t . getMessage ( ) ) ; return false ; } catch ( Throwable t ) { logger . error ( "Error making partition " + partition . getRoot ( ) , t ) ; return false ; } }


signature:
public class GribCdmIndex { /** * Open GribCollection from config .
 * CollectionUpdater calls InvDatasetFc . update ( ) calls InvDatasetFcGrib . updateCollection ( ) */
public static GribCollectionImmutable openGribCollection ( FeatureCollectionConfig config , CollectionUpdateType updateType , Logger logger ) throws IOException { } }

implementation:
// update if needed
boolean changed = updateGribCollection ( config , updateType , logger ) ; File idxFile = makeTopIndexFileFromConfig ( config ) ; // If call to updateGribCollection shows a change happened , then collection changed .
// If updateType is never ( tds is in charge of updating , not TDM or some other external application ) ,
// then this is being called after receiving an outside trigger . Assume collection changed .
// At this point , there isn ' t a good way of invalidating the gribColectionCache entries associated with the
// particular collection being updated , so we have to clear the whole cache . Will revisit this in
// 5.0 if performance is an issue
if ( ( updateType == CollectionUpdateType . never ) || changed ) { gribCollectionCache . clearCache ( true ) ; } return openCdmIndex ( idxFile . getPath ( ) , config , true , logger ) ;


signature:
public class GribCdmIndex { /** * Used by IOSPs */
public static GribCollectionImmutable openGribCollectionFromRaf ( RandomAccessFile raf , FeatureCollectionConfig config , CollectionUpdateType updateType , org . slf4j . Logger logger ) throws IOException { } }

implementation:
GribCollectionImmutable result ; // check if its a plain ole GRIB1/2 data file
boolean isGrib1 = false ; boolean isGrib2 = Grib2RecordScanner . isValidFile ( raf ) ; if ( ! isGrib2 ) isGrib1 = Grib1RecordScanner . isValidFile ( raf ) ; if ( isGrib1 || isGrib2 ) { result = openGribCollectionFromDataFile ( isGrib1 , raf , config , updateType , null , logger ) ; // close the data file , the ncx raf file is managed by gribCollection
raf . close ( ) ; } else { // check its an ncx file
result = openGribCollectionFromIndexFile ( raf , config , logger ) ; } return result ;


signature:
public class GribCdmIndex { /** * Open a grib collection from a single grib1 or grib2 file .
 * Create the gbx9 and ncx2 files if needed .
 * @ param isGrib1 true if grib1
 * @ param dataRaf the data file already open
 * @ param config special configuration
 * @ param updateType force writing index
 * @ return the resulting GribCollection
 * @ throws IOException on io error */
private static GribCollectionImmutable openGribCollectionFromDataFile ( boolean isGrib1 , RandomAccessFile dataRaf , FeatureCollectionConfig config , CollectionUpdateType updateType , Formatter errlog , org . slf4j . Logger logger ) throws IOException { } }

implementation: String filename = dataRaf . getLocation ( ) ; File dataFile = new File ( filename ) ; MFile mfile = new MFileOS ( dataFile ) ; return openGribCollectionFromDataFile ( isGrib1 , mfile , updateType , config , errlog , logger ) ;


signature:
public class GribCdmIndex { /** * from a single file , read in the index , create if it doesnt exist ; return null on failure */
@ Nullable public static GribCollectionImmutable openGribCollectionFromDataFile ( boolean isGrib1 , MFile mfile , CollectionUpdateType updateType , FeatureCollectionConfig config , Formatter errlog , org . slf4j . Logger logger ) throws IOException { } }

implementation:
MCollection dcm = new CollectionSingleFile ( mfile , logger ) ; dcm . putAuxInfo ( FeatureCollectionConfig . AUX_CONFIG , config ) ; if ( isGrib1 ) { Grib1CollectionBuilder builder = new Grib1CollectionBuilder ( dcm . getCollectionName ( ) , dcm , logger ) ; // LOOK ignoring partition type
boolean changed = ( builder . updateNeeded ( updateType ) && builder . createIndex ( FeatureCollectionConfig . PartitionType . file , errlog ) ) ; } else { Grib2CollectionBuilder builder = new Grib2CollectionBuilder ( dcm . getCollectionName ( ) , dcm , logger ) ; boolean changed = ( builder . updateNeeded ( updateType ) && builder . createIndex ( FeatureCollectionConfig . PartitionType . file , errlog ) ) ; } // the index file should now exist , open it
GribCollectionImmutable result = openCdmIndex ( dcm . getIndexFilename ( NCX_SUFFIX ) , config , true , logger ) ; if ( result != null ) return result ; // if open fails , force recreate the index
if ( updateType == CollectionUpdateType . never ) return null ; // not allowed to write
if ( updateType == CollectionUpdateType . always ) return null ; // already tried to force write , give up
return openGribCollectionFromDataFile ( isGrib1 , mfile , CollectionUpdateType . always , config , errlog , logger ) ;


signature:
public class GribCdmIndex { /** * Create a grib collection / partition collection from an existing ncx2 file .
 * PartionCollection . partition . getGribCollection ( ) .
 * @ param indexRaf the ncx2 file already open
 * @ param config special configuration
 * @ return the resulting GribCollection , or null on failure
 * @ throws IOException on io error */
@ Nullable public static GribCollectionImmutable openGribCollectionFromIndexFile ( RandomAccessFile indexRaf , FeatureCollectionConfig config , org . slf4j . Logger logger ) throws IOException { } }

implementation:
GribCollectionType type = getType ( indexRaf ) ; String location = indexRaf . getLocation ( ) ; File f = new File ( location ) ; int pos = f . getName ( ) . lastIndexOf ( "." ) ; String name = ( pos > 0 ) ? f . getName ( ) . substring ( 0 , pos ) : f . getName ( ) ; // remove " . ncx2"
switch ( type ) { case Partition1 : return Grib1PartitionBuilderFromIndex . createTimePartitionFromIndex ( name , indexRaf , config , logger ) ; case GRIB1 : return Grib1CollectionBuilderFromIndex . readFromIndex ( name , indexRaf , config , logger ) ; case Partition2 : return Grib2PartitionBuilderFromIndex . createTimePartitionFromIndex ( name , indexRaf , config , logger ) ; case GRIB2 : return Grib2CollectionBuilderFromIndex . readFromIndex ( name , indexRaf , config , logger ) ; } return null ;


signature:
public class GribCdmIndex { /** * / IndexReader interface */
@ Override public boolean readChildren ( Path indexFile , AddChildCallback callback ) throws IOException { } }

implementation:
logger . debug ( "GribCdmIndex.readChildren %s%n" , indexFile ) ; try ( RandomAccessFile raf = RandomAccessFile . acquire ( indexFile . toString ( ) ) ) { GribCollectionType type = getType ( raf ) ; if ( type == GribCollectionType . Partition1 || type == GribCollectionType . Partition2 ) { if ( openIndex ( raf , logger ) ) { String topDir = gribCollectionIndex . getTopDir ( ) ; int n = gribCollectionIndex . getMfilesCount ( ) ; // partition index files stored in MFiles
for ( int i = 0 ; i < n ; i ++ ) { GribCollectionProto . MFile mfilep = gribCollectionIndex . getMfiles ( i ) ; callback . addChild ( topDir , mfilep . getFilename ( ) , mfilep . getLastModified ( ) ) ; } return true ; } } return false ; }


signature:
public class RC { /** * Match has different semantics than urlCompare */
static boolean urlMatch ( URL pattern , URL url ) { } }

implementation:
int relation ; if ( pattern == null ) return ( url == null ) ; if ( ! ( url . getHost ( ) . endsWith ( pattern . getHost ( ) ) ) ) return false ; // e . g . pattern = x . y . org url = y . org
if ( ! ( url . getPath ( ) . startsWith ( pattern . getPath ( ) ) ) ) return false ; // e . g . pattern = y . org / a / b url = y . org / a
if ( pattern . getPort ( ) > 0 && pattern . getPort ( ) != url . getPort ( ) ) return false ; // note : all other fields are ignored
return true ;


signature:
public class RC { /** * Allow users to add to the default rc
 * @ param key
 * @ param value
 * @ param url null = > not url specific */
static synchronized public void add ( String key , String value , String url ) { } }

implementation:
if ( key == null ) return ; if ( ! initialized ) RC . initialize ( ) ; Triple t = new Triple ( key , value , url ) ; dfaltRC . insert ( t ) ; // recompute well - knowns
setWellKnown ( ) ;


signature:
public class RC { /** * Allow users to search the default rc
 * @ param key
 * @ param url null = > not url specific
 * @ return value corresponding to key + url , or null if does not exist */
static synchronized public String find ( String key , String url ) { } }

implementation: if ( key == null ) return null ; if ( ! initialized ) RC . initialize ( ) ; Triple t = dfaltRC . lookup ( key , url ) ; return ( t == null ? null : t . value ) ;


signature:
public class RC { /** * Record some well known parameters */
static void setWellKnown ( ) { } }

implementation:
if ( dfaltRC . triplestore . size ( ) == 0 ) return ; // Walk the set of triples looking for those that have no url
for ( String key : dfaltRC . keySet ( ) ) { Triple triple = dfaltRC . lookup ( key ) ; if ( triple . url == null ) { RC . set ( key , triple . value ) ; // let set sort it out
} }


signature:
public class RC { /** * overwrite existing entries */
public boolean load ( String abspath ) { } }

implementation:
abspath = abspath . replace ( '\\' , '/' ) ; File rcFile = new File ( abspath ) ; if ( ! rcFile . exists ( ) || ! rcFile . canRead ( ) ) { return false ; } if ( showlog ) log . debug ( "Loading rc file: " + abspath ) ; try ( BufferedReader rdr = new BufferedReader ( new InputStreamReader ( new FileInputStream ( rcFile ) , CDM . UTF8 ) ) ) { for ( int lineno = 1 ; ; lineno ++ ) { URL url = null ; String line = rdr . readLine ( ) ; if ( line == null ) break ; // trim leading blanks
line = line . trim ( ) ; if ( line . length ( ) == 0 ) continue ; // empty line
if ( line . charAt ( 0 ) == '#' ) continue ; // check for comment
// parse the line
if ( line . charAt ( 0 ) == LTAG ) { int rindex = line . indexOf ( RTAG ) ; if ( rindex < 0 ) return false ; if ( showlog ) log . error ( "Malformed [url] at " + abspath + "." + lineno ) ; String surl = line . substring ( 1 , rindex ) ; try { url = new URL ( surl ) ; } catch ( MalformedURLException mue ) { if ( showlog ) log . error ( "Malformed [url] at " + abspath + "." + lineno ) ; } line = line . substring ( rindex + 1 ) ; // trim again
line = line . trim ( ) ; } // Get the key , value part
String [ ] pieces = line . split ( "\\s*=\\s*" ) ; assert ( pieces . length == 1 || pieces . length == 2 ) ; // Create the triple
String value = "1" ; if ( pieces . length == 2 ) value = pieces [ 1 ] . trim ( ) ; Triple triple = new Triple ( pieces [ 0 ] . trim ( ) , value , url ) ; List < Triple > list = triplestore . get ( triple . key ) ; if ( list == null ) list = new ArrayList < Triple > ( ) ; Triple prev = addtriple ( list , triple ) ; triplestore . put ( triple . key , list ) ; } } catch ( FileNotFoundException fe ) { if ( showlog ) log . debug ( "Loading rc file: " + abspath ) ; return false ; } catch ( IOException ioe ) { if ( showlog ) log . error ( "File " + abspath + ": IO exception: " + ioe . getMessage ( ) ) ; return false ; } return true ;


signature:
public class RC { /** * Allow for external loading */
public Triple insert ( Triple t ) { } }

implementation: if ( t . key == null ) return null ; List < Triple > list = triplestore . get ( t . key ) ; if ( list == null ) list = new ArrayList < Triple > ( ) ; Triple prev = addtriple ( list , t ) ; triplestore . put ( t . key , list ) ; return prev ;


signature:
public class RelOpClause { /** * Prints the original string representation of this clause .
 * For use in debugging . */
public void printConstraint ( PrintWriter os ) { } }

implementation:
lhs . printConstraint ( os ) ; String op = ExprParserConstants . tokenImage [ operator ] ; op = op . substring ( 1 , op . length ( ) - 1 ) ; os . print ( op ) ; // os . print ( ExprParserConstants . tokenImage [ operator ] . substring ( 2 , 3 ) ) ;
if ( rhs . size ( ) == 1 ) { ( ( ValueClause ) rhs . get ( 0 ) ) . printConstraint ( os ) ; } else { os . print ( "{" ) ; Iterator it = rhs . iterator ( ) ; boolean first = true ; while ( it . hasNext ( ) ) { if ( ! first ) os . print ( "," ) ; ( ( ValueClause ) it . next ( ) ) . printConstraint ( os ) ; first = false ; } os . print ( "}" ) ; }


signature:
public class DatasetNode { /** * Get top level datasets contained directly in this catalog .
 * Do not dereference catRefs . */
public List < Dataset > getDatasetsLocal ( ) { } }

implementation: List < Dataset > datasets = ( List < Dataset > ) flds . get ( Dataset . Datasets ) ; return datasets == null ? new ArrayList < > ( 0 ) : datasets ;


signature:
public class DatasetNode { /** * Look though all datasets here or under here . do not go into catrefs */
public Dataset findDatasetByName ( String name ) { } }

implementation: for ( Dataset ds : getDatasets ( ) ) { if ( ds . getName ( ) . equals ( name ) ) return ds ; Dataset result = ds . findDatasetByName ( name ) ; if ( result != null ) return result ; } return null ;


signature:
public class GisFeatureRendererMulti { /** * Sets new projection for subsequent drawing .
 * @ param project the new projection */
public void setProjection ( ProjectionImpl project ) { } }

implementation: displayProject = project ; if ( featSetList == null ) return ; Iterator iter = featSetList . iterator ( ) ; while ( iter . hasNext ( ) ) { FeatureSet fs = ( FeatureSet ) iter . next ( ) ; fs . newProjection = true ; }


signature:
public class GisFeatureRendererMulti { /** * we have to deal with both projections and resolution - dependence */
protected Iterator getShapes ( java . awt . Graphics2D g , AffineTransform normal2device ) { } }

implementation:
long startTime = System . currentTimeMillis ( ) ; if ( featSetList == null ) { initFeatSetList ( ) ; assert ! featSetList . isEmpty ( ) ; } // which featureSet should we ue ?
FeatureSet fs = ( FeatureSet ) featSetList . get ( 0 ) ; if ( featSetList . size ( ) > 1 ) { // compute scale
double scale = 1.0 ; try { AffineTransform world2device = g . getTransform ( ) ; AffineTransform world2normal = normal2device . createInverse ( ) ; world2normal . concatenate ( world2device ) ; scale = Math . max ( Math . abs ( world2normal . getScaleX ( ) ) , Math . abs ( world2normal . getShearX ( ) ) ) ; // drawing or printing
if ( Debug . isSet ( "GisFeature/showTransform" ) ) { System . out . println ( "GisFeature/showTransform: " + world2normal + "\n scale = " + scale ) ; } } catch ( java . awt . geom . NoninvertibleTransformException e ) { System . out . println ( " GisRenderFeature: NoninvertibleTransformException on " + normal2device ) ; } if ( ! displayProject . isLatLon ( ) ) scale *= 111.0 ; // km / deg
double minD = Double . MAX_VALUE ; for ( Object aFeatSetList : featSetList ) { FeatureSet tryfs = ( FeatureSet ) aFeatSetList ; double d = Math . abs ( scale * tryfs . minDist - pixelMatch ) ; // we want min features ~ 2 pixels
if ( d < minD ) { minD = d ; fs = tryfs ; } } if ( Debug . isSet ( "GisFeature/MapResolution" ) ) { System . out . println ( "GisFeature/MapResolution: scale = " + scale + " minDist = " + fs . minDist ) ; } } // we may have deferred the actual creation of the points
if ( fs . featureList == null ) fs . createFeatures ( ) ; // ok , now see if we need to project
if ( ! displayProject . equals ( fs . project ) ) { fs . setProjection ( displayProject ) ; } else { // deal with LatLon
if ( fs . newProjection && displayProject . isLatLon ( ) ) { fs . setProjection ( displayProject ) ; } } fs . newProjection = false ; if ( Debug . isSet ( "GisFeature/timing/getShapes" ) ) { long tookTime = System . currentTimeMillis ( ) - startTime ; System . out . println ( "timing.getShapes: " + tookTime * .001 + " seconds" ) ; } // so return it , already
return fs . getShapes ( ) ;


signature:
public class GisFeatureRendererMulti { /** * make an ArrayList of Shapes from the given featureList and current display Projection */
private ArrayList makeShapes ( Iterator featList ) { } }

implementation:
Shape shape ; ArrayList shapeList = new ArrayList ( ) ; ProjectionImpl dataProject = getDataProjection ( ) ; if ( Debug . isSet ( "GisFeature/MapDraw" ) ) { System . out . println ( "GisFeature/MapDraw: makeShapes with " + displayProject ) ; } /* if ( Debug . isSet ( " bug . drawShapes " ) ) {
 int count = 0;
 / / make each GisPart a seperate shape for debugging
 feats : while ( featList . hasNext ( ) ) {
 AbstractGisFeature feature = ( AbstractGisFeature ) featList . next ( ) ;
 java . util . Iterator pi = feature . getGisParts ( ) ;
 while ( pi . hasNext ( ) ) {
 GisPart gp = ( GisPart ) pi . next ( ) ;
 int np = gp . getNumPoints ( ) ;
 GeneralPath path = new GeneralPath ( GeneralPath . WIND _ EVEN _ ODD , np ) ;
 double [ ] xx = gp . getX ( ) ;
 double [ ] yy = gp . getY ( ) ;
 path . moveTo ( ( float ) xx [ 0 ] , ( float ) yy [ 0 ] ) ;
 if ( count = = 63)
 System . out . println ( " moveTo x = " + xx [ 0 ] + " y = " + yy [ 0 ] ) ;
 for ( int i = 1 ; i < np ; i + + ) {
 path . lineTo ( ( float ) xx [ i ] , ( float ) yy [ i ] ) ;
 if ( count = = 63)
 System . out . println ( " lineTo x = " + xx [ i ] + " y = " + yy [ i ] ) ;
 shapeList . add ( path ) ;
 if ( count = = 63)
 break feats ;
 count + + ;
 System . out . println ( " bug . drawShapes : # shapes = " + shapeList . size ( ) ) ;
 return shapeList ; */
while ( featList . hasNext ( ) ) { AbstractGisFeature feature = ( AbstractGisFeature ) featList . next ( ) ; if ( dataProject . isLatLon ( ) ) // always got to run it through if its lat / lon
shape = feature . getProjectedShape ( displayProject ) ; else if ( dataProject == displayProject ) shape = feature . getShape ( ) ; else shape = feature . getProjectedShape ( dataProject , displayProject ) ; shapeList . add ( shape ) ; } return shapeList ;


signature:
public class PrefixName { /** * Compares this PrefixName with a string .
 * @ param stringThe string to compare this PrefixName against .
 * @ returnA negative value , zero , or a positive value
 * depending on whether this PrefixName is less
 * than , equal to , or greater than < code >
 * string < / code > , respectively . */
public final int compareTo ( String string ) { } }

implementation: return getID ( ) . length ( ) >= string . length ( ) ? getID ( ) . compareToIgnoreCase ( string ) : getID ( ) . compareToIgnoreCase ( string . substring ( 0 , getID ( ) . length ( ) ) ) ;


signature:
public class StopButton { /** * The given task is run in a background thread .
 * Progress is indicated once a second .
 * You cannot call this method again till the task is completed .
 * @ param pmt heres where the work is done .
 * @ return true task was started , false if still busy with previous task . */
public boolean startProgressMonitorTask ( ProgressMonitorTask pmt ) { } }

implementation:
if ( busy ) return false ; busy = true ; this . task = pmt ; isCancelled = false ; count = 0 ; setIcon ( icon [ 0 ] ) ; // create timer , whose events happen on the awt event Thread
ActionListener watcher = new ActionListener ( ) { public void actionPerformed ( ActionEvent evt ) { // System . out . println ( " timer event " + evt ) ;
if ( isCancelled && ! task . isCancel ( ) ) { task . cancel ( ) ; if ( debug ) System . out . println ( " task.cancel" ) ; return ; // give it a chance to finish up
} else { // indicate progress
count ++ ; setIcon ( icon [ count % 2 ] ) ; if ( debug ) System . out . println ( " stop count=" + count ) ; } // need to make sure task acknowledges the cancel ; so dont shut down
// until the task is done
if ( task . isDone ( ) ) { if ( myTimer != null ) myTimer . stop ( ) ; myTimer = null ; if ( task . isError ( ) ) javax . swing . JOptionPane . showMessageDialog ( null , task . getErrorMessage ( ) ) ; if ( task . isSuccess ( ) ) fireEvent ( new ActionEvent ( this , 0 , "success" ) ) ; else if ( task . isError ( ) ) fireEvent ( new ActionEvent ( this , 0 , "error" ) ) ; else if ( task . isCancel ( ) ) fireEvent ( new ActionEvent ( this , 0 , "cancel" ) ) ; else fireEvent ( new ActionEvent ( this , 0 , "done" ) ) ; busy = false ; } } } ; myTimer = new javax . swing . Timer ( 1000 , watcher ) ; // every second
myTimer . start ( ) ; // do task in a seperate , non - event , thread
Thread taskThread = new Thread ( task ) ; taskThread . start ( ) ; return true ;


signature:
public class GCpass1 { /** * Update all the grib indices in one directory , and the collection index for that directory
 * @ param config FeatureCollectionConfig
 * @ param dirPath directory path
 * @ throws IOException */
private Accum scanLeafDirectoryCollection ( boolean isGrib1 , FeatureCollectionConfig config , Counters parentCounters , Logger logger , Path dirPath , boolean isTop , Indent indent , Formatter fm ) throws IOException { } }

implementation:
if ( config . ptype == FeatureCollectionConfig . PartitionType . file ) { reportOneFileHeader ( indent , fm ) ; fm . format ( "%sDirectory %s%n" , indent , dirPath ) ; } Accum accum = new Accum ( ) ; int nfiles = 0 ; Counters countersThisDir = parentCounters . makeSubCounters ( ) ; Formatter errlog = new Formatter ( ) ; CollectionSpecParser specp = config . getCollectionSpecParser ( errlog ) ; DirectoryCollection dcm = new DirectoryCollection ( config . collectionName , dirPath , isTop , config . olderThan , logger ) ; // dcm . setUseGribFilter ( false ) ;
dcm . putAuxInfo ( FeatureCollectionConfig . AUX_CONFIG , config ) ; if ( specp . getFilter ( ) != null ) dcm . setStreamFilter ( new StreamFilter ( specp . getFilter ( ) , specp . getFilterOnName ( ) ) ) ; try ( CloseableIterator < MFile > iter = dcm . getFileIterator ( ) ) { while ( iter . hasNext ( ) ) { MFile mfile = iter . next ( ) ; Counters countersOneFile = countersThisDir . makeSubCounters ( ) ; int nrecords = 0 ; if ( isGrib1 ) { Grib1Index grib1Index = readGrib1Index ( mfile , false ) ; if ( grib1Index == null ) { System . out . printf ( "%s%s: read or create failed%n" , indent , mfile . getPath ( ) ) ; continue ; } for ( ucar . nc2 . grib . grib1 . Grib1Record gr : grib1Index . getRecords ( ) ) { accumGrib1Record ( gr , countersOneFile ) ; nrecords ++ ; } } else { Grib2Index grib2Index = readGrib2Index ( mfile , false ) ; if ( grib2Index == null ) { System . out . printf ( "%s%s: read or create failed%n" , indent , mfile . getPath ( ) ) ; continue ; } for ( ucar . nc2 . grib . grib2 . Grib2Record gr : grib2Index . getRecords ( ) ) { accumGrib2Record ( gr , countersOneFile ) ; nrecords ++ ; } } accum . nrecords += nrecords ; countersThisDir . addTo ( countersOneFile ) ; if ( config . ptype == FeatureCollectionConfig . PartitionType . file ) reportOneFile ( mfile , nrecords , countersOneFile , indent , fm ) ; nfiles ++ ; // get file sizes
String path = mfile . getPath ( ) ; if ( path . endsWith ( GribIndex . GBX9_IDX ) ) { accum . indexSize += ( ( float ) mfile . getLength ( ) / ( 1000 * 1000 ) ) ; // mb
} else { accum . fileSize += ( ( float ) mfile . getLength ( ) / ( 1000 * 1000 ) ) ; // mb
File idxFile = GribIndexCache . getExistingFileOrCache ( path + GribIndex . GBX9_IDX ) ; if ( idxFile . exists ( ) ) accum . indexSize += ( ( float ) idxFile . length ( ) / ( 1000 * 1000 ) ) ; // mb
} } } parentCounters . addTo ( countersThisDir ) ; accum . nfiles += nfiles ; accum . last = reportOneDir ( dirPath . toString ( ) , accum , countersThisDir , indent , accum . last ) ; return accum ;


signature:
public class GribPartitionBuilder { /** * LOOK need an option to only scan latest last partition or something */
private boolean needsUpdate ( CollectionUpdateType ff , File collectionIndexFile ) throws IOException { } }

implementation:
long collectionLastModified = collectionIndexFile . lastModified ( ) ; Set < String > newFileSet = new HashSet < > ( ) ; for ( MCollection dcm : partitionManager . makePartitions ( CollectionUpdateType . test ) ) { String partitionIndexFilename = StringUtil2 . replace ( dcm . getIndexFilename ( GribCdmIndex . NCX_SUFFIX ) , '\\' , "/" ) ; File partitionIndexFile = GribIndexCache . getExistingFileOrCache ( partitionIndexFilename ) ; if ( partitionIndexFile == null ) // make sure each partition has an index
return true ; if ( collectionLastModified < partitionIndexFile . lastModified ( ) ) // and the partition index is earlier than the collection index
return true ; newFileSet . add ( partitionIndexFilename ) ; } if ( ff == CollectionUpdateType . testIndexOnly ) return false ; // now see if any files were deleted
GribCdmIndex reader = new GribCdmIndex ( logger ) ; List < MFile > oldFiles = new ArrayList < > ( ) ; reader . readMFiles ( collectionIndexFile . toPath ( ) , oldFiles ) ; Set < String > oldFileSet = new HashSet < > ( ) ; for ( MFile oldFile : oldFiles ) { if ( ! newFileSet . contains ( oldFile . getPath ( ) ) ) return true ; // got deleted - must recreate the index
oldFileSet . add ( oldFile . getPath ( ) ) ; } // now see if any files were added
for ( String newFilename : newFileSet ) { if ( ! oldFileSet . contains ( newFilename ) ) return true ; // got added - must recreate the index
} return false ;


signature:
public class GribPartitionBuilder { /** * return true if changed , exception on failure */
boolean createPartitionedIndex ( CollectionUpdateType forcePartition , Formatter errlog ) throws IOException { } }

implementation:
if ( errlog == null ) errlog = new Formatter ( ) ; // info will be discarded
// create partitions from the partitionManager
for ( MCollection dcmp : partitionManager . makePartitions ( forcePartition ) ) { dcmp . putAuxInfo ( FeatureCollectionConfig . AUX_CONFIG , partitionManager . getAuxInfo ( FeatureCollectionConfig . AUX_CONFIG ) ) ; result . addPartition ( dcmp ) ; } result . sortPartitions ( ) ; // after this the partition list is immutable
// choose the " canonical " partition , aka prototype
// only used in copyInfo
int n = result . getPartitionSize ( ) ; if ( n == 0 ) { errlog . format ( "ERR Nothing in this partition = %s%n" , result . showLocation ( ) ) ; throw new IllegalStateException ( "Nothing in this partition =" + result . showLocation ( ) ) ; } int idx = partitionManager . getProtoIndex ( n ) ; PartitionCollectionMutable . Partition canon = result . getPartition ( idx ) ; logger . debug ( "     Using canonical partition {}" , canon . getDcm ( ) . getCollectionName ( ) ) ; try ( GribCollectionMutable gc = canon . makeGribCollection ( ) ) { // LOOK open / close canonical partition
if ( gc == null ) throw new IllegalStateException ( "canon.makeGribCollection failed on =" + result . showLocation ( ) + " " + canon . getName ( ) + "; errs=" + errlog ) ; // copy info from canon gribCollection to result partitionCollection
result . copyInfo ( gc ) ; result . isPartitionOfPartitions = ( gc instanceof PartitionCollectionMutable ) ; result . dateRange = gc . dateRange ; } // check consistency across vert and ens coords
// create partitioned variables
// partition index is used - do not resort partitions
GribCollectionMutable . Dataset ds2D = makeDataset2D ( errlog ) ; if ( ds2D == null ) { errlog . format ( " ERR makeDataset2D failed, index not written on %s%n" , result . showLocation ( ) ) ; throw new IllegalStateException ( "makeDataset2D failed, index not written on =" + result . showLocation ( ) + "; errs=" + errlog ) ; } // Make Best for a TwoD
if ( ds2D . gctype == GribCollectionImmutable . Type . TwoD ) makeDatasetBest ( ds2D , false ) ; // else if ( ds2D . gctype = = GribCollectionImmutable . Type . MRUTC )
// makeTime2runtime ( ds2D , false ) ;
// ready to write the index file
return writeIndex ( result , errlog ) ;


signature:
public class GribPartitionBuilder { /** * / * LOOK heres a place where one could " post process " and combine , instead of at coverage level .
 * this would benefit iosp , ie the netcdf API
 * private void makeTime2runtime ( GribCollectionMutable . Dataset ds2D , boolean isComplete ) throws IOException {
 * for ( GribCollectionMutable . GroupGC group2D : ds2D . groups ) {
 * for each time2D , add time2runtime
 * for ( Coordinate coord : group2D . coords ) {
 * if ( coord instanceof CoordinateTime2D ) {
 * ( ( CoordinateTime2D ) coord ) . makeTime2runtime ( result . masterRuntime ) ; */
private void makeDatasetBest ( GribCollectionMutable . Dataset ds2D , boolean isComplete ) { } }

implementation:
GribCollectionMutable . Dataset dsBest = result . makeDataset ( isComplete ? GribCollectionImmutable . Type . BestComplete : GribCollectionImmutable . Type . Best ) ; int npart = result . getPartitionSize ( ) ; // for each 2D group
for ( GribCollectionMutable . GroupGC group2D : ds2D . groups ) { GribCollectionMutable . GroupGC groupB = dsBest . addGroupCopy ( group2D ) ; // make copy of group , add to Best dataset
groupB . isTwoD = false ; // for each time2D , create the best time coordinates
HashMap < Coordinate , CoordinateTimeAbstract > map2DtoBest = new HashMap < > ( ) ; // associate 2D coord with best
CoordinateSharerBest sharer = new CoordinateSharerBest ( ) ; for ( Coordinate coord : group2D . coords ) { if ( coord instanceof CoordinateRuntime ) continue ; // skip it
if ( coord instanceof CoordinateTime2D ) { CoordinateTimeAbstract best = ( ( CoordinateTime2D ) coord ) . makeBestTimeCoordinate ( result . masterRuntime ) ; if ( ! isComplete ) best = best . makeBestFromComplete ( ) ; sharer . addCoordinate ( best ) ; map2DtoBest . put ( coord , best ) ; } else { sharer . addCoordinate ( coord ) ; } } groupB . coords = sharer . finish ( ) ; // these are the unique coords for group Best
// transfer variables to Best group , set shared Coordinates
for ( GribCollectionMutable . VariableIndex vi2d : group2D . variList ) { // copy vi2d and add to groupB
PartitionCollectionMutable . VariableIndexPartitioned vip = result . makeVariableIndexPartitioned ( groupB , vi2d , npart ) ; vip . finish ( ) ; // set shared coordinates
List < Coordinate > newCoords = new ArrayList < > ( ) ; for ( Integer groupIndex : vi2d . coordIndex ) { Coordinate coord2D = group2D . coords . get ( groupIndex ) ; if ( coord2D instanceof CoordinateRuntime ) continue ; // skip runtime ;
if ( coord2D instanceof CoordinateTime2D ) { newCoords . add ( map2DtoBest . get ( coord2D ) ) ; // add the best coordinate for that CoordinateTime2D
} else { newCoords . add ( coord2D ) ; } } vip . coordIndex = sharer . reindex ( newCoords ) ; } } // loop over groups


signature:
public class GribPartitionBuilder { /** * MAGIC _ START
 * version
 * sizeRecords
 * VariableRecords ( sizeRecords bytes )
 * sizeIndex
 * GribCollectionIndex ( sizeIndex bytes ) */
protected boolean writeIndex ( PartitionCollectionMutable pc , Formatter f ) throws IOException { } }

implementation:
File idxFile = GribIndexCache . getFileOrCache ( partitionManager . getIndexFilename ( GribCdmIndex . NCX_SUFFIX ) ) ; if ( idxFile . exists ( ) ) { RandomAccessFile . eject ( idxFile . getPath ( ) ) ; if ( ! idxFile . delete ( ) ) logger . error ( "gc2tp cant delete " + idxFile . getPath ( ) ) ; } writer = new GribCollectionWriter ( null , null ) ; try ( RandomAccessFile raf = new RandomAccessFile ( idxFile . getPath ( ) , "rw" ) ) { raf . order ( RandomAccessFile . BIG_ENDIAN ) ; // / / header message
raf . write ( getMagicStart ( ) . getBytes ( CDM . utf8Charset ) ) ; raf . writeInt ( getVersion ( ) ) ; raf . writeLong ( 0 ) ; // no record section
/* message GribCollection {
 required string name = 1 ; / / must be unique - index filename is name . ncx
 required string topDir = 2 ; / / filenames are reletive to this
 repeated MFile mfiles = 3 ; / / list of grib MFiles
 repeated Dataset dataset = 4;
 repeated Gds gds = 5 ; / / unique Gds , shared amongst datasets
 required int32 center = 6 ; / / these 4 fields are to get a GribTable object
 required int32 subcenter = 7;
 required int32 master = 8;
 required int32 local = 9 ; / / grib1 table Version
 optional int32 genProcessType = 10;
 optional int32 genProcessId = 11;
 optional int32 backProcessId = 12;
 / / repeated Parameter params = 20 ; / / not used
 FcConfig config = 21;
 uint64 startTime = 22 ; / / calendar date , first valid time
 uint64 endTime = 23 ; / / calendar date , last valid time
 extensions 100 to 199;
 extend GribCollection {
 repeated Partition partitions = 100; */
GribCollectionProto . GribCollection . Builder indexBuilder = GribCollectionProto . GribCollection . newBuilder ( ) ; indexBuilder . setName ( pc . getName ( ) ) ; Path topDir = pc . directory . toPath ( ) ; String pathS = StringUtil2 . replace ( topDir . toString ( ) , '\\' , "/" ) ; indexBuilder . setTopDir ( pathS ) ; // mfiles are the partition indexes
int count = 0 ; for ( PartitionCollectionMutable . Partition part : pc . partitions ) { GribCollectionProto . MFile . Builder b = GribCollectionProto . MFile . newBuilder ( ) ; String pathRS = makeReletiveFilename ( pc , part ) ; // reletive to pc . directory
b . setFilename ( pathRS ) ; b . setLastModified ( part . getLastModified ( ) ) ; b . setLength ( part . fileSize ) ; b . setIndex ( count ++ ) ; indexBuilder . addMfiles ( b . build ( ) ) ; } indexBuilder . setCenter ( pc . center ) ; indexBuilder . setSubcenter ( pc . subcenter ) ; indexBuilder . setMaster ( pc . master ) ; indexBuilder . setLocal ( pc . local ) ; indexBuilder . setGenProcessId ( pc . genProcessId ) ; indexBuilder . setGenProcessType ( pc . genProcessType ) ; indexBuilder . setBackProcessId ( pc . backProcessId ) ; indexBuilder . setStartTime ( pc . dateRange . getStart ( ) . getMillis ( ) ) ; indexBuilder . setEndTime ( pc . dateRange . getEnd ( ) . getMillis ( ) ) ; indexBuilder . setMasterRuntime ( writer . writeCoordProto ( pc . masterRuntime ) ) ; // dataset
for ( GribCollectionMutable . Dataset ds : pc . datasets ) indexBuilder . addDataset ( writeDatasetProto ( pc , ds ) ) ; // extensions
if ( pc . run2part != null ) { for ( int part : pc . run2part ) indexBuilder . addRun2Part ( part ) ; } for ( PartitionCollectionMutable . Partition part : pc . partitions ) indexBuilder . addPartitions ( writePartitionProto ( pc , part ) ) ; indexBuilder . setIsPartitionOfPartitions ( pc . isPartitionOfPartitions ) ; // write it out
GribCollectionProto . GribCollection index = indexBuilder . build ( ) ; byte [ ] b = index . toByteArray ( ) ; NcStream . writeVInt ( raf , b . length ) ; // message size
raf . write ( b ) ; // message - all in one gulp
f . format ( "Grib2PartitionIndex= %d bytes file size =  %d bytes%n%n" , b . length , raf . length ( ) ) ; } return true ;


signature:
public class GribPartitionBuilder { /** * message Dataset {
 * required Type type = 1;
 * repeated Group groups = 2; */
private GribCollectionProto . Dataset writeDatasetProto ( PartitionCollectionMutable pc , GribCollectionMutable . Dataset ds ) throws IOException { } }

implementation: GribCollectionProto . Dataset . Builder b = GribCollectionProto . Dataset . newBuilder ( ) ; GribCollectionProto . Dataset . Type type = GribCollectionProto . Dataset . Type . valueOf ( ds . gctype . toString ( ) ) ; b . setType ( type ) ; for ( GribCollectionMutable . GroupGC group : ds . groups ) b . addGroups ( writeGroupProto ( pc , group ) ) ; return b . build ( ) ;


signature:
public class GribPartitionBuilder { /** * message Group {
 * Gds gds = 1 ; / / use this to build the HorizCoordSys
 * repeated Variable variables = 2 ; / / list of variables
 * repeated Coord coords = 3 ; / / list of coordinates
 * repeated uint32 fileno = 4 [ packed = true ] ; / / the component files that are in this group , key into gc . mfiles */
private GribCollectionProto . Group writeGroupProto ( PartitionCollectionMutable pc , GribCollectionMutable . GroupGC g ) throws IOException { } }

implementation: GribCollectionProto . Group . Builder b = GribCollectionProto . Group . newBuilder ( ) ; b . setGds ( GribCollectionWriter . writeGdsProto ( g . horizCoordSys . getRawGds ( ) , g . horizCoordSys . getPredefinedGridDefinition ( ) ) ) ; for ( GribCollectionMutable . VariableIndex vb : g . variList ) { b . addVariables ( writeVariableProto ( ( PartitionCollectionMutable . VariableIndexPartitioned ) vb ) ) ; } for ( Coordinate coord : g . coords ) { switch ( coord . getType ( ) ) { case runtime : b . addCoords ( writer . writeCoordProto ( ( CoordinateRuntime ) coord ) ) ; break ; case time : b . addCoords ( writer . writeCoordProto ( ( CoordinateTime ) coord ) ) ; break ; case timeIntv : b . addCoords ( writer . writeCoordProto ( ( CoordinateTimeIntv ) coord ) ) ; break ; case time2D : b . addCoords ( writer . writeCoordProto ( ( CoordinateTime2D ) coord ) ) ; break ; case vert : b . addCoords ( writer . writeCoordProto ( ( CoordinateVert ) coord ) ) ; break ; case ens : b . addCoords ( writer . writeCoordProto ( ( CoordinateEns ) coord ) ) ; break ; } } if ( g . filenose != null ) for ( Integer fileno : g . filenose ) b . addFileno ( fileno ) ; return b . build ( ) ;


signature:
public class GribPartitionBuilder { /** * message Variable {
 * uint32 discipline = 1;
 * bytes pds = 2 ; / / raw pds
 * repeated uint32 ids = 3 [ packed = true ] ; / / extra info not in pds ; grib2 id section
 * uint64 recordsPos = 4 ; / / offset of SparseArray message for this Variable
 * uint32 recordsLen = 5 ; / / size of SparseArray message for this Variable
 * repeated uint32 coordIdx = 6 [ packed = true ] ; / / indexes into Group . coords
 * optionally keep stats
 * uint32 ndups = 8;
 * uint32 nrecords = 9;
 * uint32 missing = 10;
 * partition only
 * repeated PartitionVariable partVariable = 100; */
private GribCollectionProto . Variable writeVariableProto ( PartitionCollectionMutable . VariableIndexPartitioned vp ) { } }

implementation:
GribCollectionProto . Variable . Builder b = GribCollectionProto . Variable . newBuilder ( ) ; b . setDiscipline ( vp . discipline ) ; b . setPds ( ByteString . copyFrom ( vp . rawPds ) ) ; // extra id info
b . addIds ( vp . center ) ; b . addIds ( vp . subcenter ) ; b . setRecordsPos ( vp . recordsPos ) ; b . setRecordsLen ( vp . recordsLen ) ; for ( int idx : vp . coordIndex ) b . addCoordIdx ( idx ) ; b . setNdups ( vp . ndups ) ; b . setNrecords ( vp . nrecords ) ; b . setMissing ( vp . nmissing ) ; /* if ( vp . twot ! = null ) { / / only for 2D
 for ( int invCount : vp . twot . getCount ( ) )
 b . addInvCount ( invCount ) ;
 if ( vp . time2runtime ! = null ) { / / only for 1D
 for ( int idx = 0 ; idx < vp . time2runtime . getN ( ) ; idx + + )
 b . addTime2Runtime ( vp . time2runtime . get ( idx ) ) ; */
// extensions
if ( vp . nparts > 0 && vp . partnoSA != null ) { for ( int i = 0 ; i < vp . nparts ; i ++ ) // PartitionCollection . PartitionForVariable2D pvar : vp . getPartitionForVariable2D ( ) )
b . addPartVariable ( writePartitionVariableProto ( vp . partnoSA . get ( i ) , vp . groupnoSA . get ( i ) , vp . varnoSA . get ( i ) , vp . nrecords , vp . ndups , vp . nmissing ) ) ; // LOOK was it finished ? ?
} return b . build ( ) ;


signature:
public class GribPartitionBuilder { /** * message PartitionVariable {
 * uint32 groupno = 1;
 * uint32 varno = 2;
 * uint32 flag = 3;
 * uint32 partno = 4;
 * optionally keep stats
 * uint32 ndups = 8;
 * uint32 nrecords = 9;
 * uint32 missing = 10; */
private GribCollectionProto . PartitionVariable writePartitionVariableProto ( int partno , int groupno , int varno , int nrecords , int ndups , int nmissing ) { } }

implementation: GribCollectionProto . PartitionVariable . Builder pb = GribCollectionProto . PartitionVariable . newBuilder ( ) ; pb . setPartno ( partno ) ; pb . setGroupno ( groupno ) ; pb . setVarno ( varno ) ; pb . setNdups ( ndups ) ; pb . setNrecords ( nrecords ) ; pb . setMissing ( nmissing ) ; return pb . build ( ) ;


signature:
public class GribPartitionBuilder { /** * message Partition {
 * string name = 1 ; / / name is used in TDS - eg the subdirectory when generated by TimePartitionCollections
 * string filename = 2 ; / / the gribCollection . ncx file , reletive to gc .
 * string directory = 3 ; / / top directory NOT USED
 * uint64 lastModified = 4;
 * int64 length = 5;
 * int64 partitionDate = 6 ; / / partition date added 11/25/14 */
private GribCollectionProto . Partition writePartitionProto ( PartitionCollectionMutable pc , PartitionCollectionMutable . Partition p ) { } }

implementation:
GribCollectionProto . Partition . Builder b = GribCollectionProto . Partition . newBuilder ( ) ; String pathRS = makeReletiveFilename ( pc , p ) ; // reletive to pc . directory
b . setFilename ( pathRS ) ; b . setName ( p . name ) ; // b . setDirectory ( p . directory ) ;
b . setLastModified ( p . lastModified ) ; b . setLength ( p . fileSize ) ; if ( p . partitionDate != null ) b . setPartitionDate ( p . partitionDate . getMillis ( ) ) ; // LOOK what about calendar ? ?
return b . build ( ) ;


signature:
public class EnsCoord { /** * LOOK */
public boolean equalsData ( ucar . nc2 . ft . fmrc . EnsCoord other ) { } }

implementation: if ( ensembles != other . ensembles ) return false ; if ( pdn != other . pdn ) return false ; for ( int i = 0 ; i < ensTypes . length ; i ++ ) { if ( ensTypes [ i ] != other . ensTypes [ i ] ) return false ; } return true ;


signature: public class EnsCoord { static public EnsCoord findEnsCoord ( List < EnsCoord > ensCoords , EnsCoord want ) { } }

implementation:
if ( want == null ) return null ; for ( EnsCoord ec : ensCoords ) { if ( want . equalsData ( ec ) ) return ec ; } // make a new one
EnsCoord result = new EnsCoord ( want ) ; ensCoords . add ( result ) ; return result ;


signature:
public class EnsCoord { /** * Extend result with all the values in the list of EnsCoord
 * @ param result extend this coord
 * @ param ecList list of EnsCoord , may be empty */
static public void normalize ( EnsCoord result , List < EnsCoord > ecList ) { } }

implementation:
List < EnsCoord > extra = new ArrayList < > ( ) ; for ( EnsCoord ec : ecList ) { if ( ! result . equalsData ( ec ) ) { // differences can only be greater
extra . add ( ec ) ; } } if ( extra . size ( ) == 0 ) return ; for ( EnsCoord ec : extra ) { if ( ec . getNEnsembles ( ) < result . getNEnsembles ( ) ) continue ; result = ec ; }


signature:
public class Grib1CollectionWriter { /** * message Record {
 * uint32 fileno = 1 ; / / which GRIB file ? key into GC . fileMap
 * uint64 pos = 2 ; / / offset in GRIB file of the start of entire message
 * uint64 bmsPos = 3 ; / / use alternate bms if non - zero ( grib2 only )
 * uint32 drsOffset = 4 ; / / offset of drs from pos ( grib2 only )
 * SparseArray only at the GCs ( MRC and SRC ) not at the Partitions
 * dont need SparseArray in memory until someone wants to read from the variable
 * message SparseArray {
 * repeated uint32 size = 2 [ packed = true ] ; / / multidim sizes = shape [ ]
 * repeated uint32 track = 3 [ packed = true ] ; / / 1 - based index into record list , 0 = = missing
 * repeated Record records = 4 ; / / List < Record >
 * uint32 ndups = 5 ; / / duplicates found when creating */
private GribCollectionProto . SparseArray writeSparseArray ( Grib1CollectionBuilder . VariableBag vb , Set < Integer > fileSet ) { } }

implementation:
GribCollectionProto . SparseArray . Builder b = GribCollectionProto . SparseArray . newBuilder ( ) ; SparseArray < Grib1Record > sa = vb . coordND . getSparseArray ( ) ; for ( int size : sa . getShape ( ) ) { b . addSize ( size ) ; } for ( int track : sa . getTrack ( ) ) { b . addTrack ( track ) ; } for ( Grib1Record gr : sa . getContent ( ) ) { GribCollectionProto . Record . Builder br = GribCollectionProto . Record . newBuilder ( ) ; br . setFileno ( gr . getFile ( ) ) ; fileSet . add ( gr . getFile ( ) ) ; Grib1SectionIndicator is = gr . getIs ( ) ; br . setStartPos ( is . getStartPos ( ) ) ; // start of entire message
b . addRecords ( br ) ; } b . setNdups ( sa . getNdups ( ) ) ; return b . build ( ) ;


signature:
public class Grib1CollectionWriter { /** * message Dataset {
 * Type type = 1;
 * repeated Group groups = 2; */
private GribCollectionProto . Dataset writeDatasetProto ( GribCollectionImmutable . Type type , List < Group > groups ) { } }

implementation: GribCollectionProto . Dataset . Builder b = GribCollectionProto . Dataset . newBuilder ( ) ; GribCollectionProto . Dataset . Type ptype = GribCollectionProto . Dataset . Type . valueOf ( type . toString ( ) ) ; b . setType ( ptype ) ; for ( Group group : groups ) { b . addGroups ( writeGroupProto ( group ) ) ; } return b . build ( ) ;


signature:
public class Grib1CollectionWriter { /** * message Group {
 * Gds gds = 1 ; / / use this to build the HorizCoordSys
 * repeated Variable variables = 2 ; / / list of variables
 * repeated Coord coords = 3 ; / / list of coordinates
 * repeated int32 fileno = 4 [ packed = true ] ; / / the component files that are in this group , key into gc . mfiles */
private GribCollectionProto . Group writeGroupProto ( Group g ) { } }

implementation: GribCollectionProto . Group . Builder b = GribCollectionProto . Group . newBuilder ( ) ; b . setGds ( writeGdsProto ( g . gdss . getRawBytes ( ) , g . gdss . getPredefinedGridDefinition ( ) ) ) ; for ( Grib1CollectionBuilder . VariableBag vbag : g . gribVars ) { b . addVariables ( writeVariableProto ( vbag ) ) ; } for ( Coordinate coord : g . coords ) { switch ( coord . getType ( ) ) { case runtime : b . addCoords ( writeCoordProto ( ( CoordinateRuntime ) coord ) ) ; break ; case time : b . addCoords ( writeCoordProto ( ( CoordinateTime ) coord ) ) ; break ; case timeIntv : b . addCoords ( writeCoordProto ( ( CoordinateTimeIntv ) coord ) ) ; break ; case time2D : b . addCoords ( writeCoordProto ( ( CoordinateTime2D ) coord ) ) ; break ; case vert : b . addCoords ( writeCoordProto ( ( CoordinateVert ) coord ) ) ; break ; case ens : b . addCoords ( writeCoordProto ( ( CoordinateEns ) coord ) ) ; break ; } } for ( Integer aFileSet : g . fileSet ) { b . addFileno ( aFileSet ) ; } return b . build ( ) ;


signature:
public class Grib1CollectionWriter { /** * message Variable {
 * uint32 discipline = 1;
 * bytes pds = 2 ; / / raw pds
 * repeated uint32 ids = 3 [ packed = true ] ; / / extra info not in pds ; grib2 id section
 * uint64 recordsPos = 4 ; / / offset of SparseArray message for this Variable
 * uint32 recordsLen = 5 ; / / size of SparseArray message for this Variable
 * repeated uint32 coordIdx = 6 [ packed = true ] ; / / indexes into Group . coords
 * optionally keep stats
 * uint32 ndups = 8;
 * uint32 nrecords = 9;
 * uint32 missing = 10;
 * partition only
 * repeated PartitionVariable partVariable = 100; */
private GribCollectionProto . Variable writeVariableProto ( Grib1CollectionBuilder . VariableBag vb ) { } }

implementation:
GribCollectionProto . Variable . Builder b = GribCollectionProto . Variable . newBuilder ( ) ; b . setDiscipline ( 0 ) ; b . setPds ( ByteString . copyFrom ( vb . first . getPDSsection ( ) . getRawBytes ( ) ) ) ; b . setRecordsPos ( vb . pos ) ; b . setRecordsLen ( vb . length ) ; for ( int idx : vb . coordIndex ) { b . addCoordIdx ( idx ) ; } // keep stats
SparseArray sa = vb . coordND . getSparseArray ( ) ; if ( sa != null ) { b . setNdups ( sa . getNdups ( ) ) ; b . setNrecords ( sa . countNotMissing ( ) ) ; b . setMissing ( sa . countMissing ( ) ) ; } return b . build ( ) ;


signature:
public class ArrayStructure { /** * Set the index - th StructureData of this ArrayStructure .
 * @ param index which one to set .
 * @ param value must be type StructureData . */
public void setObject ( int index , Object value ) { } }

implementation: if ( sdata == null ) sdata = new StructureData [ nelems ] ; sdata [ index ] = ( StructureData ) value ;


signature:
public class ArrayStructure { /** * Get the index - th StructureData of this ArrayStructure .
 * @ param index which one to get , specified by an integer .
 * @ return object of type StructureData . */
public StructureData getStructureData ( int index ) { } }

implementation: if ( sdata == null ) sdata = new StructureData [ nelems ] ; if ( index >= sdata . length ) throw new IllegalArgumentException ( index + " > " + sdata . length ) ; if ( sdata [ index ] == null ) sdata [ index ] = makeStructureData ( this , index ) ; return sdata [ index ] ;


signature:
public class ArrayStructure { /** * Get member data of any type for a specific record as an Array .
 * This may avoid the overhead of creating the StructureData object , but is equivilent to
 * getStructure ( recno ) . getArray ( Member m ) .
 * @ param recno get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member .
 * @ return Array values . */
public Array getArray ( int recno , StructureMembers . Member m ) { } }

implementation: DataType dataType = m . getDataType ( ) ; switch ( dataType ) { case DOUBLE : double [ ] da = getJavaArrayDouble ( recno , m ) ; return Array . factory ( dataType , m . getShape ( ) , da ) ; case FLOAT : float [ ] fa = getJavaArrayFloat ( recno , m ) ; return Array . factory ( dataType , m . getShape ( ) , fa ) ; case BYTE : case UBYTE : case ENUM1 : byte [ ] ba = getJavaArrayByte ( recno , m ) ; return Array . factory ( dataType , m . getShape ( ) , ba ) ; case SHORT : case USHORT : case ENUM2 : short [ ] sa = getJavaArrayShort ( recno , m ) ; return Array . factory ( dataType , m . getShape ( ) , sa ) ; case INT : case UINT : case ENUM4 : int [ ] ia = getJavaArrayInt ( recno , m ) ; return Array . factory ( dataType , m . getShape ( ) , ia ) ; case ULONG : case LONG : long [ ] la = getJavaArrayLong ( recno , m ) ; return Array . factory ( dataType , m . getShape ( ) , la ) ; case CHAR : char [ ] ca = getJavaArrayChar ( recno , m ) ; return Array . factory ( dataType , m . getShape ( ) , ca ) ; case STRING : String [ ] str = getJavaArrayString ( recno , m ) ; return Array . factory ( dataType , m . getShape ( ) , str ) ; case STRUCTURE : return getArrayStructure ( recno , m ) ; case SEQUENCE : return getArraySequence ( recno , m ) ; case OPAQUE : return getArrayObject ( recno , m ) ; } throw new RuntimeException ( "Dont have implemenation for " + dataType ) ;


signature:
public class ArrayStructure { /** * Set data for one member , over all structures .
 * This is used by VariableDS to do scale / offset .
 * @ param m set data for this StructureMembers . Member .
 * @ param memberArray Array values . */
public void setMemberArray ( StructureMembers . Member m , Array memberArray ) { } }

implementation:
m . setDataArray ( memberArray ) ; if ( memberArray instanceof ArrayStructure ) { // LOOK
ArrayStructure as = ( ArrayStructure ) memberArray ; m . setStructureMembers ( as . getStructureMembers ( ) ) ; }


signature:
public class ArrayStructure { /** * Extract data for one member , over all structures .
 * @ param m get data from this StructureMembers . Member .
 * @ return Array values .
 * @ throws java . io . IOException on read error ( only happens for Sequences , otherwise data is already read ) */
public Array extractMemberArray ( StructureMembers . Member m ) throws IOException { } }

implementation:
if ( m . getDataArray ( ) != null ) return m . getDataArray ( ) ; DataType dataType = m . getDataType ( ) ; /* special handling for sequences
 if ( dataType = = DataType . SEQUENCE ) {
 List < StructureData > sdataList = new ArrayList < StructureData > ( ) ;
 for ( int recno = 0 ; recno < getSize ( ) ; recno + + ) {
 ArraySequence2 seq = getArraySequence ( recno , m ) ;
 StructureDataIterator iter = seq . getStructureDataIterator ( ) ;
 while ( iter . hasNext ( ) )
 sdataList . add ( iter . next ( ) ) ;
 ArraySequence2 seq = getArraySequence ( 0 , m ) ;
 int size = sdataList . size ( ) ;
 StructureData [ ] sdataArray = sdataList . toArray ( new StructureData [ size ] ) ;
 return new ArrayStructureW ( seq . getStructureMembers ( ) , new int [ ] { size } , sdataArray ) ; */
// combine the shapes
int [ ] mshape = m . getShape ( ) ; int rrank = rank + mshape . length ; int [ ] rshape = new int [ rrank ] ; System . arraycopy ( getShape ( ) , 0 , rshape , 0 , rank ) ; System . arraycopy ( mshape , 0 , rshape , rank , mshape . length ) ; // create an empty array to hold the result
Array result ; if ( dataType == DataType . STRUCTURE ) { StructureMembers membersw = new StructureMembers ( m . getStructureMembers ( ) ) ; // no data arrays get propagated
result = new ArrayStructureW ( membersw , rshape ) ; } else if ( dataType == DataType . OPAQUE ) { result = Array . factory ( DataType . OPAQUE , rshape ) ; } else { result = Array . factory ( dataType , rshape ) ; } IndexIterator resultIter = result . getIndexIterator ( ) ; if ( dataType == DataType . DOUBLE ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copyDoubles ( recno , m , resultIter ) ; } else if ( dataType == DataType . FLOAT ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copyFloats ( recno , m , resultIter ) ; } else if ( dataType . getPrimitiveClassType ( ) == byte . class ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copyBytes ( recno , m , resultIter ) ; } else if ( dataType . getPrimitiveClassType ( ) == short . class ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copyShorts ( recno , m , resultIter ) ; } else if ( dataType . getPrimitiveClassType ( ) == int . class ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copyInts ( recno , m , resultIter ) ; } else if ( dataType . getPrimitiveClassType ( ) == long . class ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copyLongs ( recno , m , resultIter ) ; } else if ( dataType == DataType . CHAR ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copyChars ( recno , m , resultIter ) ; } else if ( ( dataType == DataType . STRING ) || ( dataType == DataType . OPAQUE ) ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copyObjects ( recno , m , resultIter ) ; } else if ( dataType == DataType . STRUCTURE ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copyStructures ( recno , m , resultIter ) ; } else if ( dataType == DataType . SEQUENCE ) { for ( int recno = 0 ; recno < getSize ( ) ; recno ++ ) copySequences ( recno , m , resultIter ) ; } return result ;


signature:
public class ArrayStructure { /** * member data is itself a structure , and may be an array of structures . */
protected void copyStructures ( int recnum , StructureMembers . Member m , IndexIterator result ) { } }

implementation: Array data = getArray ( recnum , m ) ; IndexIterator dataIter = data . getIndexIterator ( ) ; while ( dataIter . hasNext ( ) ) result . setObjectNext ( dataIter . getObjectNext ( ) ) ;


signature:
public class ArrayStructure { /** * Get member data array of any type as an Object , eg , Float , Double , String , StructureData etc .
 * @ param recno get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member .
 * @ return value as Float , Double , etc . . */
public Object getScalarObject ( int recno , StructureMembers . Member m ) { } }

implementation:
DataType dataType = m . getDataType ( ) ; if ( dataType == DataType . DOUBLE ) { return getScalarDouble ( recno , m ) ; } else if ( dataType == DataType . FLOAT ) { return getScalarFloat ( recno , m ) ; } else if ( dataType . getPrimitiveClassType ( ) == byte . class ) { return getScalarByte ( recno , m ) ; } else if ( dataType . getPrimitiveClassType ( ) == short . class ) { return getScalarShort ( recno , m ) ; } else if ( dataType . getPrimitiveClassType ( ) == int . class ) { return getScalarInt ( recno , m ) ; } else if ( dataType . getPrimitiveClassType ( ) == long . class ) { return getScalarLong ( recno , m ) ; } else if ( dataType == DataType . CHAR ) { return getScalarString ( recno , m ) ; } else if ( dataType == DataType . STRING ) { return getScalarString ( recno , m ) ; } else if ( dataType == DataType . STRUCTURE ) { return getScalarStructure ( recno , m ) ; } else if ( dataType == DataType . OPAQUE ) { ArrayObject data = ( ArrayObject ) m . getDataArray ( ) ; return data . getObject ( recno * m . getSize ( ) ) ; // LOOK ? ?
} throw new RuntimeException ( "Dont have implementation for " + dataType ) ;


signature:
public class ArrayStructure { /** * Get scalar value as a float , with conversion as needed . Underlying type must be convertible to float .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m member Variable .
 * @ return scalar float value
 * @ throws ForbiddenConversionException if not convertible to float . */
public float convertScalarFloat ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) == DataType . FLOAT ) return getScalarFloat ( recnum , m ) ; if ( m . getDataType ( ) == DataType . DOUBLE ) return ( float ) getScalarDouble ( recnum , m ) ; Object o = getScalarObject ( recnum , m ) ; if ( o instanceof Number ) return ( ( Number ) o ) . floatValue ( ) ; throw new ForbiddenConversionException ( "Type is " + m . getDataType ( ) + ", not convertible to float" ) ;


signature:
public class ArrayStructure { /** * Get scalar value as a double , with conversion as needed . Underlying type must be convertible to double .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m member Variable .
 * @ return scalar double value
 * @ throws ForbiddenConversionException if not convertible to double . */
public double convertScalarDouble ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) == DataType . DOUBLE ) return getScalarDouble ( recnum , m ) ; if ( m . getDataType ( ) == DataType . FLOAT ) return ( double ) getScalarFloat ( recnum , m ) ; Object o = getScalarObject ( recnum , m ) ; if ( o instanceof Number ) return ( ( Number ) o ) . doubleValue ( ) ; throw new ForbiddenConversionException ( "Type is " + m . getDataType ( ) + ", not convertible to double" ) ;


signature:
public class ArrayStructure { /** * Get scalar value as an int , with conversion as needed . Underlying type must be convertible to int .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m member Variable .
 * @ return scalar double value
 * @ throws ForbiddenConversionException if not convertible to double . */
public int convertScalarInt ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) == DataType . INT || m . getDataType ( ) == DataType . UINT ) return getScalarInt ( recnum , m ) ; if ( m . getDataType ( ) == DataType . SHORT ) return ( int ) getScalarShort ( recnum , m ) ; if ( m . getDataType ( ) == DataType . USHORT ) return DataType . unsignedShortToInt ( getScalarShort ( recnum , m ) ) ; if ( m . getDataType ( ) == DataType . BYTE ) return ( int ) getScalarByte ( recnum , m ) ; if ( m . getDataType ( ) == DataType . UBYTE ) return ( int ) DataType . unsignedByteToShort ( getScalarByte ( recnum , m ) ) ; if ( m . getDataType ( ) == DataType . LONG || m . getDataType ( ) == DataType . ULONG ) return ( int ) getScalarLong ( recnum , m ) ; Object o = getScalarObject ( recnum , m ) ; if ( o instanceof Number ) return ( ( Number ) o ) . intValue ( ) ; throw new ForbiddenConversionException ( "Type is " + m . getDataType ( ) + ", not convertible to int" ) ;


signature:
public class ArrayStructure { /** * Get scalar member data of type float .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member . Must be of type float .
 * @ return scalar double value */
public float getScalarFloat ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) != DataType . FLOAT ) throw new IllegalArgumentException ( "Type is " + m . getDataType ( ) + ", must be float" ) ; Array data = m . getDataArray ( ) ; return data . getFloat ( recnum * m . getSize ( ) ) ; // gets first one in the array


signature:
public class ArrayStructure { /** * Get scalar member data of type byte .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member . Must be of type byte .
 * @ return scalar double value */
public byte getScalarByte ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( ! ( m . getDataType ( ) . getPrimitiveClassType ( ) == byte . class ) ) throw new IllegalArgumentException ( "Type is " + m . getDataType ( ) + ", must be byte" ) ; Array data = m . getDataArray ( ) ; return data . getByte ( recnum * m . getSize ( ) ) ; // gets first one in the array


signature:
public class ArrayStructure { /** * Get scalar member data of type short .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member . Must be of type short .
 * @ return scalar double value */
public short getScalarShort ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( ! ( m . getDataType ( ) . getPrimitiveClassType ( ) == short . class ) ) throw new IllegalArgumentException ( "Type is " + m . getDataType ( ) + ", must be short" ) ; Array data = m . getDataArray ( ) ; return data . getShort ( recnum * m . getSize ( ) ) ; // gets first one in the array


signature:
public class ArrayStructure { /** * Get scalar member data of type char .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member . Must be of type char .
 * @ return scalar double value */
public char getScalarChar ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) != DataType . CHAR ) throw new IllegalArgumentException ( "Type is " + m . getDataType ( ) + ", must be char" ) ; Array data = m . getDataArray ( ) ; return data . getChar ( recnum * m . getSize ( ) ) ; // gets first one in the array


signature:
public class ArrayStructure { /** * Get member data of type String or char .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member . Must be of type String or char .
 * @ return scalar String value */
public String getScalarString ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) == DataType . CHAR ) { ArrayChar data = ( ArrayChar ) m . getDataArray ( ) ; return data . getString ( recnum ) ; } if ( m . getDataType ( ) == DataType . STRING ) { Array data = m . getDataArray ( ) ; return ( String ) data . getObject ( recnum ) ; } throw new IllegalArgumentException ( "Type is " + m . getDataType ( ) + ", must be String or char" ) ;


signature:
public class ArrayStructure { /** * Get member data of type Structure .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member . Must be of type Structure .
 * @ return scalar StructureData */
public StructureData getScalarStructure ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) != DataType . STRUCTURE ) throw new IllegalArgumentException ( "Type is " + m . getDataType ( ) + ", must be Structure" ) ; ArrayStructure data = ( ArrayStructure ) m . getDataArray ( ) ; return data . getStructureData ( recnum * m . getSize ( ) ) ; // gets first in the array


signature:
public class ArrayStructure { /** * Get member data of type array of Structure .
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member . Must be of type Structure .
 * @ return nested ArrayStructure . */
public ArrayStructure getArrayStructure ( int recnum , StructureMembers . Member m ) { } }

implementation:
if ( ( m . getDataType ( ) != DataType . STRUCTURE ) && ( m . getDataType ( ) != DataType . SEQUENCE ) ) throw new IllegalArgumentException ( "Type is " + m . getDataType ( ) + ", must be Structure or Sequence" ) ; if ( m . getDataType ( ) == DataType . SEQUENCE ) return getArraySequence ( recnum , m ) ; ArrayStructure array = ( ArrayStructure ) m . getDataArray ( ) ; int count = m . getSize ( ) ; StructureData [ ] this_sdata = new StructureData [ count ] ; for ( int i = 0 ; i < count ; i ++ ) this_sdata [ i ] = array . getStructureData ( recnum * count + i ) ; // make a copy of the members , but remove the data arrays , since the structureData must be used instead
StructureMembers membersw = new StructureMembers ( array . getStructureMembers ( ) ) ; return new ArrayStructureW ( membersw , m . getShape ( ) , this_sdata ) ;


signature:
public class ArrayStructure { /** * Get member data of type ArraySequence
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member . Must be of type Structure .
 * @ return nested ArrayStructure . */
public ArraySequence getArraySequence ( int recnum , StructureMembers . Member m ) { } }

implementation:
if ( m . getDataType ( ) != DataType . SEQUENCE ) throw new IllegalArgumentException ( "Type is " + m . getDataType ( ) + ", must be Sequence" ) ; // should store sequences as ArrayObject of ArraySequence objects
ArrayObject array = ( ArrayObject ) m . getDataArray ( ) ; return ( ArraySequence ) array . getObject ( recnum ) ;


signature:
public class ArrayStructure { /** * Get member data of type ArrayObject
 * @ param recnum get data from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get data from this StructureMembers . Member . Must be of type Structure .
 * @ return ArrayObject . */
public ArrayObject getArrayObject ( int recnum , StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) != DataType . OPAQUE ) throw new IllegalArgumentException ( "Type is " + m . getDataType ( ) + ", must be Sequence" ) ; ArrayObject array = ( ArrayObject ) m . getDataArray ( ) ; return ( ArrayObject ) array . getObject ( recnum ) ; // LOOK ? ?


signature:
public class Index3D { /** * experimental */
int setDirect ( int v0 , int v1 , int v2 ) { } }

implementation: if ( v0 < 0 || v0 >= shape0 ) throw new ArrayIndexOutOfBoundsException ( ) ; if ( v1 < 0 || v1 >= shape1 ) throw new ArrayIndexOutOfBoundsException ( ) ; if ( v2 < 0 || v2 >= shape2 ) throw new ArrayIndexOutOfBoundsException ( ) ; return offset + v0 * stride0 + v1 * stride1 + v2 * stride2 ;


signature:
public class Orthographic { /** * Precalculate some stuff */
private void precalculate ( ) { } }

implementation: sinLat0 = Math . sin ( lat0 ) ; cosLat0 = Math . cos ( lat0 ) ; lon0Degrees = Math . toDegrees ( lon0 ) ;


signature:
public class Orthographic { /** * This returns true when the line between pt1 and pt2 crosses the seam .
 * When the cone is flattened , the " seam " is lon0 + - 180.
 * @ param pt1 point 1
 * @ param pt2 point 2
 * @ return true when the line between pt1 and pt2 crosses the seam . */
public boolean crossSeam ( ProjectionPoint pt1 , ProjectionPoint pt2 ) { } }

implementation:
// either point is infinite
if ( ProjectionPointImpl . isInfinite ( pt1 ) || ProjectionPointImpl . isInfinite ( pt2 ) ) return true ; // opposite signed X values , larger then 5000 km
return ( pt1 . getX ( ) * pt2 . getX ( ) < 0 ) && ( Math . abs ( pt1 . getX ( ) - pt2 . getX ( ) ) > 5000.0 ) ;


signature:
public class CoreTypeFcns { /** * Force an attribute value ( typically string )
 * to match a given basetype
 * @ param type expected type
 * @ param value actual value
 * @ return the value as made to conform to the expected type */
static public Object attributeConvert ( DapType type , Object value ) { } }

implementation:
if ( value == null ) return value ; if ( type . isEnumType ( ) ) { if ( value instanceof String ) { // See if the constant is an int vs enum const name
try { int ival = Integer . parseInt ( value . toString ( ) ) ; return ival ; } catch ( NumberFormatException nfe ) { // Assume it is an econst name ; try to locate it
DapEnumConst dec = ( ( DapEnumeration ) type ) . lookup ( value . toString ( ) ) ; if ( dec == null ) return value ; return dec . getValue ( ) ; } } else if ( value instanceof Long ) { return ( Long ) value ; } } else if ( value instanceof Long ) { return ( Long ) value ; } else if ( value instanceof Float ) { return ( Float ) value ; } else if ( value instanceof Double ) { return ( Double ) value ; } else if ( value instanceof Character ) { return ( ( Character ) value ) ; } return value ;


signature:
public class CoreTypeFcns { /** * / * Get the size of an equivalent java object ; zero if not defined */
static public int getJavaSize ( TypeSort atomtype ) { } }

implementation: switch ( atomtype ) { case Char : case Int8 : case UInt8 : return 1 ; case Int16 : case UInt16 : return 2 ; case Int32 : case UInt32 : return 4 ; case Int64 : case UInt64 : return 8 ; case Float32 : return 4 ; case Float64 : return 8 ; default : break ; } return 0 ;