signature:
public class CELexer { /** * Entry point for the scanner .
 * Returns the token identifier corresponding
 * to the next token and prepares to return the semantic value
 * of the token .
 * @ return the token identifier corresponding to the next token . */
public int yylex ( ) throws ParseException { } }

implementation:
int token ; int c = 0 ; token = 0 ; yytext . setLength ( 0 ) ; text . mark ( ) ; token = - 1 ; while ( token < 0 && ( c = text . read ( ) ) != EOS ) { if ( c <= ' ' || c == '\177' ) { /* whitespace : ignore */
} else if ( c == '"' || c == '\'' ) { int delim = c ; boolean more = true ; /* We have a string token ; will be reported as STRINGCONST */
while ( more && ( c = text . read ( ) ) > 0 ) { switch ( c ) { case EOS : throw new ParseException ( "Unterminated character or string constant" ) ; case '"' : more = ( delim != c ) ; break ; case '\'' : more = ( delim != c ) ; break ; case ESCAPE : /* Suppress for now
 if ( c > = ' 0 ' & & c < = ' 9 ' ) {
 int decimal = 0;
 do {
 decimal = decimal * 10 + ( c - ' 0 ' ) ;
 c = text . read ( ) ;
 } while ( c > = ' 0 ' & & c < = ' 9 ' ) ;
 c = decimal ;
 text . backup ( ) ;
 break ;
 } else */
switch ( c ) { case 'r' : c = '\r' ; break ; case 'n' : c = '\n' ; break ; case 'f' : c = '\f' ; break ; case 't' : c = '\t' ; break ; default : break ; } break ; default : break ; } if ( more ) yytext . append ( ( char ) c ) ; } token = CEParserImpl . Lexer . STRING ; } else if ( DELIMS . indexOf ( c ) >= 0 ) { // Single char delimiter
yytext . append ( ( char ) c ) ; token = c ; } else { // Assume we have a word or integer
yytext . append ( ( char ) c ) ; while ( ( c = text . read ( ) ) > 0 ) { if ( c <= ' ' || c == '\177' ) break ; // whitespace
if ( DELIMS . indexOf ( c ) >= 0 ) break ; if ( c == ESCAPE ) { c = text . read ( ) ; if ( c == EOS ) throw new ParseException ( "Unterminated backslash escape" ) ; } yytext . append ( ( char ) c ) ; } // pushback the delimiter
if ( c != EOS ) text . backup ( ) ; try { // See if this looks like an integer
long num = Long . parseLong ( yytext . toString ( ) ) ; token = CEParserImpl . Lexer . LONG ; } catch ( NumberFormatException nfe ) { token = CEParserImpl . Lexer . NAME ; } } } if ( c == EOS && token < 0 ) { token = 0 ; lval = null ; } else { lval = ( yytext . length ( ) == 0 ? ( String ) null : yytext . toString ( ) ) ; } if ( parsestate . getDebugLevel ( ) > 0 ) dumptoken ( token , ( String ) lval ) ; return token ; // Return the type of the token


signature:
public class CELexer { /** * Entry point for error reporting . Emits an error
 * in a user - defined way .
 * Part of Lexer interface .
 * @ param s The string for the error message . */
public void yyerror ( String s ) { } }

implementation: System . err . println ( "CEParserImpl.yyerror: " + s + "; parse failed at char: " + charno + "; near: " ) ; String context = getInput ( ) ; int show = ( context . length ( ) < CONTEXTLEN ? context . length ( ) : CONTEXTLEN ) ; System . err . println ( context . substring ( context . length ( ) - show ) + "^" ) ; new Exception ( ) . printStackTrace ( System . err ) ;


signature:
public class DtCoverageDataset { /** * Open a netcdf dataset , using NetcdfDataset . defaultEnhanceMode plus CoordSystems
 * and turn into a DtCoverageDataset .
 * @ param location netcdf dataset to open , using NetcdfDataset . acquireDataset ( ) .
 * @ return GridDataset
 * @ throws java . io . IOException on read error
 * @ see ucar . nc2 . dataset . NetcdfDataset # acquireDataset */
static public DtCoverageDataset open ( String location ) throws java . io . IOException { } }

implementation: DatasetUrl durl = DatasetUrl . findDatasetUrl ( location ) ; return open ( durl , NetcdfDataset . getDefaultEnhanceMode ( ) ) ;


signature:
public class DtCoverageDataset { /** * Open a netcdf dataset , using NetcdfDataset . defaultEnhanceMode plus CoordSystems
 * and turn into a DtCoverageDataset .
 * @ param durl netcdf dataset to open , using NetcdfDataset . acquireDataset ( ) .
 * @ param enhanceMode open netcdf dataset with this enhanceMode
 * @ return GridDataset
 * @ throws java . io . IOException on read error
 * @ see ucar . nc2 . dataset . NetcdfDataset # acquireDataset */
static public DtCoverageDataset open ( DatasetUrl durl , Set < NetcdfDataset . Enhance > enhanceMode ) throws java . io . IOException { } }

implementation: NetcdfDataset ds = ucar . nc2 . dataset . NetcdfDataset . acquireDataset ( null , durl , enhanceMode , - 1 , null , null ) ; return new DtCoverageDataset ( ds , null ) ;


signature:
public class DtCoverageDataset { /** * the name of the dataset is the last part of the location
 * @ return the name of the dataset */
public String getName ( ) { } }

implementation: String loc = ncd . getLocation ( ) ; int pos = loc . lastIndexOf ( '/' ) ; if ( pos < 0 ) pos = loc . lastIndexOf ( '\\' ) ; return ( pos < 0 ) ? loc : loc . substring ( pos + 1 ) ;


signature:
public class DtCoverageDataset { /** * find the named GeoGrid .
 * @ param fullName find this GeoGrid by full name
 * @ return the named GeoGrid , or null if not found */
public DtCoverage findGridByName ( String fullName ) { } }

implementation: for ( DtCoverage ggi : grids ) { if ( fullName . equals ( ggi . getFullName ( ) ) ) return ggi ; } return null ;


signature:
public class DtCoverageDataset { /** * find the named GeoGrid .
 * @ param shortName find this GeoGrid by short name
 * @ return the named GeoGrid , or null if not found */
public DtCoverage findGridByShortName ( String shortName ) { } }

implementation: for ( DtCoverage ggi : grids ) { if ( shortName . equals ( ggi . getShortName ( ) ) ) return ggi ; } return null ;


signature:
public class LambertConformalConicEllipse { /** * Create a String of the parameters .
 * @ return a String of the parameters */
public String paramsToString ( ) { } }

implementation: Formatter f = new Formatter ( ) ; f . format ( "origin lat,lon=%f,%f parellels=%f,%f earth=%s" , lat0deg , lon0deg , par1deg , par2deg , earth ) ; return f . toString ( ) ;


signature:
public class LambertConformalConicEllipse { /** * 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:
if ( ProjectionPointImpl . isInfinite ( pt1 ) || ProjectionPointImpl . isInfinite ( pt2 ) ) { return true ; } return false ; /* opposite signed X values , larger then 5000 km LOOK ? ? ? ?
 return ( pt1 . getX ( ) * pt2 . getX ( ) < 0)
 & & ( Math . abs ( pt1 . getX ( ) - pt2 . getX ( ) ) > 5000.0 ) ; */


signature:
public class LambertConformalConicEllipse { /** * public ProjectionPoint latLonToProj ( LatLonPoint latLon ,
 * ProjectionPointImpl result ) {
 * double toX , toY ;
 * double fromLat = latLon . getLatitude ( ) ;
 * double fromLon = latLon . getLongitude ( ) ;
 * fromLat = Math . toRadians ( fromLat ) ;
 * double dlon = LatLonPointImpl . lonNormal ( fromLon - lon0Degrees ) ;
 * double theta = n * Math . toRadians ( dlon ) ;
 * double tn = Math . pow ( Math . tan ( PI _ OVER _ 4 + fromLat / 2 ) , n ) ;
 * double r = earthRadiusTimesF / tn ;
 * toX = r * Math . sin ( theta ) ;
 * toY = rho - r * Math . cos ( theta ) ;
 * result . setLocation ( toX + falseEasting , toY + falseNorthing ) ;
 * return result ;
 * public Point2D . Double project ( double x , double y , Point2D . Double out ) {
 * double rho ;
 * if ( Math . abs ( Math . abs ( y ) - MapMath . HALFPI ) < 1e - 10)
 * rho = 0.0;
 * else
 * rho = c * ( spherical ?
 * Math . pow ( Math . tan ( MapMath . QUARTERPI + . 5 * y ) , - n ) :
 * Math . pow ( MapMath . tsfn ( y , Math . sin ( y ) , e ) , n ) ) ;
 * out . x = scaleFactor * ( rho * Math . sin ( x * = n ) ) ;
 * out . y = scaleFactor * ( rho0 - rho * Math . cos ( x ) ) ;
 * return out ; */
private double computeTheta ( double lon ) { } }

implementation: double dlon = LatLonPointImpl . lonNormal ( lon - lon0deg ) ; return n * Math . toRadians ( dlon ) ;


signature:
public class LambertConformalConicEllipse { /** * also see Snyder p 101 */
public ProjectionPoint latLonToProj ( LatLonPoint latLon , ProjectionPointImpl result ) { } }

implementation: double fromLat = Math . toRadians ( latLon . getLatitude ( ) ) ; double theta = computeTheta ( latLon . getLongitude ( ) ) ; double rho = 0.0 ; if ( Math . abs ( Math . abs ( fromLat ) - MapMath . HALFPI ) >= TOL ) { double term ; if ( isSpherical ) term = Math . pow ( Math . tan ( MapMath . QUARTERPI + .5 * fromLat ) , - n ) ; else term = Math . pow ( MapMath . tsfn ( fromLat , Math . sin ( fromLat ) , e ) , n ) ; rho = c * term ; } double toX = ( rho * Math . sin ( theta ) ) ; double toY = ( rho0 - rho * Math . cos ( theta ) ) ; result . setLocation ( totalScale * toX + falseEasting , totalScale * toY + falseNorthing ) ; return result ;


signature:
public class LambertConformalConicEllipse { /** * public LatLonPoint projToLatLon ( ProjectionPoint world ,
 * LatLonPointImpl result ) {
 * double toLat , toLon ;
 * double fromX = world . getX ( ) - falseEasting ;
 * double fromY = world . getY ( ) - falseNorthing ;
 * double rhop = rho ;
 * if ( n < 0 ) {
 * rhop * = - 1.0;
 * fromX * = - 1.0;
 * fromY * = - 1.0;
 * double yd = ( rhop - fromY ) ;
 * double theta = Math . atan2 ( fromX , yd ) ;
 * double r = Math . sqrt ( fromX * fromX + yd * yd ) ;
 * if ( n < 0.0 ) {
 * r * = - 1.0;
 * toLon = ( Math . toDegrees ( theta / n + lon0 ) ) ;
 * if ( Math . abs ( r ) < TOLERANCE ) {
 * toLat = ( ( n < 0.0)
 * ? - 90.0
 * : 90.0 ) ;
 * } else {
 * double rn = Math . pow ( EARTH _ RADIUS * F / r , 1 / n ) ;
 * toLat = Math . toDegrees ( 2.0 * Math . atan ( rn ) - Math . PI / 2 ) ;
 * result . setLatitude ( toLat ) ;
 * result . setLongitude ( toLon ) ;
 * return result ;
 * public Point2D . Double projectInverse ( double x , double y , Point2D . Double out ) {
 * x / = scaleFactor ;
 * y / = scaleFactor ;
 * double rho = MapMath . distance ( x , y = rho0 - y ) ;
 * if ( rho ! = 0 ) {
 * if ( n < 0.0 ) {
 * rho = - rho ;
 * x = - x ;
 * y = - y ;
 * if ( spherical )
 * out . y = 2.0 * Math . atan ( Math . pow ( c / rho , 1.0 / n ) ) - MapMath . HALFPI ;
 * else
 * out . y = MapMath . phi2 ( Math . pow ( rho / c , 1.0 / n ) , e ) ;
 * out . x = Math . atan2 ( x , y ) / n ;
 * } else {
 * out . x = 0.0;
 * out . y = n > 0.0 ? MapMath . HALFPI : - MapMath . HALFPI ;
 * return out ; */
public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) { } }

implementation:
double toLat , toLon ; double fromX = ( world . getX ( ) - falseEasting ) / totalScale ; // assumes cartesion coords in km
double fromY = ( world . getY ( ) - falseNorthing ) / totalScale ; fromY = rho0 - fromY ; double rho = MapMath . distance ( fromX , fromY ) ; if ( rho != 0 ) { if ( n < 0.0 ) { rho = - rho ; fromX = - fromX ; fromY = - fromY ; } if ( isSpherical ) toLat = 2.0 * Math . atan ( Math . pow ( c / rho , 1.0 / n ) ) - MapMath . HALFPI ; else toLat = MapMath . phi2 ( Math . pow ( rho / c , 1.0 / n ) , e ) ; toLon = Math . atan2 ( fromX , fromY ) / n ; // coverity [ swapped _ arguments ]
} else { toLon = 0.0 ; toLat = n > 0.0 ? MapMath . HALFPI : - MapMath . HALFPI ; } result . setLatitude ( Math . toDegrees ( toLat ) ) ; result . setLongitude ( Math . toDegrees ( toLon ) + lon0deg ) ; return result ;


signature:
public class LambertConformalConicEllipse { /** * proj + inv + proj = aea + lat _ 0 = 23.0 + lat _ 1 = 29.5 + lat _ 2 = 45.5 + a = 6378137.0 + rf = 298.257222101 + b = 6356752.31414 + lon _ 0 = - 96.0
 * Input X , Y : 1730692.593817677 1970917.991173046
 * results in :
 * Output Lon , Lat : - 75.649278 39.089117 */
private static void toProj ( ProjectionImpl p , double lat , double lon ) { } }

