signature:
public class McIDASAreaProjection { /** * Convert projection coordinates to a LatLonPoint
 * Note : a new object is not created on each call for the return value .
 * @ param world convert from these projection coordinates
 * @ param result the object to write to
 * @ return LatLonPoint convert to these lat / lon coordinates */
public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) { } }

implementation: double toLat , toLon ; double fromX = world . getX ( ) ; double fromY = world . getY ( ) ; double [ ] [ ] latlon = anav . toLatLon ( new double [ ] [ ] { { fromX } , { fromY } } ) ; toLat = latlon [ 0 ] [ 0 ] ; toLon = latlon [ 1 ] [ 0 ] ; result . setLatitude ( toLat ) ; result . setLongitude ( toLon ) ; return result ;


signature:
public class McIDASAreaProjection { /** * Convert lat / lon coordinates to projection coordinates .
 * @ param from array of lat / lon coordinates : from [ 2 ] [ n ] ,
 * where from [ 0 ] [ i ] , from [ 1 ] [ i ] is the ( lat , lon )
 * coordinate of the ith point
 * @ param to resulting array of projection coordinates ,
 * where to [ 0 ] [ i ] , to [ 1 ] [ i ] is the ( x , y ) coordinate
 * of the ith point
 * @ param latIndex index of latitude in " from "
 * @ param lonIndex index of longitude in " from "
 * @ return the " to " array . */
public float [ ] [ ] latLonToProj ( float [ ] [ ] from , float [ ] [ ] to , int latIndex , int lonIndex ) { } }

implementation: float [ ] fromLatA = from [ latIndex ] ; float [ ] fromLonA = from [ lonIndex ] ; float [ ] [ ] xy = anav . toLinEle ( new float [ ] [ ] { fromLatA , fromLonA } ) ; if ( xy == null ) return null ; to [ INDEX_X ] = xy [ 0 ] ; to [ INDEX_Y ] = xy [ 1 ] ; return to ;


signature:
public class McIDASAreaProjection { /** * Convert lat / lon coordinates to projection coordinates .
 * @ param from array of lat / lon coordinates : from [ 2 ] [ n ] , where
 * ( from [ 0 ] [ i ] , from [ 1 ] [ i ] ) is the ( lat , lon ) coordinate
 * of the ith point
 * @ param to resulting array of projection coordinates : to [ 2 ] [ n ]
 * where ( to [ 0 ] [ i ] , to [ 1 ] [ i ] ) is the ( x , y ) coordinate
 * of the ith point
 * @ return the " to " array */
public float [ ] [ ] projToLatLon ( float [ ] [ ] from , float [ ] [ ] to ) { } }

implementation: float [ ] fromXA = from [ INDEX_X ] ; float [ ] fromYA = from [ INDEX_Y ] ; float [ ] [ ] latlon = anav . toLatLon ( new float [ ] [ ] { fromXA , fromYA } ) ; to [ INDEX_LAT ] = latlon [ 0 ] ; to [ INDEX_LON ] = latlon [ 1 ] ; return to ;


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

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


signature:
public class McIDASAreaProjection { /** * make a double array out of an int array
 * @ param ints array of ints
 * @ return array of doubles */
private double [ ] makeDoubleArray ( int [ ] ints ) { } }

implementation: double [ ] newArray = new double [ ints . length ] ; for ( int i = 0 ; i < ints . length ; i ++ ) { newArray [ i ] = ints [ i ] ; } return newArray ;


signature: public class NcssGridController { @ RequestMapping ( value = { } }

implementation:
"**/dataset.xml" , "**/pointDataset.xml" } ) // Same response for both Grid and GridAsPoint .
public ModelAndView getDatasetDescriptionXml ( HttpServletRequest req , HttpServletResponse res ) throws IOException { String datasetPath = getDatasetPath ( req ) ; try ( CoverageCollection gcd = TdsRequestedDataset . getCoverageCollection ( req , res , datasetPath ) ) { if ( gcd == null ) return null ; // restricted dataset
String datasetUrlPath = buildDatasetUrl ( datasetPath ) ; CoverageDatasetCapabilities writer = new CoverageDatasetCapabilities ( gcd , "path" ) ; Document doc = writer . makeDatasetDescription ( ) ; Element root = doc . getRootElement ( ) ; root . setAttribute ( "location" , datasetUrlPath ) ; root . addContent ( makeAcceptXML ( SupportedOperation . GRID_REQUEST ) ) ; return new ModelAndView ( "threddsXmlView" , "Document" , doc ) ; }


signature:
public class NcssGridController { /** * Supported for backwards compatibility . We prefer that datasetBoundaries . wkt or datasetBoundaries . json are used . */
@ RequestMapping ( "**/datasetBoundaries.xml" ) public void getDatasetBoundaries ( NcssParamsBean params , HttpServletRequest req , HttpServletResponse res ) throws IOException , UnsupportedResponseFormatException { } }

implementation: SupportedFormat format = SupportedOperation . DATASET_BOUNDARIES_REQUEST . getSupportedFormat ( params . getAccept ( ) ) ; switch ( format ) { case WKT : getDatasetBoundariesWKT ( req , res ) ; break ; case JSON : getDatasetBoundariesGeoJSON ( req , res ) ; break ; default : throw new IllegalArgumentException ( String . format ( "Expected %s or %s, but got %s" , SupportedFormat . WKT , SupportedFormat . JSON , format ) ) ; }


signature:
public class NcssGridController { /** * Checks that all the requested vars exist . If " all " , fills out the param . vars with all grid names
 * Throws exception if some of the variables in the request are not contained in the dataset */
private void checkRequestedVars ( CoverageCollection gcd , NcssGridParamsBean params ) throws VariableNotContainedInDatasetException { } }

implementation:
// if var = = all - - > all variables requested
if ( params . getVar ( ) . get ( 0 ) . equalsIgnoreCase ( "all" ) ) { params . setVar ( getAllGridNames ( gcd ) ) ; return ; } // Check vars are contained in the grid
for ( String gridName : params . getVar ( ) ) { Coverage grid = gcd . findCoverage ( gridName ) ; if ( grid == null ) throw new VariableNotContainedInDatasetException ( "Variable: " + gridName + " is not contained in the requested dataset" ) ; }


signature:
public class NcssGridController { /** * Returns true if all the variables have the same vertical axis ( if they have an axis ) .
 * Could be broadened to allow all with same coordinate unites ? coordinate value ? ? */
protected boolean checkVarsHaveSameVertAxis ( CoverageCollection gcd , NcssGridParamsBean params ) { } }

implementation: String zaxisName = null ; for ( String gridName : params . getVar ( ) ) { Coverage grid = gcd . findCoverage ( gridName ) ; CoverageCoordAxis zaxis = grid . getCoordSys ( ) . getZAxis ( ) ; if ( zaxis != null ) { if ( zaxisName == null ) zaxisName = zaxis . getName ( ) ; else if ( ! zaxisName . equals ( zaxis . getName ( ) ) ) return false ; } } return true ;


signature:
public class Stereographic { /** * Construct a Stereographic Projection using latitude of true scale and calculating scale factor .
 * < p > Since the scale factor at lat = k = 2 * k0 / ( 1 + sin ( lat ) ) [ Snyder , Working Manual p157]
 * then to make scale = 1 at lat , set k0 = ( 1 + sin ( lat ) ) / 2
 * @ param latt tangent point of projection , also origin of projection coord system
 * @ param lont tangent point of projection , also origin of projection coord system
 * @ param latTrue latitude of true scale in degrees north ; latitude where scale factor = 1.0
 * @ return Stereographic projection */
static public Stereographic factory ( double latt , double lont , double latTrue ) { } }

implementation: double scale = ( 1.0 + Math . sin ( Math . toRadians ( latTrue ) ) ) / 2.0 ; return new Stereographic ( latt , lont , scale ) ;


signature:
public class Stereographic { /** * Calculate polar stereographic scale factor based on the natural latitude and
 * longitude of the original
 * Ref : OGP Surveying and Positioning Guidance Note number 7 , part 2 April 2009
 * http : / / www . epsg . org
 * added by Qun He < qunhe @ unc . edu >
 * @ param lat _ ts Latitude at natural origin
 * @ param north Is it north polar ?
 * @ return scale factor */
private double getScaleFactor ( double lat_ts , boolean north ) { } }

implementation: double e = 0.081819191 ; double tf = 1.0 , mf = 1.0 , k0 = 1.0 ; double root = ( 1 + e * Math . sin ( lat_ts ) ) / ( 1 - e * Math . sin ( lat_ts ) ) ; double power = e / 2 ; if ( north ) tf = Math . tan ( Math . PI / 4 - lat_ts / 2 ) * ( Math . pow ( root , power ) ) ; else tf = Math . tan ( Math . PI / 4 + lat_ts / 2 ) / ( Math . pow ( root , power ) ) ; mf = Math . cos ( lat_ts ) / Math . sqrt ( 1 - e * e * Math . pow ( Math . sin ( lat_ts ) , 2 ) ) ; k0 = mf * Math . sqrt ( Math . pow ( 1 + e , 1 + e ) * Math . pow ( 1 - e , 1 - e ) ) / ( 2 * tf ) ; return Double . isNaN ( k0 ) ? 1.0 : k0 ;


signature:
public class Stereographic { /** * 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 */
public ProjectionPoint latLonToProj ( LatLonPoint latLon , ProjectionPointImpl result ) { } }

implementation:
double toX , toY ; double fromLat = latLon . getLatitude ( ) ; double fromLon = latLon . getLongitude ( ) ; double lat = Math . toRadians ( fromLat ) ; double lon = Math . toRadians ( fromLon ) ; // keep away from the singular point
if ( ( Math . abs ( lat + latt ) <= TOLERANCE ) ) { lat = - latt * ( 1.0 - TOLERANCE ) ; } double sdlon = Math . sin ( lon - lont ) ; double cdlon = Math . cos ( lon - lont ) ; double sinlat = Math . sin ( lat ) ; double coslat = Math . cos ( lat ) ; double k = 2.0 * scale / ( 1.0 + sinlatt * sinlat + coslatt * coslat * cdlon ) ; toX = k * coslat * sdlon ; toY = k * ( coslatt * sinlat - sinlatt * coslat * cdlon ) ; result . setLocation ( toX + falseEasting , toY + falseNorthing ) ; return result ;


signature:
public class Stereographic { /** * Convert projection coordinates to a LatLonPoint
 * Note : a new object is not created on each call for the return value .
 * @ param world convert from these projection coordinates
 * @ param result the object to write to
 * @ return LatLonPoint convert to these lat / lon coordinates */
public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) { } }

implementation: double toLat , toLon ; double fromX = world . getX ( ) - falseEasting ; double fromY = world . getY ( ) - falseNorthing ; double phi , lam ; double rho = Math . sqrt ( fromX * fromX + fromY * fromY ) ; double c = 2.0 * Math . atan2 ( rho , 2.0 * scale ) ; double sinc = Math . sin ( c ) ; double cosc = Math . cos ( c ) ; if ( Math . abs ( rho ) < TOLERANCE ) { phi = latt ; } else { phi = Math . asin ( cosc * sinlatt + fromY * sinc * coslatt / rho ) ; } toLat = Math . toDegrees ( phi ) ; if ( ( Math . abs ( fromX ) < TOLERANCE ) && ( Math . abs ( fromY ) < TOLERANCE ) ) { lam = lont ; } else if ( Math . abs ( coslatt ) < TOLERANCE ) { lam = lont + Math . atan2 ( fromX , ( ( latt > 0 ) ? - fromY : fromY ) ) ; } else { lam = lont + Math . atan2 ( fromX * sinc , rho * coslatt * cosc - fromY * sinc * sinlatt ) ; } toLon = Math . toDegrees ( lam ) ; result . setLatitude ( toLat ) ; result . setLongitude ( toLon ) ; return result ;


signature:
public class Stereographic { /** * Convert projection coordinates to lat / lon coordinate .
 * @ param from array of projection coordinates : from [ 2 ] [ n ] , where
 * ( from [ 0 ] [ i ] , from [ 1 ] [ i ] ) is the ( x , y ) coordinate
 * of the ith point
 * @ param to resulting array of lat / lon coordinates : to [ 2 ] [ n ] where
 * ( to [ 0 ] [ i ] , to [ 1 ] [ i ] ) is the ( lat , lon ) coordinate of
 * the ith point
 * @ return the " to " array */
public float [ ] [ ] projToLatLon ( float [ ] [ ] from , float [ ] [ ] to ) { } }

implementation: int cnt = from [ 0 ] . length ; float [ ] fromXA = from [ INDEX_X ] ; float [ ] fromYA = from [ INDEX_Y ] ; float [ ] toLatA = to [ INDEX_LAT ] ; float [ ] toLonA = to [ INDEX_LON ] ; double phi , lam ; double toLat , toLon ; for ( int i = 0 ; i < cnt ; i ++ ) { double fromX = fromXA [ i ] - falseEasting ; double fromY = fromYA [ i ] - falseNorthing ; double rho = Math . sqrt ( fromX * fromX + fromY * fromY ) ; double c = 2.0 * Math . atan2 ( rho , 2.0 * scale ) ; double sinc = Math . sin ( c ) ; double cosc = Math . cos ( c ) ; if ( Math . abs ( rho ) < TOLERANCE ) { phi = latt ; } else { phi = Math . asin ( cosc * sinlatt + fromY * sinc * coslatt / rho ) ; } toLat = Math . toDegrees ( phi ) ; if ( ( Math . abs ( fromX ) < TOLERANCE ) && ( Math . abs ( fromY ) < TOLERANCE ) ) { lam = lont ; } else if ( Math . abs ( coslatt ) < TOLERANCE ) { lam = lont + Math . atan2 ( fromX , ( ( latt > 0 ) ? - fromY : fromY ) ) ; } else { lam = lont + Math . atan2 ( fromX * sinc , rho * coslatt * cosc - fromY * sinc * sinlatt ) ; } toLon = Math . toDegrees ( lam ) ; toLatA [ i ] = ( float ) toLat ; toLonA [ i ] = ( float ) toLon ; } return to ;


