signature:
public class DConnect2 { /** * Returns the ` Data object ' from the dataset referenced by this object ' s
 * URL given the constraint expression CE . Note that the Data object is
 * really just a DDS object with data bound to the variables . The DDS will
 * probably contain fewer variables ( and those might have different
 * types ) than in the DDS returned by getDDS ( ) because that method returns
 * the entire DDS ( but without any data ) while this method returns
 * only those variables listed in the projection part of the constraint
 * expression .
 * Note that if CE is an empty String then the entire dataset will be
 * returned , unless a " sticky " CE has been specified in the constructor .
 * @ param CE The constraint expression to be applied to this request by the
 * server . This is combined with any CE given in the constructor .
 * @ param statusUI the < code > StatusUI < / code > object to use for GUI updates
 * and user cancellation notification ( may be null ) .
 * @ return The < code > DataDDS < / code > object that results from applying the
 * given CE , combined with this object ' s sticky CE , on the referenced
 * dataset .
 * @ throws MalformedURLException if the URL given to the constructor
 * has an error
 * @ throws IOException if any error connecting to the remote server
 * @ throws ParseException if the DDS parser returned an error
 * @ throws DDSException on an error constructing the DDS
 * @ throws DAP2Exception if any error returned by the remote server */
public DataDDS getData ( String CE , StatusUI statusUI ) throws MalformedURLException , IOException , ParseException , DDSException , DAP2Exception { } }

implementation: return getData ( CE , statusUI , new DefaultFactory ( ) ) ;


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

implementation:
// either point is infinite
if ( ProjectionPointImpl . isInfinite ( pt1 ) || ProjectionPointImpl . isInfinite ( pt2 ) ) { return true ; } // opposite signed long lines
double x1 = pt1 . getX ( ) - falseEasting ; double x2 = pt2 . getX ( ) - falseEasting ; return ( x1 * x2 < 0 ) && ( Math . abs ( x1 - x2 ) > earthRadius ) ;


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

implementation:
double deltaLon_d = LatLonPointImpl . range180 ( latLon . getLongitude ( ) - centMeridian ) ; double fromLat_r = Math . toRadians ( latLon . getLatitude ( ) ) ; double toX = earthRadius * Math . toRadians ( deltaLon_d ) * Math . cos ( fromLat_r ) ; double toY = earthRadius * fromLat_r ; // p 247 Snyder
result . setLocation ( toX + falseEasting , toY + falseNorthing ) ; return result ;


signature:
public class Sinusoidal { /** * Convert projection coordinates to a LatLonPoint
 * @ param world convert from these projection coordinates
 * @ param result the object to write to
 * @ return LatLonPoint the lat / lon coordinates */
@ Override public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) { } }

implementation:
double fromX = world . getX ( ) - falseEasting ; double fromY = world . getY ( ) - falseNorthing ; double toLat_r = fromY / earthRadius ; double toLon_r ; if ( Misc . nearlyEquals ( Math . abs ( toLat_r ) , PI_OVER_2 , 1e-10 ) ) { toLat_r = toLat_r < 0 ? - PI_OVER_2 : + PI_OVER_2 ; toLon_r = Math . toRadians ( centMeridian ) ; // if lat = = + - pi / 2 , set lon = centMeridian ( Snyder 248)
} else if ( Math . abs ( toLat_r ) < PI_OVER_2 ) { toLon_r = Math . toRadians ( centMeridian ) + fromX / ( earthRadius * Math . cos ( toLat_r ) ) ; } else { return INVALID ; // Projection point is off the map .
} if ( Misc . nearlyEquals ( Math . abs ( toLon_r ) , PI , 1e-10 ) ) { toLon_r = toLon_r < 0 ? - PI : + PI ; } else if ( Math . abs ( toLon_r ) > PI ) { return INVALID ; // Projection point is off the map .
} result . setLatitude ( Math . toDegrees ( toLat_r ) ) ; result . setLongitude ( Math . toDegrees ( toLon_r ) ) ; return result ;


signature:
public class Sinusoidal { /** * Returns the points at which { @ code projBB } intersects the map edge .
 * @ param projBB defines a bounding box that may intersect the map edge , in projection coordinates .
 * @ return the points at which { @ code projBB } intersects the map edge . May be empty . */
public List < ProjectionPoint > getMapEdgeIntercepts ( ProjectionRect projBB ) { } }

implementation: List < ProjectionPoint > intercepts = new LinkedList < > ( ) ; for ( ProjectionPoint topIntercept : getMapEdgeInterceptsAtY ( projBB . getUpperRightPoint ( ) . getY ( ) ) ) { if ( pointIsBetween ( topIntercept , projBB . getUpperLeftPoint ( ) , projBB . getUpperRightPoint ( ) ) ) { intercepts . add ( topIntercept ) ; } } for ( ProjectionPoint rightIntercept : getMapEdgeInterceptsAtX ( projBB . getUpperRightPoint ( ) . getX ( ) ) ) { if ( pointIsBetween ( rightIntercept , projBB . getUpperRightPoint ( ) , projBB . getLowerRightPoint ( ) ) ) { intercepts . add ( rightIntercept ) ; } } for ( ProjectionPoint bottomIntercept : getMapEdgeInterceptsAtY ( projBB . getLowerLeftPoint ( ) . getY ( ) ) ) { if ( pointIsBetween ( bottomIntercept , projBB . getLowerLeftPoint ( ) , projBB . getLowerRightPoint ( ) ) ) { intercepts . add ( bottomIntercept ) ; } } for ( ProjectionPoint leftIntercept : getMapEdgeInterceptsAtX ( projBB . getLowerLeftPoint ( ) . getX ( ) ) ) { if ( pointIsBetween ( leftIntercept , projBB . getLowerLeftPoint ( ) , projBB . getUpperLeftPoint ( ) ) ) { intercepts . add ( leftIntercept ) ; } } return intercepts ;


signature:
public class Sinusoidal { /** * Returns the points at which the line { @ code x = x0 } intersects the map edge .
 * @ param x0 defines a line that may intersect the map edge , in projection coordinates .
 * @ return the points at which the line { @ code x = x0 } intersects the map edge . May be empty . */
public List < ProjectionPoint > getMapEdgeInterceptsAtX ( double x0 ) { } }

implementation:
List < ProjectionPoint > mapEdgeIntercepts = new LinkedList < > ( ) ; if ( projToLatLon ( x0 , falseNorthing ) == INVALID ) { // The line { @ code x = x0 } does not intersect the map .
return mapEdgeIntercepts ; // Empty list .
} double x0natural = x0 - falseEasting ; double limitLon_r = ( x0natural < 0 ) ? - PI : + PI ; double deltaLon_r = limitLon_r - Math . toRadians ( centMeridian ) ; // This formula comes from solving 30-1 for phi , and then plugging it into 30-2 . See Snyder , p 247.
double minY = - earthRadius * Math . acos ( x0natural / ( earthRadius * deltaLon_r ) ) ; double maxY = + earthRadius * Math . acos ( x0natural / ( earthRadius * deltaLon_r ) ) ; mapEdgeIntercepts . add ( new ProjectionPointImpl ( x0 , minY + falseNorthing ) ) ; mapEdgeIntercepts . add ( new ProjectionPointImpl ( x0 , maxY + falseNorthing ) ) ; return mapEdgeIntercepts ;


signature:
public class Sinusoidal { /** * Returns the points at which the line { @ code y = y0 } intersects the map edge .
 * @ param y0 defines a line that intersects the map edge , in projection coordinates .
 * @ return the points at which the line { @ code y = y0 } intersects the map edge . May be empty . */
public List < ProjectionPoint > getMapEdgeInterceptsAtY ( double y0 ) { } }

implementation:
List < ProjectionPoint > mapEdgeIntercepts = new LinkedList < > ( ) ; if ( projToLatLon ( falseEasting , y0 ) == INVALID ) { // The line { @ code y = y0 } does not intersect the map .
return mapEdgeIntercepts ; // Empty list .
} double minX = getXAt ( y0 , - PI ) ; double maxX = getXAt ( y0 , + PI ) ; mapEdgeIntercepts . add ( new ProjectionPointImpl ( minX , y0 ) ) ; mapEdgeIntercepts . add ( new ProjectionPointImpl ( maxX , y0 ) ) ; return mapEdgeIntercepts ;


signature:
public class Grib1SectionProductDefinition { /** * Reference Date ( octet 13-17 ) .
 * Reference time of data – date and time of start of averaging or accumulation period .
 * @ return Reference Date as CalendarDate . */
public final CalendarDate getReferenceDate ( ) { } }

implementation: int century = getReferenceCentury ( ) - 1 ; if ( century == - 1 ) century = 20 ; int year = getOctet ( 13 ) ; int month = getOctet ( 14 ) ; int day = getOctet ( 15 ) ; int hour = getOctet ( 16 ) ; int minute = getOctet ( 17 ) ; return CalendarDate . of ( null , century * 100 + year , month , day , hour , minute , 0 ) ;


signature:
public class Grib1SectionProductDefinition { /** * NCEP Appendix C Manual 388
 * http : / / www . nco . ncep . noaa . gov / pmb / docs / on388 / appendixc . html
 * states that if the PDS is > 28 bytes and octet 41 = = 1
 * then it ' s an ensemble an product . */
public boolean isEnsemble ( ) { } }

implementation: switch ( getCenter ( ) ) { case 7 : return ( ( rawData . length >= 43 ) && ( getOctet ( 41 ) == 1 ) ) ; case 98 : return ( ( rawData . length >= 51 ) && ( getOctet ( 41 ) == 1 || getOctet ( 41 ) == 30 ) && ( getOctet ( 43 ) == 10 || getOctet ( 43 ) == 11 ) ) ; } return false ;


signature:
public class FslWindProfiler { /** * : title = " WPDN data : selected by ob time : time range from 1207951200 to 1207954800 " ; */
public boolean isMine ( FeatureType wantFeatureType , NetcdfDataset ds ) { } }

implementation: String title = ds . findAttValueIgnoreCase ( null , "title" , null ) ; if ( title == null ) { title = ds . findAttValueIgnoreCase ( null , "DD_reference" , null ) ; if ( title != null ) { title = ds . findVariable ( "staLat" ) != null ? title : null ; } } return title != null && ( title . startsWith ( "WPDN data" ) || title . startsWith ( "RASS data" ) || title . contains ( "88-21-R2" ) ) ;


signature:
public class RadarServerController { /** * This code tweaks our catalog output to match . */
private String idvDatasetCatalog ( String xml ) { } }

implementation: String ret = xml . replace ( "variables" , "Variables" ) ; ret = ret . replace ( "timeCoverage" , "TimeSpan" ) ; StringBuilder sub = new StringBuilder ( ret . substring ( 0 , ret . indexOf ( "<geospatialCoverage>" ) ) ) ; sub . append ( "<LatLonBox>\n\t<north>90.0</north>\n\t<south>-90.0</south>" ) ; sub . append ( "\n\t<east>180.0</east>\n\t<west>-180.0</west></LatLonBox>" ) ; String endCoverage = "</geospatialCoverage>" ; sub . append ( ret . substring ( ret . indexOf ( endCoverage ) + endCoverage . length ( ) ) ) ; return sub . toString ( ) ;


signature:
public class RadarServerController { /** * present and 14 days . */
private DateRange idvCompatibleRange ( DateRange range ) { } }

implementation: CalendarDate start = range . getStart ( ) . getCalendarDate ( ) ; CalendarDate end = range . getEnd ( ) . getCalendarDate ( ) ; return new DateRange ( start . toDate ( ) , end . toDate ( ) ) ;


signature:
public class NcTimeObjectPropertyType { /** * wml2 : Collection / wml2 : observationMember / om : OM _ Observation / om : phenomenonTime */
public static TimeObjectPropertyType initPhenomenonTime ( TimeObjectPropertyType phenomenonTime , StationTimeSeriesFeature stationFeat ) throws IOException { } }

implementation:
// gml : TimePeriod
TimePeriodDocument timePeriodDoc = TimePeriodDocument . Factory . newInstance ( ) ; NcTimePeriodType . initTimePeriod ( timePeriodDoc . addNewTimePeriod ( ) , stationFeat ) ; phenomenonTime . set ( timePeriodDoc ) ; return phenomenonTime ;


signature:
public class DMSPHeader { /** * Check basic DMSP file validity of given random access file . */
boolean isValidFile ( ucar . unidata . io . RandomAccessFile raFile ) { } }

implementation:
// @ todo This method should not be called if read ( ) has or will be called on this instance .
this . raFile = raFile ; try { this . actualSize = raFile . length ( ) ; } catch ( IOException e ) { return ( false ) ; } try { this . readHeaderFromFile ( raFile ) ; this . handleFileInformation ( ) ; this . handleProcessingInformation ( ) ; this . handleSatelliteInformation ( ) ; this . handleSensorInformation ( ) ; } catch ( IOException e ) { return ( false ) ; } return ( true ) ;