implementation: System . out . printf ( "lon,lat = %f %f%n" , lon , lat ) ; ProjectionPoint pt = p . latLonToProj ( lat , lon ) ; System . out . printf ( "x,y     = %f %f%n" , pt . getX ( ) , pt . getY ( ) ) ; LatLonPoint ll = p . projToLatLon ( pt ) ; System . out . printf ( "lon,lat = %f %f%n%n" , ll . getLongitude ( ) , ll . getLatitude ( ) ) ;


signature:
public class FileDSP { /** * A path is file if it has no base protocol or is file :
 * @ param location file : / or possibly an absolute path
 * @ param context Any parameters that may help to decide .
 * @ return true if this path appears to be processible by this DSP */
public boolean dspMatch ( String location , DapContext context ) { } }

implementation: try { XURI xuri = new XURI ( location ) ; if ( xuri . isFile ( ) ) { String path = xuri . getPath ( ) ; for ( String ext : EXTENSIONS ) { if ( path . endsWith ( ext ) ) return true ; } } } catch ( URISyntaxException use ) { return false ; } return false ;


signature:
public class FileDSP { /** * Extension to access a raw byte stream */
public FileDSP open ( byte [ ] rawdata ) throws DapException { } }

implementation: try { this . raw = rawdata ; ByteArrayInputStream stream = new ByteArrayInputStream ( this . raw ) ; ChunkInputStream rdr = new ChunkInputStream ( stream , RequestMode . DAP ) ; String document = rdr . readDMR ( ) ; byte [ ] serialdata = DapUtil . readbinaryfile ( rdr ) ; super . build ( document , serialdata , rdr . getRemoteByteOrder ( ) ) ; return this ; } catch ( IOException ioe ) { throw new DapException ( ioe ) . setCode ( DapCodes . SC_INTERNAL_SERVER_ERROR ) ; }


signature:
public class Alias { /** * Returns a clone of this < code > Alias < / code > .
 * See DAPNode . cloneDag ( )
 * @ param map track previously cloned nodes
 * @ return a clone of this < code > Alias < / code > . */
public DAPNode cloneDAG ( CloneMap map ) throws CloneNotSupportedException { } }

implementation: Alias a = ( Alias ) super . cloneDAG ( map ) ; a . aliasedToAttributeNamed = this . aliasedToAttributeNamed ; a . targetAttribute = ( Attribute ) cloneDAG ( map , this . targetAttribute ) ; a . targetVariable = ( BaseType ) cloneDAG ( map , this . targetVariable ) ; return a ;


signature:
public class DayOfMonthOfFixedYearDateTimeField { /** * Adapted from the package - private BasicDayOfMonthDateTimeField */
@ Override public int getMaximumValue ( ReadablePartial partial ) { } }

implementation:
if ( partial . isSupported ( DateTimeFieldType . monthOfYear ( ) ) ) { int month = partial . get ( DateTimeFieldType . monthOfYear ( ) ) ; return this . daysInMonth [ month - 1 ] ; // Months are 1 - based
} return this . getMaximumValue ( ) ;


signature:
public class DayOfMonthOfFixedYearDateTimeField { /** * Adapted from the package - private BasicDayOfMonthDateTimeField */
@ Override public int getMaximumValue ( ReadablePartial partial , int [ ] values ) { } }

implementation: int size = partial . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { if ( partial . getFieldType ( i ) == DateTimeFieldType . monthOfYear ( ) ) { int month = values [ i ] ; return this . daysInMonth [ month - 1 ] ; } } return this . getMaximumValue ( ) ;


signature:
public class HorizCoordSys2D { /** * return y , x ranges */
private Optional < List < RangeIterator > > computeBounds ( LatLonRect llbb , int horizStride ) { } }

implementation: synchronized ( this ) { if ( edges == null ) edges = new Edges ( ) ; } return edges . computeBoundsExhaustive ( llbb , horizStride ) ;


signature:
public class NcCollectionType { /** * wml2 : Collection */
public static CollectionType initCollection ( CollectionType collection , FeatureDatasetPoint fdPoint , List < VariableSimpleIF > dataVars ) throws IOException { } }

implementation:
// @ gml : id
String id = MarshallingUtil . createIdForType ( CollectionType . class ) ; collection . setId ( id ) ; // wml2 : metadata
NcDocumentMetadataPropertyType . initMetadata ( collection . addNewMetadata ( ) ) ; // wml2 : observationMember [ 0 . . * ]
StationTimeSeriesFeatureCollection stationFeatColl = getStationFeatures ( fdPoint ) ; try { while ( stationFeatColl . hasNext ( ) ) { StationTimeSeriesFeature stationFeat = stationFeatColl . next ( ) ; for ( VariableSimpleIF dataVar : dataVars ) { if ( dataVar . getDataType ( ) . isNumeric ( ) ) { // wml2 : observationMember
NcOMObservationPropertyType . initObservationMember ( collection . addNewObservationMember ( ) , stationFeat , dataVar ) ; } } } } finally { stationFeatColl . finish ( ) ; } return collection ;


signature:
public class NcOMObservationType { /** * wml2 : Collection / wml2 : observationMember / om : OM _ Observation */
public static OMObservationType initOmObservation ( OMObservationType omObservation , StationTimeSeriesFeature stationFeat , VariableSimpleIF dataVar ) throws IOException { } }

implementation:
// @ gml : id
String id = MarshallingUtil . createIdForType ( OMObservationType . class ) ; omObservation . setId ( id ) ; // om : phenomenonTime
NcTimeObjectPropertyType . initPhenomenonTime ( omObservation . addNewPhenomenonTime ( ) , stationFeat ) ; // om : resultTime
NcTimeInstantPropertyType . initResultTime ( omObservation . addNewResultTime ( ) ) ; // om : observedProperty
NcReferenceType . initObservedProperty ( omObservation . addNewObservedProperty ( ) , dataVar ) ; // om : procedure
NcOMProcessPropertyType . initProcedure ( omObservation . addNewProcedure ( ) ) ; // om : featureOfInterest
NcFeaturePropertyType . initFeatureOfInterest ( omObservation . addNewFeatureOfInterest ( ) , stationFeat ) ; // om : result
MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument . Factory . newInstance ( ) ; NcMeasurementTimeseriesType . initMeasurementTimeseries ( measurementTimeseriesDoc . addNewMeasurementTimeseries ( ) , stationFeat , dataVar ) ; omObservation . setResult ( measurementTimeseriesDoc ) ; return omObservation ;


signature: public class BufrReportPanel { private void doCheckHash ( Formatter f , MCollection dcm , boolean useIndex ) throws IOException { } }

implementation: f . format ( "Check Files for hash consistency%n" ) ; int [ ] accum = new int [ 4 ] ; TrackMessageTypes all = new TrackMessageTypes ( ) ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { String path = mfile . getPath ( ) ; if ( path . endsWith ( ".ncx" ) ) continue ; f . format ( "%n %s%n" , path ) ; try { doCheckHash ( mfile , f , all , accum ) ; } catch ( Throwable t ) { System . out . printf ( "FAIL on %s%n" , mfile . getPath ( ) ) ; t . printStackTrace ( ) ; } } f . format ( "%n================%nTotals countMess=%d countObs = %d%n" , accum [ 0 ] , accum [ 1 ] ) ; show ( all , f ) ;


signature: public class BufrReportPanel { private void doBufrSplitter ( Formatter f , MCollection dcm , boolean useIndex ) throws IOException { } }

implementation:
long start = System . currentTimeMillis ( ) ; String dirName = dcm . getRoot ( ) + "/split" ; // LOOK temp kludge
f . format ( "BufrSplitter on files in collection %s, write to %s%n" , dcm , dirName ) ; BufrSplitter2 splitter = new BufrSplitter2 ( dirName , f ) ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { String path = mfile . getPath ( ) ; if ( path . endsWith ( ".ncx" ) ) continue ; f . format ( "%n %s%n" , path ) ; System . out . printf ( " BufrSplitter on %s%n" , path ) ; long start2 = System . currentTimeMillis ( ) ; try { splitter . execute ( path ) ; long took2 = System . currentTimeMillis ( ) - start2 ; System . out . printf ( "  %s took %s msecs%n" , path , took2 ) ; } catch ( Throwable t ) { System . out . printf ( "FAIL on %s%n" , mfile . getPath ( ) ) ; t . printStackTrace ( ) ; } } splitter . exit ( ) ; long took = ( System . currentTimeMillis ( ) - start ) / 1000 ; System . out . printf ( "That took %s secs%n" , took ) ;


signature:
public class UspLightning1 { /** * 2006-10-23T17:59:39,18.415434 , - 93.480526 , - 26.8,1 */
int readAllData ( RandomAccessFile raf ) throws IOException , NumberFormatException , ParseException { } }

implementation:
ArrayList records = new ArrayList ( ) ; java . text . SimpleDateFormat isoDateTimeFormat = new java . text . SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss" ) ; isoDateTimeFormat . setTimeZone ( java . util . TimeZone . getTimeZone ( "GMT" ) ) ; // java . io . RandomAccessFile jraf = raf . getRandomAccessFile ( ) ;
raf . seek ( 0 ) ; int count = 0 ; while ( true ) { String line = raf . readLine ( ) ; if ( line == null ) break ; if ( line . startsWith ( MAGIC ) ) continue ; StringTokenizer stoker = new StringTokenizer ( line , ",\r\n" ) ; while ( stoker . hasMoreTokens ( ) ) { Date d = isoDateTimeFormat . parse ( stoker . nextToken ( ) ) ; double lat = Double . parseDouble ( stoker . nextToken ( ) ) ; double lon = Double . parseDouble ( stoker . nextToken ( ) ) ; double amp = Double . parseDouble ( stoker . nextToken ( ) ) ; String tok = stoker . nextToken ( ) ; int nstrikes = Integer . parseInt ( tok ) ; Strike s = new Strike ( d , lat , lon , amp , nstrikes ) ; records . add ( s ) ; if ( count < 10 ) System . out . println ( count + " " + isoDateTimeFormat . format ( d ) + " " + s ) ; } count ++ ; } System . out . println ( "processed " + count + " records" ) ; int n = records . size ( ) ; int [ ] shape = new int [ ] { n } ; dateArray = ( ArrayInt . D1 ) Array . factory ( DataType . INT , shape ) ; latArray = ( ArrayDouble . D1 ) Array . factory ( DataType . DOUBLE , shape ) ; lonArray = ( ArrayDouble . D1 ) Array . factory ( DataType . DOUBLE , shape ) ; ampArray = ( ArrayDouble . D1 ) Array . factory ( DataType . DOUBLE , shape ) ; nstrokesArray = ( ArrayInt . D1 ) Array . factory ( DataType . INT , shape ) ; for ( int i = 0 ; i < records . size ( ) ; i ++ ) { Strike strike = ( Strike ) records . get ( i ) ; dateArray . set ( i , strike . d ) ; latArray . set ( i , strike . lat ) ; lonArray . set ( i , strike . lon ) ; ampArray . set ( i , strike . amp ) ; nstrokesArray . set ( i , strike . n ) ; } return n ;


signature:
public class RangeDateSelector { /** * set values on the UI */
private void synchUI ( boolean slidersOK ) { } }

implementation: eventOK = false ; if ( slidersOK ) minSlider . setValue ( scale . world2slider ( dateRange . getStart ( ) ) ) ; minField . setValue ( dateRange . getStart ( ) ) ; if ( maxField != null ) { if ( slidersOK ) maxSlider . setValue ( scale . world2slider ( dateRange . getEnd ( ) ) ) ; maxField . setValue ( dateRange . getEnd ( ) ) ; } if ( durationField != null ) durationField . setValue ( dateRange . getDuration ( ) ) ; eventOK = true ;


signature:
public class Nc4ChunkingDefault { /** * make it easy to test by using dimension list */
public int [ ] computeUnlimitedChunking ( List < Dimension > dims , int elemSize ) { } }

implementation: int maxElements = defaultChunkSize / elemSize ; int [ ] result = fillRightmost ( convertUnlimitedShape ( dims ) , maxElements ) ; long resultSize = new Section ( result ) . computeSize ( ) ; if ( resultSize < minChunksize ) { maxElements = minChunksize / elemSize ; result = incrUnlimitedShape ( dims , result , maxElements ) ; } return result ;


signature:
public class CatalogWatcher { /** * Register the given directory with the WatchService */
public void register ( Path dir ) throws IOException { } }

implementation: if ( ! enable ) return ; WatchKey key = dir . register ( watcher , ENTRY_CREATE , ENTRY_DELETE , ENTRY_MODIFY ) ; if ( trace ) { Path prev = keys . get ( key ) ; if ( prev == null ) { System . out . format ( "CatalogWatcher register: %s%n" , dir ) ; } else { if ( ! dir . equals ( prev ) ) { System . out . format ( "update: %s -> %s%n" , prev , dir ) ; } } } keys . put ( key , dir ) ;


signature:
public class CatalogWatcher { /** * Process all events for keys queued to the watcher */
public void processEvents ( ) { } }

implementation:
if ( ! enable ) return ; for ( ; ; ) { // wait for key to be signalled
WatchKey key ; try { key = watcher . take ( ) ; } catch ( InterruptedException x ) { return ; } Path dir = keys . get ( key ) ; if ( dir == null ) { System . err . println ( "WatchKey not recognized!!" ) ; continue ; } for ( WatchEvent < ? > event : key . pollEvents ( ) ) { WatchEvent . Kind kind = event . kind ( ) ; // TBD - provide example of how OVERFLOW event is handled
if ( kind == OVERFLOW ) { continue ; } // Context for directory entry event is the file name of entry
WatchEvent < Path > ev = cast ( event ) ; Path name = ev . context ( ) ; Path child = dir . resolve ( name ) ; // print out event
System . out . format ( "%s: %s%n" , event . kind ( ) . name ( ) , child ) ; // if directory is created , and watching recursively , then
// register it and its sub - directories
if ( recursive && ( kind == ENTRY_CREATE ) ) { try { if ( Files . isDirectory ( child , NOFOLLOW_LINKS ) ) { registerAll ( child ) ; } } catch ( IOException x ) { // ignore to keep sample readbale
} } } // reset key and remove from set if directory no longer accessible
boolean valid = key . reset ( ) ; if ( ! valid ) { keys . remove ( key ) ; // all directories are inaccessible
if ( keys . isEmpty ( ) ) { break ; } } }