signature:
public class Stereographic { /** * Convert lat / lon coordinates to projection coordinates .
 * @ param from array of lat / lon coordinates : from [ 2 ] [ n ] , where
 * ( from [ latIndex ] [ i ] , from [ lonIndex ] [ i ] ) is the ( lat , lon )
 * coordinate of the ith point
 * @ param to resulting array of projection coordinates : to [ 2 ] [ n ]
 * where ( to [ 0 ] [ i ] , to [ 1 ] [ i ] ) is the ( x , y ) coordinate of
 * the ith point
 * @ param latIndex index of lat coordinate ; must be 0 or 1
 * @ param lonIndex index of lon coordinate ; must be 0 or 1
 * @ return the " to " array */
public double [ ] [ ] latLonToProj ( double [ ] [ ] from , double [ ] [ ] to , int latIndex , int lonIndex ) { } }

implementation:
int cnt = from [ 0 ] . length ; double [ ] fromLatA = from [ latIndex ] ; double [ ] fromLonA = from [ lonIndex ] ; double [ ] resultXA = to [ INDEX_X ] ; double [ ] resultYA = to [ INDEX_Y ] ; double toX , toY ; for ( int i = 0 ; i < cnt ; i ++ ) { double fromLat = fromLatA [ i ] ; double fromLon = fromLonA [ i ] ; double lat = Math . toRadians ( fromLat ) ; double lon = Math . toRadians ( fromLon ) ; // keep away from the singular point
if ( ( Math . abs ( lat + latt ) <= TOLERANCE ) ) { lat = - latt * ( 1.0 - TOLERANCE ) ; } double sdlon = Math . sin ( lon - lont ) ; double cdlon = Math . cos ( lon - lont ) ; double sinlat = Math . sin ( lat ) ; double coslat = Math . cos ( lat ) ; double k = 2.0 * scale / ( 1.0 + sinlatt * sinlat + coslatt * coslat * cdlon ) ; toX = k * coslat * sdlon ; toY = k * ( coslatt * sinlat - sinlatt * coslat * cdlon ) ; resultXA [ i ] = toX + falseEasting ; resultYA [ i ] = toY + falseNorthing ; } return to ;


signature:
public class DatasetSourceStructure { /** * Find the DatasetSourceStructure that matches this name .
 * @ param name
 * @ return DatasetSourceStructure or null if no match . */
public static DatasetSourceStructure getStructure ( String name ) { } }

implementation: if ( name == null ) return null ; return ( DatasetSourceStructure ) hash . get ( name ) ;


signature:
public class Dap4Controller { /** * to work under Intellij . */
@ Override public String getResourcePath ( DapRequest drq , String location ) throws DapException { } }

implementation:
String realpath ; if ( TdsRequestedDataset . getDatasetManager ( ) != null ) { realpath = TdsRequestedDataset . getLocationFromRequestPath ( location ) ; } else { assert TdsRequestedDataset . getDatasetManager ( ) == null ; String prefix = drq . getResourceRoot ( ) ; assert ( prefix != null ) ; realpath = DapUtil . canonjoin ( prefix , location ) ; } if ( ! TESTING ) { if ( ! TdsRequestedDataset . resourceControlOk ( drq . getRequest ( ) , drq . getResponse ( ) , realpath ) ) throw new DapException ( "Not authorized: " + location ) . setCode ( DapCodes . SC_FORBIDDEN ) ; } File f = new File ( realpath ) ; if ( ! f . exists ( ) || ! f . canRead ( ) ) throw new DapException ( "Not found: " + location ) . setCode ( DapCodes . SC_NOT_FOUND ) ; // ncfile = TdsRequestedDataset . getNetcdfFile ( this . request , this . response , path ) ;
return realpath ;


signature:
public class GridIndexToNC { /** * Fill in the netCDF file
 * @ param index grid index
 * @ param lookup lookup table
 * @ param version version of data
 * @ param ncfile netCDF file to fill in
 * @ param cancelTask cancel task
 * @ throws IOException Problem reading from the file */
public void open ( GridIndex index , GridTableLookup lookup , int version , NetcdfFile ncfile , CancelTask cancelTask ) throws IOException { } }

implementation:
// create the HorizCoord Systems : one for each gds
List < GridDefRecord > hcsList = index . getHorizCoordSys ( ) ; boolean needGroups = ( hcsList . size ( ) > 1 ) ; for ( GridDefRecord gds : hcsList ) { Group g = null ; if ( needGroups ) { g = new Group ( ncfile , null , gds . getGroupName ( ) ) ; ncfile . addGroup ( null , g ) ; } // ( GridDefRecord gdsIndex , String grid _ name , String shape _ name , Group g )
GridHorizCoordSys hcs = makeGridHorizCoordSys ( gds , lookup , g ) ; hcsHash . put ( gds . getParam ( GridDefRecord . GDS_KEY ) , hcs ) ; } // run through each record
GridRecord firstRecord = null ; List < GridRecord > records = index . getGridRecords ( ) ; for ( GridRecord gridRecord : records ) { if ( firstRecord == null ) { firstRecord = gridRecord ; } GridHorizCoordSys hcs = hcsHash . get ( gridRecord . getGridDefRecordId ( ) ) ; int cdmHash = gridRecord . cdmVariableHash ( ) ; GridVariable pv = hcs . varHash . get ( cdmHash ) ; if ( null == pv ) { String name = gridRecord . cdmVariableName ( lookup , true , true ) ; pv = makeGridVariable ( indexFilename , name , hcs , lookup ) ; hcs . varHash . put ( cdmHash , pv ) ; // keep track of all products with same parameter name = = " simple name "
String simpleName = gridRecord . getParameterDescription ( ) ; List < GridVariable > plist = hcs . productHash . get ( simpleName ) ; if ( null == plist ) { plist = new ArrayList < > ( ) ; hcs . productHash . put ( simpleName , plist ) ; } plist . add ( pv ) ; } /* else if ( lookup instanceof Grib2GridTableLookup ) {
 Grib2GridTableLookup g2lookup = ( Grib2GridTableLookup ) lookup ;
 / / check for non interval pv and interval record which needs a interval pv
 if ( ! pv . isInterval ( ) & & g2lookup . isInterval ( gridRecord ) ) {
 / / make an interval variable
 String interval = name + " _ interval " ;
 pv = ( GridVariable ) hcs . varHash . get ( interval ) ;
 if ( null = = pv ) {
 pv = new GridVariable ( interval , hcs , lookup ) ;
 hcs . varHash . put ( cdmHash , pv ) ;
 String simpleName = makeVariableName ( gridRecord , lookup , false , true ) ; / / LOOK may not be a good idea
 List < GridVariable > plist = hcs . productHash . get ( simpleName ) ;
 if ( null = = plist ) {
 plist = new ArrayList < GridVariable > ( ) ;
 hcs . productHash . put ( simpleName , plist ) ;
 plist . add ( pv ) ;
 } else if ( pv . isInterval ( ) & & ! g2lookup . isInterval ( gridRecord ) ) {
 / / make a non - interval variable
 / / logger . info ( " Non - Interval records for % s % n " , pv . getName ( ) ) ; LOOK
 continue ;
 } / / grid2 */
pv . addProduct ( gridRecord ) ; } // global CF Conventions
// Conventions attribute change must be in sync with CDM code
ncfile . addAttribute ( null , new Attribute ( "Conventions" , "CF-1.4" ) ) ; addExtraAttributes ( firstRecord , lookup , ncfile ) ; // CF Global attributes
ncfile . addAttribute ( null , new Attribute ( "title" , lookup . getTitle ( ) ) ) ; if ( lookup . getInstitution ( ) != null ) ncfile . addAttribute ( null , new Attribute ( "institution" , lookup . getInstitution ( ) ) ) ; String source = lookup . getSource ( ) ; if ( source != null && ! source . startsWith ( "Unknown" ) ) ncfile . addAttribute ( null , new Attribute ( "source" , source ) ) ; // String now = formatter . toDateTimeStringISO ( Calendar . getInstance ( ) . getTime ( ) ) ;
ncfile . addAttribute ( null , new Attribute ( "history" , "Direct read of " + lookup . getGridType ( ) + " into NetCDF-Java 4 API" ) ) ; if ( lookup . getComment ( ) != null ) ncfile . addAttribute ( null , new Attribute ( "comment" , lookup . getComment ( ) ) ) ; // dataset discovery
// if ( center ! = null )
// ncfile . addAttribute ( null , new Attribute ( " center _ name " , center ) ) ;
// CDM attributes
ncfile . addAttribute ( null , new Attribute ( CF . FEATURE_TYPE , FeatureType . GRID . toString ( ) ) ) ; ncfile . addAttribute ( null , new Attribute ( "file_format" , lookup . getGridType ( ) ) ) ; // ncfile . addAttribute ( null , new Attribute ( " location " , ncfile . getLocation ( ) ) ) ;
ncfile . addAttribute ( null , new Attribute ( _Coordinate . ModelRunDate , formatter . toDateTimeStringISO ( lookup . getFirstBaseTime ( ) ) ) ) ; /* if ( fmrcCoordSys ! = null ) {
 makeDefinedCoordSys ( ncfile , lookup , fmrcCoordSys ) ;
 } else {
 makeDenseCoordSys ( ncfile , lookup , cancelTask ) ; */
makeDenseCoordSys ( ncfile , lookup , cancelTask ) ; if ( GridServiceProvider . debugMissing ) { try ( Formatter f = new Formatter ( System . out ) ) { int count = 0 ; Collection < GridHorizCoordSys > hcset = hcsHash . values ( ) ; for ( GridHorizCoordSys hcs : hcset ) { List < GridVariable > gribvars = new ArrayList < > ( hcs . varHash . values ( ) ) ; for ( GridVariable gv : gribvars ) { count += gv . showMissingSummary ( f ) ; } } System . out . println ( " total missing= " + count ) ; } } if ( GridServiceProvider . debugMissingDetails ) { Formatter f = new Formatter ( ) ; Collection < GridHorizCoordSys > hcset = hcsHash . values ( ) ; for ( GridHorizCoordSys hcs : hcset ) { f . format ( "******** Horiz Coordinate= %s%n" , hcs . getGridName ( ) ) ; String lastVertDesc = null ; List < GridVariable > gribvars = new ArrayList < > ( hcs . varHash . values ( ) ) ; Collections . sort ( gribvars , new CompareGridVariableByVertName ( ) ) ; for ( GridVariable gv : gribvars ) { String vertDesc = gv . getVertName ( ) ; if ( ! vertDesc . equals ( lastVertDesc ) ) { f . format ( "---Vertical Coordinate= %s%n" , vertDesc ) ; lastVertDesc = vertDesc ; } gv . showMissing ( f ) ; } } } // clean out stuff we dont need anymore
// for ( GridHorizCoordSys ghcs : hcsHash . values ( ) ) {
// ghcs . empty ( ) ;


signature:
public class GridIndexToNC { /** * Make coordinate system without missing data - means that we
 * have to make a coordinate axis for each unique set
 * of time or vertical levels .
 * @ param ncfile netCDF file
 * @ param lookup lookup table
 * @ param cancelTask cancel task
 * @ throws IOException problem reading file */
private void makeDenseCoordSys ( NetcdfFile ncfile , GridTableLookup lookup , CancelTask cancelTask ) throws IOException { } }