signature:
public class DMSPHeader { /** * Read the header information from the file into name / value pairs .
 * @ param raFile - the file to be read .
 * @ throws IOException if any problems reading the file ( or validating the file ) . */
private void readHeaderFromFile ( ucar . unidata . io . RandomAccessFile raFile ) throws IOException { } }

implementation:
long pos = 0 ; raFile . seek ( pos ) ; // Read in first record .
this . headerSizeInBytes = raFile . length ( ) > this . headerSizeInBytesGuess ? this . headerSizeInBytesGuess : ( int ) raFile . length ( ) ; byte [ ] b = new byte [ this . headerSizeInBytes ] ; if ( raFile . read ( b ) != this . headerSizeInBytes ) throw new IOException ( "Invalid DMSP file: could not read first " + this . headerSizeInBytes + " bytes." ) ; String fullHeader = new String ( b , CDM . utf8Charset ) ; // Make sure header starts with the proper item .
if ( ! fullHeader . startsWith ( HeaderInfoTitle . FILE_ID . toString ( ) ) ) { throw new IOException ( "Invalid DMSP file: header does not start with \"" + HeaderInfoTitle . FILE_ID . toString ( ) + "\"." ) ; } // Make sure header contains end - of - header marker .
int endOfHeaderIndex = fullHeader . indexOf ( HeaderInfoTitle . END_HEADER . toString ( ) ) ; if ( endOfHeaderIndex == - 1 ) { throw new IOException ( "Invalid DMSP file: header does not end with \"" + HeaderInfoTitle . END_HEADER . toString ( ) + "\"." ) ; } // Drop the end - of - header marker and the line feed ( ' \ n ' ) proceeding it .
header = fullHeader . substring ( 0 , endOfHeaderIndex - 1 ) . split ( "\n" ) ; int lineSeperatorIndex = 0 ; String curHeaderLine = null ; String curHeaderTitle = null ; String curHeaderValue = null ; for ( String aHeader : this . header ) { curHeaderLine = aHeader . trim ( ) ; lineSeperatorIndex = curHeaderLine . indexOf ( ':' ) ; if ( lineSeperatorIndex == - 1 ) throw new IOException ( "Invalid DMSP file: header line <" + curHeaderLine + "> contains no seperator <:>." ) ; if ( lineSeperatorIndex == 0 ) throw new IOException ( "Invalid DMSP file: header line <" + curHeaderLine + "> contains no title." ) ; if ( lineSeperatorIndex == curHeaderLine . length ( ) - 1 ) throw new IOException ( "Invalid DMSP file: header line <" + curHeaderLine + "> contains no value." ) ; curHeaderTitle = curHeaderLine . substring ( 0 , lineSeperatorIndex ) . trim ( ) ; curHeaderValue = curHeaderLine . substring ( lineSeperatorIndex + 1 ) . trim ( ) ; if ( curHeaderValue . equals ( "" ) ) throw new IOException ( "Invalid DMSP file: header line <" + curHeaderLine + "> contains no value." ) ; headerInfo . put ( curHeaderTitle , curHeaderValue ) ; }


signature:
public class DMSPHeader { /** * Parse the file header information about the file ( e . g . , file ID , dataset ID ,
 * record size , number of records ) and create netCDF attributes and dimensions
 * where appropriate .
 * @ throws IOException if any problems reading the file ( or validating the file ) . */
private void handleFileInformation ( ) throws IOException { } }

implementation: fileIdAtt = new Attribute ( this . fileIdAttName , headerInfo . get ( HeaderInfoTitle . FILE_ID . toString ( ) ) ) ; datasetIdAtt = new Attribute ( this . datasetIdAttName , headerInfo . get ( HeaderInfoTitle . DATA_SET_ID . toString ( ) ) ) ; recordSizeInBytes = Integer . parseInt ( headerInfo . get ( HeaderInfoTitle . RECORD_BYTES . toString ( ) ) ) ; numRecords = Integer . parseInt ( headerInfo . get ( HeaderInfoTitle . NUM_RECORDS . toString ( ) ) ) ; numHeaderRecords = Integer . parseInt ( headerInfo . get ( HeaderInfoTitle . NUM_HEADER_RECORDS . toString ( ) ) ) ; numDataRecords = Integer . parseInt ( headerInfo . get ( HeaderInfoTitle . NUM_DATA_RECORDS . toString ( ) ) ) ; numDataRecordsDim = new Dimension ( this . numDataRecordsDimName , numDataRecords , true , true , false ) ; numArtificialDataRecords = Integer . parseInt ( headerInfo . get ( HeaderInfoTitle . NUM_ARTIFICIAL_DATA_RECORDS . toString ( ) ) ) ; this . headerSizeInBytes = this . numHeaderRecords * this . recordSizeInBytes ; if ( numRecords * ( ( long ) this . recordSizeInBytes ) != this . actualSize ) { throw new IOException ( "Invalid DMSP file: the number of records <" + this . numRecords + "> times the record size <" + this . recordSizeInBytes + "> does not equal the size of the file <" + this . actualSize + ">." ) ; }


signature:
public class DMSPHeader { /** * Parse the processing / history information from the header .
 * @ throws IOException if any problems reading the file ( or validating the file ) . */
private void handleProcessingInformation ( ) throws IOException { } }

implementation: suborbitHistoryAtt = new Attribute ( this . suborbitHistoryAttName , headerInfo . get ( HeaderInfoTitle . SUBORBIT_HISTORY . toString ( ) ) ) ; processingSystemAtt = new Attribute ( this . processingSystemAttName , headerInfo . get ( HeaderInfoTitle . PROCESSING_SYSTEM . toString ( ) ) ) ; String processingDateString = headerInfo . get ( HeaderInfoTitle . PROCESSING_DATE . toString ( ) ) ; try { processingDate = DateFormatHandler . ALT_DATE_TIME . getDateFromDateTimeString ( processingDateString ) ; } catch ( ParseException e ) { throw new IOException ( "Invalid DMSP file: processing date string <" + processingDateString + "> not parseable: " + e . getMessage ( ) ) ; } processingDateAtt = new Attribute ( this . processingDateAttName , DateFormatHandler . ISO_DATE_TIME . getDateTimeStringFromDate ( processingDate ) ) ;


signature:
public class DMSPHeader { /** * Parse the satellite information from the header . */
private void handleSatelliteInformation ( ) { } }

implementation: spacecraftIdAtt = new Attribute ( this . spacecraftIdAttName , headerInfo . get ( HeaderInfoTitle . SPACECRAFT_ID . toString ( ) ) ) ; noradIdAtt = new Attribute ( this . noradIdAttName , headerInfo . get ( HeaderInfoTitle . NORAD_ID . toString ( ) ) ) ;


signature:
public class DMSPHeader { /** * Parse the sensor information from the header . */
private void handleSensorInformation ( ) { } }

implementation:
numSamplesPerBand = Integer . parseInt ( headerInfo . get ( HeaderInfoTitle . SAMPLES_PER_BAND . toString ( ) ) ) ; numSamplesPerBandDim = new Dimension ( this . numSamplesPerBandDimName , numSamplesPerBand ) ; // Read nominal resolution information
nominalResolutionAtt = new Attribute ( nominalResolutionAttName , headerInfo . get ( HeaderInfoTitle . NOMINAL_RESOLUTION . toString ( ) ) ) ; // Read bands per scanlin information .
bandsPerScanlineAtt = new Attribute ( bandsPerScanlineAttName , Integer . valueOf ( headerInfo . get ( HeaderInfoTitle . BANDS_PER_SCANLINE . toString ( ) ) ) ) ; // Read bytes per smaple information
bytesPerSampleAtt = new Attribute ( bytesPerSampleAttName , Integer . valueOf ( headerInfo . get ( HeaderInfoTitle . BYTES_PER_SAMPLE . toString ( ) ) ) ) ; // Read byte offset for band 1 information .
byteOffsetBand1Att = new Attribute ( byteOffsetBand1AttName , Integer . valueOf ( headerInfo . get ( HeaderInfoTitle . BYTE_OFFSET_BAND_1 . toString ( ) ) ) ) ; // Read byte offset for band 2 information .
byteOffsetBand2Att = new Attribute ( byteOffsetBand2AttName , Integer . valueOf ( headerInfo . get ( HeaderInfoTitle . BYTE_OFFSET_BAND_2 . toString ( ) ) ) ) ; // Band 1 description
band1Att = new Attribute ( band1AttName , headerInfo . get ( HeaderInfoTitle . BAND_1 . toString ( ) ) ) ; // Band 2 description
band2Att = new Attribute ( band2AttName , headerInfo . get ( HeaderInfoTitle . BAND_2 . toString ( ) ) ) ; // Band organization
bandOrganizationAtt = new Attribute ( bandOrganizationAttName , headerInfo . get ( HeaderInfoTitle . ORGANIZATION . toString ( ) ) ) ; // thermal offset
thermalOffsetAtt = new Attribute ( thermalOffsetAttName , headerInfo . get ( HeaderInfoTitle . THERMAL_OFFSET . toString ( ) ) ) ; // thermal scale
thermalScaleAtt = new Attribute ( thermalScaleAttName , headerInfo . get ( HeaderInfoTitle . THERMAL_SCALE . toString ( ) ) ) ; // percent daylight
percentDaylightAtt = new Attribute ( percentDaylightAttName , Double . valueOf ( headerInfo . get ( HeaderInfoTitle . PERCENT_DAYLIGHT . toString ( ) ) ) ) ; // percent full moon
percentFullMoonAtt = new Attribute ( percentFullMoonAttName , Double . valueOf ( headerInfo . get ( HeaderInfoTitle . PERCENT_FULL_MOON . toString ( ) ) ) ) ; // percent terminator evident
percentTerminatorEvidentAtt = new Attribute ( percentTerminatorEvidentAttName , Double . valueOf ( headerInfo . get ( HeaderInfoTitle . PERCENT_TERMINATOR_EVIDENT . toString ( ) ) ) ) ;


signature:
public class DMSPHeader { /** * Return a string containing the header name / value pairs .
 * @ return a string of the file header name / value pairs . */
protected String headerInfoDump ( ) { } }

implementation: StringBuilder retVal = new StringBuilder ( ) ; for ( String curHeaderTitle : this . headerInfo . keySet ( ) ) { String curHeaderValue = this . headerInfo . get ( curHeaderTitle ) ; retVal . append ( curHeaderTitle ) ; retVal . append ( ":::::" ) ; retVal . append ( curHeaderValue ) ; retVal . append ( ":::::\n" ) ; } return ( retVal . toString ( ) ) ;


signature:
public class Parse { /** * Read an XML Document from a URL and return the root element .
 * @ param location the URL location
 * @ return the root element of the Document
 * @ throws java . io . IOException on read error */
static public Element readRootElement ( String location ) throws IOException { } }

implementation: org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; doc = builder . build ( location ) ; } catch ( JDOMException e ) { throw new IOException ( e . getMessage ( ) ) ; } return doc . getRootElement ( ) ;


signature:
public class Parse { /** * Make sure that text is XML safe
 * @ param text check this
 * @ return original text if ok , else with bad characters removed */
static public String cleanCharacterData ( String text ) { } }

implementation: if ( text == null ) return null ; boolean bad = false ; for ( int i = 0 , len = text . length ( ) ; i < len ; i ++ ) { int ch = text . charAt ( i ) ; if ( ! org . jdom2 . Verifier . isXMLCharacter ( ch ) ) { bad = true ; break ; } } if ( ! bad ) return text ; StringBuilder sbuff = new StringBuilder ( text . length ( ) ) ; for ( int i = 0 , len = text . length ( ) ; i < len ; i ++ ) { int ch = text . charAt ( i ) ; if ( org . jdom2 . Verifier . isXMLCharacter ( ch ) ) sbuff . append ( ( char ) ch ) ; } return sbuff . toString ( ) ;


signature:
public class Uspln { /** * Check if this is a valid file for this IOServiceProvider .
 * @ param raf RandomAccessFile
 * @ return true if valid .
 * @ throws IOException if read error */
public boolean isValidFile ( RandomAccessFile raf ) throws IOException { } }

implementation: raf . seek ( 0 ) ; int n = MAGIC . length ( ) ; if ( raf . length ( ) < n ) { return false ; } String got = raf . readString ( n ) ; return ( pMAGIC . matcher ( got ) . find ( ) || pMAGIC_OLD . matcher ( got ) . find ( ) ) ;


signature:
public class Uspln { /** * Open existing file , and populate ncfile with it . This method is only
 * called by the NetcdfFile constructor on itself . The provided NetcdfFile
 * object will be empty except for the location String and the
 * IOServiceProvider associated with this NetcdfFile object .
 * @ param raf the file to work on , it has already passed the
 * isValidFile ( ) test .
 * @ param ncfile add objects to this empty NetcdfFile
 * @ param cancelTask used to monitor user cancellation ; may be null .
 * @ throws IOException if read error */
public void open ( RandomAccessFile raf , NetcdfFile ncfile , CancelTask cancelTask ) throws IOException { } }