signature:
public class TimeHelper { /** * copy on modify */
public TimeHelper setReferenceDate ( CalendarDate refDate ) { } }

implementation: CalendarDateUnit cdUnit = CalendarDateUnit . of ( dateUnit . getCalendar ( ) , dateUnit . getCalendarField ( ) , refDate ) ; return new TimeHelper ( cdUnit ) ;


signature:
public class FeatureDatasetFactoryManager { /** * Register a class that implements a FeatureDatasetFactory .
 * @ param datatype scientific data type
 * @ param className name of class that implements FeatureDatasetFactory .
 * @ return true if successfully loaded */
static public boolean registerFactory ( FeatureType datatype , String className ) { } }

implementation:
try { Class c = Class . forName ( className ) ; registerFactory ( datatype , c ) ; return true ; } catch ( ClassNotFoundException e ) { // ok - these are optional
return false ; }


signature:
public class FeatureDatasetFactoryManager { /** * Register a class that implements a FeatureDatasetFactory .
 * @ param className name of class that implements FeatureDatasetFactory .
 * @ throws ClassNotFoundException if loading error */
static public void registerFactory ( String className ) throws ClassNotFoundException { } }

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


signature:
public class FeatureDatasetFactoryManager { /** * Register a class that implements a FeatureDatasetFactory .
 * Find out which type by calling getFeatureType ( ) .
 * @ param c class that implements FeatureDatasetFactory . */
static public void registerFactory ( Class c ) { } }

implementation:
if ( ! ( FeatureDatasetFactory . class . isAssignableFrom ( c ) ) ) throw new IllegalArgumentException ( "Class " + c . getName ( ) + " must implement FeatureDatasetFactory" ) ; // fail fast - get Instance
Object instance ; try { instance = c . newInstance ( ) ; } catch ( InstantiationException e ) { throw new IllegalArgumentException ( "FeatureDatasetFactoryManager Class " + c . getName ( ) + " cannot instantiate, probably need default Constructor" ) ; } catch ( IllegalAccessException e ) { throw new IllegalArgumentException ( "FeatureDatasetFactoryManager Class " + c . getName ( ) + " is not accessible" ) ; } // find out what type of Features
try { Method m = c . getMethod ( "getFeatureTypes" , new Class [ 0 ] ) ; FeatureType [ ] result = ( FeatureType [ ] ) m . invoke ( instance , new Object [ 0 ] ) ; for ( FeatureType ft : result ) { if ( userMode ) factoryList . add ( 0 , new Factory ( ft , c , ( FeatureDatasetFactory ) instance ) ) ; else factoryList . add ( new Factory ( ft , c , ( FeatureDatasetFactory ) instance ) ) ; } } catch ( Exception ex ) { throw new IllegalArgumentException ( "FeatureDatasetFactoryManager Class " + c . getName ( ) + " failed invoking getFeatureType()" , ex ) ; }


signature:
public class FeatureDatasetFactoryManager { /** * Open a dataset as a FeatureDataset .
 * @ param wantFeatureType open this kind of FeatureDataset ; may be null , which means search all factories .
 * If datatype is not null , only return correct FeatureDataset ( eg PointFeatureDataset for DataType . POINT ) .
 * @ param location URL or file location of the dataset . This may be a
 * < ol >
 * < li > thredds catalog # dataset ( with a thredds : prefix )
 * < li > cdmrFeature dataset ( with a cdmrFeature : prefix )
 * < li > cdmremote dataset ( with a cdmremote : prefix )
 * < li > collection dataset ( with a collection : prefix )
 * < li > file location for a CDM dataset opened with NetcdfDataset . acquireDataset ( )
 * < / ol >
 * @ param task user may cancel
 * @ param errlog place errors here , may not be null
 * @ return a subclass of FeatureDataset , or null if no suitable factory was found , message in errlog
 * @ throws java . io . IOException on io error */
static public FeatureDataset open ( FeatureType wantFeatureType , String location , ucar . nc2 . util . CancelTask task , Formatter errlog ) throws IOException { } }

implementation:
// special processing for thredds : datasets
if ( location . startsWith ( DataFactory . SCHEME ) ) { DataFactory . Result result = new DataFactory ( ) . openFeatureDataset ( wantFeatureType , location , task ) ; errlog . format ( "%s" , result . errLog ) ; if ( ! featureTypeOk ( wantFeatureType , result . featureType ) ) { errlog . format ( "wanted %s but dataset is of type %s%n" , wantFeatureType , result . featureType ) ; result . close ( ) ; return null ; } return result . featureDataset ; // special processing for cdmrFeature : datasets
} else if ( location . startsWith ( CdmrFeatureDataset . SCHEME ) ) { Optional < FeatureDataset > opt = CdmrFeatureDataset . factory ( wantFeatureType , location ) ; if ( opt . isPresent ( ) ) return opt . get ( ) ; errlog . format ( "%s" , opt . getErrorMessage ( ) ) ; return null ; // special processing for collection : datasets
} else if ( location . startsWith ( ucar . nc2 . ft . point . collection . CompositeDatasetFactory . SCHEME ) ) { String spec = location . substring ( CompositeDatasetFactory . SCHEME . length ( ) ) ; MFileCollectionManager dcm = MFileCollectionManager . open ( spec , spec , null , errlog ) ; // LOOK we dont have a name
return CompositeDatasetFactory . factory ( location , wantFeatureType , dcm , errlog ) ; } DatasetUrl durl = DatasetUrl . findDatasetUrl ( location ) ; // Cache ServiceType so we don ' t have to keep figuring it out
if ( durl . serviceType == null ) { // skip GRIB check for anything not a plain ole file
// check if its GRIB , may not have to go through NetcdfDataset
Optional < FeatureDatasetCoverage > opt = CoverageDatasetFactory . openGrib ( location ) ; if ( opt . isPresent ( ) ) { // its a GRIB file
return opt . get ( ) ; } else if ( ! opt . getErrorMessage ( ) . startsWith ( CoverageDatasetFactory . NOT_GRIB_FILE ) && ! opt . getErrorMessage ( ) . startsWith ( CoverageDatasetFactory . NO_GRIB_CLASS ) ) { errlog . format ( "%s%n" , opt . getErrorMessage ( ) ) ; // its a GRIB file with an error
return null ; } } // otherwise open as NetcdfDataset and run it through the FeatureDatasetFactories
NetcdfDataset ncd = NetcdfDataset . acquireDataset ( durl , true , task ) ; FeatureDataset fd = wrap ( wantFeatureType , ncd , task , errlog ) ; if ( fd == null ) ncd . close ( ) ; return fd ;


signature:
public class FeatureDatasetFactoryManager { /** * Wrap a NetcdfDataset as a FeatureDataset .
 * @ param wantFeatureType open this kind of FeatureDataset ; may be null , which means search all factories .
 * If datatype is not null , only return FeatureDataset with objects of that type
 * @ param ncd the NetcdfDataset to wrap as a FeatureDataset
 * @ param task user may cancel
 * @ param errlog place errors here , may not be null
 * @ return a subclass of FeatureDataset , or null if no suitable factory was found
 * @ throws java . io . IOException on io error */
static public FeatureDataset wrap ( FeatureType wantFeatureType , NetcdfDataset ncd , ucar . nc2 . util . CancelTask task , Formatter errlog ) throws IOException { } }

implementation:
if ( debug ) System . out . println ( "wrap " + ncd . getLocation ( ) + " want = " + wantFeatureType ) ; // the case where we dont know what type it is
if ( ( wantFeatureType == null ) || ( wantFeatureType == FeatureType . ANY ) ) { return wrapUnknown ( ncd , task , errlog ) ; } // find a Factory that claims this dataset by passing back an " analysis result " object
Object analysis = null ; FeatureDatasetFactory useFactory = null ; for ( Factory fac : factoryList ) { if ( ! featureTypeOk ( wantFeatureType , fac . featureType ) ) continue ; if ( debug ) System . out . println ( " wrap try factory " + fac . factory . getClass ( ) . getName ( ) ) ; analysis = fac . factory . isMine ( wantFeatureType , ncd , errlog ) ; if ( analysis != null ) { useFactory = fac . factory ; break ; } } if ( null == useFactory ) { errlog . format ( "**Failed to find FeatureDatasetFactory for= %s datatype=%s%n" , ncd . getLocation ( ) , wantFeatureType ) ; return null ; } // this call must be thread safe - done by implementation
return useFactory . open ( wantFeatureType , ncd , analysis , task , errlog ) ;


signature:
public class FeatureDatasetFactoryManager { /** * Determine if factory type matches wanted feature type .
 * @ param want want this FeatureType
 * @ param facType factory is of this type
 * @ return true if match */
static public boolean featureTypeOk ( FeatureType want , FeatureType facType ) { } }

implementation:
if ( want == null ) return true ; if ( want == facType ) return true ; if ( want == FeatureType . ANY_POINT ) { return facType . isPointFeatureType ( ) ; } if ( facType == FeatureType . ANY_POINT ) { return want . isPointFeatureType ( ) ; } if ( want == FeatureType . COVERAGE ) { return facType . isCoverageFeatureType ( ) ; } if ( want == FeatureType . GRID ) { // for backwards compatibility
return facType . isCoverageFeatureType ( ) ; } if ( want == FeatureType . SIMPLE_GEOMETRY ) { return facType . isCoverageFeatureType ( ) ; } if ( want == FeatureType . UGRID ) { return facType . isUnstructuredGridFeatureType ( ) ; } return false ;


signature:
public class FeatureDatasetFactoryManager { /** * Try to determine the feature type of the dataset , by examining its metadata .
 * @ param ncd the dataset
 * @ return FeatureType if found , else null */
static public FeatureType findFeatureType ( NetcdfFile ncd ) { } }

implementation:
// search for explicit featureType global attribute
String cdm_datatype = ncd . findAttValueIgnoreCase ( null , CF . FEATURE_TYPE , null ) ; if ( cdm_datatype == null ) cdm_datatype = ncd . findAttValueIgnoreCase ( null , "cdm_data_type" , null ) ; if ( cdm_datatype == null ) cdm_datatype = ncd . findAttValueIgnoreCase ( null , "cdm_datatype" , null ) ; if ( cdm_datatype == null ) cdm_datatype = ncd . findAttValueIgnoreCase ( null , "thredds_data_type" , null ) ; if ( cdm_datatype != null ) { for ( FeatureType ft : FeatureType . values ( ) ) if ( cdm_datatype . equalsIgnoreCase ( ft . name ( ) ) ) { if ( debug ) System . out . println ( " wrapUnknown found cdm_datatype " + cdm_datatype ) ; return ft ; } } CF . FeatureType cff = CF . FeatureType . getFeatureTypeFromGlobalAttribute ( ncd ) ; if ( cff != null ) return CF . FeatureType . convert ( cff ) ; return null ;


signature:
public class HTTPRandomAccessFile { /** * Read directly from file , without going through the buffer .
 * All reading goes through here or readToByteChannel ;
 * @ param pos start here in the file
 * @ param buff put data into this buffer
 * @ param offset buffer offset
 * @ param len this number of bytes
 * @ return actual number of bytes read
 * @ throws IOException on io error */
@ Override protected int read_ ( long pos , byte [ ] buff , int offset , int len ) throws IOException { } }

implementation: long end = pos + len - 1 ; if ( end >= total_length ) end = total_length - 1 ; if ( debug ) System . out . println ( " HTTPRandomAccessFile bytes=" + pos + "-" + end + ": " ) ; try ( HTTPMethod method = HTTPFactory . Get ( session , url ) ) { method . setFollowRedirects ( true ) ; method . setRange ( pos , end ) ; doConnect ( method ) ; int code = method . getStatusCode ( ) ; if ( code != 206 ) throw new IOException ( "Server does not support Range requests, code= " + code ) ; String s = method . getResponseHeader ( "Content-Length" ) . getValue ( ) ; if ( s == null ) throw new IOException ( "Server does not send Content-Length header" ) ; int readLen = Integer . parseInt ( s ) ; readLen = Math . min ( len , readLen ) ; InputStream is = method . getResponseAsStream ( ) ; readLen = copy ( is , buff , offset , readLen ) ; return readLen ; }


signature:
public class ConfigCatalogHtmlWriter { /** * Write an Catalog to the HttpServletResponse , return the size in bytes of the catalog written to the response .
 * @ param req the HttpServletRequest
 * @ param res the HttpServletResponse .
 * @ param cat the InvCatalogImpl to write to the HttpServletResponse .
 * @ param isLocalCatalog indicates whether this catalog is local to this server .
 * @ return the size in bytes of the catalog written to the HttpServletResponse .
 * @ throws IOException if problems writing the response . */
public int writeCatalog ( HttpServletRequest req , HttpServletResponse res , Catalog cat , boolean isLocalCatalog ) throws IOException { } }

implementation:
String catHtmlAsString = convertCatalogToHtml ( cat , isLocalCatalog ) ; // Once this header is set , we know the encoding , and thus the actual
// number of * bytes * , not characters , to encode
res . setContentType ( ContentType . html . getContentHeader ( ) ) ; int len = ServletUtil . setResponseContentLength ( res , catHtmlAsString ) ; if ( ! req . getMethod ( ) . equals ( "HEAD" ) ) { PrintWriter writer = res . getWriter ( ) ; writer . write ( catHtmlAsString ) ; writer . flush ( ) ; } return len ;