implementation:
List < GridTimeCoord > timeCoords = new ArrayList < > ( ) ; List < GridVertCoord > vertCoords = new ArrayList < > ( ) ; List < GridEnsembleCoord > ensembleCoords = new ArrayList < > ( ) ; Calendar calendar = Calendar . getInstance ( ) ; calendar . setTimeZone ( java . util . TimeZone . getTimeZone ( "GMT" ) ) ; // loop over HorizCoordSys
Collection < GridHorizCoordSys > hcset = hcsHash . values ( ) ; for ( GridHorizCoordSys hcs : hcset ) { if ( ( cancelTask != null ) && cancelTask . isCancel ( ) ) break ; // loop over GridVariables in the HorizCoordSys
// create the time and vertical coordinates
List < GridVariable > gribvars = new ArrayList < > ( hcs . varHash . values ( ) ) ; for ( GridVariable gv : gribvars ) { if ( ( cancelTask != null ) && cancelTask . isCancel ( ) ) break ; List < GridRecord > recordList = gv . getRecords ( ) ; GridRecord record = recordList . get ( 0 ) ; String vname = gv . makeLevelName ( record , lookup ) ; // look to see if vertical already exists
GridVertCoord useVertCoord = null ; for ( GridVertCoord gvcs : vertCoords ) { if ( vname . equals ( gvcs . getLevelName ( ) ) ) { if ( gvcs . matchLevels ( recordList ) ) { // must have the same levels
useVertCoord = gvcs ; } } } if ( useVertCoord == null ) { // nope , got to create it
useVertCoord = makeGridVertCoord ( recordList , vname , lookup , hcs ) ; vertCoords . add ( useVertCoord ) ; } gv . setVertCoord ( useVertCoord ) ; // look to see if time coord already exists
GridTimeCoord useTimeCoord = null ; for ( GridTimeCoord gtc : timeCoords ) { if ( gtc . matchTimes ( recordList ) ) { // must have the same time coords
useTimeCoord = gtc ; break ; } } if ( useTimeCoord == null ) { // nope , got to create it
useTimeCoord = makeGridTimeCoord ( recordList , ncfile . getLocation ( ) ) ; timeCoords . add ( useTimeCoord ) ; } gv . setTimeCoord ( useTimeCoord ) ; if ( gv . isEnsemble ( ) ) { GridEnsembleCoord useEnsembleCoord = addEnsembles ( ensembleCoords , recordList ) ; if ( useEnsembleCoord != null ) gv . setEnsembleCoord ( useEnsembleCoord ) ; } } // assign time coordinate names , add dimensions to file
// reverse sort by length - give time dimensions unique names
Collections . sort ( timeCoords ) ; int count = 0 ; for ( GridTimeCoord tcs : timeCoords ) { tcs . setSequence ( count ++ ) ; tcs . addDimensionsToNetcdfFile ( ncfile , hcs . getGroup ( ) ) ; } // add Ensemble dimensions , give Ensemble dimensions unique names
int seqno = 0 ; for ( GridEnsembleCoord gec : ensembleCoords ) { gec . setSequence ( seqno ++ ) ; gec . addDimensionsToNetcdfFile ( ncfile , hcs . getGroup ( ) ) ; } // add x , y dimensions
hcs . addDimensionsToNetcdfFile ( ncfile ) ; // add vertical dimensions , give them unique names
Collections . sort ( vertCoords ) ; int vcIndex = 0 ; String listName = null ; int start = 0 ; for ( vcIndex = 0 ; vcIndex < vertCoords . size ( ) ; vcIndex ++ ) { GridVertCoord gvcs = vertCoords . get ( vcIndex ) ; String vname = gvcs . getLevelName ( ) ; if ( listName == null ) { listName = vname ; // initial
} if ( ! vname . equals ( listName ) ) { makeVerticalDimensions ( vertCoords . subList ( start , vcIndex ) , ncfile , hcs . getGroup ( ) ) ; listName = vname ; start = vcIndex ; } } makeVerticalDimensions ( vertCoords . subList ( start , vcIndex ) , ncfile , hcs . getGroup ( ) ) ; // create a variable for each entry , but check for other products with same simple name to disambiguate
List < List < GridVariable > > products = new ArrayList < > ( hcs . productHash . values ( ) ) ; for ( List < GridVariable > plist : products ) { if ( ( cancelTask != null ) && cancelTask . isCancel ( ) ) break ; if ( plist . size ( ) == 1 ) { GridVariable pv = plist . get ( 0 ) ; String name = pv . getFirstRecord ( ) . cdmVariableName ( lookup , false , false ) ; // plain ole name
Variable v = pv . makeVariable ( ncfile , hcs . getGroup ( ) , name , raf ) ; ncfile . addVariable ( hcs . getGroup ( ) , v ) ; } else { // collect them grouped by vertical coord
Map < GridVertCoord , VertCollection > vcMap = new HashMap < > ( ) ; for ( GridVariable gv : plist ) { VertCollection vc = vcMap . get ( gv . getVertCoord ( ) ) ; if ( vc == null ) { vc = new VertCollection ( gv ) ; vcMap . put ( gv . getVertCoord ( ) , vc ) ; } vc . list . add ( gv ) ; } // sort by larger # vert levels
List < VertCollection > vclist = new ArrayList < > ( vcMap . values ( ) ) ; Collections . sort ( vclist ) ; boolean firstVertCoord = true ; for ( VertCollection vc : vclist ) { boolean hasMultipleLevels = vc . vc . getNLevels ( ) > 1 ; boolean noLevelOk = firstVertCoord ; // & & hasMultipleLevels ; LOOK turned off for now 9/15/10
List < GridVariable > list = vc . list ; if ( list . size ( ) == 1 ) { GridVariable gv = list . get ( 0 ) ; String name = gv . getFirstRecord ( ) . cdmVariableName ( lookup , ! noLevelOk , false ) ; ncfile . addVariable ( hcs . getGroup ( ) , gv . makeVariable ( ncfile , hcs . getGroup ( ) , name , raf ) ) ; } else { for ( GridVariable gv : list ) { // more than one - disambiguate by stat name
String name = gv . getFirstRecord ( ) . cdmVariableName ( lookup , ! noLevelOk , true ) ; ncfile . addVariable ( hcs . getGroup ( ) , gv . makeVariable ( ncfile , hcs . getGroup ( ) , name , raf ) ) ; } } firstVertCoord = false ; } } // multiple vertical levels
} // create variable
// add coordinate variables at the end
for ( GridTimeCoord tcs : timeCoords ) { tcs . addToNetcdfFile ( ncfile , hcs . getGroup ( ) ) ; } for ( GridEnsembleCoord ens : ensembleCoords ) { ens . addToNetcdfFile ( ncfile , hcs . getGroup ( ) ) ; } hcs . addToNetcdfFile ( ncfile ) ; for ( GridVertCoord gvcs : vertCoords ) { gvcs . addToNetcdfFile ( ncfile , hcs . getGroup ( ) ) ; } } // loop over hcs
// TODO : check this , in ToolsUI it caused problems
// for ( GridVertCoord gvcs : vertCoords ) {
// gvcs . empty ( ) ;


signature:
public class GridIndexToNC { /** * Make a vertical dimensions
 * @ param vertCoordList vertCoords all with the same name
 * @ param ncfile netCDF file to add to
 * @ param group group in ncfile */
private void makeVerticalDimensions ( List < GridVertCoord > vertCoordList , NetcdfFile ncfile , Group group ) { } }

implementation:
// find biggest vert coord
GridVertCoord gvcs0 = null ; int maxLevels = 0 ; for ( GridVertCoord gvcs : vertCoordList ) { if ( gvcs . getNLevels ( ) > maxLevels ) { gvcs0 = gvcs ; maxLevels = gvcs . getNLevels ( ) ; } } int seqno = 1 ; for ( GridVertCoord gvcs : vertCoordList ) { if ( gvcs != gvcs0 ) { gvcs . setSequence ( seqno ++ ) ; } gvcs . addDimensionsToNetcdfFile ( ncfile , group ) ; }


signature:
public class FysatHeader { /** * Read the header and populate the ncfile
 * @ param raf
 * @ throws IOException */
boolean readPIB ( RandomAccessFile raf ) throws IOException { } }

implementation:
this . firstHeader = new AwxFileFirstHeader ( ) ; int pos = 0 ; raf . seek ( pos ) ; // gini header process
byte [ ] buf = new byte [ FY_AWX_PIB_LEN ] ; int count = raf . read ( buf ) ; EndianByteBuffer byteBuffer ; if ( count == FY_AWX_PIB_LEN ) { byteBuffer = new EndianByteBuffer ( buf , this . firstHeader . byteOrder ) ; this . firstHeader . fillHeader ( byteBuffer ) ; } else { return false ; } if ( ! ( ( this . firstHeader . fileName . endsWith ( ".AWX" ) || this . firstHeader . fileName . endsWith ( ".awx" ) ) && this . firstHeader . firstHeaderLength == FY_AWX_PIB_LEN ) ) { return false ; } // skip the fills of the first record
// raf . seek ( FY _ AWX _ PIB _ LEN + this . firstHeader . fillSectionLength ) ;
buf = new byte [ this . firstHeader . secondHeaderLength ] ; raf . readFully ( buf ) ; byteBuffer = new EndianByteBuffer ( buf , this . firstHeader . byteOrder ) ; switch ( this . firstHeader . typeOfProduct ) { case AwxFileFirstHeader . AWX_PRODUCT_TYPE_UNDEFINED : throw new UnsupportedDatasetException ( ) ; case AwxFileFirstHeader . AWX_PRODUCT_TYPE_GEOSAT_IMAGE : secondHeader = new AwxFileGeoSatelliteSecondHeader ( ) ; secondHeader . fillHeader ( byteBuffer ) ; break ; case AwxFileFirstHeader . AWX_PRODUCT_TYPE_POLARSAT_IMAGE : throw new UnsupportedDatasetException ( ) ; case AwxFileFirstHeader . AWX_PRODUCT_TYPE_GRID : secondHeader = new AwxFileGridProductSecondHeader ( ) ; secondHeader . fillHeader ( byteBuffer ) ; break ; case AwxFileFirstHeader . AWX_PRODUCT_TYPE_DISCREET : throw new UnsupportedDatasetException ( ) ; case AwxFileFirstHeader . AWX_PRODUCT_TYPE_GRAPH_ANALIYSIS : throw new UnsupportedDatasetException ( ) ; } return true ;


signature:
public class InvDatasetImpl { /** * Finish constructing after all elements have been added .
 * This does the inheritence thing
 * This can be called again if new elements are added .
 * @ return true if successful . */
public boolean finish ( ) { } }

implementation:
boolean ok = true ; java . util . Iterator iter ; logger . debug ( "Now finish " + getName ( ) + " id= " + getID ( ) ) ; authorityName = null ; dataType = null ; dataFormatType = null ; defaultService = null ; gc = null ; tc = null ; docs = new ArrayList < > ( ) ; metadata = new ArrayList < > ( ) ; properties = new ArrayList < > ( ) ; creators = new ArrayList < > ( ) ; contributors = new ArrayList < > ( ) ; dates = new ArrayList < > ( ) ; keywords = new ArrayList < > ( ) ; projects = new ArrayList < > ( ) ; publishers = new ArrayList < > ( ) ; variables = new ArrayList < > ( ) ; canonicalize ( ) ; // canonicalize thredds metadata
transfer2PublicMetadata ( tm , true ) ; // add local metadata
transfer2PublicMetadata ( tmi , true ) ; // add local inherited metadata
transferInheritable2PublicMetadata ( ( InvDatasetImpl ) getParent ( ) ) ; // add inheritable metadata from parents
// build the expanded access list
access = new ArrayList < > ( ) ; // add access element if urlPath is specified
if ( ( urlPath != null ) && ( getServiceDefault ( ) != null ) ) { InvAccessImpl a = new InvAccessImpl ( this , urlPath , getServiceDefault ( ) ) ; a . setSize ( size ) ; a . finish ( ) ; addExpandedAccess ( a ) ; } // add local access elements
iter = accessLocal . iterator ( ) ; while ( iter . hasNext ( ) ) { InvAccessImpl a = ( InvAccessImpl ) iter . next ( ) ; a . finish ( ) ; addExpandedAccess ( a ) ; } // recurse into child datasets .
if ( ! ( this instanceof InvCatalogRef ) ) { for ( InvDataset invDataset : this . getDatasets ( ) ) { InvDatasetImpl curDs = ( InvDatasetImpl ) invDataset ; ok &= curDs . finish ( ) ; } } return ok ;


signature:
public class InvDatasetImpl { /** * Look for InvMetadata elements in the parent that need to be added to the public metadata of this dataset .
 * Recurse up through all ancestors .
 * @ param parent transfer from here */
private void transferInheritable2PublicMetadata ( InvDatasetImpl parent ) { } }

implementation:
if ( parent == null ) return ; logger . debug ( " inheritFromParent= " + parent . getID ( ) ) ; transfer2PublicMetadata ( parent . getLocalMetadataInheritable ( ) , true ) ; // transfer2PublicMetadata ( parent . getCat6Metadata ( ) , true ) ;
/* look through local metadata , find inherited InvMetadata elements
 ThreddsMetadata tmd = parent . getLocalMetadata ( ) ;
 Iterator iter = tmd . getMetadata ( ) . iterator ( ) ;
 while ( iter . hasNext ( ) ) {
 InvMetadata meta = ( InvMetadata ) iter . next ( ) ;
 if ( meta . isInherited ( ) ) {
 if ( ! meta . isThreddsMetadata ( ) ) {
 metadata . add ( meta ) ;
 } else {
 if ( debugInherit ) System . out . println ( " inheritMetadata Element " + tmd . isInherited ( ) + " " + meta . isInherited ( ) ) ;
 meta . finish ( ) ; / / make sure XLink is read in .
 transfer2PublicMetadata ( meta . getThreddsMetadata ( ) , false ) ; */
// recurse
transferInheritable2PublicMetadata ( ( InvDatasetImpl ) parent . getParent ( ) ) ;


signature:
public class InvDatasetImpl { /** * take all elements from tmd and add to the public metadata of this dataset .
 * for InvMetadata elements , only add if inheritAll | | InvMetadata . isInherited ( ) .
 * @ param tmd tahe metadata from here
 * @ param inheritAll true if all should be inherited , else only those which are specifically mareked */
private void transfer2PublicMetadata ( ThreddsMetadata tmd , boolean inheritAll ) { } }

implementation:
if ( tmd == null ) return ; logger . debug ( "  transferMetadata " + tmd ) ; if ( authorityName == null ) authorityName = tmd . getAuthority ( ) ; if ( dataType == null || ( dataType == FeatureType . ANY ) ) dataType = tmd . getDataType ( ) ; if ( dataFormatType == null || dataFormatType == DataFormatType . NONE ) dataFormatType = tmd . getDataFormatType ( ) ; if ( defaultService == null ) defaultService = findService ( tmd . getServiceName ( ) ) ; if ( gc == null ) { ThreddsMetadata . GeospatialCoverage tgc = tmd . getGeospatialCoverage ( ) ; if ( ( tgc != null ) && ! tgc . isEmpty ( ) ) gc = tgc ; } if ( tc == null ) { DateRange ttc = tmd . getTimeCoverage ( ) ; if ( ttc != null ) { tc = ttc ; } } if ( tc == null ) tc = tmd . getTimeCoverage ( ) ; for ( InvProperty item : tmd . getProperties ( ) ) { logger . debug ( "  add Property " + item + " to " + getID ( ) ) ; properties . add ( item ) ; } creators . addAll ( tmd . getCreators ( ) ) ; contributors . addAll ( tmd . getContributors ( ) ) ; dates . addAll ( tmd . getDates ( ) ) ; docs . addAll ( tmd . getDocumentation ( ) ) ; keywords . addAll ( tmd . getKeywords ( ) ) ; projects . addAll ( tmd . getProjects ( ) ) ; publishers . addAll ( tmd . getPublishers ( ) ) ; variables . addAll ( tmd . getVariables ( ) ) ; if ( variableMapLink == null ) variableMapLink = tmd . variableMapLink ; for ( InvMetadata meta : tmd . getMetadata ( ) ) { if ( meta . isInherited ( ) || inheritAll ) { if ( ! meta . isThreddsMetadata ( ) ) { metadata . add ( meta ) ; } else { logger . debug ( "  add metadata Element " + tmd . isInherited ( ) + " " + meta ) ; meta . finish ( ) ; // make sure XLink is read in .
transfer2PublicMetadata ( meta . getThreddsMetadata ( ) , inheritAll ) ; metadata . add ( meta ) ; } } }