implementation: super . open ( raf , ncfile , cancelTask ) ; isExtended = checkFormat ( ) ; isoDateFormat = new SimpleDateFormat ( ) ; isoDateFormat . setTimeZone ( java . util . TimeZone . getTimeZone ( "GMT" ) ) ; isoDateFormat . applyPattern ( isExtended ? TIME_FORMAT_EX : TIME_FORMAT ) ; Sequence seq = makeSequence ( ncfile ) ; ncfile . addVariable ( null , seq ) ; addLightningGlobalAttributes ( ncfile ) ; ncfile . finish ( ) ; sm = seq . makeStructureMembers ( ) ; ArrayStructureBB . setOffsets ( sm ) ;


signature:
public class Uspln { /** * Add the global attributes .
 * @ param ncfile the file to add to */
protected void addLightningGlobalAttributes ( NetcdfFile ncfile ) { } }

implementation:
super . addLightningGlobalAttributes ( ncfile ) ; ncfile . addAttribute ( null , new Attribute ( "title" , "USPLN Lightning Data" ) ) ; ncfile . addAttribute ( null , new Attribute ( "file_format" , "USPLN1 " + ( isExtended ? "(extended)" : "(original)" ) ) ) ; /* ncfile . addAttribute ( null ,
 new Attribute ( " time _ coverage _ start " ,
 time _ min + " " + secondsSince1970 ) ) ;
 ncfile . addAttribute ( null ,
 new Attribute ( " time _ coverage _ end " ,
 time _ max + " " + secondsSince1970 ) ) ;
 ncfile . addAttribute ( null ,
 new Attribute ( " geospatial _ lat _ min " ,
 new Double ( lat _ min ) ) ) ;
 ncfile . addAttribute ( null ,
 new Attribute ( " geospatial _ lat _ max " ,
 new Double ( lat _ max ) ) ) ;
 ncfile . addAttribute ( null ,
 new Attribute ( " geospatial _ lon _ min " ,
 new Double ( lon _ min ) ) ) ;
 ncfile . addAttribute ( null ,
 new Attribute ( " geospatial _ lon _ max " ,
 new Double ( lon _ max ) ) ) ; */


signature:
public class Uspln { /** * Read all the data and return the number of strokes
 * @ return true if extended format
 * @ throws IOException if read error */
private boolean checkFormat ( ) throws IOException { } }

implementation: raf . seek ( 0 ) ; boolean extended = false ; while ( true ) { long offset = raf . getFilePointer ( ) ; String line = raf . readLine ( ) ; if ( line == null ) { break ; } if ( pMAGIC . matcher ( line ) . find ( ) || pMAGIC_OLD . matcher ( line ) . find ( ) ) { extended = pMAGIC_EX . matcher ( line ) . find ( ) ; break ; } } return extended ;


signature:
public class Uspln { /** * Read all the data and return the number of strokes
 * @ param raf the file to read
 * @ return the number of strokes
 * @ throws IOException if read error
 * @ throws NumberFormatException if problem parsing data
 * @ throws ParseException if parse problem */
int readAllData ( RandomAccessFile raf ) throws IOException , NumberFormatException , ParseException { } }

implementation:
ArrayList offsetList = new ArrayList ( ) ; java . text . SimpleDateFormat isoDateTimeFormat = new java . text . SimpleDateFormat ( TIME_FORMAT ) ; isoDateTimeFormat . setTimeZone ( java . util . TimeZone . getTimeZone ( "GMT" ) ) ; lat_min = 1000.0 ; lat_max = - 1000.0 ; lon_min = 1000.0 ; lon_max = - 1000.0 ; time_min = Double . POSITIVE_INFINITY ; time_max = Double . NEGATIVE_INFINITY ; raf . seek ( 0 ) ; int count = 0 ; boolean knowExtended = false ; while ( true ) { long offset = raf . getFilePointer ( ) ; String line = raf . readLine ( ) ; if ( line == null ) { break ; } if ( pMAGIC . matcher ( line ) . find ( ) || pMAGIC_OLD . matcher ( line ) . find ( ) ) { if ( ! knowExtended ) { isExtended = pMAGIC_EX . matcher ( line ) . find ( ) ; if ( isExtended ) { isoDateTimeFormat . applyPattern ( TIME_FORMAT_EX ) ; } knowExtended = true ; } continue ; } // 2006-10-23T17:59:39,18.415434 , - 93.480526 , - 26.8,1 ( original )
// 2006-10-23T17:59:39,18.415434 , - 93.480526 , - 26.8,0.25,0.5,80 ( extended )
StringTokenizer stoker = new StringTokenizer ( line , ",\r\n" ) ; while ( stoker . hasMoreTokens ( ) ) { Date date = isoDateTimeFormat . parse ( stoker . nextToken ( ) ) ; double lat = Double . parseDouble ( stoker . nextToken ( ) ) ; double lon = Double . parseDouble ( stoker . nextToken ( ) ) ; double amp = Double . parseDouble ( stoker . nextToken ( ) ) ; int nstrokes = 1 ; double axisMaj = Double . NaN ; double axisMin = Double . NaN ; int orient = 0 ; if ( isExtended ) { axisMaj = Double . parseDouble ( stoker . nextToken ( ) ) ; axisMin = Double . parseDouble ( stoker . nextToken ( ) ) ; orient = Integer . parseInt ( stoker . nextToken ( ) ) ; } else { nstrokes = Integer . parseInt ( stoker . nextToken ( ) ) ; } Stroke s = isExtended ? new Stroke ( date , lat , lon , amp , axisMaj , axisMin , orient ) : new Stroke ( date , lat , lon , amp , nstrokes ) ; lat_min = Math . min ( lat_min , s . lat ) ; lat_max = Math . max ( lat_max , s . lat ) ; lon_min = Math . min ( lon_min , s . lon ) ; lon_max = Math . max ( lon_max , s . lon ) ; time_min = Math . min ( time_min , s . secs ) ; time_max = Math . max ( time_max , s . secs ) ; } offsetList . add ( new Long ( offset ) ) ; count ++ ; } offsets = new long [ count ] ; for ( int i = 0 ; i < offsetList . size ( ) ; i ++ ) { Long off = ( Long ) offsetList . get ( i ) ; offsets [ i ] = off . longValue ( ) ; } // System . out . println ( " processed " + count + " records " ) ;
return count ;


signature:
public class Uspln { /** * Read data from a top level Variable and return a memory resident Array .
 * This Array has the same element type as the Variable , and the requested shape .
 * @ param v2 a top - level Variable
 * @ param section the section of data to read .
 * There must be a Range for each Dimension in the variable , in order .
 * Note : no nulls allowed . IOSP may not modify .
 * @ return the requested data in a memory - resident Array
 * @ throws IOException if read error
 * @ throws InvalidRangeException if invalid section
 * @ see ucar . ma2 . Range */
public Array readData ( Variable v2 , Section section ) throws IOException , InvalidRangeException { } }

implementation: return new ArraySequence ( sm , getStructureIterator ( null , 0 ) , nelems ) ;


signature:
public class Escape { /** * Given a string that contains WWW escape sequences , translate those escape
 * sequences back into ASCII characters . Return the modified string .
 * @ param in The string to modify .
 * @ param escape The character used to signal the begining of an escape sequence .
 * param except If there is some escape code that should not be removed by
 * this call ( e . g . , you might not want to remove spaces , % 20 ) use this
 * parameter to specify that code . The function will then transform all
 * escapes except that one .
 * @ param spaceplus True if spaces should be replaced by ' + ' .
 * @ return The modified string . */
private static String xunescapeString ( String in , char escape , boolean spaceplus ) { } }

implementation:
try { if ( in == null ) return null ; byte [ ] utf8 = in . getBytes ( utf8Charset ) ; byte escape8 = ( byte ) escape ; byte [ ] out = new byte [ utf8 . length ] ; // Should be max we need
int index8 = 0 ; for ( int i = 0 ; i < utf8 . length ; ) { byte b = utf8 [ i ++ ] ; if ( b == plus && spaceplus ) { out [ index8 ++ ] = blank ; } else if ( b == escape8 ) { // check to see if there are enough characters left
if ( i + 2 <= utf8 . length ) { b = ( byte ) ( fromHex ( utf8 [ i ] ) << 4 | fromHex ( utf8 [ i + 1 ] ) ) ; i += 2 ; } } out [ index8 ++ ] = b ; } return new String ( out , 0 , index8 , utf8Charset ) ; } catch ( Exception e ) { return in ; }


signature:
public class Escape { /** * Define the DEFINITIVE URL constraint expression escape function .
 * @ param ce The expression to modify .
 * @ return The escaped expression . */
public static String escapeURLQuery ( String ce ) { } }

implementation: try { ce = escapeString ( ce , _allowableInUrlQuery ) ; } catch ( Exception e ) { ce = null ; } return ce ;


signature:
public class Escape { /** * Define the DEFINITIVE URL constraint expression unescape function .
 * @ param ce The expression to unescape .
 * @ return The unescaped expression . */
public static String unescapeURLQuery ( String ce ) { } }

implementation: try { ce = unescapeString ( ce ) ; } catch ( Exception e ) { ce = null ; } return ce ;


signature:
public class Escape { /** * Define the DEFINITIVE URL BACKSLASH unescape function .
 * @ param s The string to unescape .
 * @ return The unescaped expression . */
public static String backslashDecode ( String s ) { } }

implementation: StringBuilder buf = new StringBuilder ( s ) ; int i = 0 ; while ( i < buf . length ( ) ) { if ( buf . charAt ( i ) == '\\' ) { buf . deleteCharAt ( i ) ; } i ++ ; } return buf . toString ( ) ;


signature:
public class Escape { /** * Define the DEFINITIVE URL BACKSLASH escape function .
 * @ param s The string to escape .
 * @ return The escaped expression . */
public static String backslashEncode ( String s ) { } }

implementation: StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int c = buf . charAt ( i ) ; if ( _MustBackslashEscape . indexOf ( c ) >= 0 ) buf . append ( _BACKSLASHEscape ) ; buf . append ( ( char ) c ) ; } return buf . toString ( ) ;


signature:
public class AbstractLightningIOSP { /** * Make lightning variables
 * @ param ncfile the netCDF file
 * @ param group the group ( may be null )
 * @ param seq the sequence to add to
 * @ param name variable name
 * @ param dataType the data type
 * @ param dims dimenstion names
 * @ param longName the long _ name attribute value ( a description )
 * @ param cfName the CF standard _ name attribute value ( may be null )
 * @ param units the units attribute value ( if null , not added )
 * @ param type coordinate axis type units ( if null , not added )
 * @ return the variable */
protected Variable makeLightningVariable ( NetcdfFile ncfile , Group group , Structure seq , String name , DataType dataType , String dims , String longName , String cfName , String units , AxisType type ) { } }

implementation: Variable v = new Variable ( ncfile , group , seq , name ) ; v . setDataType ( dataType ) ; v . setDimensions ( dims ) ; v . addAttribute ( new Attribute ( CDM . LONG_NAME , longName ) ) ; if ( cfName != null ) { v . addAttribute ( new Attribute ( CF . STANDARD_NAME , cfName ) ) ; } if ( units != null ) { v . addAttribute ( new Attribute ( CDM . UNITS , units ) ) ; } if ( type != null ) { v . addAttribute ( new Attribute ( _Coordinate . AxisType , type . toString ( ) ) ) ; } return v ;


signature:
public class AbstractLightningIOSP { /** * Add the global attributes . Specific implementations should call super
 * and then add their own .
 * @ param ncfile the file to add to */
protected void addLightningGlobalAttributes ( NetcdfFile ncfile ) { } }

implementation: ncfile . addAttribute ( null , new Attribute ( CF . FEATURE_TYPE , CF . FeatureType . point . toString ( ) ) ) ; ncfile . addAttribute ( null , new Attribute ( CDM . HISTORY , "Read directly by Netcdf Java IOSP" ) ) ;


signature:
public class Constants { /** * res . setHeader ( " Content - Disposition " , " attachment ; filename = " + path + " . nc " ) ; */
public static String setContentDispositionValue ( String filename , String suffix ) { } }

implementation: int pos = filename . lastIndexOf ( '/' ) ; String outname = ( pos > 0 ) ? filename . substring ( pos + 1 ) : filename ; int pos2 = outname . lastIndexOf ( '.' ) ; outname = ( pos > 0 ) ? outname . substring ( 0 , pos2 ) : outname ; outname = outname + suffix ; return setContentDispositionValue ( outname ) ;