signature:
public class ConfigCatalogHtmlWriter { /** * Write a catalog in HTML , make it look like a file directory .
 * @ param cat catalog to write */
String convertCatalogToHtml ( Catalog cat , boolean isLocalCatalog ) { } }

implementation:
StringBuilder sb = new StringBuilder ( 10000 ) ; String uri = cat . getUriString ( ) ; if ( uri == null ) uri = cat . getName ( ) ; if ( uri == null ) uri = "unknown" ; String catname = Escape . html ( uri ) ; // Render the page header
sb . append ( getHtmlDoctypeAndOpenTag ( ) ) ; // "  \ n " ) ;
sb . append ( "\r\n" ) ; sb . append ( "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>" ) ; sb . append ( "<title>" ) ; // if ( cat . isStatic ( ) )
// sb . append ( " TdsStaticCatalog " ) . append ( catname ) ; / / for searching
// else
sb . append ( "Catalog " ) . append ( catname ) ; sb . append ( "</title>\r\n" ) ; sb . append ( getTdsCatalogCssLink ( ) ) . append ( "\n" ) ; sb . append ( this . getGoogleTrackingContent ( ) ) ; sb . append ( "\r\n" ) ; sb . append ( "" ) ; sb . append ( "
" ) ; // Logo
// String logoUrl = this . htmlConfig . getInstallLogoUrl ( ) ;
String logoUrl = htmlConfig . prepareUrlStringForHtml ( htmlConfig . getInstallLogoUrl ( ) ) ; if ( logoUrl != null ) { sb . append ( "\n" ) ; } sb . append ( " Catalog " ) . append ( catname ) ; sb . append ( "
" ) ; sb . append ( "
" ) ; sb . append ( "
\r\n" ) ; // Render the column headings
sb . append ( "
\r\n" ) ; sb . append ( "" ) ; sb . append ( "Dataset" ) ; sb . append ( "	\r\n" ) ; sb . append ( "" ) ; sb . append ( "Size" ) ; sb . append ( "	\r\n" ) ; sb . append ( "" ) ; sb . append ( "Last Modified" ) ; sb . append ( "	\r\n" ) ; sb . append ( "
" ) ; // Recursively render the datasets
doDatasets ( cat , cat . getDatasetsLocal ( ) , sb , false , 0 , isLocalCatalog ) ; // Render the page footer
sb . append ( "
\r\n" ) ; sb . append ( "
" ) ; appendSimpleFooter ( sb ) ; sb . append ( "\r\n" ) ; sb . append ( "\r\n" ) ; return ( sb . toString ( ) ) ;


signature:
public class ConfigCatalogHtmlWriter { /** * public static final String UNIDATA _ CSS */
public String getUserCSS ( ) { } }

implementation: return new StringBuilder ( ) . append ( "<link rel='stylesheet' href='" ) . append ( this . htmlConfig . prepareUrlStringForHtml ( this . htmlConfig . getPageCssUrl ( ) ) ) . append ( "' type='text/css' >" ) . toString ( ) ;


signature:
public class ConfigCatalogHtmlWriter { /** * public static final String UNIDATA _ HEAD */
public String getUserHead ( ) { } }

implementation:
return new StringBuilder ( ) . append ( "

\n" ) . append ( "  \n" ) . append ( "
" ) . append ( this . tdsContext . getWebappDisplayName ( ) ) . append ( "
\n" ) . append ( "

\n" ) . toString ( ) ;


signature:
public class CatalogManager { /** * If a catalog exists and is allowed ( not filtered out ) for the given path , return
 * the catalog as an Catalog . Otherwise , return null .
 * The validity of the returned catalog is not guaranteed . Use Catalog . check ( ) to
 * check that the catalog is valid .
 * @ param path the path for the requested catalog .
 * @ param baseURI the base URI for the catalog , used to resolve relative URLs .
 * @ return the requested Catalog , or null if catalog does not exist or is not allowed . */
public Catalog getCatalog ( String path , URI baseURI ) throws IOException { } }

implementation:
if ( path == null ) return null ; String workPath = path ; if ( workPath . startsWith ( "/" ) ) workPath = workPath . substring ( 1 ) ; // Check if its a CatalogBuilder or ConfigCatalog
Object dyno = makeDynamicCatalog ( workPath , baseURI ) ; if ( dyno != null ) { CatalogBuilder catBuilder ; if ( dyno instanceof CatalogBuilder ) { catBuilder = ( CatalogBuilder ) dyno ; } else { ConfigCatalog configCatalog = ( ConfigCatalog ) dyno ; catBuilder = configCatalog . makeCatalogBuilder ( ) ; // turn it back into mutable object
} addGlobalServices ( catBuilder ) ; return catBuilder . makeCatalog ( ) ; } // check cache and read if needed
ConfigCatalog configCatalog = ccc . get ( workPath ) ; if ( configCatalog == null ) return null ; CatalogBuilder catBuilder = configCatalog . makeCatalogBuilder ( ) ; addGlobalServices ( catBuilder ) ; return catBuilder . makeCatalog ( ) ;


signature:
public class CatalogManager { /** * barfola on the return type */
private Object makeDynamicCatalog ( String path , URI baseURI ) throws IOException { } }

implementation:
boolean isLatest = path . endsWith ( "/latest.xml" ) ; // strip off the filename
int pos = path . lastIndexOf ( "/" ) ; String workPath = ( pos >= 0 ) ? path . substring ( 0 , pos ) : path ; String filename = ( pos > 0 ) ? path . substring ( pos + 1 ) : path ; // now look through the data roots for a maximal match
DataRootManager . DataRootMatch match = dataRootManager . findDataRootMatch ( workPath ) ; if ( match == null ) return null ; // Feature Collection
if ( match . dataRoot . getFeatureCollection ( ) != null ) { InvDatasetFeatureCollection fc = featureCollectionCache . get ( match . dataRoot . getFeatureCollection ( ) ) ; if ( isLatest ) return fc . makeLatest ( match . remaining , path , baseURI ) ; else return fc . makeCatalog ( match . remaining , path , baseURI ) ; } // DatasetScan
DatasetScan dscan = match . dataRoot . getDatasetScan ( ) ; if ( dscan != null ) { if ( log . isDebugEnabled ( ) ) log . debug ( "makeDynamicCatalog(): Calling DatasetScan.makeCatalogForDirectory( " + baseURI + ", " + path + ")." ) ; CatalogBuilder cat ; if ( isLatest ) cat = dscan . makeCatalogForLatest ( workPath , baseURI ) ; else cat = dscan . makeCatalogForDirectory ( workPath , baseURI ) ; if ( null == cat ) log . error ( "makeDynamicCatalog(): DatasetScan.makeCatalogForDirectory failed = " + workPath ) ; return cat ; } // CatalogScan
CatalogScan catScan = match . dataRoot . getCatalogScan ( ) ; if ( catScan != null ) { if ( ! filename . equalsIgnoreCase ( CatalogScan . CATSCAN ) ) { // its an actual catalog
return catScan . getCatalog ( tdsContext . getThreddsDirectory ( ) , match . remaining , filename , ccc ) ; } if ( log . isDebugEnabled ( ) ) log . debug ( "makeDynamicCatalog(): Calling CatalogScan.makeCatalogForDirectory( " + baseURI + ", " + path + ")." ) ; CatalogBuilder cat = catScan . makeCatalogFromDirectory ( tdsContext . getThreddsDirectory ( ) , match . remaining , baseURI ) ; if ( null == cat ) log . error ( "makeDynamicCatalog(): CatalogScan.makeCatalogForDirectory failed = " + workPath ) ; return cat ; } log . warn ( "makeDynamicCatalog() failed for =" + workPath + " request path= " + path ) ; return null ;


signature:
public class CatalogManager { /** * rigamorole to modify invariant catalogs ; we may need to add global services */
private void addGlobalServices ( CatalogBuilder cat ) { } }

implementation:
// look for datasets that want to use global services
Set < String > allServiceNames = new HashSet < > ( ) ; findServices ( cat . getDatasets ( ) , allServiceNames ) ; // all services used
if ( ! allServiceNames . isEmpty ( ) ) { List < Service > servicesMissing = new ArrayList < > ( ) ; // all services missing
for ( String name : allServiceNames ) { if ( cat . hasServiceInDataset ( name ) ) continue ; Service s = globalServices . findGlobalService ( name ) ; if ( s != null ) servicesMissing . add ( s ) ; } servicesMissing . forEach ( cat :: addService ) ; } // look for datasets that want to use standard services
for ( DatasetBuilder node : cat . getDatasets ( ) ) { String sname = ( String ) node . getFldOrInherited ( Dataset . ServiceName ) ; String urlPath = ( String ) node . get ( Dataset . UrlPath ) ; String ftypeS = ( String ) node . getFldOrInherited ( Dataset . FeatureType ) ; if ( sname == null && urlPath != null && ftypeS != null ) { Service s = globalServices . getStandardServices ( ftypeS ) ; if ( s != null ) { node . put ( Dataset . ServiceName , s . getName ( ) ) ; cat . addService ( s ) ; } } }


signature:
public class HttpClientManager { /** * initialize the HttpClient layer .
 * @ param provider CredentialsProvider .
 * @ param userAgent Content of User - Agent header , may be null */
static public void init ( CredentialsProvider provider , String userAgent ) { } }

implementation: if ( provider != null ) try { HTTPSession . setGlobalCredentialsProvider ( provider ) ; } catch ( HTTPException e ) { throw new IllegalArgumentException ( e ) ; } if ( userAgent != null ) HTTPSession . setGlobalUserAgent ( userAgent + "/NetcdfJava/HttpClient" ) ; else HTTPSession . setGlobalUserAgent ( "NetcdfJava/HttpClient" ) ;


signature:
public class HttpClientManager { /** * Get the content from a url . For large returns , its better to use getResponseAsStream .
 * @ param session use this session , if null , create a new one
 * @ param urlencoded url as a String
 * @ return contents of url as a String
 * @ throws java . io . IOException on error */
@ Urlencoded @ Deprecated public static String getContentAsString ( HTTPSession session , String urlencoded ) throws IOException { } }

implementation: HTTPSession useSession = session ; try { if ( useSession == null ) useSession = HTTPFactory . newSession ( urlencoded ) ; try ( HTTPMethod m = HTTPFactory . Get ( useSession , urlencoded ) ) { m . execute ( ) ; return m . getResponseAsString ( ) ; } } finally { if ( ( session == null ) && ( useSession != null ) ) useSession . close ( ) ; }


signature:
public class HttpClientManager { /** * Put content to a url , using HTTP PUT . Handles one level of 302 redirection .
 * @ param urlencoded url as a String
 * @ param content PUT this content at the given url .
 * @ return the HTTP status return code
 * @ throws java . io . IOException on error */
public static int putContent ( String urlencoded , String content ) throws IOException { } }

implementation:
try ( HTTPMethod m = HTTPFactory . Put ( urlencoded ) ) { m . setRequestContent ( new StringEntity ( content , "application/text" , "UTF-8" ) ) ; m . execute ( ) ; int resultCode = m . getStatusCode ( ) ; // followRedirect wont work for PUT
if ( resultCode == 302 ) { String redirectLocation ; Header locationHeader = m . getResponseHeader ( "location" ) ; if ( locationHeader != null ) { redirectLocation = locationHeader . getValue ( ) ; resultCode = putContent ( redirectLocation , content ) ; } } return resultCode ; }


signature: public class HttpClientManager { static public String getUrlContentsAsString ( String urlencoded , int maxKbytes ) throws IOException { } }

implementation: return getUrlContentsAsString ( null , urlencoded , maxKbytes ) ;


signature:
public class Operator { /** * Performs the Relatove Operation ( RelOp ) indicated by the
 * parameter < code > oprtr < / code > on the 2 passed BaseTypes if
 * appropriate .
 * Obviously some type don ' t compare logically , such as asking if
 * String is less than a Float . For these non sensical operations
 * and < code > InvalidOperatorException < / code > is thrown .
 * @ param oprtr The operatoration to perform as defined in < code >
 * opendap . servers . parsers . ExprParserConstants < / code >
 * @ param lop A BaseType to be used as the left operand .
 * @ param rop A BaseType to be used as the right operand .
 * @ return True is the operation evaluates as true , flase otherwise .
 * @ throws InvalidOperatorException
 * @ throws RegExpException
 * @ throws SBHException
 * @ see opendap . servers . parsers . ExprParserConstants */
public static boolean op ( int oprtr , BaseType lop , BaseType rop ) throws InvalidOperatorException , RegExpException , SBHException { } }

implementation: if ( lop instanceof DByte ) return ( op ( oprtr , ( DByte ) lop , rop ) ) ; else if ( lop instanceof DFloat32 ) return ( op ( oprtr , ( DFloat32 ) lop , rop ) ) ; else if ( lop instanceof DFloat64 ) return ( op ( oprtr , ( DFloat64 ) lop , rop ) ) ; else if ( lop instanceof DInt16 ) return ( op ( oprtr , ( DInt16 ) lop , rop ) ) ; else if ( lop instanceof DInt32 ) return ( op ( oprtr , ( DInt32 ) lop , rop ) ) ; else if ( lop instanceof DString ) return ( op ( oprtr , ( DString ) lop , rop ) ) ; else if ( lop instanceof DUInt16 ) return ( op ( oprtr , ( DUInt16 ) lop , rop ) ) ; else if ( lop instanceof DUInt32 ) return ( op ( oprtr , ( DUInt32 ) lop , rop ) ) ; else if ( lop instanceof DURL ) return ( op ( oprtr , ( DURL ) lop , rop ) ) ; else throw new InvalidOperatorException ( "Binary operations not supported for the type:" + lop . getClass ( ) ) ;


signature: public class Operator { private static String opErrorMsg ( int oprtr , String lop , String rop ) { } }

implementation: switch ( oprtr ) { case LESS : return ( "Less Than (<) Operator not valid between types" + lop + "and" + rop + "." ) ; case LESS_EQL : return ( "Less Than Equal To (<=) Operator not valid between types" + lop + "and" + rop + "." ) ; case GREATER : return ( "Greater Than (>) Operator not valid between types" + lop + "and" + rop + "." ) ; case GREATER_EQL : return ( "Greater Than Equal To (>=) Operator not valid between types" + lop + "and" + rop + "." ) ; case EQUAL : return ( "Equal To (==) Operator not valid between types" + lop + "and" + rop + "." ) ; case NOT_EQUAL : return ( "Not Equal To (!=) Operator not valid between types" + lop + "and" + rop + "." ) ; case REGEXP : return ( "Regular Expression cannot beevaluated between types" + lop + "and" + rop + "." ) ; default : return ( "Unknown Operator Requested! RTFM!" ) ; }


signature: public class Operator { private static boolean op ( int oprtr , DFloat32 lop , DByte rop ) throws InvalidOperatorException { } }

implementation: switch ( oprtr ) { case LESS : return ( lop . getValue ( ) < rop . getValue ( ) ) ; case LESS_EQL : return ( lop . getValue ( ) <= rop . getValue ( ) ) ; case GREATER : return ( lop . getValue ( ) > rop . getValue ( ) ) ; case GREATER_EQL : return ( lop . getValue ( ) >= rop . getValue ( ) ) ; case EQUAL : return ( lop . getValue ( ) == rop . getValue ( ) ) ; case NOT_EQUAL : return ( lop . getValue ( ) != rop . getValue ( ) ) ; case REGEXP : throw new InvalidOperatorException ( opErrorMsg ( oprtr , lop . getTypeName ( ) , rop . getTypeName ( ) ) ) ; default : throw new InvalidOperatorException ( "Unknown Operator Requested! RTFM!" ) ; }


signature: public class Operator { private static boolean op ( int oprtr , DUInt16 lop , DByte rop ) throws InvalidOperatorException { } }

implementation: int lval = ( ( int ) lop . getValue ( ) ) & 0xFFFF ; switch ( oprtr ) { case LESS : return ( lval < rop . getValue ( ) ) ; case LESS_EQL : return ( lval <= rop . getValue ( ) ) ; case GREATER : return ( lval > rop . getValue ( ) ) ; case GREATER_EQL : return ( lval >= rop . getValue ( ) ) ; case EQUAL : return ( lval == rop . getValue ( ) ) ; case NOT_EQUAL : return ( lval != rop . getValue ( ) ) ; case REGEXP : throw new InvalidOperatorException ( opErrorMsg ( oprtr , lop . getTypeName ( ) , rop . getTypeName ( ) ) ) ; default : throw new InvalidOperatorException ( "Unknown Operator Requested! RTFM!" ) ; }


signature:
public class D4TSServlet { /** * Capabilities processors */
@ Override protected void doFavicon ( String icopath , DapContext cxt ) throws IOException { } }

implementation: DapRequest drq = ( DapRequest ) cxt . get ( DapRequest . class ) ; String favfile = getResourcePath ( drq , icopath ) ; if ( favfile != null ) { try ( FileInputStream fav = new FileInputStream ( favfile ) ; ) { byte [ ] content = DapUtil . readbinaryfile ( fav ) ; OutputStream out = drq . getOutputStream ( ) ; out . write ( content ) ; } }


signature:
public class D4TSServlet { /** * Isolate front page builder so we can override if desired for testing .
 * @ param drq
 * @ param cxt
 * @ return FrontPage object */
protected FrontPage getFrontPage ( DapRequest drq , DapContext cxt ) throws DapException { } }

implementation:
if ( this . defaultroots == null ) { // Figure out the directory containing
// the files to display .
String pageroot ; pageroot = getResourcePath ( drq , "" ) ; if ( pageroot == null ) throw new DapException ( "Cannot locate resources directory" ) ; this . defaultroots = new ArrayList < > ( ) ; this . defaultroots . add ( new Root ( "testfiles" , pageroot ) ) ; } return new FrontPage ( this . defaultroots , drq ) ;


signature: public class InvDatasetFcGrib { private String makeCollectionShortName ( String collectionName ) { } }

implementation: String topCollectionName = config . collectionName ; if ( collectionName . equals ( topCollectionName ) ) return topCollectionName ; if ( collectionName . startsWith ( topCollectionName ) ) { return name + collectionName . substring ( topCollectionName . length ( ) ) ; } return collectionName ;


signature:
public class InvDatasetFcGrib { /** * this catalog lists the individual files comprising the collection . */
protected void addFileDatasets ( DatasetBuilder parent , String parentPath , GribCollectionImmutable fromGc ) throws IOException { } }

implementation:
DatasetBuilder filesParent = new DatasetBuilder ( parent ) ; filesParent . setName ( "Raw Files" ) ; filesParent . addServiceToCatalog ( downloadService ) ; ThreddsMetadata tmi = filesParent . getInheritableMetadata ( ) ; tmi . set ( Dataset . ServiceName , downloadService . getName ( ) ) ; parent . addDataset ( filesParent ) ; List < MFile > mfiles = new ArrayList < > ( fromGc . getFiles ( ) ) ; Collections . sort ( mfiles ) ; // if not increasing ( i . e . we WANT newest file listed first ) , reverse sort
if ( ! this . config . getSortFilesAscending ( ) ) { Collections . reverse ( mfiles ) ; } for ( MFile mfile : mfiles ) { DatasetBuilder ds = new DatasetBuilder ( parent ) ; ds . setName ( mfile . getName ( ) ) ; String lpath = parentPath + "/" + FILES + "/" + mfile . getName ( ) ; ds . put ( Dataset . UrlPath , lpath ) ; ds . put ( Dataset . Id , lpath ) ; ds . put ( Dataset . DataSize , mfile . getLength ( ) ) ; if ( mfile . getLastModified ( ) > 0 ) { CalendarDate cdate = CalendarDate . of ( mfile . getLastModified ( ) ) ; ds . put ( Dataset . Dates , new DateType ( cdate ) . setType ( "modified" ) ) ; } filesParent . addDataset ( ds ) ; }


signature:
public class InvDatasetFcGrib { /** * see top javadoc for possible URLs */
@ Override public CatalogBuilder makeCatalog ( String match , String reqPath , URI catURI ) throws IOException { } }

implementation:
StateGrib localState = ( StateGrib ) checkState ( ) ; if ( localState == null ) return null ; // not ready yet maybe
if ( localState . gribCollection == null ) return null ; // not ready yet maybe
try { // case 0
if ( ( match == null ) || ( match . length ( ) == 0 ) ) { return makeCatalogTop ( catURI , localState ) ; // top catalog : uses state . top previously made in checkState ( )
} // case 1
if ( localState . gribCollection instanceof PartitionCollectionImmutable ) { String [ ] paths = match . split ( "/" ) ; PartitionCollectionImmutable pc = ( PartitionCollectionImmutable ) localState . gribCollection ; return makeCatalogFromPartition ( pc , paths , 0 , catURI ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; logger . error ( "Error making catalog for " + configPath , e ) ; } return null ;


signature: public class InvDatasetFcGrib { @ Override protected DatasetBuilder makeDatasetTop ( URI catURI , State state ) throws IOException { } }

implementation: StateGrib localState = ( StateGrib ) state ; return makeDatasetFromCollection ( catURI , true , null , null , localState . gribCollection ) ;


signature:
public class InvDatasetFcGrib { /** * LOOK how come we arent using MetadataExtractor ? ? */
private ThreddsMetadata . GeospatialCoverage extractGeospatial ( GribCollectionImmutable . GroupGC group ) { } }

implementation: GdsHorizCoordSys gdsCoordSys = group . getGdsHorizCoordSys ( ) ; LatLonRect llbb = GridCoordSys . getLatLonBoundingBox ( gdsCoordSys . proj , gdsCoordSys . getStartX ( ) , gdsCoordSys . getStartY ( ) , gdsCoordSys . getEndX ( ) , gdsCoordSys . getEndY ( ) ) ; double dx = 0.0 , dy = 0.0 ; if ( gdsCoordSys . isLatLon ( ) ) { dx = Math . abs ( gdsCoordSys . dx ) ; dy = Math . abs ( gdsCoordSys . dy ) ; } return new ThreddsMetadata . GeospatialCoverage ( llbb , null , dx , dy ) ;


signature:
public class InvDatasetFcGrib { /** * returns visitor . obtain ( ) , either a GridDataset or a NetcdfDataset */
private Object findDataset ( String matchPath , GribCollectionImmutable topCollection , DatasetCreator visit ) throws IOException { } }

implementation: String [ ] paths = matchPath . split ( "/" ) ; List < String > pathList = ( paths . length < 1 ) ? new ArrayList < > ( ) : Arrays . asList ( paths ) ; DatasetAndGroup dg = findDatasetAndGroup ( pathList , topCollection ) ; if ( dg != null ) return visit . obtain ( topCollection , dg . ds , dg . group ) ; if ( ! ( topCollection instanceof PartitionCollectionImmutable ) ) return null ; PartitionCollectionImmutable pc = ( PartitionCollectionImmutable ) topCollection ; return findDatasetPartition ( visit , pc , pathList ) ;


signature:
public class InvDatasetFcGrib { /** * / * case 0 : path / dataset ( dataset = " " ) / / single dataset
 * case 1 : path / dataset ( dataset = BEST , TWOD , TP ) / / single group
 * case 2 : path / dataset / groupName / / dataset with group
 * case 3 : path / groupName / / single dataset not sure this is actually used ? ? */
private DatasetAndGroup findDatasetAndGroup ( List < String > paths , GribCollectionImmutable gc ) { } }

implementation:
if ( paths . size ( ) < 1 || paths . get ( 0 ) . length ( ) == 0 ) { // case 0 : use first dataset , group in the collection
GribCollectionImmutable . Dataset ds = gc . getDataset ( 0 ) ; GribCollectionImmutable . GroupGC dg = ds . getGroup ( 0 ) ; return new DatasetAndGroup ( ds , dg ) ; } GribCollectionImmutable . Dataset ds = getSingleDatasetOrByTypeName ( gc , paths . get ( 0 ) ) ; if ( ds == null ) return null ; boolean isSingleGroup = ds . getGroupsSize ( ) == 1 ; if ( isSingleGroup ) { GribCollectionImmutable . GroupGC g = ds . getGroup ( 0 ) ; // case 1
return new DatasetAndGroup ( ds , g ) ; } // otherwise last component is group name
String groupName = ( paths . size ( ) == 1 ) ? paths . get ( 0 ) : paths . get ( 1 ) ; // case 3 else case 2
GribCollectionImmutable . GroupGC g = ds . findGroupById ( groupName ) ; if ( g != null ) return new DatasetAndGroup ( ds , g ) ; return null ;


signature:
public class InvDatasetFcGrib { /** * kinda kludgey , but trying not keep URLs stable */
public GribCollectionImmutable . Dataset getSingleDatasetOrByTypeName ( GribCollectionImmutable gc , String typeName ) { } }

implementation: if ( gc . getDatasets ( ) . size ( ) == 1 ) return gc . getDataset ( 0 ) ; for ( GribCollectionImmutable . Dataset ds : gc . getDatasets ( ) ) if ( ds . getType ( ) . toString ( ) . equalsIgnoreCase ( typeName ) ) return ds ; return null ;


signature:
public class VertCoordValue { /** * cannot do approx equals and be consistent with hashCode , so make seperate call */
public boolean nearlyEquals ( VertCoordValue other ) { } }

implementation: return Misc . nearlyEquals ( value1 , other . value1 ) && Misc . nearlyEquals ( value2 , other . value2 ) ;


signature:
public class UnitID { /** * Factory method for constructing an identifier from a name , plural , and
 * symbol .
 * @ param name
 * The name for the unit . May be < code > null
 * < / code > .
 * @ param plural
 * The plural form of the name . If < code > null
 * < / code > and
 * < code > name < / code > is non - < code >
 * null < / code > , then regular
 * plural - forming rules are used on the name .
 * @ param symbol
 * The symbol for the unit . May be < code > null
 * < / code > . */
public static UnitID newUnitID ( final String name , final String plural , final String symbol ) { } }

implementation:
UnitID id ; try { id = name == null ? new UnitSymbol ( symbol ) : UnitName . newUnitName ( name , plural , symbol ) ; } catch ( final NameException e ) { id = null ; // can ' t happen
} return id ;


signature:
public class GradsAttribute { /** * Parse an attribute spec
 * @ param attrSpec the attribute spec ( e . g . @ precip String units mm / day )
 * @ return the associated attribute */
public static GradsAttribute parseAttribute ( String attrSpec ) { } }

implementation:
String [ ] toks = attrSpec . split ( "\\s+" ) ; StringBuffer buf = new StringBuffer ( ) ; for ( int i = 4 ; i < toks . length ; i ++ ) { buf . append ( toks [ i ] ) ; buf . append ( " " ) ; } // toks [ 0 ] is " @ "
return new GradsAttribute ( toks [ 1 ] , toks [ 2 ] , toks [ 3 ] , buf . toString ( ) . trim ( ) ) ;


signature:
public class NOWRadheader { /** * read the header of input file and parsing the NOWRAD part
 * @ param raf input file
 * @ return 1 if checking passing
 * @ throws IOException */
int readTop ( ucar . unidata . io . RandomAccessFile raf ) throws IOException { } }

implementation:
int pos = 0 ; // long actualSize = 0;
raf . seek ( pos ) ; int readLen = 35 ; // Read in the contents of the NEXRAD Level III product head
byte [ ] b = new byte [ readLen ] ; int rc = raf . read ( b ) ; if ( rc != readLen ) { return 0 ; } // check
if ( ( convertunsignedByte2Short ( b [ 0 ] ) != 0x00 ) || ( convertunsignedByte2Short ( b [ 1 ] ) != 0xF0 ) || ( convertunsignedByte2Short ( b [ 2 ] ) != 0x09 ) ) { return 0 ; } String pidd = new String ( b , 15 , 5 , CDM . utf8Charset ) ; if ( pidd . contains ( "NOWRA" ) || pidd . contains ( "USRAD" ) || pidd . contains ( "NEX" ) ) { return 1 ; } else { return 0 ; }


signature:
public class NOWRadheader { /** * read and parse the header of the nids / tdwr file
 * @ param raf input file
 * @ param ncfile output file
 * @ throws IOException */
void read ( ucar . unidata . io . RandomAccessFile raf , ucar . nc2 . NetcdfFile ncfile ) throws Exception { } }

implementation:
this . raf = raf ; int rc ; /* function return status */
int hoffset ; int readLen = 250 ; this . ncfile = ncfile ; int pos = 0 ; raf . seek ( pos ) ; byte [ ] b = new byte [ readLen ] ; rc = raf . read ( b ) ; if ( rc != readLen ) { log . warn ( " error reading nids product header " + raf . getLocation ( ) ) ; } int hsize = b [ 3 ] ; String product = new String ( b , 15 , 8 , CDM . utf8Charset ) ; // image lines
// byte [ ] bt = new byte [ ] { ( byte ) 0xF0 , ( byte ) 0x0A } ;
int t1 = 0 ; int ii = 0 ; for ( int i = 0 ; i < readLen ; i ++ ) { if ( convertunsignedByte2Short ( b [ i + hsize ] ) == 0xF0 && convertunsignedByte2Short ( b [ i + 1 + hsize ] ) == 0x0A ) { t1 = i + hsize ; ii = i ; break ; } } if ( t1 == 0 ) return ; // if ( convertunsignedByte2Short ( b [ 6 + hsize ] ) ! = 0xF0 | |
// convertunsignedByte2Short ( b [ 7 + hsize ] ) ! = 0x0A )
// return ;
String lstr = trim ( new String ( b , t1 + 2 , 4 , CDM . utf8Charset ) ) ; numY = Integer . parseInt ( lstr ) ; String estr = trim ( new String ( b , t1 + 6 , 5 , CDM . utf8Charset ) ) ; numX = Integer . parseInt ( estr ) ; // bt = new byte [ ] { ( byte ) 0xF0 , ( byte ) 0x03 } ;
t1 = 0 ; for ( int i = ii ; i < readLen ; i ++ ) { if ( convertunsignedByte2Short ( b [ i + hsize ] ) == 0xF0 && convertunsignedByte2Short ( b [ i + 1 + hsize ] ) == 0x03 ) { t1 = i + hsize ; ii = i ; break ; } } if ( t1 == 0 ) return ; // if ( ( lstr . length ( ) + estr . length ( ) < 8 ) )
// hsize = hsize - 2;
// if ( convertunsignedByte2Short ( b [ 18 + hsize ] ) ! = 0xF0 | |
// convertunsignedByte2Short ( b [ 19 + hsize ] ) ! = 0x03 )
// return ;
int off = 0 ; if ( product . contains ( "USRADHF" ) ) { off = 3 ; } // Image time , HHMMSS . The time will be in the form HH : MM , so look :
String ts = new String ( b , t1 + 22 + off , 2 , CDM . utf8Charset ) ; int hr = Integer . parseInt ( ts ) ; ts = new String ( b , t1 + 25 + off , 2 , CDM . utf8Charset ) ; int min = Integer . parseInt ( ts ) ; ts = new String ( b , t1 + 28 + off , 2 , CDM . utf8Charset ) ; int dd = Integer . parseInt ( ts ) ; ts = new String ( b , t1 + 31 + off , 3 , CDM . utf8Charset ) ; String mon = ts ; int month = getMonth ( mon ) ; ts = new String ( b , t1 + 35 + off , 2 , CDM . utf8Charset ) ; int year = Integer . parseInt ( ts ) ; SimpleDateFormat sdf = new SimpleDateFormat ( ) ; sdf . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; sdf . applyPattern ( "yyyy/MM/dd HH:mm" ) ; Date date = sdf . parse ( year + "/" + month + "/" + dd + " " + hr + ":" + min ) ; // bt = new byte [ ] { ( byte ) 0xF0 , ( byte ) 0x0b } ;
t1 = 0 ; for ( int i = ii ; i < readLen ; i ++ ) { if ( convertunsignedByte2Short ( b [ i + hsize ] ) == 0xF0 && convertunsignedByte2Short ( b [ i + 1 + hsize ] ) == 0x0b ) { t1 = i + hsize ; break ; } } if ( t1 == 0 ) return ; // if ( convertunsignedByte2Short ( b [ 101 + hsize ] ) ! = 0xF0 | |
// convertunsignedByte2Short ( b [ 102 + hsize ] ) ! = 0x0b )
// return ;
if ( product . contains ( "NOWRAD" ) ) { String ot = new String ( b , t1 + 2 , 68 , CDM . utf8Charset ) ; // List < String > toks = StringUtil . split ( ot , " " , true , true ) ;
String [ ] toks = StringUtil2 . splitString ( ot ) ; double nav1 = Math . toDegrees ( Double . parseDouble ( toks [ 1 ] ) ) ; // lon
double nav2 = Math . toDegrees ( Double . parseDouble ( toks [ 2 ] ) ) ; // lat
double nav3 = Math . toDegrees ( Double . parseDouble ( toks [ 3 ] ) ) ; double nav4 = Math . toDegrees ( Double . parseDouble ( toks [ 4 ] ) ) ; // lat sp
double nav5 = Math . toDegrees ( Double . parseDouble ( toks [ 5 ] ) ) ; // lon sp
// lower left and upper right corner
float rlat1 ; float rlon1 ; float rlat2 ; float rlon2 ; rlat1 = ( float ) ( nav2 - ( numY - 1 ) * nav4 ) ; rlon1 = ( float ) ( nav1 + nav3 ) ; rlat2 = ( float ) nav2 ; rlon2 = ( float ) ( nav1 - nav3 ) ; hoffset = t1 + 71 ; // 172 + hsize ;
// start of the image sequence
if ( ( convertunsignedByte2Short ( b [ 172 + hsize ] ) != 0xF0 ) || ( convertunsignedByte2Short ( b [ 173 + hsize ] ) != 0x0c ) ) { return ; } // hoffset = 174 + hsize ;
// Set product - dependent information
setProductInfo ( product , date ) ; // data struct
nowrad ( hoffset , rlat1 , rlon1 , rlat2 , rlon2 , ( float ) nav4 , ( float ) nav5 , date ) ; } else if ( product . contains ( "USRADHF" ) ) { String ot = new String ( b , t1 + 2 , 107 , CDM . utf8Charset ) ; String [ ] toks = StringUtil2 . splitString ( ot ) ; double nav1 = Math . toDegrees ( Double . parseDouble ( toks [ 1 ] ) ) ; // standard lat 1
double nav2 = Math . toDegrees ( Double . parseDouble ( toks [ 2 ] ) ) ; // standard lat 2
double nav3 = Math . toDegrees ( Double . parseDouble ( toks [ 3 ] ) ) ; // lat . center of proj
double nav4 = Math . toDegrees ( Double . parseDouble ( toks [ 4 ] ) ) ; // lon . center of proj
double nav5 = Math . toDegrees ( Double . parseDouble ( toks [ 5 ] ) ) ; // upper left lat
double nav6 = Math . toDegrees ( Double . parseDouble ( toks [ 6 ] ) ) ; // upper left lon
/* List < String > toks = StringUtil . split ( ot , " " , true , true ) ;
 String pj = toks . get ( 0 ) ;
 double nav1 = Math . toDegrees ( Double . parseDouble ( toks . get ( 1 ) ) ) ; / / standard lat 1
 double nav2 = Math . toDegrees ( Double . parseDouble ( toks . get ( 2 ) ) ) ; / / standard lat 2
 double nav3 = Math . toDegrees ( Double . parseDouble ( toks . get ( 3 ) ) ) ; / / lat . center of proj
 double nav4 = Math . toDegrees ( Double . parseDouble ( toks . get ( 4 ) ) ) ; / / lon . center of proj
 double nav5 = Math . toDegrees ( Double . parseDouble ( toks . get ( 5 ) ) ) ; / / upper left lat
 double nav6 = Math . toDegrees ( Double . parseDouble ( toks . get ( 6 ) ) ) ; / / upper left lon
 double nav7 = Math . toDegrees ( Double . parseDouble ( toks . get ( 7 ) ) ) ; / / lat sp
 double nav8 = Math . toDegrees ( Double . parseDouble ( toks . get ( 8 ) ) ) ; / / lon sp */
// lower left and upper right corner
// int offh = 39;
hoffset = t1 + 110 ; // 172 + hsize + offh ;
// start of the image sequence
if ( ( convertunsignedByte2Short ( b [ t1 + 110 ] ) != 0xF0 ) || ( convertunsignedByte2Short ( b [ t1 + 111 ] ) != 0x0c ) ) { return ; } // Set product - dependent information
setProductInfo ( product , date ) ; // data struct
nowradL ( hoffset , ( float ) nav1 , ( float ) nav2 , ( float ) nav3 , ( float ) nav4 , ( float ) nav5 , ( float ) nav6 , date ) ; } ncfile . finish ( ) ;


signature:
public class NOWRadheader { /** * construct a raster dataset for NIDS raster products ;
 * @ return soff - - not used */
ProjectionImpl nowrad ( int hoff , float rlat1 , float rlon1 , float rlat2 , float rlon2 , float dlat , float dlon , Date dd ) { } }

implementation:
List < Dimension > dims = new ArrayList < > ( ) ; Dimension dimT = new Dimension ( "time" , 1 , true , false , false ) ; ncfile . addDimension ( null , dimT ) ; String timeCoordName = "time" ; Variable taxis = new Variable ( ncfile , null , null , timeCoordName ) ; taxis . setDataType ( DataType . DOUBLE ) ; taxis . setDimensions ( "time" ) ; taxis . addAttribute ( new Attribute ( CDM . LONG_NAME , "time since base date" ) ) ; taxis . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Time . toString ( ) ) ) ; double [ ] tdata = new double [ 1 ] ; tdata [ 0 ] = dd . getTime ( ) ; Array dataT = Array . factory ( DataType . DOUBLE , new int [ ] { 1 } , tdata ) ; taxis . setCachedData ( dataT , false ) ; DateFormatter formatter = new DateFormatter ( ) ; taxis . addAttribute ( new Attribute ( CDM . UNITS , "msecs since " + formatter . toDateTimeStringISO ( new Date ( 0 ) ) ) ) ; ncfile . addVariable ( null , taxis ) ; dims . add ( dimT ) ; Dimension jDim = new Dimension ( "lat" , numY , true , false , false ) ; Dimension iDim = new Dimension ( "lon" , numX , true , false , false ) ; dims . add ( jDim ) ; dims . add ( iDim ) ; ncfile . addDimension ( null , iDim ) ; ncfile . addDimension ( null , jDim ) ; ncfile . addAttribute ( null , new Attribute ( "cdm_data_type" , FeatureType . GRID . toString ( ) ) ) ; String coordinates = "time lat lon" ; Variable v = new Variable ( ncfile , null , null , cname ) ; v . setDataType ( DataType . BYTE ) ; v . setDimensions ( dims ) ; ncfile . addVariable ( null , v ) ; v . addAttribute ( new Attribute ( CDM . LONG_NAME , ctitle ) ) ; v . addAttribute ( new Attribute ( CDM . SCALE_FACTOR , 5.0f ) ) ; v . addAttribute ( new Attribute ( CDM . MISSING_VALUE , 0 ) ) ; v . addAttribute ( new Attribute ( CDM . UNITS , cunit ) ) ; v . setSPobject ( new Vinfo ( numX , numY , hoff ) ) ; v . addAttribute ( new Attribute ( _Coordinate . Axes , coordinates ) ) ; // create coordinate variables
Variable xaxis = new Variable ( ncfile , null , null , "lon" ) ; xaxis . setDataType ( DataType . DOUBLE ) ; xaxis . setDimensions ( "lon" ) ; xaxis . addAttribute ( new Attribute ( CDM . LONG_NAME , "longitude" ) ) ; xaxis . addAttribute ( new Attribute ( CDM . UNITS , "degree" ) ) ; xaxis . addAttribute ( new Attribute ( _Coordinate . AxisType , "Lon" ) ) ; double [ ] data1 = new double [ numX ] ; for ( int i = 0 ; i < numX ; i ++ ) { data1 [ i ] = ( double ) ( rlon1 + i * dlon ) ; } Array dataA = Array . factory ( DataType . DOUBLE , new int [ ] { numX } , data1 ) ; xaxis . setCachedData ( dataA , false ) ; ncfile . addVariable ( null , xaxis ) ; Variable yaxis = new Variable ( ncfile , null , null , "lat" ) ; yaxis . setDataType ( DataType . DOUBLE ) ; yaxis . setDimensions ( "lat" ) ; yaxis . addAttribute ( new Attribute ( CDM . LONG_NAME , "latitude" ) ) ; yaxis . addAttribute ( new Attribute ( CDM . UNITS , "degree" ) ) ; yaxis . addAttribute ( new Attribute ( _Coordinate . AxisType , "Lat" ) ) ; data1 = new double [ numY ] ; for ( int i = 0 ; i < numY ; i ++ ) { data1 [ i ] = rlat1 + i * dlat ; } dataA = Array . factory ( DataType . DOUBLE , new int [ ] { numY } , data1 ) ; yaxis . setCachedData ( dataA , false ) ; ncfile . addVariable ( null , yaxis ) ; // projection
// lower left and upper right corner lat / lons
// modified cylind . equidistant or CED with lat / lon ration ! = 1
/* LatLonProjection llproj = new LatLonProjection ( " LatitudeLongitudeProjection " ,
 new ProjectionRect ( rlat1 , rlon1 , rlat2 , rlon2 ) ) ;
 Variable ct = new Variable ( ncfile , null , null , llproj . getClassName ( ) ) ;
 ct . setDataType ( DataType . CHAR ) ;
 ct . setDimensions ( " " ) ;
 List params = llproj . getProjectionParameters ( ) ;
 for ( int i = 0 ; i < params . size ( ) ; i + + ) {
 Parameter p = ( Parameter ) params . get ( i ) ;
 ct . addAttribute ( new Attribute ( p ) ) ;
 ct . addAttribute ( new Attribute ( _ Coordinate . TransformType , " Projection " ) ) ;
 ct . addAttribute ( new Attribute ( _ Coordinate . Axes , " lat lon " ) ) ;
 / / fake data
 dataA = Array . factory ( DataType . CHAR , new int [ ] { } ) ;
 dataA . setChar ( dataA . getIndex ( ) , ' ' ) ;
 ct . setCachedData ( dataA , false ) ;
 ncfile . addVariable ( null , ct ) ; */
return null ;


signature:
public class NOWRadheader { /** * parsing the product information into netcdf dataset */
void setProductInfo ( String prod , Date dd ) { } }

implementation:
String summary = null ; if ( prod . contains ( "NOWRADHF" ) ) { cmemo = "NOWRAD  Base Reflectivity at Tilt 1" ; ctitle = "BREF: Base Reflectivity [dBZ]" ; cunit = "dBZ" ; cname = "Reflectivity" ; summary = "NOWRAD Product" ; } else if ( prod . contains ( "USRADHF" ) ) { cmemo = "NOWRAD  Base Reflectivity at Tilt 1" ; ctitle = "BREF: Base Reflectivity [dBZ]" ; cunit = "dBZ" ; cname = "Reflectivity" ; summary = "NOWRAD Product" ; } else if ( prod . contains ( "NEXET" ) ) { cmemo = "NOWRAD Echo Tops" ; ctitle = "Echo Tops Composite" ; cunit = "K FT" ; cname = "EchoTopsComposite" ; summary = "NOWRAD Product" ; } else if ( prod . contains ( "NEXLL" ) ) { cmemo = "NOWRAD Layer Comp. Reflectivity - Low" ; ctitle = "LayerReflectivityLow" ; cunit = "dBZ" ; cname = "Reflectivity" ; summary = "NOWRAD Product" ; } else if ( prod . contains ( "NEXLM" ) ) { cmemo = "NOWRAD Layer Comp. Reflectivity - Mid" ; ctitle = "LayerReflectivityMid" ; cunit = "dBZ" ; cname = "Reflectivity" ; summary = "NOWRAD Product" ; } else if ( prod . contains ( "NEXLH" ) ) { cmemo = "NOWRAD Layer Comp. Reflectivity - High" ; ctitle = "LayerReflectivityHigh" ; cunit = "dBZ" ; cname = "ReflectivityHigh" ; summary = "NOWRAD Product" ; } else if ( prod . contains ( "NEXVI" ) ) { cmemo = "NOWRAD " ; ctitle = "Vert. Integrated Liquid Water" ; cunit = "Knots" ; cname = "VILwater" ; summary = "NOWRAD " ; } else { ctilt = "error" ; ctitle = "error" ; cunit = "error" ; cname = "error" ; } /* add geo global att */
ncfile . addAttribute ( null , new Attribute ( "summary" , "NOWRAD radar composite products." + summary ) ) ; ncfile . addAttribute ( null , new Attribute ( "title" , "NOWRAD" ) ) ; ncfile . addAttribute ( null , new Attribute ( "keywords" , "NOWRAD" ) ) ; ncfile . addAttribute ( null , new Attribute ( "creator_name" , "NOAA/NWS" ) ) ; ncfile . addAttribute ( null , new Attribute ( "creator_url" , "http://www.ncdc.noaa.gov/oa/radar/radarproducts.html" ) ) ; ncfile . addAttribute ( null , new Attribute ( "naming_authority" , "NOAA/NCDC" ) ) ; ncfile . addAttribute ( null , new Attribute ( "base_date" , formatter . toDateOnlyString ( dd ) ) ) ; ncfile . addAttribute ( null , new Attribute ( "conventions" , _Coordinate . Convention ) ) ; ncfile . addAttribute ( null , new Attribute ( "cdm_data_type" , FeatureType . GRID . toString ( ) ) ) ;


signature:
public class NOWRadheader { /** * convert two short into a integer
 * @ param s1 short one
 * @ param s2 short two
 * @ param swapBytes if swap bytes
 * @ return integer */
public static int shortsToInt ( short s1 , short s2 , boolean swapBytes ) { } }


signature:
public class NOWRadheader { /** * convert bytes into integer
 * @ param bytes bytes array
 * @ param swapBytes if need to swap
 * @ return integer */
public static int bytesToInt ( byte [ ] bytes , boolean swapBytes ) { } }


signature:
public class NOWRadheader { /** * get jave date
 * @ param julianDays
 * @ param msecs
 * @ return java date */
static public java . util . Date getDate ( int julianDays , int msecs ) { } }

implementation: long total = ( ( long ) ( julianDays - 1 ) ) * 24 * 3600 * 1000 + msecs ; return new Date ( total ) ;


signature:
public class N3iosp { /** * Set a static property .
 * Supported static properties : < ul >
 * < li > syncExtendOnly = " true " : assume all file changes are syncExtend only .
 * < / ul >
 * @ param name property name
 * @ param value property value */
static public void setProperty ( String name , String value ) { } }

implementation: if ( name . equalsIgnoreCase ( "syncExtendOnly" ) ) syncExtendOnly = value . equalsIgnoreCase ( "true" ) ;


signature:
public class N3iosp { /** * Should match makeValidNetcdfObjectName ( ) */
public static boolean isValidNetcdfObjectName ( String name ) { } }

implementation:
if ( name == null || name . isEmpty ( ) ) { // Null and empty names disallowed
return false ; } int cp = name . codePointAt ( 0 ) ; // First char must be [ a - z ] [ A - Z ] [ 0-9 ] _ | UTF8
if ( cp <= 0x7f ) { if ( ! ( 'A' <= cp && cp <= 'Z' ) && ! ( 'a' <= cp && cp <= 'z' ) && ! ( '0' <= cp && cp <= '9' ) && cp != '_' ) { return false ; } } for ( int i = 1 ; i < name . length ( ) ; ++ i ) { cp = name . codePointAt ( i ) ; // handle simple 0x00-0x7f characters here
if ( cp <= 0x7f ) { if ( cp < ' ' || cp > 0x7E || cp == '/' ) { // control char , DEL , or forward - slash
return false ; } } } if ( cp <= 0x7f && Character . isWhitespace ( cp ) ) { // trailing spaces disallowed
return false ; } return true ;


signature:
public class N3iosp { /** * Convert a name to a legal netcdf - 3 name .
 * @ param name the name to convert .
 * @ return the converted name .
 * @ see # isValidNetcdfObjectName ( String ) */
public static String makeValidNetcdfObjectName ( String name ) { } }

implementation:
StringBuilder sb = new StringBuilder ( name ) ; while ( sb . length ( ) > 0 ) { int cp = sb . codePointAt ( 0 ) ; // First char must be [ a - z ] [ A - Z ] [ 0-9 ] _ | UTF8
if ( cp <= 0x7f ) { if ( ! ( 'A' <= cp && cp <= 'Z' ) && ! ( 'a' <= cp && cp <= 'z' ) && ! ( '0' <= cp && cp <= '9' ) && cp != '_' ) { sb . deleteCharAt ( 0 ) ; continue ; } } break ; } for ( int pos = 1 ; pos < sb . length ( ) ; ++ pos ) { int cp = sb . codePointAt ( pos ) ; // handle simple 0x00-0x7F characters here
if ( cp <= 0x7F ) { if ( cp < ' ' || cp > 0x7E || cp == '/' ) { // control char , DEL , or forward - slash
sb . deleteCharAt ( pos ) ; -- pos ; } } } while ( sb . length ( ) > 0 ) { int cp = sb . codePointAt ( sb . length ( ) - 1 ) ; if ( cp <= 0x7f && Character . isWhitespace ( cp ) ) { sb . deleteCharAt ( sb . length ( ) - 1 ) ; } else { break ; } } if ( sb . length ( ) == 0 ) { throw new IllegalArgumentException ( String . format ( "Illegal NetCDF object name: '%s'" , name ) ) ; } return sb . toString ( ) ;


signature:
public class N3iosp { /** * Determine if the given name can be used for a Dimension , Attribute , or Variable name .
 * Should match makeValidNetcdf3ObjectName .
 * @ param name test this .
 * @ return true if valid name .
 * @ deprecated use isValidNetcdfObjectName */
static public boolean isValidNetcdf3ObjectName ( String name ) { } }

implementation: Matcher m = objectNamePatternOld . matcher ( name ) ; return m . matches ( ) ;


signature:
public class N3iosp { /** * read existing file */
@ Override public void openForWriting ( ucar . unidata . io . RandomAccessFile raf , ucar . nc2 . NetcdfFile ncfile , ucar . nc2 . util . CancelTask cancelTask ) throws IOException { } }

implementation: open ( raf , ncfile , cancelTask ) ;


signature:
public class N3iosp { /** * data reading */
@ Override public Array readData ( ucar . nc2 . Variable v2 , Section section ) throws IOException , InvalidRangeException { } }

implementation:
/* if ( debugRead ) {
 System . out . printf ( " debugRead % s % s % n " , v2 . toStringDebug ( ) , section ) ;
 if ( v2 . getShortName ( ) . equals ( " cref " ) )
 System . out . println ( " HEY " ) ; */
if ( v2 instanceof Structure ) return readRecordData ( ( Structure ) v2 , section ) ; N3header . Vinfo vinfo = ( N3header . Vinfo ) v2 . getSPobject ( ) ; DataType dataType = v2 . getDataType ( ) ; Layout layout = ( ! v2 . isUnlimited ( ) ) ? new LayoutRegular ( vinfo . begin , v2 . getElementSize ( ) , v2 . getShape ( ) , section ) : new LayoutRegularSegmented ( vinfo . begin , v2 . getElementSize ( ) , header . recsize , v2 . getShape ( ) , section ) ; if ( layout . getTotalNelems ( ) == 0 ) { return Array . factory ( dataType , section . getShape ( ) ) ; } Object data = readData ( layout , dataType ) ; return Array . factory ( dataType , section . getShape ( ) , data ) ;


signature:
public class N3iosp { /** * Read data from record structure . For N3 , this is the only possible structure , and there can be no nesting .
 * Read all variables for each record , put in ByteBuffer .
 * @ param s the record structure
 * @ param section the record range to read
 * @ return an ArrayStructure , with all the data read in .
 * @ throws IOException on error */
private ucar . ma2 . Array readRecordData ( ucar . nc2 . Structure s , Section section ) throws java . io . IOException { } }

implementation:
// if ( s . isSubset ( ) )
// return readRecordDataSubset ( s , section ) ;
// has to be 1D
Range recordRange = section . getRange ( 0 ) ; // create the ArrayStructure
StructureMembers members = s . makeStructureMembers ( ) ; for ( StructureMembers . Member m : members . getMembers ( ) ) { Variable v2 = s . findVariable ( m . getName ( ) ) ; N3header . Vinfo vinfo = ( N3header . Vinfo ) v2 . getSPobject ( ) ; m . setDataParam ( ( int ) ( vinfo . begin - header . recStart ) ) ; } // protect agains too large of reads
if ( header . recsize > Integer . MAX_VALUE ) throw new IllegalArgumentException ( "Cant read records when recsize > " + Integer . MAX_VALUE ) ; long nrecs = section . computeSize ( ) ; if ( nrecs * header . recsize > Integer . MAX_VALUE ) throw new IllegalArgumentException ( "Too large read: nrecs * recsize= " + ( nrecs * header . recsize ) + "bytes exceeds " + Integer . MAX_VALUE ) ; members . setStructureSize ( ( int ) header . recsize ) ; ArrayStructureBB structureArray = new ArrayStructureBB ( members , new int [ ] { recordRange . length ( ) } ) ; // note dependency on raf ; should probably defer to subclass
// loop over records
byte [ ] result = structureArray . getByteBuffer ( ) . array ( ) ; int count = 0 ; for ( int recnum : recordRange ) { if ( debugRecord ) System . out . println ( " read record " + recnum ) ; raf . seek ( header . recStart + recnum * header . recsize ) ; // where the record starts
if ( recnum != header . numrecs - 1 ) raf . readFully ( result , ( int ) ( count * header . recsize ) , ( int ) header . recsize ) ; else raf . read ( result , ( int ) ( count * header . recsize ) , ( int ) header . recsize ) ; // " wart " allows file to be one byte short . since its always padding , we allow
count ++ ; } return structureArray ;


signature:
public class N3iosp { /** * Read data from record structure , that has been subsetted .
 * Read one record at at time , put requested variable into ArrayStructureMA .
 * @ param s the record structure
 * @ param section the record range to read
 * @ return an ArrayStructure , with all the data read in .
 * @ throws IOException on error */
private ucar . ma2 . Array readRecordDataSubset ( ucar . nc2 . Structure s , Section section ) throws java . io . IOException { } }

implementation:
Range recordRange = section . getRange ( 0 ) ; int nrecords = recordRange . length ( ) ; // create the ArrayStructureMA
StructureMembers members = s . makeStructureMembers ( ) ; for ( StructureMembers . Member m : members . getMembers ( ) ) { Variable v2 = s . findVariable ( m . getName ( ) ) ; N3header . Vinfo vinfo = ( N3header . Vinfo ) v2 . getSPobject ( ) ; m . setDataParam ( ( int ) ( vinfo . begin - header . recStart ) ) ; // offset from start of record
// construct the full shape
int rank = m . getShape ( ) . length ; int [ ] fullShape = new int [ rank + 1 ] ; fullShape [ 0 ] = nrecords ; // the first dimension
System . arraycopy ( m . getShape ( ) , 0 , fullShape , 1 , rank ) ; // the remaining dimensions
Array data = Array . factory ( m . getDataType ( ) , fullShape ) ; m . setDataArray ( data ) ; m . setDataObject ( data . getIndexIterator ( ) ) ; } // LOOK this is all wrong - why using recsize ? ? ?
return null ; /* members . setStructureSize ( recsize ) ;
 ArrayStructureMA structureArray = new ArrayStructureMA ( members , new int [ ] { nrecords } ) ;
 / / note dependency on raf ; should probably defer to subclass
 / / loop over records
 byte [ ] record = new byte [ recsize ] ;
 ByteBuffer bb = ByteBuffer . wrap ( record ) ;
 for ( int recnum = recordRange . first ( ) ; recnum < = recordRange . last ( ) ; recnum + = recordRange . stride ( ) ) {
 if ( debugRecord ) System . out . println ( " readRecordDataSubset recno = " + recnum ) ;
 / / read one record
 raf . seek ( recStart + recnum * recsize ) ; / / where the record starts
 if ( recnum ! = numrecs - 1)
 raf . readFully ( record , 0 , recsize ) ;
 else
 raf . read ( record , 0 , recsize ) ; / / " wart " allows file to be one byte short . since its always padding , we allow
 / / transfer desired variable ( s ) to result array ( s )
 for ( StructureMembers . Member m : members . getMembers ( ) ) {
 IndexIterator dataIter = ( IndexIterator ) m . getDataObject ( ) ;
 IospHelper . copyFromByteBuffer ( bb , m , dataIter ) ;
 return structureArray ; */


signature:
public class N3iosp { /** * protected HashMap dimHash = new HashMap ( 50 ) ; */
@ Override public void create ( String filename , ucar . nc2 . NetcdfFile ncfile , int extra , long preallocateSize , boolean largeFile ) throws IOException { } }

implementation:
this . ncfile = ncfile ; this . readonly = false ; // finish any structures
ncfile . finish ( ) ; raf = new ucar . unidata . io . RandomAccessFile ( filename , "rw" ) ; raf . order ( RandomAccessFile . BIG_ENDIAN ) ; if ( preallocateSize > 0 ) { java . io . RandomAccessFile myRaf = raf . getRandomAccessFile ( ) ; myRaf . setLength ( preallocateSize ) ; } header = new N3header ( ) ; header . create ( raf , ncfile , extra , largeFile , null ) ; // recsize = header . recsize ; / / record size
// recStart = header . recStart ; / / record variables start here
// fileUsed = headerParser . getMinLength ( ) ; / / track what is actually used
_create ( raf ) ; if ( fill ) fillNonRecordVariables ( ) ; // else
// raf . setMinLength ( recStart ) ; / / make sure file length is long enough , even if not written to .


signature:
public class N3iosp { /** * write */
@ Override public void writeData ( Variable v2 , Section section , Array values ) throws java . io . IOException , InvalidRangeException { } }

implementation: N3header . Vinfo vinfo = ( N3header . Vinfo ) v2 . getSPobject ( ) ; DataType dataType = v2 . getDataType ( ) ; if ( v2 . isUnlimited ( ) ) { Range firstRange = section . getRange ( 0 ) ; setNumrecs ( firstRange . last ( ) + 1 ) ; } if ( v2 instanceof Structure ) { if ( ! ( values instanceof ArrayStructure ) ) throw new IllegalArgumentException ( "writeData for Structure: data must be ArrayStructure" ) ; if ( v2 . getRank ( ) == 0 ) throw new IllegalArgumentException ( "writeData for Structure: must have rank > 0" ) ; Dimension d = v2 . getDimension ( 0 ) ; if ( ! d . isUnlimited ( ) ) throw new IllegalArgumentException ( "writeData for Structure: must have unlimited dimension" ) ; writeRecordData ( ( Structure ) v2 , section , ( ArrayStructure ) values ) ; } else { Layout layout = ( ! v2 . isUnlimited ( ) ) ? new LayoutRegular ( vinfo . begin , v2 . getElementSize ( ) , v2 . getShape ( ) , section ) : new LayoutRegularSegmented ( vinfo . begin , v2 . getElementSize ( ) , header . recsize , v2 . getShape ( ) , section ) ; writeData ( values , layout , dataType ) ; }


signature:
public class N3iosp { /** * Update the value of an existing attribute . Attribute is found by name , which must match exactly .
 * You cannot make an attribute longer , or change the number of values .
 * For strings : truncate if longer , zero fill if shorter . Strings are padded to 4 byte boundaries , ok to use padding if it exists .
 * For numerics : must have same number of values .
 * @ param v2 variable , or null for fglobal attribute
 * @ param att replace with this value
 * @ throws IOException */
@ Override public void updateAttribute ( ucar . nc2 . Variable v2 , Attribute att ) throws IOException { } }

implementation: header . updateAttribute ( v2 , att ) ;


signature:
public class N3iosp { /** * fill buffer with fill value */
protected void fillNonRecordVariables ( ) throws IOException { } }

implementation:
// run through each variable
for ( Variable v : ncfile . getVariables ( ) ) { if ( v . isUnlimited ( ) ) continue ; try { writeData ( v , v . getShapeAsSection ( ) , makeConstantArray ( v ) ) ; } catch ( InvalidRangeException e ) { e . printStackTrace ( ) ; // shouldnt happen
} }


signature: public class N3iosp { @ Override public boolean syncExtend ( ) throws IOException { } }

implementation: boolean result = header . synchNumrecs ( ) ; if ( result && log . isDebugEnabled ( ) ) log . debug ( " N3iosp syncExtend " + raf . getLocation ( ) + " numrecs =" + header . numrecs ) ; return result ;


signature:
public class N3iosp { /** * / * @ Override
 * public boolean sync ( ) throws IOException {
 * if ( syncExtendOnly )
 * return syncExtend ( ) ;
 * if ( lastModified = = 0 ) / / ? ? HttpRandomAccessFile
 * return false ;
 * File file = new File ( raf . getLocation ( ) ) ;
 * if ( file . exists ( ) ) {
 * long currentModified = file . lastModified ( ) ;
 * if ( currentModified = = lastModified )
 * return false ;
 * so things have been modified , heres where we need to reread the header ! !
 * ncfile . empty ( ) ;
 * open ( raf , ncfile , null ) ;
 * if ( log . isDebugEnabled ( ) )
 * log . debug ( " N3iosp resynced " + raf . getLocation ( ) + " currentModified = " + currentModified + " lastModified = " + lastModified ) ;
 * return true ;
 * can this happen ?
 * throw new IOException ( " File does not exist " ) ; */
@ Override public void flush ( ) throws java . io . IOException { } }

implementation: if ( raf != null ) { raf . flush ( ) ; header . writeNumrecs ( ) ; raf . flush ( ) ; }


signature:
public class NcSDArray { /** * Read the data values ( parameters are ignored ) .
 * Use the start , stop and stride values , typically set by the constraint evaluator .
 * @ param datasetName not used
 * @ param specialO not used
 * @ return false ( no more data to be read )
 * @ throws IOException
 * @ throws EOFException */
public boolean read ( String datasetName , Object specialO ) throws IOException { } }

implementation:
long tstart = System . currentTimeMillis ( ) ; Array a ; try { if ( log . isDebugEnabled ( ) ) log . debug ( getRequestedRange ( ) ) ; // set up the netcdf read
int n = numDimensions ( ) ; List < Range > ranges = new ArrayList < > ( n ) ; for ( int i = 0 ; i < n ; i ++ ) ranges . add ( new Range ( getStart ( i ) , getStop ( i ) , getStride ( i ) ) ) ; try { a = ncVar . read ( ranges ) ; } catch ( java . lang . ArrayIndexOutOfBoundsException t ) { log . error ( getRequestedRange ( ) , t ) ; throw new RuntimeException ( "NcSDArray java.lang.ArrayIndexOutOfBoundsException=" + t . getMessage ( ) + " for request= " + getRequestedRange ( ) + " dataset= " + datasetName , t ) ; } if ( debug ) System . out . println ( "  NcSDArray Read " + getEncodedName ( ) + " " + a . getSize ( ) + " elems of type = " + a . getElementType ( ) ) ; if ( debugRead ) System . out . println ( "  Read = " + a . getSize ( ) + " elems of type = " + a . getElementType ( ) ) ; if ( log . isDebugEnabled ( ) ) { long tookTime = System . currentTimeMillis ( ) - tstart ; log . debug ( "NcSDArray read array: " + tookTime * .001 + " seconds" ) ; } } catch ( InvalidDimensionException e ) { log . error ( getRequestedRange ( ) , e ) ; throw new IllegalStateException ( "NcSDArray InvalidDimensionException=" + e . getMessage ( ) ) ; } catch ( InvalidRangeException e ) { log . error ( getRequestedRange ( ) , e ) ; throw new IllegalStateException ( "NcSDArray InvalidRangeException=" + e . getMessage ( ) ) ; } setData ( a ) ; if ( debugRead ) System . out . println ( " PrimitiveVector len = " + getPrimitiveVector ( ) . getLength ( ) + " type = " + getPrimitiveVector ( ) . getTemplate ( ) ) ; return ( false ) ;


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

implementation:
List < String > levels = getLevels ( ) ; if ( levels == null ) { return null ; } if ( levels . size ( ) != getSize ( ) ) { // do someting
} // Time is always LINEAR
int inc = 0 ; double [ ] vals = new double [ getSize ( ) ] ; String tstart = levels . get ( 0 ) . trim ( ) . toLowerCase ( ) ; String pattern = null ; if ( tstart . indexOf ( ":" ) >= 0 ) { // HH : mmZddMMMyyyy
pattern = dateFormats [ 0 ] ; } else if ( tstart . indexOf ( "z" ) >= 0 ) { // mmZddMMMyyyy
pattern = dateFormats [ 1 ] ; } else if ( Character . isLetter ( tstart . charAt ( 0 ) ) ) { // MMMyyyy
pattern = dateFormats [ 3 ] ; } else { pattern = dateFormats [ 2 ] ; // ddMMMyyyy
} SimpleDateFormat sdf = new SimpleDateFormat ( pattern ) ; // sdf . setLenient ( true ) ;
sdf . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; ParsePosition p = new ParsePosition ( 0 ) ; Date d = sdf . parse ( tstart , p ) ; if ( d == null ) { System . out . println ( "couldn't parse at " + p . getErrorIndex ( ) ) ; d = new Date ( 0 ) ; } // System . out . println ( " start = " + d ) ;
// set the unit
sdf . applyPattern ( "yyyy-MM-dd HH:mm:ss Z" ) ; setUnit ( "hours since " + sdf . format ( d , new StringBuffer ( ) , new FieldPosition ( 0 ) ) ) ; // parse the increment
// vvkk where
// vv = an integer number , 1 or 2 digits
// kk = mn ( minute )
// hr ( hour )
// dy ( day )
// mo ( month )
// yr ( year )
String tinc = levels . get ( 1 ) . toLowerCase ( ) ; int incIndex = 0 ; for ( int i = 0 ; i < incStr . length ; i ++ ) { int index = tinc . indexOf ( incStr [ i ] ) ; if ( index < 0 ) { continue ; } int numOf = Integer . parseInt ( tinc . substring ( 0 , index ) ) ; inc = numOf ; incIndex = i ; break ; } Calendar calendar = Calendar . getInstance ( TimeZone . getTimeZone ( "GMT" ) ) ; calendar . setTime ( d ) ; vals [ 0 ] = 0 ; initialTime = makeTimeStruct ( calendar ) ; // System . out . println ( " initial time = " + initialTime ) ;
int calInc = calIncs [ incIndex ] ; double hours = ( double ) 1000 * 60 * 60 ; for ( int i = 1 ; i < getSize ( ) ; i ++ ) { calendar . add ( calInc , inc ) ; // subtract from origin , convert to hours
double offset = ( calendar . getTime ( ) . getTime ( ) - d . getTime ( ) ) / hours ; // millis in an hour
vals [ i ] = offset ; } return vals ;


signature:
public class GradsTimeDimension { /** * Make a time struct from the index .
 * @ param timeIndex the time value index
 * @ return the corresponding TimeStruct */
public GradsTimeStruct makeTimeStruct ( int timeIndex ) { } }

implementation: double tVal = getValues ( ) [ timeIndex ] ; Date d = DateUnit . getStandardDate ( tVal + " " + getUnit ( ) ) ; Calendar calendar = Calendar . getInstance ( ) ; calendar . setTimeZone ( java . util . TimeZone . getTimeZone ( "GMT" ) ) ; calendar . setTime ( d ) ; return makeTimeStruct ( calendar ) ;


signature:
public class GradsTimeDimension { /** * Make a GradsTimeStruct from the calendar state
 * @ param calendar the calendar
 * @ return the corresponding GradsTimeStruct */
private GradsTimeStruct makeTimeStruct ( Calendar calendar ) { } }

implementation:
GradsTimeStruct ts = new GradsTimeStruct ( ) ; ts . year = calendar . get ( Calendar . YEAR ) ; ts . month = calendar . get ( Calendar . MONTH ) + 1 ; // MONTH is zero based
ts . day = calendar . get ( Calendar . DAY_OF_MONTH ) ; ts . hour = calendar . get ( Calendar . HOUR_OF_DAY ) ; ts . minute = calendar . get ( Calendar . MINUTE ) ; ts . jday = calendar . get ( Calendar . DAY_OF_YEAR ) ; return ts ;