signature:
public class InvDatasetImpl { /** * Transfer all inheritable metadata from fromDs to the local metadata of this dataset .
 * Called by InvDatasetScan to transfer inheritable metaddata to the nested catalogRef
 * @ param fromDs transfer from here */
public void transferMetadata ( InvDatasetImpl fromDs , boolean copyInheritedMetadataFromParents ) { } }

implementation: if ( fromDs == null ) return ; logger . debug ( " transferMetadata= " + fromDs . getName ( ) ) ; if ( this != fromDs ) getLocalMetadata ( ) . add ( fromDs . getLocalMetadata ( ) , false ) ; transferInheritableMetadata ( fromDs , getLocalMetadataInheritable ( ) , copyInheritedMetadataFromParents ) ; setResourceControl ( fromDs . getRestrictAccess ( ) ) ;


signature:
public class InvDatasetImpl { /** * transfer inherited metadata , consolidating it into target
 * @ param fromDs transfer from here , plus its parents
 * @ param target transfer to here */
private void transferInheritableMetadata ( InvDatasetImpl fromDs , ThreddsMetadata target , boolean copyInheritedMetadataFromParents ) { } }

implementation:
if ( fromDs == null ) return ; logger . debug ( " transferInheritedMetadata= " + fromDs . getName ( ) ) ; target . add ( fromDs . getLocalMetadataInheritable ( ) , true ) ; /* look through local metadata , find inherited InvMetadata elements
 ThreddsMetadata tmd = fromDs . getLocalMetadata ( ) ;
 Iterator iter = tmd . getMetadata ( ) . iterator ( ) ;
 while ( iter . hasNext ( ) ) {
 InvMetadata meta = ( InvMetadata ) iter . next ( ) ;
 if ( meta . isInherited ( ) ) {
 if ( ! meta . isThreddsMetadata ( ) ) {
 tmc . addMetadata ( meta ) ;
 } else {
 logger . debug ( " transferInheritedMetadata " + meta . hashCode ( ) + " = " + meta ) ;
 meta . finish ( ) ; / / LOOK ? ? make sure XLink is read in .
 tmc . add ( meta . getThreddsMetadata ( ) , true ) ; */
// now do the same for the parents
if ( copyInheritedMetadataFromParents ) transferInheritableMetadata ( ( InvDatasetImpl ) fromDs . getParent ( ) , target , true ) ;


signature:
public class InvDatasetImpl { /** * Put metadata into canonical form .
 * All non - inherited thredds metadata put into single metadata element , pointed to by getLocalMetadata ( ) .
 * All inherited thredds metadata put into single metadata element , pointed to by getLocalMetadataInherited ( ) .
 * This is needed to do reliable editing . */
protected void canonicalize ( ) { } }

implementation:
List < InvMetadata > whatsLeft = new ArrayList < > ( ) ; List < InvMetadata > original = new ArrayList < > ( tm . metadata ) ; // get copy of metadata
tm . metadata = new ArrayList < > ( ) ; // transfer all non - inherited thredds metadata to tm
// transfer all inherited thredds metadata to tmi
for ( InvMetadata m : original ) { if ( m . isThreddsMetadata ( ) && ! m . isInherited ( ) && ! m . hasXlink ( ) ) { ThreddsMetadata nested = m . getThreddsMetadata ( ) ; tm . add ( nested , false ) ; } else if ( m . isThreddsMetadata ( ) && m . isInherited ( ) && ! m . hasXlink ( ) ) { ThreddsMetadata nested = m . getThreddsMetadata ( ) ; tmi . add ( nested , true ) ; } else { whatsLeft . add ( m ) ; } } // non ThreddsMetadata goes into tm
tm . metadata . addAll ( whatsLeft ) ;


signature:
public class InvDatasetImpl { /** * LOOK these are wrong */
public void setContributors ( List < ThreddsMetadata . Contributor > a ) { } }

implementation: List < ThreddsMetadata . Contributor > dest = tm . getContributors ( ) ; for ( ThreddsMetadata . Contributor item : a ) { if ( ! dest . contains ( item ) ) dest . add ( item ) ; } hashCode = 0 ;


signature:
public class InvDatasetImpl { /** * Add a nested dataset at the location indicated by index .
 * @ param index add at this position
 * @ param ds add this */
public void addDataset ( int index , InvDatasetImpl ds ) { } }

implementation: if ( ds == null ) return ; ds . setParent ( this ) ; datasets . add ( index , ds ) ; hashCode = 0 ;


signature:
public class InvDatasetImpl { /** * Remove the given dataset element from this dataset if it is in the dataset .
 * @ param ds - the dataset element to be removed
 * @ return true if this dataset contained the given dataset element . */
public boolean removeDataset ( InvDatasetImpl ds ) { } }

implementation: if ( this . datasets . remove ( ds ) ) { ds . setParent ( null ) ; InvCatalogImpl cat = ( InvCatalogImpl ) getParentCatalog ( ) ; if ( cat != null ) cat . removeDatasetByID ( ds ) ; return ( true ) ; } return ( false ) ;


signature:
public class InvDatasetImpl { /** * Replace the given dataset if it is a nesetd dataset .
 * @ param remove - the dataset element to be removed
 * @ param add - the dataset element to be added
 * @ return true on success */
public boolean replaceDataset ( InvDatasetImpl remove , InvDatasetImpl add ) { } }

implementation: for ( int i = 0 ; i < datasets . size ( ) ; i ++ ) { InvDataset dataset = datasets . get ( i ) ; if ( dataset . equals ( remove ) ) { datasets . set ( i , add ) ; InvCatalogImpl cat = ( InvCatalogImpl ) getParentCatalog ( ) ; if ( cat != null ) { cat . removeDatasetByID ( remove ) ; cat . addDatasetByID ( add ) ; } return true ; } } return false ;


signature:
public class InvDatasetImpl { /** * Add a service to this dataset .
 * @ param service add this service to the dataset
 * @ deprecated add services only to catalog */
public void addService ( InvService service ) { } }

implementation:
// System . out . println ( " - - add dataset service = " + service . getName ( ) ) ;
servicesLocal . add ( service ) ; services . add ( service ) ; // add nested servers
for ( InvService nested : service . getServices ( ) ) { services . add ( nested ) ; // System . out . println ( " - - add expanded service = " + nested . getName ( ) ) ;
} hashCode = 0 ;


signature:
public class InvDatasetImpl { /** * Remove a service from this dataset .
 * @ param service remove this
 * @ deprecated put services in catalog */
public void removeService ( InvService service ) { } }

implementation:
servicesLocal . remove ( service ) ; services . remove ( service ) ; // remove nested servers
for ( InvService nested : service . getServices ( ) ) { services . remove ( nested ) ; }


signature:
public class InvDatasetImpl { /** * Set the list of services attached specifically to this dataset .
 * Discard any previous servies .
 * @ param s list of services . */
public void setServicesLocal ( java . util . List < InvService > s ) { } }

implementation: this . services = new ArrayList < > ( ) ; this . servicesLocal = new ArrayList < > ( ) ; for ( InvService elem : s ) { addService ( elem ) ; } hashCode = 0 ;


signature:
public class InvDatasetImpl { /** * Remove the given InvMetadata from the set of metadata local to this dataset .
 * @ param metadata remove this
 * @ return true if an InvMetadata is removed , false otherwise . */
public boolean removeLocalMetadata ( InvMetadata metadata ) { } }

implementation:
InvDatasetImpl parentDataset = ( ( InvDatasetImpl ) metadata . getParentDataset ( ) ) ; List localMdata = parentDataset . getLocalMetadata ( ) . getMetadata ( ) ; if ( localMdata . contains ( metadata ) ) { if ( localMdata . remove ( metadata ) ) { hashCode = 0 ; // Need to recalculate the hash code .
return ( true ) ; } } return ( false ) ;


signature:
public class InvDatasetImpl { /** * Look up the User property having the given key
 * @ param key property key
 * @ return User property having the given key , or null */
public Object getUserProperty ( Object key ) { } }

implementation: if ( userMap == null ) return null ; return userMap . get ( key ) ;


signature:
public class InvDatasetImpl { /** * Write an Html representation of the given dataset .
 * < p > With datasetEvents , catrefEvents = true , this is used to construct an HTML page on the client
 * ( eg using HtmlPage ) ; the client then detects URL clicks and processes .
 * < p > With datasetEvents , catrefEvents = false , this is used to construct an HTML page on the server .
 * ( eg using HtmlPage ) ; the client then detects URL clicks and processes .
 * @ param buff put HTML here .
 * @ param ds the dataset .
 * @ param complete if true , add HTML header and ender so its a complete , valid HTML page .
 * @ param isServer if true , then we are in the thredds data server , so do the following : < ul >
 * < li > append " html " to DODS Access URLs
 * < / ul >
 * @ param datasetEvents if true , prepend " dataset : " to any dataset access URLS
 * @ param catrefEvents if true , prepend " catref : " to any catref URLS */
static public void writeHtmlDescription ( StringBuilder buff , InvDatasetImpl ds , boolean complete , boolean isServer , boolean datasetEvents , boolean catrefEvents , boolean resolveRelativeUrls ) { } }