signature:
public class SDGrid { /** * Write the variable ' s declaration in a C - style syntax . This
 * function is used to create textual representation of the Data
 * Descriptor Structure ( DDS ) . See < em > The OPeNDAP User Manual < / em > for
 * information about this structure .
 * @ param os The < code > PrintWriter < / code > on which to print the
 * declaration .
 * @ param space Each line of the declaration will begin with the
 * characters in this string . Usually used for leading spaces .
 * @ param print _ semi a boolean value indicating whether to print a
 * semicolon at the end of the declaration .
 * @ see BaseType # printDecl ( PrintWriter , String , boolean ) */
public void printDecl ( PrintWriter os , String space , boolean print_semi , boolean constrained ) { } }

implementation:
// BEWARE ! Since printDecl ( ) is ( multiple ) overloaded in BaseType
// and all of the different signatures of printDecl ( ) in BaseType
// lead to one signature , we must be careful to override that
// SAME signature here . That way all calls to printDecl ( ) for
// this object lead to this implementation .
boolean isSingle = false ; boolean isStructure = false ; boolean isGrid = false ; boolean psemi = true ; // os . println ( " The grid contains " + projectedComponents ( true ) + " projected components " ) ;
if ( constrained && projectedComponents ( true ) == 0 ) return ; // If we are printing the declaration of a constrained Grid then check for
// the case where the projection removes all but one component ; the
// resulting object is a simple array .
// 2013-2-26 : Heimbigner : this is incorrect , even single
// projected components should be in a structure .
/* Wrong
 if ( constrained & & projectedComponents ( true ) = = 1 ) {
 / / os . println ( " It ' s a single Array . " ) ;
 isSingle = true ;
 psemi = print _ semi ; */
// If there are M ( < N ) components ( Array and Maps combined ) in a N
// component Grid , send the M components as elements of a Structure .
// This will preserve the grouping without violating the rules for a
// Grid .
else if ( constrained && ! projectionYieldsGrid ( true ) ) { // os . println ( " It ' s a Structure . " ) ;
isStructure = true ; } else { // The number of elements in the ( projected ) Grid must be such that
// we have a valid Grid object ; send it as such .
// os . println ( " It ' s a Grid . " ) ;
isGrid = true ; } if ( isGrid ) os . println ( space + getTypeName ( ) + " {" ) ; if ( isGrid ) os . println ( space + " ARRAY:" ) ; if ( isStructure ) os . println ( space + "Structure {" ) ; ( ( SDArray ) arrayVar ) . printDecl ( os , space + "    " , psemi , constrained ) ; if ( isGrid ) os . println ( space + " MAPS:" ) ; for ( Enumeration e = mapVars . elements ( ) ; e . hasMoreElements ( ) ; ) { SDArray sda = ( SDArray ) e . nextElement ( ) ; sda . printDecl ( os , space + "    " , psemi , constrained ) ; } if ( isStructure || isGrid ) { os . print ( space + "} " + getEncodedName ( ) ) ; if ( print_semi ) os . println ( ";" ) ; } return ;


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

implementation:
if ( ! isProject ( ) ) return ; // System . out . println ( " \ nSome Part of this object is projected . . . " ) ;
if ( print_decl_p ) { printDecl ( os , space , false , true ) ; os . print ( " = " ) ; } boolean isStillGrid = projectionYieldsGrid ( true ) ; os . print ( "{ " ) ; if ( isStillGrid ) os . print ( "ARRAY: " ) ; if ( ( ( SDArray ) arrayVar ) . isProject ( ) ) arrayVar . printVal ( os , "" , false ) ; if ( isStillGrid ) os . print ( " MAPS: " ) ; boolean firstPass = true ; Enumeration e = mapVars . elements ( ) ; while ( e . hasMoreElements ( ) ) { SDArray sda = ( SDArray ) e . nextElement ( ) ; if ( ( ( SDArray ) sda ) . isProject ( ) ) { if ( ! firstPass ) os . print ( ", " ) ; sda . printVal ( os , "" , false ) ; firstPass = false ; } } os . print ( " }" ) ; if ( print_decl_p ) os . println ( ";" ) ;


signature:
public class SDGrid { /** * Set the state of this variable ' s projection . < code > true < / code > means
 * that this variable is part of the current projection as defined by
 * the current constraint expression , otherwise the current projection
 * for this variable should be < code > false < / code > .
 * @ param state < code > true < / code > if the variable is part of the current
 * projection , < code > false < / code > otherwise .
 * @ param all If < code > true < / code > , set the Project property of all the
 * members ( and their children , and so on ) .
 * @ see CEEvaluator */
@ Override public void setProject ( boolean state , boolean all ) { } }

implementation:
setProjected ( state ) ; if ( all ) { // System . out . println ( " SDGrid : setProject : Blindly setting Project " ) ;
( ( SDArray ) arrayVar ) . setProject ( state ) ; for ( Enumeration e = mapVars . elements ( ) ; e . hasMoreElements ( ) ; ) { ServerMethods sm = ( ServerMethods ) e . nextElement ( ) ; sm . setProject ( state ) ; } }


signature:
public class SDGrid { /** * Server - side serialization for OPeNDAP variables ( sub - classes of
 * < code > BaseType < / code > ) .
 * This does not send the entire class as the Java < code > Serializable < / code >
 * interface does , rather it sends only the binary data values . Other software
 * is responsible for sending variable type information ( see < code > DDS < / code > ) .
 * Writes data to a < code > DataOutputStream < / code > . This method is used
 * on the server side of the OPeNDAP client / server connection , and possibly
 * by GUI clients which need to download OPeNDAP data , manipulate it , and
 * then re - save it as a binary file .
 * @ param sink a < code > DataOutputStream < / code > to write to .
 * @ throws IOException thrown on any < code > OutputStream < / code > exception .
 * @ see BaseType
 * @ see DDS
 * @ see ServerDDS */
public void serialize ( String dataset , DataOutputStream sink , CEEvaluator ce , Object specialO ) throws NoSuchVariableException , DAP2ServerSideException , IOException { } }

implementation: if ( ! isRead ( ) ) read ( dataset , specialO ) ; if ( ce . evalClauses ( specialO ) ) { if ( ( ( ServerMethods ) arrayVar ) . isProject ( ) ) ( ( ServerMethods ) arrayVar ) . serialize ( dataset , sink , ce , specialO ) ; for ( Enumeration e = mapVars . elements ( ) ; e . hasMoreElements ( ) ; ) { ServerMethods sm = ( ServerMethods ) e . nextElement ( ) ; if ( sm . isProject ( ) ) sm . serialize ( dataset , sink , ce , specialO ) ; } }


signature:
public class SDGrid { /** * Set the projection information for this dimension . The internal < code > DArray < / code > is
 * retrieved and then the < code > DArrayDimension < / code >
 * associated with the < code > dimension < / code > specified is retrieved and the < code > start < / code >
 * < code > stride < / code > and < code > stop < / code > parameters are passed to its
 * < code > setProjection ( ) < / code > method .
 * @ param dimension The dimension that is to be modified .
 * @ param start The starting point for the projection of this < code > DArrayDimension < / code > .
 * @ param stride The size of the stride for the projection of this < code > DArrayDimension < / code > .
 * @ param stop The stopping point for the projection of this < code > DArrayDimension < / code > .
 * @ see DArray
 * @ see DArrayDimension */
public void setProjection ( int dimension , int start , int stride , int stop ) throws InvalidDimensionException , SBHException { } }

implementation: try { DArray a = ( DArray ) getVar ( 0 ) ; DArrayDimension d = a . getDimension ( dimension ) ; d . setProjection ( start , stride , stop ) ; DArray map = ( DArray ) getVar ( dimension + 1 ) ; DArrayDimension mapD = map . getDimension ( 0 ) ; mapD . setProjection ( start , stride , stop ) ; } catch ( NoSuchVariableException e ) { throw new InvalidDimensionException ( "SDGrid.setProjection(): Bad Value for dimension!: " + e . getMessage ( ) ) ; }


signature:
public class SDGrid { /** * Gets the < b > start < / b > value for the projection of the
 * < code > dimension < / code > indicated . The parameter
 * < code > dimension < / code > is checked against the instance of the
 * < code > SDArray < / code > for bounds violation .
 * @ param dimension The dimension from whose projection to retrieve the
 * < code > start < / code > value . */
public int getStart ( int dimension ) throws InvalidDimensionException { } }

implementation: try { DArray a = ( DArray ) getVar ( 0 ) ; DArrayDimension d = a . getDimension ( dimension ) ; return ( d . getStart ( ) ) ; } catch ( NoSuchVariableException e ) { throw new InvalidDimensionException ( "SDGrid.getStart(): Bad Value for dimension!: " + e . getMessage ( ) ) ; }


signature:
public class SDGrid { /** * Write the variable ' s declaration in a C - style syntax . This
 * function is used to create textual representation of the Data
 * Descriptor Structure ( DDS ) . See < em > The OPeNDAP User Manual < / em > for
 * information about this structure .
 * @ see BaseType # printDecl ( PrintWriter , String , boolean )
 * @ opendap . ddx . experimental */
public void printXML ( PrintWriter pw , String pad , boolean constrained ) { } }

implementation:
// BEWARE ! Since printDecl ( ) is ( multiple ) overloaded in BaseType
// and all of the different signatures of printDecl ( ) in BaseType
// lead to one signature , we must be careful to override that
// SAME signature here . That way all calls to printDecl ( ) for
// this object lead to this implementation .
boolean isSingle = false ; boolean isStructure = false ; boolean isGrid = false ; boolean psemi = true ; // os . println ( " The gird contains " + projectedComponents ( true ) + " projected components " ) ;
if ( constrained && projectedComponents ( true ) == 0 ) return ; // If we are printing the declaration of a constrained Grid then check for
// the case where the projection removes all but one component ; the
// resulting object is a simple array .
if ( constrained && projectedComponents ( true ) == 1 ) { // os . println ( " It ' s a single Array . " ) ;
isSingle = true ; } // If there are M ( < N ) componets ( Array and Maps combined ) in a N
// component Grid , send the M components as elements of a Struture .
// This will preserve the grouping without violating the rules for a
// Grid .
else if ( constrained && ! projectionYieldsGrid ( true ) ) { // os . println ( " It ' s a Structure . " ) ;
isStructure = true ; } else { // The number of elements in the ( projected ) Grid must be such that
// we have a valid Grid object ; send it as such .
// os . println ( " It ' s a Grid . " ) ;
isGrid = true ; } if ( isGrid ) { pw . print ( pad + "<Grid " ) ; if ( getEncodedName ( ) != null ) { pw . print ( " name=\"" + DDSXMLParser . normalizeToXML ( getEncodedName ( ) ) + "\"" ) ; } pw . println ( ">" ) ; } if ( isStructure ) { pw . print ( pad + "<Structure" ) ; if ( getEncodedName ( ) != null ) { pw . print ( " name=\"" + DDSXMLParser . normalizeToXML ( getEncodedName ( ) ) + "\"" ) ; } pw . println ( ">" ) ; } Enumeration e = getAttributeNames ( ) ; while ( e . hasMoreElements ( ) ) { String aName = ( String ) e . nextElement ( ) ; Attribute a = getAttribute ( aName ) ; if ( a != null ) a . printXML ( pw , pad + "\t" , constrained ) ; } ( ( SDArray ) arrayVar ) . printXML ( pw , pad + ( isSingle ? "" : "\t" ) , constrained ) ; if ( isGrid ) { e = mapVars . elements ( ) ; while ( e . hasMoreElements ( ) ) { SDArray map = ( SDArray ) e . nextElement ( ) ; // Coverity [ DEADCODE ]
map . printAsMapXML ( pw , pad + ( isSingle ? "" : "\t" ) , constrained ) ; } } else { e = mapVars . elements ( ) ; while ( e . hasMoreElements ( ) ) { SDArray sda = ( SDArray ) e . nextElement ( ) ; sda . printXML ( pw , pad + ( isSingle ? "" : "\t" ) , constrained ) ; } } if ( isStructure ) { pw . println ( pad + "</Structure>" ) ; } else if ( isGrid ) { pw . println ( pad + "</Grid>" ) ; } return ;


signature:
public class Swap { /** * Returns the short resulting from swapping 2 bytes at a specified
 * offset in a byte array .
 * @ param b the byte array
 * @ param offset the offset of the first byte
 * @ return the short represented by the bytes
 * < code > b [ offset + 1 ] , b [ offset ] < / code > */
static public short swapShort ( byte [ ] b , int offset ) { } }

implementation:
// 2 bytes
int low = b [ offset ] & 0xff ; int high = b [ offset + 1 ] & 0xff ; return ( short ) ( high << 8 | low ) ;


signature:
public class Swap { /** * Returns the int resulting from reversing 4 bytes at a specified
 * offset in a byte array .
 * @ param b the byte array
 * @ param offset the offset of the first byte
 * @ return the int represented by the bytes
 * < code > b [ offset + 3 ] , b [ offset + 2 ] , . . . , b [ offset ] < / code > */
static public int swapInt ( byte [ ] b , int offset ) { } }

implementation:
// 4 bytes
int accum = 0 ; for ( int shiftBy = 0 , i = offset ; shiftBy < 32 ; shiftBy += 8 , i ++ ) { accum |= ( b [ i ] & 0xff ) << shiftBy ; } return accum ;