implementation:
if ( ds == null ) return ; if ( complete ) { buff . append ( "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n" ) . append ( "        \"http://www.w3.org/TR/html4/loose.dtd\">\n" ) . append ( "\n" ) ; buff . append ( "" ) ; buff . append ( "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" ) ; buff . append ( "" ) ; buff . append ( "\n" ) ; } buff . append ( "
Dataset: " ) . append ( ds . getFullName ( ) ) . append ( "
\n
\n" ) ; if ( ( ds . getDataFormatType ( ) != null ) && ( ds . getDataFormatType ( ) != DataFormatType . NONE ) ) buff . append ( "
Data format: " ) . append ( StringUtil2 . quoteHtmlContent ( ds . getDataFormatType ( ) . toString ( ) ) ) . append ( "
\n" ) ; if ( ( ds . getDataSize ( ) != 0.0 ) && ! Double . isNaN ( ds . getDataSize ( ) ) ) buff . append ( "
Data size: " ) . append ( Format . formatByteSize ( ds . getDataSize ( ) ) ) . append ( "
\n" ) ; if ( ( ds . getDataType ( ) != null ) && ( ds . getDataType ( ) != FeatureType . ANY ) ) buff . append ( "
Data type: " ) . append ( StringUtil2 . quoteHtmlContent ( ds . getDataType ( ) . toString ( ) ) ) . append ( "
\n" ) ; if ( ( ds . getCollectionType ( ) != null ) && ( ds . getCollectionType ( ) != CollectionType . NONE ) ) buff . append ( "
Collection type: " ) . append ( StringUtil2 . quoteHtmlContent ( ds . getCollectionType ( ) . toString ( ) ) ) . append ( "
\n" ) ; if ( ds . isHarvest ( ) ) buff . append ( "
Harvest: " ) . append ( ds . isHarvest ( ) ) . append ( "
\n" ) ; if ( ds . getAuthority ( ) != null ) buff . append ( "
Naming Authority: " ) . append ( StringUtil2 . quoteHtmlContent ( ds . getAuthority ( ) ) ) . append ( "
\n" ) ; if ( ds . getID ( ) != null ) buff . append ( "
ID: " ) . append ( StringUtil2 . quoteHtmlContent ( ds . getID ( ) ) ) . append ( "
\n" ) ; if ( ds . getRestrictAccess ( ) != null ) buff . append ( "
RestrictAccess: " ) . append ( StringUtil2 . quoteHtmlContent ( ds . getRestrictAccess ( ) ) ) . append ( "
\n" ) ; if ( ds instanceof InvCatalogRef ) { InvCatalogRef catref = ( InvCatalogRef ) ds ; String href = resolveRelativeUrls || catrefEvents ? resolve ( ds , catref . getXlinkHref ( ) ) : catref . getXlinkHref ( ) ; if ( catrefEvents ) href = "catref:" + href ; buff . append ( "
CatalogRef: " ) . append ( makeHref ( href , null ) ) . append ( "
\n" ) ; } buff . append ( "
\n" ) ; java . util . List < InvDocumentation > docs = ds . getDocumentation ( ) ; if ( docs . size ( ) > 0 ) { buff . append ( "
Documentation:
\n
\n" ) ; for ( InvDocumentation doc : docs ) { String type = ( doc . getType ( ) == null ) ? "" : "" + StringUtil2 . quoteHtmlContent ( doc . getType ( ) ) + ": " ; String inline = doc . getInlineContent ( ) ; if ( ( inline != null ) && ( inline . length ( ) > 0 ) ) buff . append ( "
" ) . append ( type ) . append ( StringUtil2 . quoteHtmlContent ( inline ) ) . append ( "
\n" ) ; if ( doc . hasXlink ( ) ) { // buff . append ( "
 " + type + makeHrefResolve ( ds , url . toString ( ) , doc . getXlinkTitle ( ) ) + "  \ n " ) ;
buff . append ( "
" ) . append ( type ) . append ( makeHref ( doc . getXlinkHref ( ) , doc . getXlinkTitle ( ) ) ) . append ( "
\n" ) ; } } buff . append ( "
\n" ) ; } java . util . List < InvAccess > access = ds . getAccess ( ) ; if ( access . size ( ) > 0 ) { buff . append ( "
Access:
\n
\n" ) ; for ( InvAccess a : access ) { InvService s = a . getService ( ) ; String urlString = resolveRelativeUrls || datasetEvents ? a . getStandardUrlName ( ) : a . getUnresolvedUrlName ( ) ; String fullUrlString = urlString ; if ( datasetEvents ) fullUrlString = "dataset:" + fullUrlString ; if ( isServer ) { ServiceType stype = s . getServiceType ( ) ; if ( ( stype == ServiceType . OPENDAP ) || ( stype == ServiceType . DODS ) ) fullUrlString = fullUrlString + ".html" ; else if ( stype == ServiceType . DAP4 ) fullUrlString = fullUrlString + ".dmr.xml" ; else if ( stype == ServiceType . WCS ) fullUrlString = fullUrlString + "?service=WCS&version=1.0.0&request=GetCapabilities" ; else if ( stype == ServiceType . WMS ) fullUrlString = fullUrlString + "?service=WMS&version=1.3.0&request=GetCapabilities" ; // NGDC update 8/18/2011
else if ( stype == ServiceType . NCML || stype == ServiceType . UDDC || stype == ServiceType . ISO ) { String catalogUrl = ds . getCatalogUrl ( ) ; String datasetId = ds . id ; if ( catalogUrl . indexOf ( '#' ) > 0 ) catalogUrl = catalogUrl . substring ( 0 , catalogUrl . lastIndexOf ( '#' ) ) ; try { catalogUrl = URLEncoder . encode ( catalogUrl , "UTF-8" ) ; datasetId = URLEncoder . encode ( datasetId , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } fullUrlString = fullUrlString + "?catalog=" + catalogUrl + "&dataset=" + datasetId ; } else if ( stype == ServiceType . NetcdfSubset ) fullUrlString = fullUrlString + "/dataset.html" ; else if ( ( stype == ServiceType . CdmRemote ) || ( stype == ServiceType . CdmrFeature ) ) fullUrlString = fullUrlString + "?req=form" ; } buff . append ( "
 " ) . append ( StringUtil2 . quoteHtmlContent ( s . getServiceType ( ) . toString ( ) ) ) ; buff . append ( ": " ) . append ( makeHref ( fullUrlString , urlString ) ) . append ( "
\n" ) ; } buff . append ( "
\n" ) ; } java . util . List < ThreddsMetadata . Contributor > contributors = ds . getContributors ( ) ; if ( contributors . size ( ) > 0 ) { buff . append ( "
Contributors:
\n
\n" ) ; for ( ThreddsMetadata . Contributor t : contributors ) { String role = ( t . getRole ( ) == null ) ? "" : " (" + StringUtil2 . quoteHtmlContent ( t . getRole ( ) ) + ") " ; buff . append ( "
" ) . append ( StringUtil2 . quoteHtmlContent ( t . getName ( ) ) ) . append ( role ) . append ( "
\n" ) ; } buff . append ( "
\n" ) ; } java . util . List < ThreddsMetadata . Vocab > keywords = ds . getKeywords ( ) ; if ( keywords . size ( ) > 0 ) { buff . append ( "
Keywords:
\n
\n" ) ; for ( ThreddsMetadata . Vocab t : keywords ) { String vocab = ( t . getVocabulary ( ) == null ) ? "" : " (" + StringUtil2 . quoteHtmlContent ( t . getVocabulary ( ) ) + ") " ; buff . append ( "
" ) . append ( StringUtil2 . quoteHtmlContent ( t . getText ( ) ) ) . append ( vocab ) . append ( "
\n" ) ; } buff . append ( "
\n" ) ; } java . util . List < DateType > dates = ds . getDates ( ) ; if ( dates . size ( ) > 0 ) { buff . append ( "
Dates:
\n
\n" ) ; for ( DateType d : dates ) { String type = ( d . getType ( ) == null ) ? "" : " (" + StringUtil2 . quoteHtmlContent ( d . getType ( ) ) + ") " ; buff . append ( "
" ) . append ( StringUtil2 . quoteHtmlContent ( d . getText ( ) ) ) . append ( type ) . append ( "
\n" ) ; } buff . append ( "
\n" ) ; } java . util . List < ThreddsMetadata . Vocab > projects = ds . getProjects ( ) ; if ( projects . size ( ) > 0 ) { buff . append ( "
Projects:
\n
\n" ) ; for ( ThreddsMetadata . Vocab t : projects ) { String vocab = ( t . getVocabulary ( ) == null ) ? "" : " (" + StringUtil2 . quoteHtmlContent ( t . getVocabulary ( ) ) + ") " ; buff . append ( "
" ) . append ( StringUtil2 . quoteHtmlContent ( t . getText ( ) ) ) . append ( vocab ) . append ( "
\n" ) ; } buff . append ( "
\n" ) ; } java . util . List < ThreddsMetadata . Source > creators = ds . getCreators ( ) ; if ( creators . size ( ) > 0 ) { buff . append ( "
Creators:
\n
\n" ) ; for ( ThreddsMetadata . Source t : creators ) { buff . append ( "
" ) . append ( StringUtil2 . quoteHtmlContent ( t . getName ( ) ) ) . append ( "
\n" ) ; buff . append ( "
email: " ) . append ( StringUtil2 . quoteHtmlContent ( t . getEmail ( ) ) ) . append ( "
\n" ) ; if ( t . getUrl ( ) != null ) { String newUrl = resolveRelativeUrls ? makeHrefResolve ( ds , t . getUrl ( ) , null ) : makeHref ( t . getUrl ( ) , null ) ; buff . append ( "
 " ) . append ( newUrl ) . append ( "
\n" ) ; } buff . append ( "

\n" ) ; } buff . append ( "
\n" ) ; } java . util . List < ThreddsMetadata . Source > publishers = ds . getPublishers ( ) ; if ( publishers . size ( ) > 0 ) { buff . append ( "
Publishers:
\n
\n" ) ; for ( ThreddsMetadata . Source t : publishers ) { buff . append ( "
" ) . append ( StringUtil2 . quoteHtmlContent ( t . getName ( ) ) ) . append ( "
\n" ) ; buff . append ( "
email: " ) . append ( StringUtil2 . quoteHtmlContent ( t . getEmail ( ) ) ) . append ( "\n" ) ; if ( t . getUrl ( ) != null ) { String urlLink = resolveRelativeUrls ? makeHrefResolve ( ds , t . getUrl ( ) , null ) : makeHref ( t . getUrl ( ) , null ) ; buff . append ( "
 " ) . append ( urlLink ) . append ( "\n" ) ; } buff . append ( "
\n" ) ; } buff . append ( "
\n" ) ; } /* 4.2:

 Variables :

  Vocabulary  [ DIF ] :

  Reflectivity  =   = EARTH SCIENCE & gt ; Spectral / Engineering & gt ; Radar & gt ; Radar Reflectivity ( db )

  Velocity  =   = EARTH SCIENCE & gt ; Spectral / Engineering & gt ; Radar & gt ; Doppler Velocity ( m / s )

  SpectrumWidth  =   = EARTH SCIENCE & gt ; Spectral / Engineering & gt ; Radar & gt ; Doppler Spectrum Width ( m / s )

 4.3:

 Variables :

  Vocabulary  [ CF - 1.0 ] :

  d3d ( meters )  =  3D Depth at Nodes

  = depth _ at _ nodes

  depth ( meters )  =  Bathymetry  = depth

  eta ( m )  =   =

  temp ( Celsius )  =  Temperature

  = sea _ water _ temperature

  u ( m / s )  =  Eastward Water

 Velocity

  = eastward _ sea _ water _ velocity

  v ( m / s )  =  Northward Water

 Velocity

  = northward _ sea _ water _ velocity

 */
java . util . List < ThreddsMetadata . Variables > vars = ds . getVariables ( ) ; if ( vars . size ( ) > 0 ) { buff . append ( "
Variables:
\n
\n" ) ; for ( ThreddsMetadata . Variables t : vars ) { buff . append ( "
Vocabulary [" ) ; if ( t . getVocabUri ( ) != null ) { URI uri = t . getVocabUri ( ) ; String vocabLink = resolveRelativeUrls ? makeHrefResolve ( ds , uri . toString ( ) , t . getVocabulary ( ) ) : makeHref ( uri . toString ( ) , t . getVocabulary ( ) ) ; buff . append ( vocabLink ) ; } else { buff . append ( StringUtil2 . quoteHtmlContent ( t . getVocabulary ( ) ) ) ; } buff . append ( "]:\n
\n" ) ; java . util . List < ThreddsMetadata . Variable > vlist = t . getVariableList ( ) ; if ( vlist . size ( ) > 0 ) { for ( ThreddsMetadata . Variable v : vlist ) { String units = ( v . getUnits ( ) == null || v . getUnits ( ) . length ( ) == 0 ) ? "" : " (" + v . getUnits ( ) + ") " ; buff . append ( "
" ) . append ( StringUtil2 . quoteHtmlContent ( v . getName ( ) + units ) ) . append ( " = " ) ; String desc = ( v . getDescription ( ) == null ) ? "" : " " + StringUtil2 . quoteHtmlContent ( v . getDescription ( ) ) + " = " ; buff . append ( desc ) ; if ( v . getVocabularyName ( ) != null ) buff . append ( StringUtil2 . quoteHtmlContent ( v . getVocabularyName ( ) ) ) ; buff . append ( "\n" ) ; } } buff . append ( "
\n" ) ; } buff . append ( "
\n" ) ; } if ( ds . getVariableMapLink ( ) != null ) { buff . append ( "
Variables:
\n" ) ; buff . append ( "

" + makeHref ( ds . getVariableMapLink ( ) , "VariableMap" ) + "

\n" ) ; } ThreddsMetadata . GeospatialCoverage gc = ds . getGeospatialCoverage ( ) ; if ( ( gc != null ) && ! gc . isEmpty ( ) ) { buff . append ( "
GeospatialCoverage:
\n
\n" ) ; if ( gc . isGlobal ( ) ) buff . append ( "
 Global \n" ) ; buff . append ( "
 Longitude:  " ) . append ( rangeString ( gc . getEastWestRange ( ) ) ) . append ( "
\n" ) ; buff . append ( "
 Latitude:  " ) . append ( rangeString ( gc . getNorthSouthRange ( ) ) ) . append ( "
\n" ) ; if ( gc . getUpDownRange ( ) != null ) { buff . append ( "
 Altitude:  " ) . append ( rangeString ( gc . getUpDownRange ( ) ) ) . append ( " (positive is " ) . append ( StringUtil2 . quoteHtmlContent ( gc . getZPositive ( ) ) ) . append ( ")
\n" ) ; } java . util . List < ThreddsMetadata . Vocab > nlist = gc . getNames ( ) ; if ( ( nlist != null ) && ( nlist . size ( ) > 0 ) ) { buff . append ( "
  Names:
\n" ) ; for ( ThreddsMetadata . Vocab elem : nlist ) { buff . append ( "
" ) . append ( StringUtil2 . quoteHtmlContent ( elem . getText ( ) ) ) . append ( "\n" ) ; } buff . append ( "
\n" ) ; } buff . append ( "
\n" ) ; } CalendarDateRange tc = ds . getCalendarDateCoverage ( ) ; if ( tc != null ) { buff . append ( "
TimeCoverage:
\n
\n" ) ; CalendarDate start = tc . getStart ( ) ; if ( start != null ) buff . append ( "
  Start:  " ) . append ( start . toString ( ) ) . append ( "\n" ) ; CalendarDate end = tc . getEnd ( ) ; if ( end != null ) { buff . append ( "
  End:  " ) . append ( end . toString ( ) ) . append ( "\n" ) ; } CalendarDuration duration = tc . getDuration ( ) ; if ( duration != null ) buff . append ( "
  Duration:  " ) . append ( StringUtil2 . quoteHtmlContent ( duration . toString ( ) ) ) . append ( "\n" ) ; CalendarDuration resolution = tc . getResolution ( ) ; if ( resolution != null ) { buff . append ( "
  Resolution:  " ) . append ( StringUtil2 . quoteHtmlContent ( resolution . toString ( ) ) ) . append ( "\n" ) ; } buff . append ( "
\n" ) ; } java . util . List < InvMetadata > metadata = ds . getMetadata ( ) ; boolean gotSomeMetadata = false ; for ( InvMetadata m : metadata ) { if ( m . hasXlink ( ) ) gotSomeMetadata = true ; } if ( gotSomeMetadata ) { buff . append ( "
Metadata:
\n
\n" ) ; for ( InvMetadata m : metadata ) { String type = ( m . getMetadataType ( ) == null ) ? "" : m . getMetadataType ( ) ; if ( m . hasXlink ( ) ) { String title = ( m . getXlinkTitle ( ) == null ) ? "Type " + type : m . getXlinkTitle ( ) ; String mdLink = resolveRelativeUrls ? makeHrefResolve ( ds , m . getXlinkHref ( ) , title ) : makeHref ( m . getXlinkHref ( ) , title ) ; buff . append ( "
 " ) . append ( mdLink ) . append ( "\n" ) ; } // else {
// buff . append ( "

 " + m . getMetadataType ( ) + " " + m . getContentObject ( ) + "
 \ n " ) ;
} buff . append ( "
\n" ) ; } java . util . List < InvProperty > propsOrg = ds . getProperties ( ) ; java . util . List < InvProperty > props = new ArrayList < > ( ds . getProperties ( ) . size ( ) ) ; for ( InvProperty p : propsOrg ) { if ( ! p . getName ( ) . startsWith ( "viewer" ) ) // eliminate the viewer properties from the html view
props . add ( p ) ; } if ( props . size ( ) > 0 ) { buff . append ( "
Properties:
\n
\n" ) ; for ( InvProperty p : props ) { if ( p . getName ( ) . equals ( "attachments" ) ) // LOOK whats this ?
{ String attachLink = resolveRelativeUrls ? makeHrefResolve ( ds , p . getValue ( ) , p . getName ( ) ) : makeHref ( p . getValue ( ) , p . getName ( ) ) ; buff . append ( "
" ) . append ( attachLink ) . append ( "\n" ) ; } else { buff . append ( "
" ) . append ( StringUtil2 . quoteHtmlContent ( p . getName ( ) + " = \"" + p . getValue ( ) ) ) . append ( "\"\n" ) ; } } buff . append ( "
\n" ) ; } if ( complete ) buff . append ( "" ) ;


signature:
public class InvDatasetImpl { /** * resolve reletive URLS against the catalog URL .
 * @ param ds use ds parent catalog , if it exists
 * @ param href URL to resolve
 * @ return resolved URL */
static public String resolve ( InvDataset ds , String href ) { } }

implementation: InvCatalog cat = ds . getParentCatalog ( ) ; if ( cat != null ) { try { java . net . URI uri = cat . resolveUri ( href ) ; href = uri . toString ( ) ; } catch ( java . net . URISyntaxException e ) { logger . warn ( "InvDatasetImpl.writeHtml: error parsing URL= " + href ) ; } } return href ;


signature:
public class DatasetNamer { /** * Validate this DatasetNamer object . Return true if valid , false if invalid .
 * @ param out StringBuffer with validation messages .
 * @ return boolean true if valid , false if invalid */
boolean validate ( StringBuilder out ) { } }

implementation:
this . isValid = true ; // If log from construction has content , append to validation output msg .
if ( this . msgLog . length ( ) > 0 ) { out . append ( this . msgLog ) ; } // Check that name is not null ( it can be an empty string ) .
if ( this . getName ( ) == null ) { this . isValid = false ; out . append ( " ** DatasetNamer (1): null value for name is not valid." ) ; } // Check that addLevel is not null .
// boolean can ' t be null
// if ( this . getAddLevel ( ) = = null )
// this . isValid = false ;
// out . append ( " * * DatasetNamer ( 2 ) : null value for addLevel is not valid . " ) ;
// Check that type is not null .
if ( this . getType ( ) == null ) { this . isValid = false ; out . append ( " ** DatasetNamer (3): null value for type is not valid (set with bad string?)." ) ; } if ( this . getType ( ) == DatasetNamerType . REGULAR_EXPRESSION && ( this . getMatchPattern ( ) == null || this . getSubstitutePattern ( ) == null ) ) { this . isValid = false ; out . append ( " ** DatasetNamer (4): invalid datasetNamer <" + this . getName ( ) + ">;" + " type is " + this . getType ( ) . toString ( ) + ": matchPattern(" + this . getMatchPattern ( ) + ") and substitutionPattern(" + this . getSubstitutePattern ( ) + ") " + "must not be null." ) ; } if ( this . getType ( ) == DatasetNamerType . DODS_ATTRIBUTE && ( this . getAttribContainer ( ) == null || this . getAttribName ( ) == null ) ) { this . isValid = false ; out . append ( " ** DatasetNamer (5): invalid datasetNamer <" + this . getName ( ) + ">;" + " type is " + this . getType ( ) . toString ( ) + ": attriuteContainer(" + this . getAttribContainer ( ) + ") and attributeName(" + this . getAttribName ( ) + ") must not be null." ) ; } return ( this . isValid ) ;


signature:
public class DatasetNamer { /** * Try to name the given dataset . */
public boolean nameDataset ( InvDatasetImpl dataset ) { } }

implementation:
if ( this . type == DatasetNamerType . REGULAR_EXPRESSION ) { return ( this . nameDatasetRegExp ( dataset ) ) ; } /* else if ( this . type = = DatasetNamerType . DODS _ ATTRIBUTE ) {
 return ( this . nameDatasetDodsAttrib ( dataset ) ) ; */
else { String tmpMsg = "This DatasetNamer <" + this . getName ( ) + "> has unsupported type <" + this . type . toString ( ) + ">." ; logger . error ( "nameDataset(): " + tmpMsg ) ; throw new IllegalStateException ( tmpMsg ) ; }


signature:
public class DatasetNamer { /** * Try to name the given dataset . */
public boolean nameDatasetList ( java . util . List datasetList ) throws java . lang . Exception { } }

implementation: boolean returnValue = false ; InvDatasetImpl curDataset = null ; for ( int i = 0 ; i < datasetList . size ( ) ; i ++ ) { curDataset = ( InvDatasetImpl ) datasetList . get ( i ) ; returnValue &= this . nameDataset ( curDataset ) ; } return ( returnValue ) ;


signature:
public class BufrDataDescriptionSection { /** * get list of data descriptors as Strings
 * @ return descriptors as List < String > */
public final List < String > getDescriptors ( ) { } }

implementation: List < String > desc = new ArrayList < String > ( ) ; for ( short fxy : descriptors ) desc . add ( Descriptor . makeString ( fxy ) ) ; return desc ;


signature:
public class Utm_To_Gdc_Converter { /** * initialize
 * @ param a major axis
 * @ param f inverse flattening
 * @ param zone UTM zone
 * @ param hemisphere _ north is in northern hemisphere */
private void init ( double a , double f , int zone , boolean hemisphere_north ) { } }


signature:
public class ServletLogParser { /** * Difficult thing is to return the extra line assocated with the previous good log
 * We do this by not returning until we get a match on the next log . We have to rewind . */
public LogReader . Log nextLog ( BufferedReader dataIS ) throws IOException { } }

implementation:
ServletLog log = new ServletLog ( ) ; boolean haveLog = false ; while ( true ) { dataIS . mark ( 20 * 1000 ) ; // track where we are
String line = dataIS . readLine ( ) ; if ( line == null ) { return haveLog ? log : null ; } // if ( count + + < limit ) System . out . println ( " \ n " + line ) ; nTest reqe
try { Matcher m = commonPattern . matcher ( line ) ; if ( m . matches ( ) ) { if ( haveLog ) { // have a log , next one matches , proceed
try { dataIS . reset ( ) ; return log ; } catch ( Throwable t ) { System . out . println ( "Cant reset " + line ) ; } } haveLog = true ; // next match will return the current log
log . date = convertDate ( m . group ( 1 ) ) ; log . reqTime = parseLong ( m . group ( 2 ) ) ; log . reqSeq = parseLong ( m . group ( 3 ) ) ; log . level = m . group ( 4 ) . intern ( ) ; log . where = m . group ( 5 ) ; String rest = m . group ( 6 ) ; if ( rest . contains ( "Request Completed" ) ) { int pos = rest . indexOf ( "Request Completed" ) ; Matcher m2 = donePattern . matcher ( rest . substring ( pos ) ) ; if ( m2 . matches ( ) ) { log . returnCode = parse ( m2 . group ( 1 ) ) ; log . sizeBytes = parseLong ( m2 . group ( 2 ) ) ; log . msecs = parseLong ( m2 . group ( 3 ) ) ; log . isDone = true ; } else { System . out . println ( "Cant parse donePattern= " + rest ) ; System . out . println ( " line= " + line ) ; log . addExtra ( rest ) ; } } else if ( rest . contains ( "Remote host" ) ) { int pos = rest . indexOf ( "Remote host" ) ; Matcher m2 = startPattern . matcher ( rest . substring ( pos ) ) ; if ( m2 . matches ( ) ) { log . ip = m2 . group ( 1 ) ; log . verb = m2 . group ( 2 ) . intern ( ) ; log . path = EscapeStrings . urlDecode ( m2 . group ( 3 ) ) ; // old URLDecoder . decode ( m2 . group ( 3 ) ) ;
if ( m2 . groupCount ( ) > 4 ) log . http = m2 . group ( 4 ) . intern ( ) ; log . isStart = true ; } else { System . out . println ( "Cant parse startPattern= " + rest ) ; System . out . println ( " line= " + line ) ; log . addExtra ( rest ) ; } } else { // a non - start , non - done log
log . addExtra ( rest ) ; } } else { // the true extra line
// System . out . println ( " No match on " + line ) ;
log . addExtra ( line ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; System . out . println ( "Cant parse " + line ) ; log . addExtra ( line ) ; } }


signature:
public class WFSController { /** * Constructs the full server URI from a request
 * @ param hsreq The relevant request
 * @ return The URI of the server corresponding to the request */
public static String constructServerPath ( HttpServletRequest hsreq ) { } }

implementation: return hsreq . getScheme ( ) + "://" + hsreq . getServerName ( ) + ":" + hsreq . getServerPort ( ) + "/thredds/wfs/" ;


signature:
public class WFSController { /** * Processes GetCapabilities requests .
 * @ param out
 * @ return */
private void getCapabilities ( PrintWriter out , HttpServletRequest hsreq , SimpleGeometryCSBuilder sgcs ) { } }

implementation: WFSGetCapabilitiesWriter gcdw = new WFSGetCapabilitiesWriter ( out , WFSController . constructServerPath ( hsreq ) ) ; gcdw . startXML ( ) ; gcdw . addOperation ( WFSRequestType . GetCapabilities ) ; gcdw . addOperation ( WFSRequestType . DescribeFeatureType ) ; gcdw . addOperation ( WFSRequestType . GetFeature ) ; gcdw . writeOperations ( ) ; List < String > seriesNames = sgcs . getGeometrySeriesNames ( ) ; for ( String name : seriesNames ) { gcdw . addFeature ( new WFSFeature ( TDSNAMESPACE + ":" + name , name ) ) ; } gcdw . writeFeatureTypes ( ) ; gcdw . finishXML ( ) ;


signature:
public class WFSController { /** * Processes GetFeature requests .
 * @ param out
 * @ return */
private WFSExceptionWriter getFeature ( PrintWriter out , HttpServletRequest hsreq , SimpleGeometryCSBuilder sgcs , String ftName , String fullFtName ) { } }

implementation:
List < SimpleGeometry > geometryList = new ArrayList < SimpleGeometry > ( ) ; GeometryType geoT = sgcs . getGeometryType ( ftName ) ; if ( geoT == null ) { return new WFSExceptionWriter ( "Feature Type of " + fullFtName + " not found." , "GetFeature" , "OperationProcessingFailed" ) ; } try { switch ( geoT ) { case POINT : Point pt = sgcs . getPoint ( ftName , 0 ) ; int j = 0 ; while ( pt != null ) { geometryList . add ( pt ) ; j ++ ; pt = sgcs . getPoint ( ftName , j ) ; } break ; case LINE : Line line = sgcs . getLine ( ftName , 0 ) ; int k = 0 ; while ( line != null ) { geometryList . add ( line ) ; k ++ ; line = sgcs . getLine ( ftName , k ) ; } break ; case POLYGON : Polygon poly = sgcs . getPolygon ( ftName , 0 ) ; int i = 0 ; while ( poly != null ) { geometryList . add ( poly ) ; i ++ ; poly = sgcs . getPolygon ( ftName , i ) ; } break ; } } // Perhaps will change this to be implemented in the CFPolygon class
catch ( ArrayIndexOutOfBoundsException aout ) { } WFSGetFeatureWriter gfdw = new WFSGetFeatureWriter ( out , WFSController . constructServerPath ( hsreq ) , WFSController . getXMLNamespaceXMLNSValue ( hsreq ) , geometryList , ftName ) ; gfdw . startXML ( ) ; gfdw . writeMembers ( ) ; gfdw . finishXML ( ) ; return null ;


signature:
public class WFSController { /** * Checks request parameters for errors .
 * Will send back an XML Exception if any errors are encountered .
 * @ param request parameter value
 * @ param version parameter value
 * @ param service parameter value
 * @ param actualFTName parameter value
 * @ return an ExceptionWriter if any errors occurred or null if none occurred */
private WFSExceptionWriter checkParametersForError ( String request , String version , String service , String typeName ) { } }

implementation:
// The SERVICE parameter is required . If not specified , is an error ( throw exception through XML ) .
if ( service != null ) { // For the WFS servlet it must be WFS if not , write out an InvalidParameterValue exception .
if ( ! service . equalsIgnoreCase ( "WFS" ) ) { return new WFSExceptionWriter ( "WFS Server error. SERVICE parameter must be of value WFS." , "service" , "InvalidParameterValue" ) ; } } else { return new WFSExceptionWriter ( "WFS server error. SERVICE parameter is required." , "request" , "MissingParameterValue" ) ; } // The REQUEST Parameter is required . If not specified , is an error ( throw exception through XML ) .
if ( request != null ) { // Only go through version checks if NOT a Get Capabilities request , the VERSION parameter is required for all operations EXCEPT GetCapabilities section 7.6.25 of WFS 2.0 Interface Standard
if ( ! request . equalsIgnoreCase ( WFSRequestType . GetCapabilities . toString ( ) ) ) { if ( version != null ) { // If the version is not failed report exception VersionNegotiationFailed , from OGC Web Services Common Standard section 7.4.1
// Get each part
String [ ] versionParts = version . split ( "\\." ) ; for ( int ind = 0 ; ind < versionParts . length ; ind ++ ) { // Check if number will throw NumberFormatException if not .
try { Integer . valueOf ( versionParts [ ind ] ) ; } /* Version parameters are only allowed to consist of numbers and periods . If this is not the case then
 * It qualifies for InvalidParameterException */
catch ( NumberFormatException excep ) { return new WFSExceptionWriter ( "WFS server error. VERSION parameter consists of invalid characters." , "version" , "InvalidParameterValue" ) ; } } /* Now the version parts are all constructed from the parameter
 * Analyze for correctness . */
boolean validVersion = false ; // If just number 2 is specified , assume 2.0.0 , pass the check
if ( versionParts . length == 1 ) if ( versionParts [ 0 ] . equals ( "2" ) ) validVersion = true ; // Two or more version parts specified , make sure it ' s 2.0 . # . # . . .
if ( versionParts . length >= 2 ) if ( versionParts [ 0 ] . equals ( "2" ) && versionParts [ 1 ] . equals ( "0" ) ) validVersion = true ; /* Another exception VersionNegotiationFailed is specified by OGC Web Services Common
 * for version mismatches . If the version check failed print this exception */
if ( ! validVersion ) { return new WFSExceptionWriter ( "WFS Server error. Version requested is not supported." , null , "VersionNegotiationFailed" ) ; } } else { return new WFSExceptionWriter ( "WFS server error. VERSION parameter is required." , "request" , "MissingParameterValue" ) ; } // Last check to see if typenames is specified , must be for GetFeature , DescribeFeatureType
if ( typeName == null ) { return new WFSExceptionWriter ( "WFS server error. For the specifed request, parameter typename or typenames must be specified." , request , "MissingParameterValue" ) ; } } WFSRequestType reqToProc = WFSRequestType . getWFSRequestType ( request ) ; if ( reqToProc == null ) return new WFSExceptionWriter ( "WFS server error. REQUEST parameter is not valid. Possible values: GetCapabilities, " + "DescribeFeatureType, GetFeature" , "request" , "InvalidParameterValue" ) ; } else { return new WFSExceptionWriter ( "WFS server error. REQUEST parameter is required." , "request" , "MissingParameterValue" ) ; } return null ;


signature:
public class WFSController { /** * A handler for WFS based HTTP requests that sends to other request handlers
 * to handle the request .
 * Servlet Path : / wfs / { request } */
@ RequestMapping ( "**" ) public void httpHandler ( HttpServletRequest hsreq , HttpServletResponse hsres ) { } }

implementation:
try { PrintWriter wr = hsres . getWriter ( ) ; List < String > paramNames = new LinkedList < String > ( ) ; Enumeration < String > paramNamesE = hsreq . getParameterNames ( ) ; while ( paramNamesE . hasMoreElements ( ) ) paramNames . add ( paramNamesE . nextElement ( ) ) ; // Prepare parameters
String request = null ; String version = null ; String service = null ; String typeNames = null ; String datasetReqPath = null ; String actualPath = null ; String actualFTName = null ; NetcdfDataset dataset = null ; if ( hsreq . getServletPath ( ) . length ( ) > 4 ) { datasetReqPath = hsreq . getServletPath ( ) . substring ( 4 , hsreq . getServletPath ( ) . length ( ) ) ; } actualPath = TdsRequestedDataset . getLocationFromRequestPath ( datasetReqPath ) ; if ( actualPath != null ) dataset = NetcdfDataset . openDataset ( actualPath ) ; else return ; List < CoordinateSystem > csList = dataset . getCoordinateSystems ( ) ; SimpleGeometryCSBuilder cs = new SimpleGeometryCSBuilder ( dataset , csList . get ( 0 ) , null ) ; /* Look for parameter names to assign values
 * in order to avoid casing issues with parameter names ( such as a mismatch between reQUEST and request and REQUEST ) . */
for ( String paramName : paramNames ) { if ( paramName . equalsIgnoreCase ( "REQUEST" ) ) { request = hsreq . getParameter ( paramName ) ; } if ( paramName . equalsIgnoreCase ( "VERSION" ) ) { version = hsreq . getParameter ( paramName ) ; } if ( paramName . equalsIgnoreCase ( "SERVICE" ) ) { service = hsreq . getParameter ( paramName ) ; } if ( paramName . equalsIgnoreCase ( "TYPENAMES" ) || paramName . equalsIgnoreCase ( "TYPENAME" ) ) { typeNames = hsreq . getParameter ( paramName ) ; // Remove namespace header for getFeature
if ( typeNames != null ) if ( typeNames . length ( ) > TDSNAMESPACE . length ( ) ) { actualFTName = typeNames . substring ( TDSNAMESPACE . length ( ) + 1 , typeNames . length ( ) ) ; } } } WFSExceptionWriter paramError = checkParametersForError ( request , version , service , typeNames ) ; WFSExceptionWriter requestProcessingError = null ; // If parameter checks all pass launch the request
if ( paramError == null ) { WFSRequestType reqToProc = WFSRequestType . getWFSRequestType ( request ) ; switch ( reqToProc ) { case GetCapabilities : getCapabilities ( wr , hsreq , cs ) ; break ; case DescribeFeatureType : describeFeatureType ( wr , hsreq , actualFTName ) ; break ; case GetFeature : requestProcessingError = getFeature ( wr , hsreq , cs , actualFTName , typeNames ) ; break ; } } // Parameter checks did not all pass , print the error and return
else { paramError . write ( hsres ) ; return ; } /* Specifically writes out exceptions that were incurred
 * while processing requests . */
if ( requestProcessingError != null ) { requestProcessingError . write ( hsres ) ; return ; } } catch ( IOException io ) { throw new RuntimeException ( "The writer may not have been able to been have retrieved" + " or the requested dataset was not found" , io ) ; }


signature:
public class HttpDSP { /** * A path is a DAP4 path if at least one of the following is true .
 * 1 . it has " dap4 : " as its leading protocol
 * 2 . it has # protocol = dap4 in its fragment
 * @ param url
 * @ param context Any parameters that may help to decide .
 * @ return true if this url appears to be processible by this DSP */
public boolean dspMatch ( String url , DapContext context ) { } }

implementation:
try { XURI xuri = new XURI ( url ) ; if ( true ) { boolean found = false ; for ( String scheme : DAP4SCHEMES ) { if ( scheme . equalsIgnoreCase ( xuri . getBaseProtocol ( ) ) || scheme . equalsIgnoreCase ( xuri . getFormatProtocol ( ) ) ) { found = true ; break ; } } if ( ! found ) return false ; // Might still be a non - dap4 url
String formatproto = xuri . getFormatProtocol ( ) ; if ( DAP4PROTO . equalsIgnoreCase ( formatproto ) ) return true ; for ( String [ ] pair : DAP4QUERYMARKERS ) { String tag = xuri . getQueryFields ( ) . get ( pair [ 0 ] ) ; if ( tag != null && ( pair [ 1 ] == null || pair [ 1 ] . equalsIgnoreCase ( tag ) ) ) return true ; } for ( String [ ] pair : DAP4FRAGMARKERS ) { String tag = xuri . getFragFields ( ) . get ( pair [ 0 ] ) ; if ( tag != null && ( pair [ 1 ] == null || pair [ 1 ] . equalsIgnoreCase ( tag ) ) ) return true ; } } else return true ; } catch ( URISyntaxException use ) { return false ; } return false ;


signature:
public class HttpDSP { /** * Open a connection and make a request for the ( possibly constrained ) DMR .
 * @ throws DapException */
protected void build ( ) throws DapException { } }

implementation:
String methodurl = buildURL ( this . xuri . assemble ( XURI . URLONLY ) , DATASUFFIX , this . dmr , this . basece ) ; InputStream stream ; // Make the request and return an input stream for accessing the databuffer
// Should fill in bigendian and stream fields
stream = callServer ( methodurl ) ; try { ChunkInputStream reader ; if ( DEBUG ) { byte [ ] raw = DapUtil . readbinaryfile ( stream ) ; ByteArrayInputStream bis = new ByteArrayInputStream ( raw ) ; DapDump . dumpbytestream ( raw , getOrder ( ) , "httpdsp.build" ) ; reader = new ChunkInputStream ( bis , RequestMode . DAP , getOrder ( ) ) ; } else { // Wrap the input stream as a ChunkInputStream
reader = new ChunkInputStream ( stream , RequestMode . DAP , getOrder ( ) ) ; } // Extract and " compile " the server response
String document = reader . readDMR ( ) ; // Extract all the remaining bytes
byte [ ] bytes = DapUtil . readbinaryfile ( reader ) ; // use super . build to compile
super . build ( document , bytes , getOrder ( ) ) ; } catch ( Throwable t ) { t . printStackTrace ( ) ; throw new DapException ( t ) ; } finally { try { stream . close ( ) ; } catch ( IOException ioe ) { /* ignore */
} }


signature:
public class HttpDSP { /** * Provide a method for getting the capabilities document .
 * @ param url for accessing the document
 * @ throws DapException */
public String getCapabilities ( String url ) throws IOException { } }

implementation:
// Save the original url
String saveurl = this . xuri . getOriginal ( ) ; parseURL ( url ) ; String fdsurl = buildURL ( this . xuri . assemble ( XURI . URLALL ) , DSRSUFFIX , null , null ) ; try { // Make the request and return an input stream for accessing the databuffer
// Should fill in context bigendian and stream fields
InputStream stream = callServer ( fdsurl ) ; // read the result , convert to string and return .
byte [ ] bytes = DapUtil . readbinaryfile ( stream ) ; String document = new String ( bytes , DapUtil . UTF8 ) ; return document ; } finally { parseURL ( saveurl ) ; }


signature:
public class HttpDSP { /** * Utilities */
static protected String buildURL ( String baseurl , String suffix , DapDataset template , String ce ) { } }

implementation: StringBuilder methodurl = new StringBuilder ( ) ; methodurl . append ( baseurl ) ; if ( suffix != null ) { methodurl . append ( '.' ) ; methodurl . append ( suffix ) ; } if ( ce != null && ce . length ( ) > 0 ) { methodurl . append ( QUERYSTART ) ; methodurl . append ( CONSTRAINTTAG ) ; methodurl . append ( '=' ) ; methodurl . append ( ce ) ; } return methodurl . toString ( ) ;


signature:
public class CrawlableDatasetAmazonS3 { /** * / / / / / CrawlableDatasetFile / / / / / */
@ Override public File getFile ( ) { } }

implementation: try { return threddsS3Client . saveObjectToFile ( s3uri , s3uri . getTempFile ( ) ) ; } catch ( IOException e ) { logger . error ( String . format ( "Could not save S3 object '%s' to file." , s3uri ) , e ) ; return null ; }


signature:
public class CrawlableDatasetAmazonS3 { /** * Returns the size of the dataset , in bytes . Will be zero if this dataset is a collection or non - existent .
 * @ return the size of the dataset */
@ Override public long length ( ) { } }

implementation:
// If the summary is already in the cache , return it .
// It ' ll have been added by a listDatasets ( ) call on the parent directory .
S3ObjectSummary objectSummary = objectSummaryCache . getIfPresent ( s3uri ) ; if ( objectSummary != null ) { return objectSummary . getSize ( ) ; } /* Get the metadata directly from S3 . This will be expensive .
 * We get punished hard if length ( ) and / or lastModified ( ) is called on a bunch of datasets without
 * listDatasets ( ) first being called on their parent directory .
 * So , is the right thing to do here " getParentDataset ( ) . listDatasets ( ) " and then query the cache again ?
 * Perhaps , but listDatasets ( ) throws an IOException , and length ( ) and lastModified ( ) do not .
 * We would have to change their signatures and the upstream client code to make it work . */
ObjectMetadata metadata = threddsS3Client . getObjectMetadata ( s3uri ) ; if ( metadata != null ) { return metadata . getContentLength ( ) ; } else { // " this " may be a collection or non - existent . In both cases , we return 0.
return 0 ; }


signature:
public class CrawlableDatasetAmazonS3 { /** * Returns the date that the dataset was last modified . Will be null if the dataset is a collection or non - existent .
 * @ return the date that the dataset was last modified */
@ Override public Date lastModified ( ) { } }

implementation:
S3ObjectSummary objectSummary = objectSummaryCache . getIfPresent ( s3uri ) ; if ( objectSummary != null ) { return objectSummary . getLastModified ( ) ; } ObjectMetadata metadata = threddsS3Client . getObjectMetadata ( s3uri ) ; if ( metadata != null ) { return metadata . getLastModified ( ) ; } else { // " this " may be a collection or non - existent . In both cases , we return null .
return null ; }


signature:
public class AbstractNcssController { /** * Exception handlers */
@ ExceptionHandler ( NcssException . class ) public ResponseEntity < String > handle ( NcssException e ) { } }

implementation: HttpHeaders responseHeaders = new HttpHeaders ( ) ; responseHeaders . setContentType ( MediaType . TEXT_PLAIN ) ; return new ResponseEntity < > ( e . getMessage ( ) , responseHeaders , HttpStatus . BAD_REQUEST ) ;


signature:
public class AbstractNcssController { /** * unit testing */
public static String getDatasetPath ( String path ) { } }

implementation:
if ( path . startsWith ( StandardService . netcdfSubsetGrid . getBase ( ) ) ) { // strip off / ncss / grid /
path = path . substring ( StandardService . netcdfSubsetGrid . getBase ( ) . length ( ) ) ; } else if ( path . startsWith ( StandardService . netcdfSubsetPoint . getBase ( ) ) ) { // strip off / ncss / point /
path = path . substring ( StandardService . netcdfSubsetPoint . getBase ( ) . length ( ) ) ; } // strip off endings
for ( String ending : endings ) { if ( path . endsWith ( ending ) ) { int len = path . length ( ) - ending . length ( ) ; path = path . substring ( 0 , len ) ; break ; } } return path ;


signature:
public class Generator { /** * Generator */
public void generate ( CEConstraint ce , ChunkWriter cw , boolean withdmr , ChecksumMode mode ) throws DapException { } }

implementation: begin ( ce , cw , withdmr , mode ) ; if ( this . withdmr ) generateDMR ( this . dmr ) ; dataset ( this . dmr ) ; end ( ) ;


signature:
public class Generator { /** * Node specific generators */
public void dataset ( DapDataset dmr ) throws DapException { } }

implementation:
// Iterate over the variables in order
for ( DapVariable var : this . dmr . getTopVariables ( ) ) { if ( ! this . ce . references ( var ) ) continue ; variable ( var ) ; }


signature:
public class CFPoint { /** * Given a dataset , variable , and index , automatically populates this Point and
 * returns it . If not found , returns null .
 * @ param dataset which the variable is a part of
 * @ param vari the variable which has a geometry attribute
 * @ param index of the point within the variable
 * @ return return a point */
public Point setupPoint ( NetcdfDataset set , Variable vari , int index ) { } }

implementation:
// Points are much simpler , node _ count is used multigeometries so it ' s a bit different
// No need for the index finder here , unless there is a multipoint
Array xPts = null ; Array yPts = null ; Integer ind = ( int ) index ; Variable nodeCounts = null ; boolean multi = false ; SimpleGeometryIndexFinder indexFinder = null ; List < CoordinateAxis > axes = set . getCoordinateAxes ( ) ; CoordinateAxis x = null ; CoordinateAxis y = null ; String [ ] nodeCoords = vari . findAttributeIgnoreCase ( CF . NODE_COORDINATES ) . getStringValue ( ) . split ( " " ) ; // Look for x and y
for ( CoordinateAxis ax : axes ) { if ( ax . getFullName ( ) . equals ( nodeCoords [ 0 ] ) ) x = ax ; if ( ax . getFullName ( ) . equals ( nodeCoords [ 1 ] ) ) y = ax ; } // Node count is used very differently in points
// Similar use to part _ node _ count in other geometries
String node_c_str = vari . findAttValueIgnoreCase ( CF . NODE_COUNT , "" ) ; if ( ! node_c_str . equals ( "" ) ) { nodeCounts = set . findVariable ( node_c_str ) ; indexFinder = new SimpleGeometryIndexFinder ( nodeCounts ) ; multi = true ; } try { if ( multi ) { xPts = x . read ( indexFinder . getBeginning ( index ) + ":" + indexFinder . getEnd ( index ) ) . reduce ( ) ; yPts = y . read ( indexFinder . getBeginning ( index ) + ":" + indexFinder . getEnd ( index ) ) . reduce ( ) ; } else { xPts = x . read ( ind . toString ( ) ) . reduce ( ) ; yPts = y . read ( ind . toString ( ) ) . reduce ( ) ; this . x = xPts . getDouble ( 0 ) ; this . y = yPts . getDouble ( 0 ) ; } // Set points
if ( ! multi ) { this . x = xPts . getDouble ( 0 ) ; this . y = yPts . getDouble ( 0 ) ; // Set data of each
switch ( vari . getRank ( ) ) { case 2 : this . setData ( vari . read ( CFSimpleGeometryHelper . getSubsetString ( vari , index ) ) . reduce ( ) ) ; break ; case 1 : this . setData ( vari . read ( "" + index ) ) ; break ; default : throw new InvalidDataseriesException ( InvalidDataseriesException . RANK_MISMATCH ) ; // currently do not support anything but dataseries and scalar associations
} } else { IndexIterator itrX = xPts . getIndexIterator ( ) ; IndexIterator itrY = yPts . getIndexIterator ( ) ; this . next = null ; this . prev = null ; Point point = this ; // x and y should have the same shape ( size ) , will add some handling on this
while ( itrX . hasNext ( ) ) { point . setX ( itrX . getDoubleNext ( ) ) ; point . setY ( itrY . getDoubleNext ( ) ) ; // Set data of each
switch ( vari . getRank ( ) ) { case 2 : point . setData ( vari . read ( CFSimpleGeometryHelper . getSubsetString ( vari , index ) ) . reduce ( ) ) ; break ; case 1 : point . setData ( vari . read ( "" + index ) ) ; break ; default : throw new InvalidDataseriesException ( InvalidDataseriesException . RANK_MISMATCH ) ; // currently do not support anything but dataseries and scalar associations
} point . setNext ( new CFPoint ( ) ) ; // -1 is a default value , it gets assigned eventually
point = point . getNext ( ) ; } // Clean up the last point since it will be invalid
point = point . getPrev ( ) ; point . setNext ( null ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; return null ; } catch ( InvalidRangeException e ) { e . printStackTrace ( ) ; return null ; } catch ( InvalidDataseriesException e ) { e . printStackTrace ( ) ; return null ; } return this ;


signature:
public class ServletUtil { /** * Return the file path dealing with leading and trailing path
 * seperators ( which must be a slash ( " / " ) ) for the given directory
 * and file paths .
 * Note : Dealing with path strings is fragile .
 * ToDo : Switch from using path strings to java . io . Files .
 * @ param dirPath the directory path .
 * @ param filePath the file path .
 * @ return a full file path with the given directory and file paths . */
public static String formFilename ( String dirPath , String filePath ) { } }

implementation: if ( ( dirPath == null ) || ( filePath == null ) ) return null ; if ( filePath . startsWith ( "/" ) ) filePath = filePath . substring ( 1 ) ; return dirPath . endsWith ( "/" ) ? dirPath + filePath : dirPath + "/" + filePath ;


signature:
public class ServletUtil { /** * Write a file to the response stream .
 * @ param servlet called from this servlet , may be null
 * @ param contentPath file root path
 * @ param path file path reletive to the root
 * @ param req the request
 * @ param res the response
 * @ param contentType content type , or null
 * @ throws IOException on write error */
public static void returnFile ( HttpServlet servlet , String contentPath , String path , HttpServletRequest req , HttpServletResponse res , String contentType ) throws IOException { } }

implementation:
String filename = ServletUtil . formFilename ( contentPath , path ) ; log . debug ( "returnFile(): returning file <" + filename + ">." ) ; // No file , nothing to view
if ( filename == null ) { res . sendError ( HttpServletResponse . SC_NOT_FOUND ) ; return ; } // dontallow . .
if ( filename . contains ( ".." ) ) { res . sendError ( HttpServletResponse . SC_FORBIDDEN ) ; return ; } // dont allow access to WEB - INF or META - INF
String upper = filename . toUpperCase ( ) ; if ( upper . contains ( "WEB-INF" ) || upper . contains ( "META-INF" ) ) { res . sendError ( HttpServletResponse . SC_FORBIDDEN ) ; return ; } returnFile ( servlet , req , res , new File ( filename ) , contentType ) ;


signature:
public class ServletUtil { /** * Write a file to the response stream . Handles Range requests .
 * @ param servlet called from this servlet , may be null
 * @ param req the request
 * @ param res the response
 * @ param file to serve
 * @ param contentType content type , if null , will try to guess
 * @ throws IOException on write error */
public static void returnFile ( HttpServlet servlet , HttpServletRequest req , HttpServletResponse res , File file , String contentType ) throws IOException { } }

implementation:
// No file , nothing to view
if ( file == null ) { res . sendError ( HttpServletResponse . SC_NOT_FOUND ) ; return ; } // check that it exists
if ( ! file . exists ( ) ) { res . sendError ( HttpServletResponse . SC_NOT_FOUND ) ; return ; } // not a directory
if ( ! file . isFile ( ) ) { res . sendError ( HttpServletResponse . SC_BAD_REQUEST ) ; return ; } // Set the type of the file
String filename = file . getPath ( ) ; if ( null == contentType ) { if ( filename . endsWith ( ".html" ) ) contentType = ContentType . html . getContentHeader ( ) ; else if ( filename . endsWith ( ".xml" ) ) contentType = ContentType . xml . getContentHeader ( ) ; else if ( filename . endsWith ( ".txt" ) || ( filename . endsWith ( ".log" ) ) ) contentType = ContentType . text . getContentHeader ( ) ; else if ( filename . indexOf ( ".log." ) > 0 ) contentType = ContentType . text . getContentHeader ( ) ; else if ( filename . endsWith ( ".nc" ) ) contentType = ContentType . netcdf . getContentHeader ( ) ; else if ( filename . endsWith ( ".nc4" ) ) contentType = ContentType . netcdf . getContentHeader ( ) ; else if ( servlet != null ) contentType = servlet . getServletContext ( ) . getMimeType ( filename ) ; if ( contentType == null ) contentType = ContentType . binary . getContentHeader ( ) ; } returnFile ( req , res , file , contentType ) ;


signature:
public class ServletUtil { /** * Write a file to the response stream . Handles Range requests .
 * @ param req request
 * @ param res response
 * @ param file must exist and not be a directory
 * @ param contentType must not be null
 * @ throws IOException or error */
public static void returnFile ( HttpServletRequest req , HttpServletResponse res , File file , String contentType ) throws IOException { } }

implementation:
res . setContentType ( contentType ) ; res . addDateHeader ( "Last-Modified" , file . lastModified ( ) ) ; // res . setHeader ( " Content - Disposition " , " attachment ; filename = \ " " + file . getName ( ) + " \ " " ) ;
// see if its a Range Request
boolean isRangeRequest = false ; long startPos = 0 , endPos = Long . MAX_VALUE ; String rangeRequest = req . getHeader ( "Range" ) ; if ( rangeRequest != null ) { // bytes = 12-34 or bytes = 12-
int pos = rangeRequest . indexOf ( "=" ) ; if ( pos > 0 ) { int pos2 = rangeRequest . indexOf ( "-" ) ; if ( pos2 > 0 ) { String startString = rangeRequest . substring ( pos + 1 , pos2 ) ; String endString = rangeRequest . substring ( pos2 + 1 ) ; startPos = Long . parseLong ( startString ) ; if ( endString . length ( ) > 0 ) endPos = Long . parseLong ( endString ) + 1 ; isRangeRequest = true ; } } } // set content length
long fileSize = file . length ( ) ; long contentLength = fileSize ; if ( isRangeRequest ) { endPos = Math . min ( endPos , fileSize ) ; contentLength = endPos - startPos ; } // when compression is turned on , ContentLength has to be overridden
// this is also true for HEAD , since this must be the same as GET without the body
if ( contentLength > Integer . MAX_VALUE ) res . addHeader ( "Content-Length" , Long . toString ( contentLength ) ) ; // allow content length > MAX _ INT
else res . setContentLength ( ( int ) contentLength ) ; String filename = file . getPath ( ) ; // indicate we allow Range Requests
res . addHeader ( "Accept-Ranges" , "bytes" ) ; if ( req . getMethod ( ) . equals ( "HEAD" ) ) { return ; } try { if ( isRangeRequest ) { // set before content is sent
res . addHeader ( "Content-Range" , "bytes " + startPos + "-" + ( endPos - 1 ) + "/" + fileSize ) ; res . setStatus ( HttpServletResponse . SC_PARTIAL_CONTENT ) ; try ( RandomAccessFile craf = RandomAccessFile . acquire ( filename ) ) { IO . copyRafB ( craf , startPos , contentLength , res . getOutputStream ( ) , new byte [ 60000 ] ) ; return ; } } // Return the file
ServletOutputStream out = res . getOutputStream ( ) ; IO . copyFileB ( file , out , 60 * 1000 ) ; /* try ( WritableByteChannel cOut = Channels . newChannel ( out ) ) {
 IO . copyFileWithChannels ( file , cOut ) ;
 res . flushBuffer ( ) ; */
} // @ todo Split up this exception handling : those from file access vs those from dealing with response
// File access : catch and res . sendError ( )
// response : don ' t catch ( let bubble up out of doGet ( ) etc )
catch ( FileNotFoundException e ) { log . error ( "returnFile(): FileNotFoundException= " + filename ) ; if ( ! res . isCommitted ( ) ) res . sendError ( HttpServletResponse . SC_NOT_FOUND ) ; } catch ( java . net . SocketException e ) { log . info ( "returnFile(): SocketException sending file: " + filename + " " + e . getMessage ( ) ) ; } catch ( IOException e ) { String eName = e . getClass ( ) . getName ( ) ; // dont want compile time dependency on ClientAbortException
if ( eName . equals ( "org.apache.catalina.connector.ClientAbortException" ) ) { log . debug ( "returnFile(): ClientAbortException while sending file: " + filename + " " + e . getMessage ( ) ) ; return ; } if ( e . getMessage ( ) . startsWith ( "File transfer not complete" ) ) { // coming from FileTransfer . transferTo ( )
log . debug ( "returnFile() " + e . getMessage ( ) ) ; return ; } log . error ( "returnFile(): IOException (" + e . getClass ( ) . getName ( ) + ") sending file " , e ) ; if ( ! res . isCommitted ( ) ) res . sendError ( HttpServletResponse . SC_NOT_FOUND , "Problem sending file: " + e . getMessage ( ) ) ; }


signature:
public class ServletUtil { /** * Send given content string as the HTTP response .
 * @ param contents the string to return as the HTTP response .
 * @ param res the HttpServletResponse
 * @ throws IOException if an I / O error occurs while writing the response . */
public static void returnString ( String contents , HttpServletResponse res ) throws IOException { } }

implementation: try { ServletOutputStream out = res . getOutputStream ( ) ; IO . copy ( new ByteArrayInputStream ( contents . getBytes ( CDM . utf8Charset ) ) , out ) ; } catch ( IOException e ) { log . error ( " IOException sending string: " , e ) ; res . sendError ( HttpServletResponse . SC_NOT_FOUND , "Problem sending string: " + e . getMessage ( ) ) ; }


signature:
public class ServletUtil { /** * Set the proper content length for the string
 * @ param response the HttpServletResponse to act upon
 * @ param s the string that will be returned
 * @ return the number of bytes
 * @ throws UnsupportedEncodingException on bad character encoding */
public static int setResponseContentLength ( HttpServletResponse response , String s ) throws UnsupportedEncodingException { } }

implementation: int length = s . getBytes ( response . getCharacterEncoding ( ) ) . length ; response . setContentLength ( length ) ; return length ;


signature:
public class ServletUtil { /** * Return the request URL relative to the server ( i . e . , starting with the context path ) .
 * @ param req request
 * @ return URL relative to the server */
public static String getReletiveURL ( HttpServletRequest req ) { } }

implementation: return req . getContextPath ( ) + req . getServletPath ( ) + req . getPathInfo ( ) ;