signature:
public class Swap { /** * Returns the double resulting from reversing 8 bytes at a specified
 * offset in a byte array .
 * @ param b the byte array
 * @ param offset the offset of the first byte
 * @ return the double represented by the bytes
 * < code > b [ offset + 7 ] , b [ offset + 6 ] , . . . , b [ offset ] < / code > */
static public double swapDouble ( byte [ ] b , int offset ) { } }

implementation: long accum = 0 ; long shiftedval ; for ( int shiftBy = 0 , i = offset ; shiftBy < 64 ; shiftBy += 8 , i ++ ) { shiftedval = ( ( long ) ( b [ i ] & 0xff ) ) << shiftBy ; accum |= shiftedval ; } return Double . longBitsToDouble ( accum ) ;


signature:
public class Swap { /** * Returns the float resulting from reversing 4 bytes of a specified
 * float .
 * @ param v input value for which byte reversal is desired
 * @ return the value represented by the bytes of < code > v < / code >
 * reversed */
static public float swapFloat ( float v ) { } }

implementation: int l = swapInt ( Float . floatToIntBits ( v ) ) ; return ( Float . intBitsToFloat ( l ) ) ;


signature:
public class Swap { /** * Returns the double resulting from reversing 8 bytes of a specified
 * double .
 * @ param v input value for which byte reversal is desired
 * @ return the value represented by the bytes of < code > v < / code >
 * reversed */
static public double swapDouble ( double v ) { } }

implementation: long l = swapLong ( Double . doubleToLongBits ( v ) ) ; return ( Double . longBitsToDouble ( l ) ) ;


signature:
public class Swap { /** * Convert a short to an array of 2 bytes .
 * @ param v input value
 * @ return the corresponding array of bytes */
static public byte [ ] shortToBytes ( short v ) { } }

implementation: byte [ ] b = new byte [ 2 ] ; int allbits = 255 ; for ( int i = 0 ; i < 2 ; i ++ ) { b [ 1 - i ] = ( byte ) ( ( v & ( allbits << i * 8 ) ) >> i * 8 ) ; } return b ;


signature:
public class Swap { /** * Convert an int to an array of 4 bytes .
 * @ param v input value
 * @ return the corresponding array of bytes */
static public byte [ ] intToBytes ( int v ) { } }

implementation: byte [ ] b = new byte [ 4 ] ; int allbits = 255 ; for ( int i = 0 ; i < 4 ; i ++ ) { b [ 3 - i ] = ( byte ) ( ( v & ( allbits << i * 8 ) ) >> i * 8 ) ; } return b ;


signature:
public class Swap { /** * Convert a long to an array of 8 bytes .
 * @ param v input value
 * @ return the corresponding array of bytes */
static public byte [ ] longToBytes ( long v ) { } }

implementation: byte [ ] b = new byte [ 8 ] ; long allbits = 255 ; for ( int i = 0 ; i < 8 ; i ++ ) { b [ 7 - i ] = ( byte ) ( ( v & ( allbits << i * 8 ) ) >> i * 8 ) ; } return b ;


signature:
public class VerticalTransformImpl { /** * Read the data { @ link ucar . ma2 . Array } from the variable , at the specified
 * time index if applicable . If the variable does not have a time
 * dimension , the data array will have the same rank as the Variable .
 * If the variable has a time dimension , the data array will have rank - 1.
 * @ param v variable to read
 * @ param timeIndex time index , ignored if ! isTimeDependent ( )
 * @ return Array from the variable at that time index
 * @ throws IOException problem reading data
 * @ throws InvalidRangeException _ more _ */
protected Array readArray ( Variable v , int timeIndex ) throws IOException , InvalidRangeException { } }

implementation: int [ ] shape = v . getShape ( ) ; int [ ] origin = new int [ v . getRank ( ) ] ; if ( getTimeDimension ( ) != null ) { int dimIndex = v . findDimensionIndex ( getTimeDimension ( ) . getShortName ( ) ) ; if ( dimIndex >= 0 ) { shape [ dimIndex ] = 1 ; origin [ dimIndex ] = timeIndex ; return v . read ( origin , shape ) . reduce ( dimIndex ) ; } } return v . read ( origin , shape ) ;


signature:
public class VerticalTransformImpl { /** * Create a subset of this VerticalTransform .
 * @ param t _ range subset the time dimension , or null if you want all of it
 * @ param z _ range subset the vertical dimension , or null if you want all of it
 * @ param y _ range subset the y dimension , or null if you want all of it
 * @ param x _ range subset the x dimension , or null if you want all of it
 * @ return the subsetted VerticalTransform
 * @ throws ucar . ma2 . InvalidRangeException if any of the range parameters are illegal */
public VerticalTransform subset ( Range t_range , Range z_range , Range y_range , Range x_range ) throws ucar . ma2 . InvalidRangeException { } }

implementation: return new VerticalTransformSubset ( this , t_range , z_range , y_range , x_range ) ;


signature:
public class GridDatasetInv { /** * current version */
public static GridDatasetInv open ( MCollection cm , MFile mfile , Element ncml ) throws IOException { } }

implementation:
// do we already have it ?
byte [ ] xmlBytes = ( ( CollectionManagerAbstract ) cm ) . getMetadata ( mfile , "fmrInv.xml" ) ; // LOOK should we keep this functionality ? ?
if ( xmlBytes != null ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( " got xmlFile in cache =" + mfile . getPath ( ) + " size = " + xmlBytes . length ) ; if ( xmlBytes . length < 300 ) { logger . warn ( " xmlFile in cache only has nbytes =" + xmlBytes . length + "; will reread" ) ; // drop through and regenerate
} else { GridDatasetInv inv = readXML ( xmlBytes ) ; // check if version required regen
if ( inv . version >= REQ_VERSION ) { // check if file has changed
long fileModifiedSecs = mfile . getLastModified ( ) / 1000 ; // ignore msecs
long xmlModifiedSecs = inv . getLastModified ( ) / 1000 ; // ignore msecs
if ( xmlModifiedSecs >= fileModifiedSecs ) { // LOOK if fileDate is - 1 , will always succeed
if ( logger . isDebugEnabled ( ) ) logger . debug ( " cache ok " + new Date ( inv . getLastModified ( ) ) + " >= " + new Date ( mfile . getLastModified ( ) ) + " for " + mfile . getName ( ) ) ; return inv ; // ok , use it
} else { if ( logger . isInfoEnabled ( ) ) logger . info ( " cache out of date " + new Date ( inv . getLastModified ( ) ) + " < " + new Date ( mfile . getLastModified ( ) ) + " for " + mfile . getName ( ) ) ; } } else { if ( logger . isInfoEnabled ( ) ) logger . info ( " version needs upgrade " + inv . version + " < " + REQ_VERSION + " for " + mfile . getName ( ) ) ; } } } // generate it and save it
GridDataset gds = null ; try { if ( ncml == null ) { gds = GridDataset . open ( mfile . getPath ( ) ) ; } else { NetcdfFile nc = NetcdfDataset . acquireFile ( new DatasetUrl ( null , mfile . getPath ( ) ) , null ) ; NetcdfDataset ncd = NcMLReader . mergeNcML ( nc , ncml ) ; // create new dataset
ncd . enhance ( ) ; // now that the ncml is added , enhance " in place " , ie modify the NetcdfDataset
gds = new GridDataset ( ncd ) ; } // System . out . println ( " gds dataset = " + gds . getNetcdfDataset ( ) ) ;
GridDatasetInv inv = new GridDatasetInv ( gds , cm . extractDate ( mfile ) ) ; String xmlString = inv . writeXML ( new Date ( mfile . getLastModified ( ) ) ) ; ( ( CollectionManagerAbstract ) cm ) . putMetadata ( mfile , "fmrInv.xml" , xmlString . getBytes ( CDM . utf8Charset ) ) ; if ( logger . isDebugEnabled ( ) ) logger . debug ( " added xmlFile " + mfile . getPath ( ) + ".fmrInv.xml to cache" ) ; if ( debug ) System . out . printf ( " added xmlFile %s.fmrInv.xml to cache%n" , mfile . getPath ( ) ) ; // System . out . println ( " new xmlBytes = " + xmlString ) ;
return inv ; } finally { if ( gds != null ) gds . close ( ) ; }


signature: public class GridDatasetInv { private TimeCoord getTimeCoordinate ( CoordinateAxis1DTime axis ) { } }

implementation:
// check for same axis
for ( TimeCoord tc : times ) { if ( tc . getAxisName ( ) . equals ( axis . getFullName ( ) ) ) return tc ; } // check for same offsets
TimeCoord want = new TimeCoord ( runDate , axis ) ; for ( TimeCoord tc : times ) { if ( ( tc . equalsData ( want ) ) ) return tc ; } // its a new one
times . add ( want ) ; return want ;


signature: public class GridDatasetInv { private VertCoord getVertCoordinate ( int wantId ) { } }

implementation: if ( wantId < 0 ) return null ; for ( VertCoord vc : vaxes ) { if ( vc . getId ( ) == wantId ) return vc ; } return null ;


signature: public class GridDatasetInv { private EnsCoord getEnsCoordinate ( int ens_id ) { } }

implementation: if ( ens_id < 0 ) return null ; for ( EnsCoord ec : eaxes ) { if ( ( ec . getId ( ) == ens_id ) ) return ec ; } return null ;


signature:
public class GridDatasetInv { /** * Write the XML representation to a String .
 * @ return the XML representation to a String . */
public String writeXML ( Date lastModified ) { } }

implementation: XMLOutputter fmt = new XMLOutputter ( Format . getPrettyFormat ( ) ) ; return fmt . outputString ( writeDocument ( lastModified ) ) ;


signature:
public class GridDatasetInv { /** * Create the XML representation of the GridDatasetInv
 * @ return the XML representation as a Document */
Document writeDocument ( Date lastModified ) { } }

implementation:
Element rootElem = new Element ( "gridInventory" ) ; Document doc = new Document ( rootElem ) ; rootElem . setAttribute ( "location" , location ) ; rootElem . setAttribute ( "runTime" , runTimeString ) ; if ( lastModified != null ) { rootElem . setAttribute ( "lastModified" , CalendarDateFormatter . toDateTimeString ( lastModified ) ) ; } rootElem . setAttribute ( "version" , Integer . toString ( CURR_VERSION ) ) ; // list all the vertical coords
Collections . sort ( vaxes ) ; int count = 0 ; for ( VertCoord vc : vaxes ) { vc . setId ( count ++ ) ; Element vcElem = new Element ( "vertCoord" ) ; rootElem . addContent ( vcElem ) ; vcElem . setAttribute ( "id" , Integer . toString ( vc . getId ( ) ) ) ; vcElem . setAttribute ( "name" , vc . getName ( ) ) ; if ( vc . getUnits ( ) != null ) vcElem . setAttribute ( CDM . UNITS , vc . getUnits ( ) ) ; StringBuilder sbuff = new StringBuilder ( ) ; double [ ] values1 = vc . getValues1 ( ) ; double [ ] values2 = vc . getValues2 ( ) ; for ( int j = 0 ; j < values1 . length ; j ++ ) { if ( j > 0 ) sbuff . append ( " " ) ; sbuff . append ( Double . toString ( values1 [ j ] ) ) ; if ( values2 != null ) { sbuff . append ( "," ) ; sbuff . append ( Double . toString ( values2 [ j ] ) ) ; } } vcElem . addContent ( sbuff . toString ( ) ) ; } // list all the time coords
count = 0 ; for ( TimeCoord tc : times ) { tc . setId ( count ++ ) ; Element timeElement = new Element ( "timeCoord" ) ; rootElem . addContent ( timeElement ) ; timeElement . setAttribute ( "id" , Integer . toString ( tc . getId ( ) ) ) ; timeElement . setAttribute ( "name" , tc . getName ( ) ) ; timeElement . setAttribute ( "isInterval" , tc . isInterval ( ) ? "true" : "false" ) ; Formatter sbuff = new Formatter ( ) ; if ( tc . isInterval ( ) ) { double [ ] bound1 = tc . getBound1 ( ) ; double [ ] bound2 = tc . getBound2 ( ) ; for ( int j = 0 ; j < bound1 . length ; j ++ ) sbuff . format ( ( Locale ) null , "%f %f," , bound1 [ j ] , bound2 [ j ] ) ; } else { for ( double offset : tc . getOffsetTimes ( ) ) sbuff . format ( ( Locale ) null , "%f," , offset ) ; } timeElement . addContent ( sbuff . toString ( ) ) ; List < GridDatasetInv . Grid > vars = tc . getGridInventory ( ) ; Collections . sort ( vars ) ; for ( Grid grid : vars ) { Element varElem = new Element ( "grid" ) ; timeElement . addContent ( varElem ) ; varElem . setAttribute ( "name" , grid . name ) ; if ( grid . ec != null ) varElem . setAttribute ( "ens_id" , Integer . toString ( grid . ec . getId ( ) ) ) ; if ( grid . vc != null ) varElem . setAttribute ( "vert_id" , Integer . toString ( grid . vc . getId ( ) ) ) ; } } return doc ;


signature:
public class GridDatasetInv { /** * Construct a GridDatasetInv from its XML representation
 * @ param xmlString the xml string
 * @ return ForecastModelRun
 * @ throws IOException on io error */
private static GridDatasetInv readXML ( byte [ ] xmlString ) throws IOException { } }

implementation:
InputStream is = new BufferedInputStream ( new ByteArrayInputStream ( xmlString ) ) ; org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; doc = builder . build ( is ) ; } catch ( JDOMException e ) { throw new IOException ( e . getMessage ( ) + " reading from XML " ) ; } Element rootElem = doc . getRootElement ( ) ; GridDatasetInv fmr = new GridDatasetInv ( ) ; fmr . runTimeString = rootElem . getAttributeValue ( "runTime" ) ; fmr . location = rootElem . getAttributeValue ( "location" ) ; if ( fmr . location == null ) fmr . location = rootElem . getAttributeValue ( "name" ) ; // old way
String lastModifiedS = rootElem . getAttributeValue ( "lastModified" ) ; if ( lastModifiedS != null ) fmr . lastModified = CalendarDateFormatter . isoStringToDate ( lastModifiedS ) ; String version = rootElem . getAttributeValue ( "version" ) ; fmr . version = ( version == null ) ? 0 : Integer . parseInt ( version ) ; if ( fmr . version < REQ_VERSION ) return fmr ; fmr . runDate = DateUnit . parseCalendarDate ( fmr . runTimeString ) ; java . util . List < Element > vList = rootElem . getChildren ( "vertCoord" ) ; for ( Element vertElem : vList ) { VertCoord vc = new VertCoord ( ) ; fmr . vaxes . add ( vc ) ; vc . setId ( Integer . parseInt ( vertElem . getAttributeValue ( "id" ) ) ) ; vc . setName ( vertElem . getAttributeValue ( "name" ) ) ; vc . setUnits ( vertElem . getAttributeValue ( CDM . UNITS ) ) ; // parse the values
String values = vertElem . getTextNormalize ( ) ; StringTokenizer stoke = new StringTokenizer ( values ) ; int n = stoke . countTokens ( ) ; double [ ] values1 = new double [ n ] ; double [ ] values2 = null ; int count = 0 ; while ( stoke . hasMoreTokens ( ) ) { String toke = stoke . nextToken ( ) ; int pos = toke . indexOf ( ',' ) ; if ( pos < 0 ) values1 [ count ] = Double . parseDouble ( toke ) ; else { if ( values2 == null ) values2 = new double [ n ] ; String val1 = toke . substring ( 0 , pos ) ; String val2 = toke . substring ( pos + 1 ) ; values1 [ count ] = Double . parseDouble ( val1 ) ; values2 [ count ] = Double . parseDouble ( val2 ) ; } count ++ ; } vc . setValues1 ( values1 ) ; vc . setValues2 ( values2 ) ; } java . util . List < Element > tList = rootElem . getChildren ( "timeCoord" ) ; for ( Element timeElem : tList ) { TimeCoord tc = new TimeCoord ( fmr . runDate ) ; fmr . times . add ( tc ) ; tc . setId ( Integer . parseInt ( timeElem . getAttributeValue ( "id" ) ) ) ; String s = timeElem . getAttributeValue ( "isInterval" ) ; boolean isInterval = ( s != null ) && ( s . equals ( "true" ) ) ; if ( isInterval ) { String boundsAll = timeElem . getTextNormalize ( ) ; String [ ] bounds = boundsAll . split ( "," ) ; int n = bounds . length ; double [ ] bound1 = new double [ n ] ; double [ ] bound2 = new double [ n ] ; int count = 0 ; for ( String b : bounds ) { String [ ] value = b . split ( " " ) ; bound1 [ count ] = Double . parseDouble ( value [ 0 ] ) ; bound2 [ count ] = Double . parseDouble ( value [ 1 ] ) ; count ++ ; } tc . setBounds ( bound1 , bound2 ) ; } else { String values = timeElem . getTextNormalize ( ) ; String [ ] value = values . split ( "," ) ; int n = value . length ; double [ ] offsets = new double [ n ] ; int count = 0 ; for ( String v : value ) offsets [ count ++ ] = Double . parseDouble ( v ) ; tc . setOffsetTimes ( offsets ) ; } // get the variable names
List < Element > varList = timeElem . getChildren ( "grid" ) ; for ( Element vElem : varList ) { Grid grid = fmr . makeGrid ( vElem . getAttributeValue ( "name" ) ) ; if ( vElem . getAttributeValue ( "ens_id" ) != null ) grid . ec = fmr . getEnsCoordinate ( Integer . parseInt ( vElem . getAttributeValue ( "ens_id" ) ) ) ; if ( vElem . getAttributeValue ( "vert_id" ) != null ) grid . vc = fmr . getVertCoordinate ( Integer . parseInt ( vElem . getAttributeValue ( "vert_id" ) ) ) ; tc . addGridInventory ( grid ) ; grid . tc = tc ; } } return fmr ;


signature:
public class Dap2Lex { /** * / * Reset the lexer */
public void reset ( Dap2Parse state ) { } }

implementation: this . parsestate = state ; this . text = new TextStream ( ) ; yytext = new StringBuilder ( ) ; lval = null ;


signature:
public class Dap2Lex { /** * 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 .
 * This is part of the Lexer interface */
public int yylex ( ) throws ParseException { } }

implementation:
int token ; int c ; token = 0 ; yytext . setLength ( 0 ) ; text . mark ( ) ; try { token = - 1 ; while ( token < 0 && ( c = text . read ( ) ) > 0 ) { if ( c == '\n' ) { lineno ++ ; } else if ( c <= ' ' || c == '\177' ) { /* whitespace : ignore */
} else if ( c == '#' ) { /* single line comment */
for ( ; ; ) { c = text . read ( ) ; if ( c == '\n' || c == '\0' ) break ; } } else if ( worddelims . indexOf ( c ) >= 0 ) { token = c ; } else if ( c == '"' ) { boolean more = true ; /* We have a string token ; will be reported as SCAN _ WORD */
while ( more && ( c = text . read ( ) ) > 0 ) { if ( DAP2STRING ) { /* Implement DAP2 standard */
switch ( c ) { case '"' : more = false ; break ; case '\\' : c = text . read ( ) ; if ( c < 0 ) more = false ; break ; case '(' : default : break ; } } else { // not used : Implement a more java / c like alternative for string encoding
switch ( c ) { case '"' : more = false ; break ; case '\\' : c = text . read ( ) ; switch ( c ) { case 'r' : c = '\r' ; break ; case 'n' : c = '\n' ; break ; case 'f' : c = '\f' ; break ; case 't' : c = '\t' ; break ; case 'x' : { int d1 , d2 ; c = text . read ( ) ; d1 = tohex ( c ) ; if ( d1 < 0 ) { throw new ParseException ( "Illegal \\xDD in TOKEN_STRING" ) ; } else { c = text . read ( ) ; d2 = tohex ( c ) ; if ( d2 < 0 ) { throw new ParseException ( "Illegal \\xDD in TOKEN_STRING" ) ; } else { c = ( ( d1 ) << 4 ) | d2 ; } } } break ; default : break ; } break ; default : break ; } } if ( more ) yytext . append ( ( char ) c ) ; } token = WORD_STRING ; } else if ( wordchars1 . indexOf ( c ) >= 0 ) { yytext . append ( ( char ) c ) ; /* we have a SCAN _ WORD ( = = identifier | number ) */
while ( ( c = text . read ( ) ) > 0 ) { if ( wordcharsn . indexOf ( c ) < 0 ) { text . backup ( ) ; break ; } yytext . append ( ( char ) c ) ; } token = WORD_WORD ; /* assume */
/* check for keyword */
String tmp = yytext . toString ( ) ; for ( int i = 0 ; ; i ++ ) { if ( keywords [ i ] == null ) break ; if ( keywords [ i ] . equalsIgnoreCase ( tmp ) ) { token = keytokens [ i ] ; break ; } } } else { /* illegal */
String msg = String . format ( "Illegal Character: '%c'" , c ) ; yytext . append ( ( char ) c ) ; lexerror ( msg ) ; throw new ParseException ( msg ) ; } } // do eof check
if ( 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 . */
} catch ( IOException ioe ) { throw new ParseException ( ioe ) ; }


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

implementation: String kind = "?" ; switch ( parsestate . parseClass ) { case Dap2Parse . DapDAS : kind = "DAS" ; break ; case Dap2Parse . DapDDS : kind = "DDS" ; break ; case Dap2Parse . DapERR : kind = "Error" ; break ; default : kind = "?" ; break ; } System . err . println ( "yyerror: " + s + "; " + kind + " parse failed at line: " + lineno + " char: " + charno + "; near: " ) ; String context = parsestate . flatten ( getInput ( ) ) ; int show = ( context . length ( ) < CONTEXTLEN ? context . length ( ) : CONTEXTLEN ) ; System . err . println ( context . substring ( context . length ( ) - show ) + "^" ) ; if ( parsestate . getURL ( ) != null ) System . err . println ( "\turl=" + parsestate . getURL ( ) ) ; new Exception ( ) . printStackTrace ( System . err ) ;


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

implementation: Array etaArray = readArray ( etaVar , timeIndex ) ; Array sArray = readArray ( sVar , timeIndex ) ; Array depthArray = readArray ( depthVar , timeIndex ) ; if ( null == c ) { double a = aVar . readScalarDouble ( ) ; double b = bVar . readScalarDouble ( ) ; depth_c = depthCVar . readScalarDouble ( ) ; c = makeC ( sArray , a , b ) ; } return makeHeight ( etaArray , sArray , depthArray , c , depth_c ) ;


signature:
public class OceanS { /** * Get the 1D vertical coordinate array for this time step and
 * the specified X , Y index for Lat - Lon point .
 * @ param timeIndex the time index . Ignored if ! isTimeDependent ( ) .
 * @ param xIndex the x index
 * @ param yIndex the y index
 * @ return vertical coordinate array
 * @ throws IOException problem reading data
 * @ throws InvalidRangeException _ more _ */
public ArrayDouble . D1 getCoordinateArray1D ( int timeIndex , int xIndex , int yIndex ) throws IOException , InvalidRangeException { } }

implementation: Array etaArray = readArray ( etaVar , timeIndex ) ; Array sArray = readArray ( sVar , timeIndex ) ; Array depthArray = readArray ( depthVar , timeIndex ) ; if ( null == c ) { double a = aVar . readScalarDouble ( ) ; double b = bVar . readScalarDouble ( ) ; depth_c = depthCVar . readScalarDouble ( ) ; c = makeC ( sArray , a , b ) ; } return makeHeight1D ( etaArray , sArray , depthArray , c , depth_c , xIndex , yIndex ) ;


signature:
public class OceanS { /** * Make the C array
 * @ param s s Array
 * @ param a " a " value
 * @ param b " b " value
 * @ return the C array */
private Array makeC ( Array s , double a , double b ) { } }

implementation:
int nz = ( int ) s . getSize ( ) ; Index sIndex = s . getIndex ( ) ; if ( a == 0 ) return s ; // per R . Signell , USGS
ArrayDouble . D1 c = new ArrayDouble . D1 ( nz ) ; double fac1 = 1.0 - b ; double denom1 = 1.0 / Math . sinh ( a ) ; double denom2 = 1.0 / ( 2.0 * Math . tanh ( 0.5 * a ) ) ; for ( int i = 0 ; i < nz ; i ++ ) { double sz = s . getDouble ( sIndex . set ( i ) ) ; double term1 = fac1 * Math . sinh ( a * sz ) * denom1 ; double term2 = b * ( Math . tanh ( a * ( sz + 0.5 ) ) * denom2 - 0.5 ) ; c . set ( i , term1 + term2 ) ; } return c ;


signature:
public class OceanS { /** * Make height from the given data . < br >
 * old equationn : height ( x , y , z ) = eta ( x , y ) * ( 1 + s ( z ) ) + depth _ c * s ( z ) + ( depth ( x , y ) - depth _ c ) * C ( z )
 * / * - sachin 03/23/09
 * The new corrected equation according to Hernan Arango ( Rutgers )
 * height ( x , y , z ) = S ( x , y , z ) + eta ( x , y ) * ( 1 + S ( x , y , z ) / depth ( x , y ) )
 * where ,
 * S ( x , y , z ) = depth _ c * s ( z ) + ( depth ( x , y ) - depth _ c ) * C ( z )
 * @ param eta eta Array
 * @ param s s Array
 * @ param depth depth Array
 * @ param c c Array
 * @ param depth _ c value of depth _ c
 * @ return hieght data */
private ArrayDouble . D3 makeHeight ( Array eta , Array s , Array depth , Array c , double depth_c ) { } }

implementation:
int nz = ( int ) s . getSize ( ) ; Index sIndex = s . getIndex ( ) ; Index cIndex = c . getIndex ( ) ; int [ ] shape2D = eta . getShape ( ) ; int ny = shape2D [ 0 ] ; int nx = shape2D [ 1 ] ; Index etaIndex = eta . getIndex ( ) ; Index depthIndex = depth . getIndex ( ) ; ArrayDouble . D3 height = new ArrayDouble . D3 ( nz , ny , nx ) ; for ( int z = 0 ; z < nz ; z ++ ) { double sz = s . getDouble ( sIndex . set ( z ) ) ; double cz = c . getDouble ( cIndex . set ( z ) ) ; double term1 = depth_c * sz ; for ( int y = 0 ; y < ny ; y ++ ) { for ( int x = 0 ; x < nx ; x ++ ) { // - sachin 03/23/09 modifications according to corrected equation .
double fac1 = depth . getDouble ( depthIndex . set ( y , x ) ) ; double term2 = ( fac1 - depth_c ) * cz ; double Sterm = term1 + term2 ; double term3 = eta . getDouble ( etaIndex . set ( y , x ) ) ; double term4 = 1 + Sterm / fac1 ; double hterm = Sterm + term3 * term4 ; height . set ( z , y , x , hterm ) ; } } } return height ;


signature:
public class WFSDescribeFeatureTypeWriter { /** * Initiate the response with an XML file with an XML header */
public void startXML ( ) { } }

implementation: fileOutput += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ; fileOutput += "<schema " + "xmlns:" + WFSController . TDSNAMESPACE + "=" + WFSXMLHelper . encQuotes ( namespace ) + " " + "xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + "xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:gml=\"http://www.opengis.net/gml\" " + "targetNamespace=\"" + server + "\" elementFormDefault=\"qualified\" " + "version=\"0.1\">" ; fileOutput += "<xsd:import namespace=\"http://www.opengis.net/gml\" " + "schemaLocation=\"http://schemas.opengis.net/gml/2.1.2/feature.xsd\"/>" ;


signature:
public class WFSDescribeFeatureTypeWriter { /** * Write the features from the featureList . For each feature , write its attributes */
public void writeFeatures ( ) { } }

implementation: for ( WFSFeature feat : featureList ) { fileOutput += "<xsd:complexType name=\"" + feat . getTitle ( ) + "\">" ; fileOutput += "<xsd:complexContent>" ; fileOutput += "<xsd:extension base=\"gml:" + feat . getType ( ) + "\">" ; fileOutput += "<xsd:sequence>" ; for ( WFSFeatureAttribute attribute : feat . getAttributes ( ) ) { fileOutput += "<xsd:element name =\"" + attribute . getName ( ) + "\" type=\"" + attribute . getType ( ) + "\"/>" ; } fileOutput += "</xsd:sequence>" ; fileOutput += "</xsd:extension>" ; fileOutput += "</xsd:complexContent>" ; fileOutput += "</xsd:complexType>" ; fileOutput += "<xsd:element name =\"" + feat . getName ( ) + "\" type=\"tds:" + feat . getTitle ( ) + "\"/>" ; }


signature:
public class GridCoordSys { /** * Add levels from the GridRecords
 * @ param records the records */
void addLevels ( List < GridRecord > records ) { } }

implementation:
for ( GridRecord record : records ) { Double d = new Double ( record . getLevel1 ( ) ) ; if ( ! levels . contains ( d ) ) { levels . add ( d ) ; } if ( dontUseVertical && ( levels . size ( ) > 1 ) ) { if ( GridServiceProvider . debugVert ) { System . out . println ( "GribCoordSys: unused level coordinate has > 1 levels = " + verticalName + " " + record . getLevelType1 ( ) + " " + levels . size ( ) ) ; } } } Collections . sort ( levels ) ; if ( positive . equals ( "down" ) ) { Collections . reverse ( levels ) ; // TODO : delete
/* for ( int i = 0 ; i < ( levels . size ( ) / 2 ) ; i + + ) {
 Double tmp = ( Double ) levels . get ( i ) ;
 levels . set ( i , levels . get ( levels . size ( ) - i - 1 ) ) ;
 levels . set ( levels . size ( ) - i - 1 , tmp ) ; */
}


signature:
public class GridCoordSys { /** * Match levels
 * @ param records list of GridRecords
 * @ return true if they match */
boolean matchLevels ( List < GridRecord > records ) { } }

implementation:
// first create a new list
List < Double > levelList = new ArrayList < Double > ( records . size ( ) ) ; for ( GridRecord record : records ) { Double d = new Double ( record . getLevel1 ( ) ) ; if ( ! levelList . contains ( d ) ) { levelList . add ( d ) ; } } Collections . sort ( levelList ) ; if ( positive . equals ( "down" ) ) { Collections . reverse ( levelList ) ; } // gotta equal existing list
return levelList . equals ( levels ) ;


signature:
public class GridCoordSys { /** * Add dimensions to the netcdf file
 * @ param ncfile the netCDF file
 * @ param g the group to add to */
void addDimensionsToNetcdfFile ( NetcdfFile ncfile , Group g ) { } }

implementation: if ( dontUseVertical ) { return ; } int nlevs = levels . size ( ) ; ncfile . addDimension ( g , new Dimension ( verticalName , nlevs , true ) ) ;


signature:
public class GridCoordSys { /** * Add this coordinate system to the netCDF file
 * @ param ncfile the netCDF file
 * @ param g the group to add to */
void addToNetcdfFile ( NetcdfFile ncfile , Group g ) { } }

implementation:
if ( dontUseVertical ) { return ; } if ( g == null ) { g = ncfile . getRootGroup ( ) ; } String dims = "time" ; if ( ! dontUseVertical ) { dims = dims + " " + verticalName ; } if ( hcs . isLatLon ( ) ) { dims = dims + " lat lon" ; } else { dims = dims + " y x" ; } // Collections . sort ( levels ) ;
int nlevs = levels . size ( ) ; // ncfile . addDimension ( g , new Dimension ( verticalName , nlevs , true ) ) ;
// coordinate axis and coordinate system Variable
Variable v = new Variable ( ncfile , g , null , verticalName ) ; v . setDataType ( DataType . DOUBLE ) ; v . addAttribute ( new Attribute ( "long_name" , lookup . getLevelDescription ( record ) ) ) ; v . addAttribute ( new Attribute ( "units" , lookup . getLevelUnit ( record ) ) ) ; // positive attribute needed for CF - 1 Height and Pressure
if ( positive != null ) { v . addAttribute ( new Attribute ( "positive" , positive ) ) ; } if ( units != null ) { AxisType axisType ; if ( SimpleUnit . isCompatible ( "millibar" , units ) ) { axisType = AxisType . Pressure ; } else if ( SimpleUnit . isCompatible ( "m" , units ) ) { axisType = AxisType . Height ; } else { axisType = AxisType . GeoZ ; } v . addAttribute ( new Attribute ( "grid_level_type" , Integer . toString ( record . getLevelType1 ( ) ) ) ) ; v . addAttribute ( new Attribute ( _Coordinate . AxisType , axisType . toString ( ) ) ) ; v . addAttribute ( new Attribute ( _Coordinate . Axes , dims ) ) ; if ( ! hcs . isLatLon ( ) ) { v . addAttribute ( new Attribute ( _Coordinate . Transforms , hcs . getGridName ( ) ) ) ; } } double [ ] data = new double [ nlevs ] ; for ( int i = 0 ; i < levels . size ( ) ; i ++ ) { Double d = ( Double ) levels . get ( i ) ; data [ i ] = d . doubleValue ( ) ; } Array dataArray = Array . factory ( DataType . DOUBLE , new int [ ] { nlevs } , data ) ; v . setDimensions ( verticalName ) ; v . setCachedData ( dataArray , false ) ; ncfile . addVariable ( g , v ) ; // look for vertical transforms
if ( record . getLevelType1 ( ) == 109 ) { findCoordinateTransform ( g , "Pressure" , record . getLevelType1 ( ) ) ; }


signature:
public class GridCoordSys { /** * Find the coordinate transform
 * @ param g group to check
 * @ param nameStartsWith beginning of name
 * @ param levelType type of level */
void findCoordinateTransform ( Group g , String nameStartsWith , int levelType ) { } }

implementation:
// look for variable that uses this coordinate
List < Variable > vars = g . getVariables ( ) ; for ( Variable v : vars ) { if ( v . getShortName ( ) . equals ( nameStartsWith ) ) { Attribute att = v . findAttribute ( "grid_level_type" ) ; if ( ( att == null ) || ( att . getNumericValue ( ) . intValue ( ) != levelType ) ) { continue ; } v . addAttribute ( new Attribute ( _Coordinate . TransformType , "Vertical" ) ) ; v . addAttribute ( new Attribute ( "transform_name" , "Existing3DField" ) ) ; } }


signature:
public class GridCoordSys { /** * Get the index of a particular GridRecord
 * @ param record record to find
 * @ return the index or - 1 */
int getIndex ( GridRecord record ) { } }

implementation: Double d = new Double ( record . getLevel1 ( ) ) ; return levels . indexOf ( d ) ;


signature:
public class DiskCache2 { /** * Be sure to call this when your application exits , otherwise your process may not exit without being killed . */
static public void exit ( ) { } }

implementation: if ( timer != null ) { timer . cancel ( ) ; System . out . printf ( "DiskCache2.exit()%n" ) ; } timer = null ;


signature:
public class DiskCache2 { /** * Default DiskCache2 strategy : use $ user _ home / . unidata / cache / , no scouring , alwaysUseCache = false
 * Mimics default DiskCache static class */
static public DiskCache2 getDefault ( ) { } }

implementation: String root = System . getProperty ( "nj22.cache" ) ; if ( root == null ) { String home = System . getProperty ( "user.home" ) ; if ( home == null ) home = System . getProperty ( "user.dir" ) ; if ( home == null ) home = "." ; root = home + "/.unidata/cache/" ; } DiskCache2 result = new DiskCache2 ( ) ; result . setRootDirectory ( root ) ; result . alwaysUseCache = false ; return result ;


signature:
public class DiskCache2 { /** * Set the cache root directory . Create it if it doesnt exist .
 * Normally this is set in the Constructor .
 * @ param cacheDir the cache directory */
public void setRootDirectory ( String cacheDir ) { } }

implementation:
if ( ! cacheDir . endsWith ( "/" ) ) cacheDir = cacheDir + "/" ; root = StringUtil2 . replace ( cacheDir , '\\' , "/" ) ; // no nasty backslash
File dir = new File ( root ) ; if ( ! dir . mkdirs ( ) ) { // ok
} if ( ! dir . exists ( ) ) { fail = true ; cacheLog . error ( "DiskCache2 failed to create directory " + root ) ; } else { cacheLog . debug ( "DiskCache2 create directory " + root ) ; }


signature:
public class DiskCache2 { /** * Get a File in the cache , corresponding to the fileLocation .
 * File may or may not exist .
 * If fileLocation has " / " in it , and cachePathPolicy = = NestedDirectory , the
 * nested directories will be created .
 * @ param fileLocation logical file location
 * @ return physical File in the cache . */
public File getCacheFile ( String fileLocation ) { } }

implementation:
if ( neverUseCache ) return null ; if ( ! alwaysUseCache ) { File f = new File ( fileLocation ) ; if ( canWrite ( f ) ) return f ; } File f = new File ( makeCachePath ( fileLocation ) ) ; // if ( f . exists ( ) )
// f . setLastModified ( System . currentTimeMillis ( ) ) ;
if ( cachePathPolicy == CachePathPolicy . NestedDirectory ) { File dir = f . getParentFile ( ) ; if ( ! dir . exists ( ) ) { boolean ret = dir . mkdirs ( ) ; if ( ! ret ) cacheLog . warn ( "Error creating dir: " + dir ) ; } } return f ;


signature:
public class DiskCache2 { /** * Get the named File .
 * If exists or isWritable , return it .
 * Otherwise get corresponding file in the cache directory .
 * If fileLocation has " / " in it , and cachePathPolicy = = NestedDirectory , the
 * nested directories will be created .
 * @ param fileLocation logical file location
 * @ return physical File as named , or in the cache . */
public File getFile ( String fileLocation ) { } }

implementation: if ( ! alwaysUseCache ) { File f = new File ( fileLocation ) ; if ( f . exists ( ) ) return f ; if ( canWrite ( f ) ) return f ; } if ( neverUseCache ) { throw new IllegalStateException ( "neverUseCache=true, but file does not exist and directory is not writeable =" + fileLocation ) ; } File f = new File ( makeCachePath ( fileLocation ) ) ; if ( cachePathPolicy == CachePathPolicy . NestedDirectory ) { File dir = f . getParentFile ( ) ; if ( ! dir . exists ( ) && ! dir . mkdirs ( ) ) cacheLog . warn ( "Cant create directories for file " + dir . getPath ( ) ) ; } return f ;


signature:
public class DiskCache2 { /** * Returns { @ code true } if we can write to the file .
 * @ param f a file . It may be a regular file or a directory . It may even be non - existent , in which case the
 * writability of the file ' s parent dir is tested .
 * @ return { @ code true } if we can write to the file . */
public static boolean canWrite ( File f ) { } }

implementation:
Path path = f . toPath ( ) . toAbsolutePath ( ) ; try { if ( Files . isDirectory ( path ) ) { // Try to create a file within the directory to determine if it ' s writable .
Files . delete ( Files . createTempFile ( path , "check" , null ) ) ; } else if ( Files . isRegularFile ( path ) ) { // Try to open the file for writing in append mode .
Files . newOutputStream ( path , StandardOpenOption . APPEND ) . close ( ) ; } else { // File does not exist . See if it ' s parent directory exists and is writeable .
Files . delete ( Files . createTempFile ( path . getParent ( ) , "check" , null ) ) ; } } catch ( IOException | SecurityException e ) { return false ; } return true ;


signature:
public class DiskCache2 { /** * Looking for an existing file , in cache or no
 * @ param fileLocation the original name
 * @ return existing file if you can find it */
public File getExistingFileOrCache ( String fileLocation ) { } }

implementation: File f = new File ( fileLocation ) ; if ( f . exists ( ) ) return f ; if ( neverUseCache ) return null ; File fc = new File ( makeCachePath ( fileLocation ) ) ; if ( fc . exists ( ) ) return fc ; return null ;


signature:
public class DiskCache2 { /** * Create a new , uniquely named file in the root directory .
 * Mimics File . createTempFile ( )
 * @ param prefix The prefix string to be used in generating the file ' s
 * name ; must be at least three characters long
 * @ param suffix The suffix string to be used in generating the file ' s
 * name ; may be < code > null < / code > , in which case the
 * suffix < code > " . tmp " < / code > will be used
 * @ return uniquely named file */
public synchronized File createUniqueFile ( String prefix , String suffix ) { } }

implementation: if ( suffix == null ) suffix = ".tmp" ; Random random = new Random ( System . currentTimeMillis ( ) ) ; File result = new File ( getRootDirectory ( ) , prefix + Integer . toString ( random . nextInt ( ) ) + suffix ) ; while ( result . exists ( ) ) result = new File ( getRootDirectory ( ) , prefix + Integer . toString ( random . nextInt ( ) ) + suffix ) ; return result ;


signature:
public class DiskCache2 { /** * Make the cache filename
 * @ param fileLocation normal file location
 * @ return cache filename */
private String makeCachePath ( String fileLocation ) { } }

implementation:
// remove ' : ' , ' ? ' , ' = ' , replace ' \ ' with ' / ' , leading or trailing ' / '
String cachePath = fileLocation ; cachePath = StringUtil2 . remove ( cachePath , '?' ) ; cachePath = StringUtil2 . remove ( cachePath , '=' ) ; cachePath = StringUtil2 . replace ( cachePath , '\\' , "/" ) ; if ( cachePath . startsWith ( "/" ) ) cachePath = cachePath . substring ( 1 ) ; if ( cachePath . endsWith ( "/" ) ) cachePath = cachePath . substring ( 0 , cachePath . length ( ) - 1 ) ; cachePath = StringUtil2 . remove ( cachePath , ':' ) ; // remove directories
if ( cachePathPolicy == CachePathPolicy . OneDirectory ) { cachePath = StringUtil2 . replace ( cachePath , '/' , "-" ) ; } // eliminate leading directories
else if ( cachePathPolicy == CachePathPolicy . NestedTruncate ) { int pos = cachePath . indexOf ( cachePathPolicyParam ) ; if ( pos >= 0 ) cachePath = cachePath . substring ( pos + cachePathPolicyParam . length ( ) ) ; if ( cachePath . startsWith ( "/" ) ) cachePath = cachePath . substring ( 1 ) ; } // make sure the parent directory exists
if ( cachePathPolicy != CachePathPolicy . OneDirectory ) { File file = new File ( root + cachePath ) ; File parent = file . getParentFile ( ) ; if ( ! parent . exists ( ) ) { if ( root == null ) { // LOOK shouldnt happen , remove soon
System . out . printf ( "mkdir4 %s%n" , parent . getPath ( ) ) ; new Throwable ( ) . printStackTrace ( ) ; } boolean ret = parent . mkdirs ( ) ; if ( ! ret ) cacheLog . warn ( "Error creating parent: " + parent ) ; } } return root + cachePath ;


signature:
public class DiskCache2 { /** * Show cache contents , for debugging .
 * @ param pw write to this PrintStream . */
public void showCache ( PrintStream pw ) { } }

implementation: pw . println ( "Cache files" ) ; pw . println ( "Size   LastModified       Filename" ) ; File dir = new File ( root ) ; File [ ] files = dir . listFiles ( ) ; if ( files != null ) for ( File file : files ) { String org = null ; try { org = URLDecoder . decode ( file . getName ( ) , "UTF8" ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } pw . println ( " " + file . length ( ) + " " + new Date ( file . lastModified ( ) ) + " " + org ) ; }


signature:
public class DiskCache2 { /** * Remove any files or directories whose last modified time greater than persistMinutes
 * @ param dir clean starting here
 * @ param sbuff status messages here , may be null
 * @ param isRoot delete empty directories , bit not root directory */
public void cleanCache ( File dir , Formatter sbuff , boolean isRoot ) { } }

implementation:
long now = System . currentTimeMillis ( ) ; File [ ] files = dir . listFiles ( ) ; if ( files == null ) { throw new IllegalStateException ( "DiskCache2: not a directory or I/O error on dir=" + dir . getAbsolutePath ( ) ) ; } // check for empty directory
if ( ! isRoot && ( files . length == 0 ) ) { long duration = now - dir . lastModified ( ) ; duration /= 1000 * 60 ; // minutes
if ( duration > persistMinutes ) { boolean ok = dir . delete ( ) ; if ( ! ok ) cacheLog . error ( "Unable to delete file " + dir . getAbsolutePath ( ) ) ; if ( sbuff != null ) sbuff . format ( " deleted %s %s lastModified= %s%n" , ok , dir . getPath ( ) , CalendarDate . of ( dir . lastModified ( ) ) ) ; } return ; } // check for expired files
for ( File file : files ) { if ( file . isDirectory ( ) ) { cleanCache ( file , sbuff , false ) ; } else { long duration = now - file . lastModified ( ) ; duration /= 1000 * 60 ; // minutes
if ( duration > persistMinutes ) { boolean ok = file . delete ( ) ; if ( ! ok ) cacheLog . error ( "Unable to delete file " + file . getAbsolutePath ( ) ) ; if ( sbuff != null ) sbuff . format ( " deleted %s %s lastModified= %s%n" , ok , file . getPath ( ) , CalendarDate . of ( file . lastModified ( ) ) ) ; } } }


signature:
public class ParseException { /** * This method has the standard behavior when this object has been
 * created using the standard constructors . Otherwise , it uses
 * " currentToken " and " expectedTokenSequences " to generate a parse
 * error message and returns it . If this object has been created
 * due to a parse error , and you do not catch it ( it gets thrown
 * from the parser ) , then this method is called during the printing
 * of the final stack trace , and hence the correct error message
 * gets displayed . */
public String getMessage ( ) { } }

implementation: if ( ! specialConstructor ) { return super . getMessage ( ) ; } StringBuilder expected = new StringBuilder ( ) ; int maxSize = 0 ; for ( int [ ] expectedTokenSequence : expectedTokenSequences ) { if ( maxSize < expectedTokenSequence . length ) { maxSize = expectedTokenSequence . length ; } for ( int anExpectedTokenSequence : expectedTokenSequence ) { expected . append ( tokenImage [ anExpectedTokenSequence ] ) . append ( ' ' ) ; } if ( expectedTokenSequence [ expectedTokenSequence . length - 1 ] != 0 ) { expected . append ( "..." ) ; } expected . append ( eol ) . append ( "    " ) ; } StringBuilder b = new StringBuilder ( "Encountered \"" ) ; Token tok = currentToken . next ; for ( int i = 0 ; i < maxSize ; i ++ ) { if ( i != 0 ) b . append ( " " ) ; if ( tok . kind == 0 ) { b . append ( tokenImage [ 0 ] ) ; break ; } b . append ( " " ) . append ( tokenImage [ tok . kind ] ) . append ( " \"" ) ; b . append ( add_escapes ( tok . image ) ) ; b . append ( " \"" ) ; tok = tok . next ; } b . append ( "\" at line " ) . append ( currentToken . next . beginLine ) . append ( ", column " ) . append ( currentToken . next . beginColumn ) ; b . append ( "." ) . append ( eol ) ; if ( expectedTokenSequences . length == 1 ) { b . append ( "Was expecting:" ) . append ( eol ) . append ( "    " ) ; } else { b . append ( "Was expecting one of:" ) . append ( eol ) . append ( "    " ) ; } expected . append ( expected . toString ( ) ) ; return b . toString ( ) ;


signature:
public class ColumnWidthsResizer { /** * / / / / / TableModelListener / / / / / */
@ Override public void tableChanged ( final TableModelEvent e ) { } }

implementation:
if ( e . getFirstRow ( ) == TableModelEvent . HEADER_ROW ) { return ; // Do not respond to changes in the number of columns here , only row and data changes .
} // ColumnWidthsResizer requires that the internal Swing TableModelListeners that update the JTable view
// run their updates BEFORE it does its thing . Unfortunately , the order in which listeners are notified is
// undefined ( see https : / / weblogs . java . net / blog / alexfromsun / archive / 2011/06/15 / swing - better - world - listeners ) .
// As a work - around , we ' re going to place the resize operation at the end of the event queue . That way , it ' ll
// be executed after all TableModelListeners have been notified .
EventQueue . invokeLater ( new Runnable ( ) { @ Override public void run ( ) { // Do not cache the value of doFullScan ; we need to reevaluate each time because the number of rows in
// the table could have changed .
boolean doFullScan = table . getRowCount ( ) <= fullScanCutoff ; if ( e . getColumn ( ) == TableModelEvent . ALL_COLUMNS ) { resize ( table , doFullScan ) ; // Resize all columns .
} else { resize ( table , e . getColumn ( ) , doFullScan ) ; // Resize only the affected column .
} } } ) ;


signature:
public class ColumnWidthsResizer { /** * / / / / / TableColumnModelListener / / / / / */
@ Override public void columnAdded ( TableColumnModelEvent e ) { } }

implementation: boolean doFullScan = table . getRowCount ( ) <= fullScanCutoff ; resize ( table , e . getToIndex ( ) , doFullScan ) ; // Only resize added column .


signature:
public class Bearing { /** * Calculate the bearing between the 2 points .
 * See calculateBearing below .
 * @ param e Earth object ( defines radius & flattening )
 * @ param pt1 Point 1
 * @ param pt2 Point 2
 * @ param result Object to use if non - null
 * @ return The bearing */
public static Bearing calculateBearing ( Earth e , LatLonPoint pt1 , LatLonPoint pt2 , Bearing result ) { } }

implementation: return calculateBearing ( e , pt1 . getLatitude ( ) , pt1 . getLongitude ( ) , pt2 . getLatitude ( ) , pt2 . getLongitude ( ) , result ) ;


signature:
public class Bearing { /** * Calculate the bearing between the 2 points .
 * See calculateBearing below . Uses default Earth object .
 * @ param pt1 Point 1
 * @ param pt2 Point 2
 * @ param result Object to use if non - null
 * @ return The bearing */
public static Bearing calculateBearing ( LatLonPoint pt1 , LatLonPoint pt2 , Bearing result ) { } }

implementation: return calculateBearing ( defaultEarth , pt1 . getLatitude ( ) , pt1 . getLongitude ( ) , pt2 . getLatitude ( ) , pt2 . getLongitude ( ) , result ) ;


signature:
public class Bearing { /** * Computes distance ( in km ) , azimuth ( degrees clockwise positive
 * from North , 0 to 360 ) , and back azimuth ( degrees clockwise positive
 * from North , 0 to 360 ) , from latitude - longituide point pt1 to
 * latitude - longituide pt2 . Uses default Earth object .
 * @ param lat1 Lat of point 1
 * @ param lon1 Lon of point 1
 * @ param lat2 Lat of point 2
 * @ param lon2 Lon of point 2
 * @ param result put result here , or null to allocate
 * @ return a Bearing object with distance ( in km ) , azimuth from
 * pt1 to pt2 ( degrees , 0 = north , clockwise positive ) */
public static Bearing calculateBearing ( double lat1 , double lon1 , double lat2 , double lon2 , Bearing result ) { } }

implementation: return calculateBearing ( defaultEarth , lat1 , lon1 , lat2 , lon2 , result ) ;