signature:
public class ASTclause { /** * public String toString ( )
 * if ( boolfcn ! = null ) {
 * return " & " + boolfcn . toString ( ) ;
 * } else {
 * StringBuilder buf = new StringBuilder ( " & " ) ;
 * buf . append ( lhs . toString ( ) ) ;
 * buf . append ( operatorString ( operator ) ) ;
 * boolean first = true ;
 * if ( rhs . size ( ) > 1 ) buf . append ( " { " ) ;
 * if ( rhs ! = null )
 * for ( ASTvalue value : rhs ) {
 * buf . append ( ( first ? " " : " , " ) + value . toString ( ) ) ;
 * first = false ;
 * if ( rhs . size ( ) > 1 ) buf . append ( " } " ) ;
 * return buf . toString ( ) ; */
public Clause translate ( ) throws DAP2ServerSideException , DAP2Exception , NoSuchFunctionException , NoSuchVariableException { } }

implementation: Clause clause = null ; if ( boolfcn != null ) clause = boolfcn . translate ( ) ; else { Vector < SubClause > cvtrhs = new Vector < SubClause > ( ) ; for ( ASTvalue v : rhs ) cvtrhs . addElement ( v . translate ( ) ) ; SubClause lhsclause = lhs . translate ( ) ; clause = getClauseFactory ( ) . newRelOpClause ( operator , lhsclause , cvtrhs ) ; } return clause ;


signature:
public class VariablePlot { /** * assume first dimension is TIME series */
public void setVariable ( Variable v ) throws IOException { } }

implementation:
log . info ( "variable " + v . getShortName ( ) ) ; AbstractIntervalXYDataset dataset = null ; Dimension dim = v . getDimension ( 0 ) ; String dimName = dim . getShortName ( ) ; Attribute title = file . findGlobalAttribute ( "title" ) ; if ( title != null ) chart . setTitle ( title . getStringValue ( ) ) ; Variable varXdim = file . findVariable ( null , dimName ) ; boolean hasXdim = false ; if ( varXdim != null ) hasXdim = true ; boolean xIsTime = false ; XYPlot p = chart . getXYPlot ( ) ; if ( hasXdim ) { Attribute xUnit = varXdim . findAttribute ( "units" ) ; Attribute xAxis = varXdim . findAttribute ( "axis" ) ; if ( xUnit != null ) if ( xUnit . getStringValue ( ) . contains ( "since" ) ) xIsTime = true ; if ( xAxis != null ) if ( xAxis . getStringValue ( ) . equals ( "T" ) ) xIsTime = true ; if ( xUnit != null ) p . getDomainAxis ( ) . setLabel ( xUnit . getStringValue ( ) ) ; else p . getDomainAxis ( ) . setLabel ( dimName ) ; if ( xAxis != null ) log . info ( "X axis type " + xUnit . getDataType ( ) + " value " + xUnit . toString ( ) + " is Time " + xIsTime ) ; } int ax = 0 ; log . info ( "dataset count " + p . getDatasetCount ( ) ) ; if ( p . getDatasetCount ( ) >= 1 ) { if ( p . getDataset ( p . getDatasetCount ( ) - 1 ) != null ) { log . info ( "number in dataset " + p . getDataset ( 0 ) ) ; ax = p . getDatasetCount ( ) ; if ( ax > 0 ) { p . setRangeAxis ( ax , new NumberAxis ( ) ) ; } } } log . info ( "axis number " + ax ) ; final XYItemRenderer renderer = p . getRenderer ( ) ; if ( xIsTime ) { final StandardXYToolTipGenerator g = new StandardXYToolTipGenerator ( StandardXYToolTipGenerator . DEFAULT_TOOL_TIP_FORMAT , new SimpleDateFormat ( "d-MMM-yyyy" ) , new DecimalFormat ( "0.00" ) ) ; renderer . setBaseToolTipGenerator ( g ) ; dataset = new TimeSeriesCollection ( ) ; } else { final StandardXYToolTipGenerator g = new StandardXYToolTipGenerator ( StandardXYToolTipGenerator . DEFAULT_TOOL_TIP_FORMAT , new DecimalFormat ( "0.00" ) , new DecimalFormat ( "0.00" ) ) ; renderer . setBaseToolTipGenerator ( g ) ; dataset = new XYSeriesCollection ( ) ; p . setDomainAxis ( new NumberAxis ( ) ) ; // change to NumberAxis from DateAxis which is what is created
} p . getRangeAxis ( ax ) . setAutoRange ( true ) ; Attribute vUnit = v . findAttribute ( "units" ) ; Attribute vfill = v . findAttribute ( "_FillValue" ) ; double dfill = Double . NaN ; if ( vfill != null ) dfill = vfill . getNumericValue ( ) . doubleValue ( ) ; if ( vUnit != null ) p . getRangeAxis ( ax ) . setLabel ( vUnit . getStringValue ( ) ) ; NetcdfDataset fds = new NetcdfDataset ( file ) ; CoordinateAxis1DTime tm = null ; List < CalendarDate > dates = null ; Array varXarray = null ; if ( hasXdim ) { varXarray = varXdim . read ( ) ; if ( xIsTime ) { tm = CoordinateAxis1DTime . factory ( fds , new VariableDS ( null , varXdim , true ) , null ) ; dates = tm . getCalendarDates ( ) ; } } Array a = v . read ( ) ; Index idx = a . getIndex ( ) ; idx . setCurrentCounter ( 0 ) ; int d2 = 1 ; int rank = idx . getRank ( ) ; for ( int k = 1 ; k < rank ; k ++ ) { d2 *= idx . getShape ( k ) ; } log . info ( "variable : " + v . getShortName ( ) + " : dims " + v . getDimensionsString ( ) + " rank " + rank + " d2 " + d2 ) ; double max = - 1000 ; double min = 1000 ; for ( int j = 0 ; j < d2 ; j ++ ) { if ( rank > 1 ) idx . set1 ( j ) ; // this wont work for 3rd dimension > 1
String name = v . getShortName ( ) ; if ( d2 > 1 ) name += "-" + j ; Series s1 ; if ( xIsTime ) s1 = new TimeSeries ( name ) ; else s1 = new XYSeries ( name ) ; for ( int i = 0 ; i < idx . getShape ( 0 ) ; i ++ ) { idx . set0 ( i ) ; float f = a . getFloat ( idx ) ; if ( f != dfill ) { if ( ! Float . isNaN ( f ) ) { max = Math . max ( max , f ) ; min = Math . min ( min , f ) ; } if ( xIsTime ) { Date ts = new Date ( dates . get ( i ) . getMillis ( ) ) ; ( ( TimeSeries ) s1 ) . addOrUpdate ( new Second ( ts ) , f ) ; } else if ( hasXdim ) { ( ( XYSeries ) s1 ) . addOrUpdate ( varXarray . getDouble ( i ) , f ) ; } else { ( ( XYSeries ) s1 ) . addOrUpdate ( i , f ) ; } } } if ( dataset instanceof TimeSeriesCollection ) ( ( TimeSeriesCollection ) dataset ) . addSeries ( ( TimeSeries ) s1 ) ; if ( dataset instanceof XYSeriesCollection ) ( ( XYSeriesCollection ) dataset ) . addSeries ( ( XYSeries ) s1 ) ; } final XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer ( true , false ) ; p . setRenderer ( ax , renderer1 ) ; log . info ( "dataset " + ax + " max " + max + " min " + min + " : " + dataset ) ; p . setDataset ( ax , dataset ) ; p . mapDatasetToRangeAxis ( ax , ax ) ; p . getRangeAxis ( ax ) . setLowerBound ( min ) ; p . getRangeAxis ( ax ) . setUpperBound ( max ) ;


signature:
public class IndependentDialog { /** * / * @ Override
 * public void setBounds ( Rectangle r ) {
 * if ( parent ! = null ) {
 * Rectangle have = parent . getGraphicsConfiguration ( ) . getBounds ( ) ;
 * if ( r . getX ( ) < have . getWidth ( ) - 25 ) ; / / may be off screen when switching between 2 monitor system
 * setBounds ( r . x , r . y , r . width , r . height ) ; */
@ Override public void setBounds ( Rectangle r ) { } }

implementation:
// keep window on the screen
Rectangle screenSize = ScreenUtils . getScreenVirtualSize ( ) ; Rectangle result = r . intersection ( screenSize ) ; if ( ! result . isEmpty ( ) ) super . setBounds ( result ) ;


signature:
public class GribIndex { /** * Create a gbx9 index from a single grib1 or grib2 file .
 * Use the existing index if it already exists .
 * @ param isGrib1 true if grib1
 * @ param mfile the grib file
 * @ param force force writing index
 * @ return the resulting GribIndex
 * @ throws IOException on io error */
public static GribIndex readOrCreateIndexFromSingleFile ( boolean isGrib1 , MFile mfile , CollectionUpdateType force , org . slf4j . Logger logger ) throws IOException { } }

implementation:
GribIndex index = isGrib1 ? new Grib1Index ( ) : new Grib2Index ( ) ; if ( ! index . readIndex ( mfile . getPath ( ) , mfile . getLastModified ( ) , force ) ) { // heres where the index date is checked against the data file
index . makeIndex ( mfile . getPath ( ) , null ) ; logger . debug ( "  Index written: {} == {} records" , mfile . getName ( ) + GBX9_IDX , index . getNRecords ( ) ) ; } else if ( debug ) { logger . debug ( "  Index read: {} == {} records" , mfile . getName ( ) + GBX9_IDX , index . getNRecords ( ) ) ; } return index ;


signature:
public class MFileCollectionManager { /** * called from Aggregation , Fmrc , FeatureDatasetFactoryManager */
static public MFileCollectionManager open ( String collectionName , String collectionSpec , String olderThan , Formatter errlog ) throws IOException { } }

implementation: return new MFileCollectionManager ( collectionName , collectionSpec , olderThan , errlog ) ;


signature:
public class MFileCollectionManager { /** * Add a directory scan to the collection
 * @ param dirName scan this directory
 * @ param suffix require this suffix ( overriddden by regexp ) , may be null
 * @ param regexpPatternString if present , use this reqular expression to filter files , may be null
 * @ param subdirsS if " true " , descend into subdirectories , may be null
 * @ param olderS udunit time unit - files must be older than this amount of time ( now - lastModified > olderTime ) , may be null
 * / / * @ param dateFormatString dateFormatMark string , may be null
 * @ param auxInfo attach this object to any MFile found by this scan */
public void addDirectoryScan ( String dirName , String suffix , String regexpPatternString , String subdirsS , String olderS , Object auxInfo ) { } }

implementation:
CompositeMFileFilter filters = new CompositeMFileFilter ( ) ; if ( null != regexpPatternString ) filters . addIncludeFilter ( new RegExpMatchOnName ( regexpPatternString ) ) ; else if ( suffix != null ) filters . addIncludeFilter ( new WildcardMatchOnPath ( "*" + suffix + "$" ) ) ; if ( olderS != null ) { try { TimeDuration tu = new TimeDuration ( olderS ) ; filters . addAndFilter ( new LastModifiedLimit ( ( long ) ( 1000 * tu . getValueInSeconds ( ) ) ) ) ; } catch ( Exception e ) { logger . error ( collectionName + ": Invalid time unit for olderThan = {}" , olderS ) ; } } boolean wantSubdirs = true ; if ( ( subdirsS != null ) && subdirsS . equalsIgnoreCase ( "false" ) ) wantSubdirs = false ; CollectionConfig mc = new CollectionConfig ( dirName , dirName , wantSubdirs , filters , auxInfo ) ; // create name
StringBuilder sb = new StringBuilder ( dirName ) ; if ( wantSubdirs ) sb . append ( "**/" ) ; if ( null != regexpPatternString ) sb . append ( regexpPatternString ) ; else if ( suffix != null ) sb . append ( suffix ) ; else sb . append ( "noFilter" ) ; collectionName = sb . toString ( ) ; scanList . add ( mc ) ;


signature:
public class MFileCollectionManager { /** * Compute if synchronous scan is needed .
 * True if recheck is true and enough time has elapsed .
 * @ return true if rescan is needed */
@ Override public boolean isScanNeeded ( ) { } }

implementation:
// see if we need to recheck
if ( recheck == null ) { logger . debug ( "{}: scan not needed, recheck null" , collectionName ) ; return false ; } if ( ! hasScans ( ) ) { logger . debug ( "{}: scan not needed, no scanners" , collectionName ) ; return false ; } synchronized ( this ) { if ( map == null && ! isStatic ( ) ) { logger . debug ( "{}: scan needed, never scanned" , collectionName ) ; return true ; } } Date now = new Date ( ) ; Date lastCheckedDate = new Date ( getLastScanned ( ) ) ; Date need = recheck . add ( lastCheckedDate ) ; if ( now . before ( need ) ) { logger . debug ( "{}: scan not needed, last scanned={}, now={}" , collectionName , lastCheckedDate , now ) ; return false ; } return true ;


signature:
public class MFileCollectionManager { /** * only called from synch methods */
private boolean scanFirstTime ( ) throws IOException { } }

implementation:
Map < String , MFile > newMap = new HashMap < > ( ) ; if ( ! hasScans ( ) ) { map = newMap ; return false ; } reallyScan ( newMap ) ; // deleteOld ( newMap ) ; / / ? ? hmmmmm LOOK this seems wrong ; maintainence in background ? ? generally collection doesnt exist
// implement olderThan
if ( olderThanInMsecs > 0 ) { long olderThan = System . currentTimeMillis ( ) - olderThanInMsecs ; // new files must be older than this .
Iterator < MFile > iter = newMap . values ( ) . iterator ( ) ; // need iterator so we can remove ( )
while ( iter . hasNext ( ) ) { MFile newFile = iter . next ( ) ; String path = newFile . getPath ( ) ; if ( newFile . getLastModified ( ) > olderThan ) { // the file is too new
iter . remove ( ) ; logger . debug ( "{}: scan found new Dataset but its too recently modified = {}" , collectionName , path ) ; } } } map = newMap ; this . lastScanned = System . currentTimeMillis ( ) ; this . lastChanged . set ( this . lastScanned ) ; logger . debug ( "{} : initial scan found n datasets = {} " , collectionName , map . keySet ( ) . size ( ) ) ; return map . keySet ( ) . size ( ) > 0 ;


signature:
public class FileWriter2 { /** * Set debugging flags
 * @ param debugFlags debug flags */
public static void setDebugFlags ( ucar . nc2 . util . DebugFlags debugFlags ) { } }

implementation: debug = debugFlags . isSet ( "ncfileWriter2/debug" ) ; debugWrite = debugFlags . isSet ( "ncfileWriter2/debugWrite" ) ; debugChunk = debugFlags . isSet ( "ncfileWriter2/debugChunk" ) ;


signature:
public class FileWriter2 { /** * Specify which variable will get written
 * @ param oldVar add this variable , and all parent groups
 * @ return new Variable . */
public Variable addVariable ( Variable oldVar ) { } }

implementation: List < Dimension > newDims = getNewDimensions ( oldVar ) ; Variable newVar ; if ( ( oldVar . getDataType ( ) . equals ( DataType . STRING ) ) && ( ! version . isExtendedModel ( ) ) ) { newVar = writer . addStringVariable ( null , oldVar , newDims ) ; } else { newVar = writer . addVariable ( null , oldVar . getShortName ( ) , oldVar . getDataType ( ) , newDims ) ; } varMap . put ( oldVar , newVar ) ; varList . add ( oldVar ) ; for ( Attribute orgAtt : oldVar . getAttributes ( ) ) writer . addVariableAttribute ( newVar , convertAttribute ( orgAtt ) ) ; return newVar ;


signature:
public class FileWriter2 { /** * Write the input file to the output file .
 * @ param cancel allow user to cancel ; may be null .
 * @ return the open output file .
 * @ throws IOException */
public NetcdfFile write ( CancelTask cancel ) throws IOException { } }

implementation:
try { if ( version . isExtendedModel ( ) ) addGroupExtended ( null , fileIn . getRootGroup ( ) ) ; else addGroupClassic ( ) ; if ( cancel != null && cancel . isCancel ( ) ) return null ; // create the file
writer . create ( ) ; if ( cancel != null && cancel . isCancel ( ) ) return null ; double total = copyVarData ( varList , null , cancel ) ; if ( cancel != null && cancel . isCancel ( ) ) return null ; writer . flush ( ) ; if ( debug ) System . out . println ( "FileWriter done total bytes = " + total ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; writer . abort ( ) ; // clean up
throw ioe ; } return writer . getNetcdfFile ( ) ;


signature:
public class CDMArraySequence { /** * / * package */
void add ( long recno , int fieldno , Array field ) { } }

implementation:
// Make sure all the space is allocated
if ( records . length <= recno ) { FieldSet [ ] newrecs = new FieldSet [ ( int ) recno + 1 ] ; System . arraycopy ( records , 0 , newrecs , 0 , records . length ) ; records = newrecs ; } FieldSet fs = records [ ( int ) recno ] ; if ( fs == null ) { records [ ( int ) recno ] = ( fs = new FieldSet ( this . nmembers ) ) ; } fs . fields [ fieldno ] = field ;


signature: public class CDMArraySequence { protected CDMArrayAtomic getAtomicArray ( int index , StructureMembers . Member m ) { } }

implementation: Array dd = memberArray ( index , CDMArrayStructure . memberIndex ( m ) ) ; if ( dd . getDataType ( ) != DataType . STRUCTURE && dd . getDataType ( ) != DataType . SEQUENCE ) return ( CDMArrayAtomic ) dd ; throw new ForbiddenConversionException ( "Cannot convert structure to AtomicArray" ) ;


signature:
public class NetcdfDatasetInfo { /** * Write the information as an XML document
 * @ return String containing netcdfDatasetInfo XML */
public String writeXML ( ) { } }

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


signature:
public class NetcdfDatasetInfo { /** * Create an XML document from this info
 * @ return netcdfDatasetInfo XML document */
public Document makeDocument ( ) { } }

implementation: Element rootElem = new Element ( "netcdfDatasetInfo" ) ; Document doc = new Document ( rootElem ) ; rootElem . setAttribute ( "location" , ds . getLocation ( ) ) ; rootElem . addContent ( new Element ( "convention" ) . setAttribute ( "name" , getConventionUsed ( ) ) ) ; int nDataVariables = 0 ; int nOtherVariables = 0 ; List < CoordinateAxis > axes = ds . getCoordinateAxes ( ) ; int nCoordAxes = axes . size ( ) ; for ( CoordinateAxis axis : axes ) { Element axisElem = new Element ( "axis" ) ; rootElem . addContent ( axisElem ) ; axisElem . setAttribute ( "name" , axis . getFullName ( ) ) ; axisElem . setAttribute ( "decl" , getDecl ( axis ) ) ; if ( axis . getAxisType ( ) != null ) axisElem . setAttribute ( "type" , axis . getAxisType ( ) . toString ( ) ) ; if ( axis . getUnitsString ( ) != null ) { axisElem . setAttribute ( CDM . UNITS , axis . getUnitsString ( ) ) ; axisElem . setAttribute ( "udunits" , isUdunits ( axis . getUnitsString ( ) ) ) ; } if ( axis instanceof CoordinateAxis1D ) { CoordinateAxis1D axis1D = ( CoordinateAxis1D ) axis ; if ( axis1D . isRegular ( ) ) axisElem . setAttribute ( "regular" , ucar . unidata . util . Format . d ( axis1D . getIncrement ( ) , 5 ) ) ; } } List < CoordinateSystem > csList = ds . getCoordinateSystems ( ) ; for ( CoordinateSystem cs : csList ) { Element csElem ; if ( GridCoordSys . isGridCoordSys ( null , cs , null ) ) { GridCoordSys gcs = new GridCoordSys ( cs , null ) ; csElem = new Element ( "gridCoordSystem" ) ; csElem . setAttribute ( "name" , cs . getName ( ) ) ; csElem . setAttribute ( "horizX" , gcs . getXHorizAxis ( ) . getFullName ( ) ) ; csElem . setAttribute ( "horizY" , gcs . getYHorizAxis ( ) . getFullName ( ) ) ; if ( gcs . hasVerticalAxis ( ) ) csElem . setAttribute ( "vertical" , gcs . getVerticalAxis ( ) . getFullName ( ) ) ; if ( gcs . hasTimeAxis ( ) ) csElem . setAttribute ( "time" , cs . getTaxis ( ) . getFullName ( ) ) ; } else { csElem = new Element ( "coordSystem" ) ; csElem . setAttribute ( "name" , cs . getName ( ) ) ; } List < CoordinateTransform > coordTransforms = cs . getCoordinateTransforms ( ) ; for ( CoordinateTransform ct : coordTransforms ) { Element ctElem = new Element ( "coordTransform" ) ; csElem . addContent ( ctElem ) ; ctElem . setAttribute ( "name" , ct . getName ( ) ) ; ctElem . setAttribute ( "type" , ct . getTransformType ( ) . toString ( ) ) ; } rootElem . addContent ( csElem ) ; } List < CoordinateTransform > coordTransforms = ds . getCoordinateTransforms ( ) ; for ( CoordinateTransform ct : coordTransforms ) { Element ctElem = new Element ( "coordTransform" ) ; rootElem . addContent ( ctElem ) ; ctElem . setAttribute ( "name" , ct . getName ( ) ) ; ctElem . setAttribute ( "type" , ct . getTransformType ( ) . toString ( ) ) ; List < Parameter > params = ct . getParameters ( ) ; for ( Parameter pp : params ) { Element ppElem = new Element ( "param" ) ; ctElem . addContent ( ppElem ) ; ppElem . setAttribute ( "name" , pp . getName ( ) ) ; ppElem . setAttribute ( "value" , pp . getStringValue ( ) ) ; } } for ( Variable var : ds . getVariables ( ) ) { VariableEnhanced ve = ( VariableEnhanced ) var ; if ( ve instanceof CoordinateAxis ) continue ; GridCoordSys gcs = getGridCoordSys ( ve ) ; if ( null != gcs ) { nDataVariables ++ ; Element gridElem = new Element ( "grid" ) ; rootElem . addContent ( gridElem ) ; gridElem . setAttribute ( "name" , ve . getFullName ( ) ) ; gridElem . setAttribute ( "decl" , getDecl ( ve ) ) ; if ( ve . getUnitsString ( ) != null ) { gridElem . setAttribute ( CDM . UNITS , ve . getUnitsString ( ) ) ; gridElem . setAttribute ( "udunits" , isUdunits ( ve . getUnitsString ( ) ) ) ; } gridElem . setAttribute ( "coordSys" , gcs . getName ( ) ) ; } } for ( Variable var : ds . getVariables ( ) ) { VariableEnhanced ve = ( VariableEnhanced ) var ; if ( ve instanceof CoordinateAxis ) continue ; GridCoordSys gcs = getGridCoordSys ( ve ) ; if ( null == gcs ) { nOtherVariables ++ ; Element elem = new Element ( "variable" ) ; rootElem . addContent ( elem ) ; elem . setAttribute ( "name" , ve . getFullName ( ) ) ; elem . setAttribute ( "decl" , getDecl ( ve ) ) ; if ( ve . getUnitsString ( ) != null ) { elem . setAttribute ( CDM . UNITS , ve . getUnitsString ( ) ) ; elem . setAttribute ( "udunits" , isUdunits ( ve . getUnitsString ( ) ) ) ; } elem . setAttribute ( "coordSys" , getCoordSys ( ve ) ) ; } } if ( nDataVariables > 0 ) { rootElem . addContent ( new Element ( "userAdvice" ) . addContent ( "Dataset contains useable gridded data." ) ) ; if ( nOtherVariables > 0 ) rootElem . addContent ( new Element ( "userAdvice" ) . addContent ( "Some variables are not gridded fields; check that is what you expect." ) ) ; } else { if ( nCoordAxes == 0 ) rootElem . addContent ( new Element ( "userAdvice" ) . addContent ( "No Coordinate Axes were found." ) ) ; else rootElem . addContent ( new Element ( "userAdvice" ) . addContent ( "No gridded data variables were found." ) ) ; } String userAdvice = getUserAdvice ( ) ; if ( userAdvice . length ( ) > 0 ) { StringTokenizer toker = new StringTokenizer ( userAdvice , "\n" ) ; while ( toker . hasMoreTokens ( ) ) rootElem . addContent ( new Element ( "userAdvice" ) . addContent ( toker . nextToken ( ) ) ) ; } return doc ;


signature:
public class NetcdfDatasetInfo { /** * debug */
public static void main ( String args [ ] ) throws IOException { } }

implementation: String url = "C:/data/badmodels/RUC_CONUS_80km_20051211_1900.nc" ; try ( NetcdfDatasetInfo info = new NetcdfDatasetInfo ( url ) ) { String infoString = info . writeXML ( ) ; System . out . println ( infoString ) ; }


signature:
public class MarshallingUtil { /** * / / / / / Marshalling / / / / / */
public static void marshalPointDataset ( FeatureDatasetPoint fdPoint , OutputStream outputStream ) throws IOException , XmlException { } }

implementation: marshalPointDataset ( fdPoint , fdPoint . getDataVariables ( ) , outputStream ) ;


signature:
public class MarshallingUtil { /** * Validates an xml doc . If the validation fails , the exception contains a detailed list of errors .
 * @ param doc the document to validate
 * @ throws XmlException thrown if the XML is incorrect */
public static void validate ( XmlObject doc , boolean strict ) throws XmlException { } }

implementation:
// Create an XmlOptions instance and set the error listener .
Set < XmlError > validationErrors = new HashSet < > ( ) ; XmlOptions validationOptions = new XmlOptions ( ) ; validationOptions . setErrorListener ( validationErrors ) ; // Validate the XML document
final boolean isValid = doc . validate ( validationOptions ) ; // Create Exception with error message if the xml document is invalid
if ( ! isValid && ! strict ) { // check if we have special validation cases which could let the message pass anyhow
validationErrors = filterToOnlySerious ( validationErrors ) ; } if ( ! validationErrors . isEmpty ( ) ) { throw new XmlException ( createErrorMessage ( validationErrors ) ) ; }


signature:
public class MultiSlice { /** * Convert this multislice to a string
 * suitable for use in a constraint
 * @ return constraint usable string
 * @ throws DapException */
@ Override public String toConstraintString ( ) throws DapException { } }

implementation: assert this . first != UNDEFINED && this . stride != UNDEFINED && this . stop != UNDEFINED ; StringBuilder buf = new StringBuilder ( ) ; buf . append ( "[" ) ; boolean first = true ; for ( Slice sub : this . subslices ) { if ( ! first ) buf . append ( "," ) ; first = false ; if ( ( sub . stop - sub . first ) == 0 ) { buf . append ( "0" ) ; } else if ( sub . stride == 1 ) { if ( ( sub . stop - sub . first ) == 1 ) buf . append ( sub . first ) ; else buf . append ( String . format ( "%d:%d" , sub . first , sub . stop - 1 ) ) ; } else buf . append ( String . format ( "%d:%d:%d" , sub . first , sub . stride , sub . stop - 1 ) ) ; } buf . append ( "]" ) ; return buf . toString ( ) ;


signature:
public class StructureDS { /** * copy ( ) doesnt work because convert gets called twice */
@ Override public Structure select ( List < String > memberNames ) { } }

implementation: StructureDS result = new StructureDS ( getParentGroup ( ) , orgVar ) ; List < Variable > members = new ArrayList < > ( ) ; for ( String name : memberNames ) { Variable m = findVariable ( name ) ; if ( null != m ) members . add ( m ) ; } result . setMemberVariables ( members ) ; result . isSubset = true ; return result ;


signature:
public class StructureDS { /** * Set the Structure to wrap .
 * @ param orgVar original Variable , must be a Structure */
public void setOriginalVariable ( ucar . nc2 . Variable orgVar ) { } }

implementation: if ( ! ( orgVar instanceof Structure ) ) throw new IllegalArgumentException ( "StructureDS must wrap a Structure; name=" + orgVar . getFullName ( ) ) ; this . orgVar = ( Structure ) orgVar ;


signature:
public class StructureDS { /** * regular Variables . */
@ Override public Array reallyRead ( Variable client , CancelTask cancelTask ) throws IOException { } }

implementation:
Array result ; if ( hasCachedData ( ) ) result = super . reallyRead ( client , cancelTask ) ; else if ( orgVar != null ) result = orgVar . read ( ) ; else { throw new IllegalStateException ( "StructureDS has no way to get data" ) ; // Object data = smProxy . getFillValue ( getDataType ( ) ) ;
// return Array . factoryConstant ( dataType . getPrimitiveClassType ( ) , getShape ( ) , data ) ;
} return convert ( result , null ) ;


signature:
public class StructureDS { /** * section of regular Variable */
@ Override public Array reallyRead ( Variable client , Section section , CancelTask cancelTask ) throws IOException , InvalidRangeException { } }

implementation:
if ( section . computeSize ( ) == getSize ( ) ) return _read ( ) ; Array result ; if ( hasCachedData ( ) ) result = super . reallyRead ( client , section , cancelTask ) ; else if ( orgVar != null ) result = orgVar . read ( section ) ; else { throw new IllegalStateException ( "StructureDS has no way to get data" ) ; // Object data = smProxy . getFillValue ( getDataType ( ) ) ;
// return Array . factoryConstant ( dataType . getPrimitiveClassType ( ) , section . getShape ( ) , data ) ;
} // do any needed conversions ( enum / scale / offset / missing / unsigned , etc )
return convert ( result , section ) ;


signature:
public class StructureDS { /** * is conversion needed ? */
private boolean convertNeeded ( StructureMembers smData ) { } }

implementation:
for ( Variable v : getVariables ( ) ) { if ( v instanceof VariableDS ) { VariableDS vds = ( VariableDS ) v ; if ( vds . needConvert ( ) ) return true ; } else if ( v instanceof StructureDS ) { StructureDS nested = ( StructureDS ) v ; if ( nested . convertNeeded ( null ) ) return true ; } // a variable with no data in the underlying smData
if ( ( smData != null ) && ! varHasData ( v , smData ) ) return true ; } return false ;


signature:
public class StructureDS { /** * 3 ) variable with cached data added to StructureDS through NcML */
protected ArrayStructure convert ( Array data , Section section ) throws IOException { } }

implementation:
ArrayStructure orgAS = ( ArrayStructure ) data ; if ( ! convertNeeded ( orgAS . getStructureMembers ( ) ) ) { // name , info change only
convertMemberInfo ( orgAS . getStructureMembers ( ) ) ; return orgAS ; } // LOOK ! converting to ArrayStructureMA
// do any enum / scale / offset / missing / unsigned conversions
ArrayStructure newAS = ArrayStructureMA . factoryMA ( orgAS ) ; for ( StructureMembers . Member m : newAS . getMembers ( ) ) { VariableEnhanced v2 = ( VariableEnhanced ) findVariable ( m . getName ( ) ) ; if ( ( v2 == null ) && ( orgVar != null ) ) // these are from orgVar - may have been renamed
v2 = findVariableFromOrgName ( m . getName ( ) ) ; if ( v2 == null ) continue ; if ( v2 instanceof VariableDS ) { VariableDS vds = ( VariableDS ) v2 ; if ( vds . needConvert ( ) ) { Array mdata = newAS . extractMemberArray ( m ) ; // mdata has not yet been enhanced , but vds would * think * that it has been if we used the 1 - arg version of
// VariableDS . convert ( ) . So , we use the 2 - arg version to explicitly request enhancement .
mdata = vds . convert ( mdata , vds . getEnhanceMode ( ) ) ; newAS . setMemberArray ( m , mdata ) ; } } else if ( v2 instanceof StructureDS ) { StructureDS innerStruct = ( StructureDS ) v2 ; if ( innerStruct . convertNeeded ( null ) ) { if ( innerStruct . getDataType ( ) == DataType . SEQUENCE ) { ArrayObject . D1 seqArray = ( ArrayObject . D1 ) newAS . extractMemberArray ( m ) ; ArrayObject . D1 newSeq = ( ArrayObject . D1 ) Array . factory ( DataType . SEQUENCE , new int [ ] { ( int ) seqArray . getSize ( ) } ) ; m . setDataArray ( newSeq ) ; // put back into member array
// wrap each Sequence
for ( int i = 0 ; i < seqArray . getSize ( ) ; i ++ ) { ArraySequence innerSeq = ( ArraySequence ) seqArray . get ( i ) ; // get old ArraySequence
newSeq . set ( i , new SequenceConverter ( innerStruct , innerSeq ) ) ; // wrap in converter
} // non - Sequence Structures
} else { Array mdata = newAS . extractMemberArray ( m ) ; mdata = innerStruct . convert ( mdata , null ) ; newAS . setMemberArray ( m , mdata ) ; } } // always convert the inner StructureMembers
innerStruct . convertMemberInfo ( m . getStructureMembers ( ) ) ; } } StructureMembers sm = newAS . getStructureMembers ( ) ; convertMemberInfo ( sm ) ; // check for variables that have been added by NcML
for ( Variable v : getVariables ( ) ) { if ( ! varHasData ( v , sm ) ) { try { Variable completeVar = getParentGroup ( ) . findVariable ( v . getShortName ( ) ) ; // LOOK BAD
Array mdata = completeVar . read ( section ) ; StructureMembers . Member m = sm . addMember ( v . getShortName ( ) , v . getDescription ( ) , v . getUnitsString ( ) , v . getDataType ( ) , v . getShape ( ) ) ; newAS . setMemberArray ( m , mdata ) ; } catch ( InvalidRangeException e ) { throw new IOException ( e . getMessage ( ) ) ; } } } return newAS ;


signature:
public class StructureDS { /** * / * convert original structureData to one that conforms to this Structure */
protected StructureData convert ( StructureData orgData , int recno ) throws IOException { } }

implementation:
if ( ! convertNeeded ( orgData . getStructureMembers ( ) ) ) { // name , info change only
convertMemberInfo ( orgData . getStructureMembers ( ) ) ; return orgData ; } // otherwise we create a new StructureData and convert to it . expensive
StructureMembers smResult = new StructureMembers ( orgData . getStructureMembers ( ) ) ; StructureDataW result = new StructureDataW ( smResult ) ; for ( StructureMembers . Member m : orgData . getMembers ( ) ) { VariableEnhanced v2 = ( VariableEnhanced ) findVariable ( m . getName ( ) ) ; if ( ( v2 == null ) && ( orgVar != null ) ) // why ?
v2 = findVariableFromOrgName ( m . getName ( ) ) ; if ( v2 == null ) { findVariableFromOrgName ( m . getName ( ) ) ; // debug
// log . warn ( " StructureDataDS . convert Cant find member " + m . getName ( ) ) ;
continue ; } StructureMembers . Member mResult = smResult . findMember ( m . getName ( ) ) ; if ( v2 instanceof VariableDS ) { VariableDS vds = ( VariableDS ) v2 ; Array mdata = orgData . getArray ( m ) ; if ( vds . needConvert ( ) ) // mdata has not yet been enhanced , but vds would * think * that it has been if we used the 1 - arg version of
// VariableDS . convert ( ) . So , we use the 2 - arg version to explicitly request enhancement .
mdata = vds . convert ( mdata , vds . getEnhanceMode ( ) ) ; result . setMemberData ( mResult , mdata ) ; } // recurse into sub - structures
if ( v2 instanceof StructureDS ) { StructureDS innerStruct = ( StructureDS ) v2 ; // if ( innerStruct . convertNeeded ( null ) ) {
if ( innerStruct . getDataType ( ) == DataType . SEQUENCE ) { Array a = orgData . getArray ( m ) ; if ( a instanceof ArrayObject . D1 ) { // LOOK when does this happen vs ArraySequence ?
ArrayObject . D1 seqArray = ( ArrayObject . D1 ) a ; ArrayObject . D1 newSeq = ( ArrayObject . D1 ) Array . factory ( DataType . SEQUENCE , new int [ ] { ( int ) seqArray . getSize ( ) } ) ; mResult . setDataArray ( newSeq ) ; // put into result member array
for ( int i = 0 ; i < seqArray . getSize ( ) ; i ++ ) { ArraySequence innerSeq = ( ArraySequence ) seqArray . get ( i ) ; // get old ArraySequence
newSeq . set ( i , new SequenceConverter ( innerStruct , innerSeq ) ) ; // wrap in converter
} } else { ArraySequence seqArray = ( ArraySequence ) a ; result . setMemberData ( mResult , new SequenceConverter ( innerStruct , seqArray ) ) ; // wrap in converter
} // non - Sequence Structures
} else { Array mdata = orgData . getArray ( m ) ; mdata = innerStruct . convert ( mdata , null ) ; result . setMemberData ( mResult , mdata ) ; } // always convert the inner StructureMembers
innerStruct . convertMemberInfo ( mResult . getStructureMembers ( ) ) ; } } StructureMembers sm = result . getStructureMembers ( ) ; convertMemberInfo ( sm ) ; // check for variables that have been added by NcML
for ( Variable v : getVariables ( ) ) { if ( ! varHasData ( v , sm ) ) { try { Variable completeVar = getParentGroup ( ) . findVariable ( v . getShortName ( ) ) ; // LOOK BAD
Array mdata = completeVar . read ( new Section ( ) . appendRange ( recno , recno ) ) ; StructureMembers . Member m = sm . addMember ( v . getShortName ( ) , v . getDescription ( ) , v . getUnitsString ( ) , v . getDataType ( ) , v . getShape ( ) ) ; result . setMemberData ( m , mdata ) ; } catch ( InvalidRangeException e ) { throw new IOException ( e . getMessage ( ) ) ; } } } return result ;


signature:
public class StructureDS { /** * the wrapper StructureMembers must be converted to correspond to the wrapper Structure */
private void convertMemberInfo ( StructureMembers wrapperSm ) { } }

implementation:
for ( StructureMembers . Member m : wrapperSm . getMembers ( ) ) { Variable v = findVariable ( m . getName ( ) ) ; if ( ( v == null ) && ( orgVar != null ) ) // may have been renamed
v = ( Variable ) findVariableFromOrgName ( m . getName ( ) ) ; if ( v != null ) { // a section will have missing variables LOOK wrapperSm probably wrong in that case
// log . error ( " Cant find " + m . getName ( ) ) ;
// else
m . setVariableInfo ( v . getShortName ( ) , v . getDescription ( ) , v . getUnitsString ( ) , v . getDataType ( ) ) ; } // nested structures
if ( v instanceof StructureDS ) { StructureDS innerStruct = ( StructureDS ) v ; innerStruct . convertMemberInfo ( m . getStructureMembers ( ) ) ; } }


signature:
public class StructureDS { /** * look for the top variable that has an orgVar with the wanted orgName */
private VariableEnhanced findVariableFromOrgName ( String orgName ) { } }

implementation: for ( Variable vTop : getVariables ( ) ) { Variable v = vTop ; while ( v instanceof VariableEnhanced ) { VariableEnhanced ve = ( VariableEnhanced ) v ; if ( ( ve . getOriginalName ( ) != null ) && ( ve . getOriginalName ( ) . equals ( orgName ) ) ) return ( VariableEnhanced ) vTop ; v = ve . getOriginalVariable ( ) ; } } return null ;


signature:
public class StructureDS { /** * verify that the variable has data in the data array */
private boolean varHasData ( Variable v , StructureMembers sm ) { } }

implementation: if ( sm . findMember ( v . getShortName ( ) ) != null ) return true ; while ( v instanceof VariableEnhanced ) { VariableEnhanced ve = ( VariableEnhanced ) v ; if ( sm . findMember ( ve . getOriginalName ( ) ) != null ) return true ; v = ve . getOriginalVariable ( ) ; } return false ;


signature:
public class StructureDS { /** * DO NOT USE DIRECTLY . public by accident .
 * recalc any enhancement info */
public void enhance ( Set < NetcdfDataset . Enhance > mode ) { } }

implementation: for ( Variable v : getVariables ( ) ) { VariableEnhanced ve = ( VariableEnhanced ) v ; ve . enhance ( mode ) ; }


signature:
public class DatasetManager { /** * return null means request has been handled , and calling routine should exit without further processing */
public NetcdfFile openNetcdfFile ( HttpServletRequest req , HttpServletResponse res , String reqPath ) throws IOException { } }

implementation:
if ( log . isDebugEnabled ( ) ) log . debug ( "DatasetHandler wants " + reqPath ) ; if ( reqPath == null ) return null ; if ( reqPath . startsWith ( "/" ) ) reqPath = reqPath . substring ( 1 ) ; // see if its under resource control
if ( ! resourceControlOk ( req , res , reqPath ) ) return null ; // HEY LOOK datascan below has its own Ncml
// look for a dataset ( non scan , non fmrc ) that has an ncml element
String ncml = datasetTracker . findNcml ( reqPath ) ; if ( ncml != null ) { NetcdfFile ncfile = NetcdfDataset . acquireFile ( new NcmlFileFactory ( ncml ) , null , DatasetUrl . findDatasetUrl ( reqPath ) , - 1 , null , null ) ; if ( ncfile == null ) throw new FileNotFoundException ( reqPath ) ; return ncfile ; } // look for a match
DataRootManager . DataRootMatch match = dataRootManager . findDataRootMatch ( reqPath ) ; // look for an feature collection dataset
if ( ( match != null ) && ( match . dataRoot . getFeatureCollection ( ) != null ) ) { FeatureCollectionRef featCollection = match . dataRoot . getFeatureCollection ( ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "  -- DatasetHandler found FeatureCollection= " + featCollection ) ; InvDatasetFeatureCollection fc = featureCollectionCache . get ( featCollection ) ; NetcdfFile ncfile = fc . getNetcdfDataset ( match . remaining ) ; if ( ncfile == null ) throw new FileNotFoundException ( reqPath ) ; return ncfile ; } // might be a pluggable DatasetSource :
NetcdfFile ncfile = null ; for ( DatasetSource datasetSource : datasetSources ) { // LOOK linear
if ( datasetSource . isMine ( req ) ) { ncfile = datasetSource . getNetcdfFile ( req , res ) ; if ( ncfile != null ) return ncfile ; } } // common case - its a file
if ( match != null ) { org . jdom2 . Element netcdfElem = null ; // find ncml if it exists
if ( match . dataRoot != null ) { DatasetScan dscan = match . dataRoot . getDatasetScan ( ) ; // if ( dscan = = null ) dscan = match . dataRoot . getDatasetRootProxy ( ) ; / / no ncml possible in getDatasetRootProxy
if ( dscan != null ) netcdfElem = dscan . getNcmlElement ( ) ; } String location = dataRootManager . getLocationFromRequestPath ( reqPath ) ; if ( location == null ) throw new FileNotFoundException ( reqPath ) ; // if theres an ncml element , open it directly through NcMLReader , therefore not being cached .
// this is safer given all the trouble we have with ncml and caching .
if ( netcdfElem != null ) { String ncmlLocation = "DatasetScan#" + location ; // LOOK some descriptive name
NetcdfDataset ncd = NcMLReader . readNcML ( ncmlLocation , netcdfElem , "file:" + location , null ) ; // new NcMLReader ( ) . readNetcdf ( reqPath , ncd , ncd , netcdfElem , null ) ;
// if ( log . isDebugEnabled ( ) ) log . debug ( " - - DatasetHandler found DataRoot NcML = " + ds ) ;
return ncd ; } DatasetUrl durl = DatasetUrl . findDatasetUrl ( location ) ; ncfile = NetcdfDataset . acquireFile ( durl , null ) ; } if ( ncfile == null ) throw new FileNotFoundException ( reqPath ) ; return ncfile ;


signature:
public class DatasetManager { /** * return null means request has been handled , and calling routine should exit without further processing */
public GridDataset openGridDataset ( HttpServletRequest req , HttpServletResponse res , String reqPath ) throws IOException { } }

implementation:
// first look for a feature collection
DataRootManager . DataRootMatch match = dataRootManager . findDataRootMatch ( reqPath ) ; if ( ( match != null ) && ( match . dataRoot . getFeatureCollection ( ) != null ) ) { // see if its under resource control
if ( ! resourceAuthorized ( req , res , match . dataRoot . getRestrict ( ) ) ) return null ; FeatureCollectionRef featCollection = match . dataRoot . getFeatureCollection ( ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "  -- DatasetHandler found FeatureCollection= " + featCollection ) ; InvDatasetFeatureCollection fc = featureCollectionCache . get ( featCollection ) ; GridDataset gds = fc . getGridDataset ( match . remaining ) ; if ( gds == null ) throw new FileNotFoundException ( reqPath ) ; return gds ; } // fetch it as a NetcdfFile ; this deals with possible NcML
NetcdfFile ncfile = openNetcdfFile ( req , res , reqPath ) ; if ( ncfile == null ) return null ; NetcdfDataset ncd = null ; try { // Convert to NetcdfDataset
ncd = NetcdfDataset . wrap ( ncfile , NetcdfDataset . getDefaultEnhanceMode ( ) ) ; return new ucar . nc2 . dt . grid . GridDataset ( ncd ) ; } catch ( Throwable t ) { if ( ncd == null ) ncfile . close ( ) ; else ncd . close ( ) ; if ( t instanceof IOException ) throw ( IOException ) t ; String msg = ncd == null ? "Problem wrapping NetcdfFile in NetcdfDataset" : "Problem creating GridDataset from NetcdfDataset" ; log . error ( "openGridDataset(): " + msg , t ) ; throw new IOException ( msg + t . getMessage ( ) ) ; }


signature:
public class DatasetManager { /** * return null means request has been handled , and calling routine should exit without further processing */
public CoverageCollection openCoverageDataset ( HttpServletRequest req , HttpServletResponse res , String reqPath ) throws IOException { } }

implementation:
if ( reqPath == null ) return null ; if ( reqPath . startsWith ( "/" ) ) reqPath = reqPath . substring ( 1 ) ; // see if its under resource control
if ( ! resourceControlOk ( req , res , reqPath ) ) return null ; DataRootManager . DataRootMatch match = dataRootManager . findDataRootMatch ( reqPath ) ; // first look for a feature collection
if ( ( match != null ) && ( match . dataRoot . getFeatureCollection ( ) != null ) ) { FeatureCollectionRef featCollection = match . dataRoot . getFeatureCollection ( ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "  -- DatasetHandler found FeatureCollection= " + featCollection ) ; InvDatasetFeatureCollection fc = featureCollectionCache . get ( featCollection ) ; CoverageCollection gds = fc . getGridCoverage ( match . remaining ) ; if ( gds == null ) throw new FileNotFoundException ( reqPath ) ; return gds ; } // otherwise assume its a local file
// try to open as a FeatureDatasetCoverage . This allows GRIB to be handle specially
String location = getLocationFromRequestPath ( reqPath ) ; if ( location != null ) { Optional < FeatureDatasetCoverage > opt = CoverageDatasetFactory . openCoverageDataset ( location ) ; if ( ! opt . isPresent ( ) ) throw new FileNotFoundException ( "Not a Grid Dataset " + reqPath + " err=" + opt . getErrorMessage ( ) ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "  -- DatasetHandler found FeatureCollection from file= " + location ) ; return opt . get ( ) . getSingleCoverageCollection ( ) ; // LOOK doesnt have to be single , then what is the URL ?
} // if ncml , must handle special , otherwise we ' re out of options for opening
// a coverage collection .
String ncml = datasetTracker . findNcml ( reqPath ) ; if ( ncml != null ) { Optional < FeatureDatasetCoverage > opt = CoverageDatasetFactory . openNcmlString ( ncml ) ; if ( ! opt . isPresent ( ) ) throw new FileNotFoundException ( "NcML is not a Grid Dataset " + reqPath + " err=" + opt . getErrorMessage ( ) ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "  -- DatasetHandler found FeatureCollection from NcML" ) ; return opt . get ( ) . getSingleCoverageCollection ( ) ; } return null ;


signature:
public class DatasetManager { /** * Check if this is making a request for a restricted dataset , and if so , if its allowed .
 * @ param req the request
 * @ param res the response
 * @ param reqPath the request path ; if null , use req . getPathInfo ( )
 * @ return true if ok to proceed . If false , the appropriate error or redirect message has been sent , the caller only needs to return . */
public boolean resourceControlOk ( HttpServletRequest req , HttpServletResponse res , String reqPath ) { } }

implementation:
if ( null == reqPath ) reqPath = TdsPathUtils . extractPath ( req , null ) ; // see if its under resource control
String rc = null ; DataRootManager . DataRootMatch match = dataRootManager . findDataRootMatch ( reqPath ) ; if ( match != null ) { rc = match . dataRoot . getRestrict ( ) ; // datasetScan , featCollection are restricted at the dataRoot
} if ( rc == null ) { rc = datasetTracker . findResourceControl ( reqPath ) ; // regular datasets tracked here
} return resourceAuthorized ( req , res , rc ) ;


signature:
public class DatasetManager { /** * DatasetSource */
public void registerDatasetSource ( String className ) { } }

implementation:
Class vClass ; try { vClass = DatasetManager . class . getClassLoader ( ) . loadClass ( className ) ; } catch ( ClassNotFoundException e ) { log . error ( "Attempt to load DatasetSource class " + className + " not found" ) ; return ; } if ( ! ( DatasetSource . class . isAssignableFrom ( vClass ) ) ) { log . error ( "Attempt to load class " + className + " does not implement " + DatasetSource . class . getName ( ) ) ; return ; } // create instance of the class
Object instance ; try { instance = vClass . newInstance ( ) ; } catch ( InstantiationException e ) { log . error ( "Attempt to load Viewer class " + className + " cannot instantiate, probably need default Constructor." ) ; return ; } catch ( IllegalAccessException e ) { log . error ( "Attempt to load Viewer class " + className + " is not accessible." ) ; return ; } registerDatasetSource ( ( DatasetSource ) instance ) ;


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

implementation: os . print ( function . getName ( ) + "(" ) ; Iterator it = children . iterator ( ) ; boolean first = true ; while ( it . hasNext ( ) ) { ValueClause vc = ( ValueClause ) it . next ( ) ; if ( ! first ) os . print ( "," ) ; vc . printConstraint ( os ) ; first = false ; } os . print ( ")" ) ;


signature:
public class GempakSoundingIOSP { /** * Is this a valid file ?
 * @ param raf RandomAccessFile to check
 * @ return true if a valid Gempak grid file
 * @ throws IOException problem reading file */
@ Override public boolean isValidFile ( RandomAccessFile raf ) throws IOException { } }

implementation:
if ( ! super . isValidFile ( raf ) ) { return false ; } // TODO : handle other types of surface files
return gemreader . getFileSubType ( ) . equals ( GempakSoundingFileReader . MERGED ) || gemreader . getFileSubType ( ) . equals ( GempakSoundingFileReader . UNMERGED ) ;


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

implementation: if ( gemreader == null ) { throw new IllegalStateException ( "reader not initialized" ) ; } return readSoundingData ( v2 , section , gemreader . getFileSubType ( ) . equals ( GempakSoundingFileReader . MERGED ) ) ;


signature:
public class GempakSoundingIOSP { /** * Read in the data for the variable . In this case , it should be
 * a Structure . The section should be rank 2 ( station , time ) .
 * @ param v2 variable to read
 * @ param section section of the variable
 * @ param isMerged flag for merged data or not
 * @ return the array of data
 * @ throws IOException problem reading the file */
private Array readSoundingData ( Variable v2 , Section section , boolean isMerged ) throws IOException { } }

implementation: Array array = null ; if ( v2 instanceof Structure ) { Range stationRange = section . getRange ( 0 ) ; Range timeRange = section . getRange ( 1 ) ; int size = stationRange . length ( ) * timeRange . length ( ) ; Structure pdata = ( Structure ) v2 ; StructureMembers members = pdata . makeStructureMembers ( ) ; ArrayStructureBB . setOffsets ( members ) ; ArrayStructureBB abb = new ArrayStructureBB ( members , new int [ ] { size } ) ; ByteBuffer buf = abb . getByteBuffer ( ) ; for ( int stnIdx : stationRange ) { for ( int timeIdx : timeRange ) { List < String > parts = ( isMerged ) ? ( ( GempakSoundingFileReader ) gemreader ) . getMergedParts ( ) : ( ( GempakSoundingFileReader ) gemreader ) . getUnmergedParts ( ) ; boolean allMissing = true ; for ( String part : parts ) { List < GempakParameter > params = gemreader . getParameters ( part ) ; GempakFileReader . RData vals = gemreader . DM_RDTR ( timeIdx + 1 , stnIdx + 1 , part ) ; ArraySequence aseq ; Sequence seq = ( Sequence ) pdata . findVariable ( part ) ; if ( vals == null ) { aseq = makeEmptySequence ( seq ) ; } else { allMissing = false ; aseq = makeArraySequence ( seq , params , vals . data ) ; } int index = abb . addObjectToHeap ( aseq ) ; buf . putInt ( index ) ; } buf . put ( ( byte ) ( allMissing ? 1 : 0 ) ) ; } } array = abb ; } return array ;


signature:
public class GempakSoundingIOSP { /** * Create an empty ArraySequence for missing data
 * @ param seq the Sequence variable
 * @ return the empty sequence */
private ArraySequence makeEmptySequence ( Sequence seq ) { } }

implementation: StructureMembers members = seq . makeStructureMembers ( ) ; return new ArraySequence ( members , new EmptyStructureDataIterator ( ) , - 1 ) ;


signature:
public class GempakSoundingIOSP { /** * Create an ArraySequence to hold the data
 * @ param seq the Sequence variable
 * @ param params the list of all GempakParameters possible in that sequence
 * @ param values the values that were read
 * @ return the ArraySequence */
private ArraySequence makeArraySequence ( Sequence seq , List < GempakParameter > params , float [ ] values ) { } }

implementation: if ( values == null ) { return makeEmptySequence ( seq ) ; } int numLevels = values . length / params . size ( ) ; StructureMembers members = seq . makeStructureMembers ( ) ; int offset = ArrayStructureBB . setOffsets ( members ) ; int size = offset * numLevels ; byte [ ] bytes = new byte [ size ] ; ByteBuffer buf = ByteBuffer . wrap ( bytes ) ; ArrayStructureBB abb = new ArrayStructureBB ( members , new int [ ] { numLevels } , buf , 0 ) ; int var = 0 ; for ( int i = 0 ; i < numLevels ; i ++ ) { for ( GempakParameter param : params ) { if ( members . findMember ( param . getName ( ) ) != null ) { buf . putFloat ( values [ var ] ) ; } var ++ ; } } return new ArraySequence ( members , new SequenceIterator ( numLevels , abb ) , numLevels ) ;


signature:
public class GempakSoundingIOSP { /** * Build the netCDF file
 * @ throws IOException problem reading the file */
protected void fillNCFile ( ) throws IOException { } }

implementation: String fileType = gemreader . getFileSubType ( ) ; buildFile ( fileType . equals ( GempakSoundingFileReader . MERGED ) ) ;


signature:
public class GempakSoundingIOSP { /** * Build a standard station structure
 * @ param isMerged true if this is a merged file */
private void buildFile ( boolean isMerged ) { } }

implementation:
// Build station list
List < GempakStation > stations = gemreader . getStations ( ) ; Dimension station = new Dimension ( "station" , stations . size ( ) , true ) ; ncfile . addDimension ( null , station ) ; ncfile . addDimension ( null , DIM_LEN8 ) ; ncfile . addDimension ( null , DIM_LEN4 ) ; ncfile . addDimension ( null , DIM_LEN2 ) ; List < Variable > stationVars = makeStationVars ( stations , station ) ; // loop through and add to ncfile
for ( Variable stnVar : stationVars ) { ncfile . addVariable ( null , stnVar ) ; } // Build variable list ( var ( station , time ) )
// time
List < Date > timeList = gemreader . getDates ( ) ; int numTimes = timeList . size ( ) ; Dimension times = new Dimension ( TIME_VAR , numTimes , true ) ; ncfile . addDimension ( null , times ) ; Array varArray ; Variable timeVar = new Variable ( ncfile , null , null , TIME_VAR , DataType . DOUBLE , TIME_VAR ) ; timeVar . addAttribute ( new Attribute ( CDM . UNITS , "seconds since 1970-01-01 00:00:00" ) ) ; timeVar . addAttribute ( new Attribute ( "long_name" , TIME_VAR ) ) ; varArray = new ArrayDouble . D1 ( numTimes ) ; int i = 0 ; for ( Date date : timeList ) { ( ( ArrayDouble . D1 ) varArray ) . set ( i , date . getTime ( ) / 1000.d ) ; i ++ ; } timeVar . setCachedData ( varArray , false ) ; ncfile . addVariable ( null , timeVar ) ; // build the data structure
List < Dimension > stationTime = new ArrayList < > ( ) ; stationTime . add ( station ) ; stationTime . add ( times ) ; String structName = ( isMerged ) ? GempakSoundingFileReader . MERGED : GempakSoundingFileReader . UNMERGED ; structName = structName + "Sounding" ; Structure sVar = new Structure ( ncfile , null , null , structName ) ; sVar . setDimensions ( stationTime ) ; sVar . addAttribute ( new Attribute ( CF . COORDINATES , "time SLAT SLON SELV" ) ) ; List < String > sequenceNames ; if ( isMerged ) { sequenceNames = new ArrayList < > ( ) ; sequenceNames . add ( GempakSoundingFileReader . SNDT ) ; } else { sequenceNames = ( ( GempakSoundingFileReader ) gemreader ) . getUnmergedParts ( ) ; } for ( String seqName : sequenceNames ) { Sequence paramData = makeSequence ( sVar , seqName , false ) ; if ( paramData == null ) { continue ; } sVar . addMemberVariable ( paramData ) ; } sVar . addMemberVariable ( makeMissingVariable ( ) ) ; ncfile . addAttribute ( null , new Attribute ( "CF:featureType" , CF . FeatureType . timeSeriesProfile . toString ( ) ) ) ; ncfile . addVariable ( null , sVar ) ;


signature:
public class GempakSoundingIOSP { /** * Make a Sequence for the part
 * @ param parent parent structure
 * @ param partName partname
 * @ param includeMissing true to include the missing variable
 * @ return a Structure */
protected Sequence makeSequence ( Structure parent , String partName , boolean includeMissing ) { } }

implementation: List < GempakParameter > params = gemreader . getParameters ( partName ) ; if ( params == null ) { return null ; } Sequence sVar = new Sequence ( ncfile , null , parent , partName ) ; sVar . setDimensions ( "" ) ; for ( GempakParameter param : params ) { Variable v = makeParamVariable ( param , null ) ; addVerticalCoordAttribute ( v ) ; sVar . addMemberVariable ( v ) ; } if ( includeMissing ) { sVar . addMemberVariable ( makeMissingVariable ( ) ) ; } return sVar ;


signature:
public class GempakSoundingIOSP { /** * Add the vertical coordinate variables if necessary
 * @ param v the variable */
private void addVerticalCoordAttribute ( Variable v ) { } }

implementation: GempakSoundingFileReader gsfr = ( GempakSoundingFileReader ) gemreader ; int vertType = gsfr . getVerticalCoordinate ( ) ; String pName = v . getFullName ( ) ; if ( gemreader . getFileSubType ( ) . equals ( GempakSoundingFileReader . MERGED ) ) { if ( ( vertType == GempakSoundingFileReader . PRES_COORD ) && pName . equals ( "PRES" ) ) { v . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Pressure . name ( ) ) ) ; } else if ( ( vertType == GempakSoundingFileReader . HGHT_COORD ) && ( pName . equals ( "HGHT" ) || pName . equals ( "MHGT" ) || pName . equals ( "DHGT" ) ) ) { v . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Height . name ( ) ) ) ; } } else if ( pName . equals ( "PRES" ) ) { v . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . Pressure . name ( ) ) ) ; }


signature:
public class InvCatalogFactory { /** * This allows the possibility of reading a catalog in another thread . The default
 * implementation does not do that , but a subclass may override and implement .
 * If the catalog is read successfully , it is passed on to the callback .
 * @ param uriString : read this catalog .
 * @ param callback : call this if successfully read .
 * @ see CatalogSetCallback */
public void readXMLasynch ( String uriString , CatalogSetCallback callback ) { } }

implementation: InvCatalogImpl cat = readXML ( uriString ) ; callback . setCatalog ( cat ) ;


signature:
public class InvCatalogFactory { /** * Create an InvCatalog from an XML document at a named URI .
 * Failures and exceptions are handled
 * by causing validate ( ) to fail . Therefore , be sure to call validate ( ) before trying
 * to use the InvCatalog object .
 * @ param uriString : the URI name that the XML doc is at . May start with a " file : "
 * @ return an InvCatalogImpl object */
public InvCatalogImpl readXML ( String uriString ) { } }

implementation:
URI uri ; try { uri = new URI ( uriString ) ; } catch ( URISyntaxException e ) { InvCatalogImpl cat = new InvCatalogImpl ( uriString , null , null ) ; cat . appendErrorMessage ( "**Fatal:  InvCatalogFactory.readXML URISyntaxException on URL (" + uriString + ") " + e . getMessage ( ) + "\n" , true ) ; return cat ; } /* if ( uriString . startsWith ( " file : " ) ) {
 String filename = uriString . substring ( 5 ) ;
 File f = new File ( filename ) ;
 if ( f . exists ( ) ) {
 try {
 return readXML ( new FileInputStream ( f ) , uri ) ;
 } catch ( Exception e ) {
 InvCatalogImpl cat = new InvCatalogImpl ( uriString , null , null ) ;
 cat . appendErrorMessage ( " * * Fatal : InvCatalogFactory . readXML error ( " +
 uriString + " ) " + e . getMessage ( ) + " \ n " , true ) ; */
return readXML ( uri ) ;


signature:
public class InvCatalogFactory { /** * Read an InvCatalog from an a URI .
 * Failures and exceptions are handled
 * by causing validate ( ) to fail . Therefore , be sure to call validate ( ) before trying
 * to use the InvCatalog object .
 * @ param uri : the URI of the document , used for resolving reletive references .
 * @ return an InvCatalogImpl object */
public InvCatalogImpl readXML ( URI uri ) { } }

implementation:
// get ready for XML parsing
warnMessages . setLength ( 0 ) ; errMessages . setLength ( 0 ) ; fatalMessages . setLength ( 0 ) ; org . jdom2 . Document jdomDoc ; InputStream is = null ; try { jdomDoc = saxBuilder . build ( uri . toURL ( ) ) ; // HttpUriResolver httpUriResolver = HttpUriResolver . newDefaultUriResolver ( ) ;
// String s = httpUriResolver . getString ( url ) ;
// / / StringReader
// is = new BufferedInputStream ( httpUriResolver . getInputStream ( url ) , 100000 ) ;
// jdomDoc = saxBuilder . build ( is ) ;
} catch ( Exception e ) { InvCatalogImpl cat = new InvCatalogImpl ( uri . toString ( ) , null , null ) ; cat . appendErrorMessage ( "**Fatal:  InvCatalogFactory.readXML failed" + "\n Exception= " + e . getClass ( ) . getName ( ) + " " + e . getMessage ( ) + "\n fatalMessages= " + fatalMessages . toString ( ) + "\n errMessages= " + errMessages . toString ( ) + "\n warnMessages= " + warnMessages . toString ( ) + "\n" , true ) ; return cat ; } finally { if ( is != null ) try { is . close ( ) ; } catch ( IOException e ) { log . warn ( "Failed to close input stream [" + uri . toString ( ) + "]." ) ; } } if ( fatalMessages . length ( ) > 0 ) { InvCatalogImpl cat = new InvCatalogImpl ( uri . toString ( ) , null , null ) ; cat . appendErrorMessage ( "**Fatal:  InvCatalogFactory.readXML XML Fatal error(s) =\n" + fatalMessages . toString ( ) + "\n" , true ) ; return cat ; } return readXML ( jdomDoc , uri ) ;


signature:
public class InvCatalogFactory { /** * Create an InvCatalog by reading catalog XML from a String .
 * Failures and exceptions are handled by causing validate ( ) to
 * fail . Therefore , be sure to call validate ( ) before trying to use
 * the InvCatalog object .
 * @ param catAsString : the String from which to read the catalog .
 * @ param baseUri : the base URI of the document , used for resolving reletive references .
 * @ return an InvCatalogImpl object */
public InvCatalogImpl readXML ( String catAsString , URI baseUri ) { } }

implementation: return readXML ( new StringReader ( catAsString ) , baseUri ) ;


signature:
public class InvCatalogFactory { /** * Create an InvCatalog by reading catalog XML from a StringReader .
 * Failures and exceptions are handled by causing validate ( ) to
 * fail . Therefore , be sure to call validate ( ) before trying to use
 * the InvCatalog object .
 * @ param catAsStringReader : the StreamReader from which to read the catalog .
 * @ param baseUri : the base URI of the document , used for resolving reletive references .
 * @ return an InvCatalogImpl object */
public InvCatalogImpl readXML ( StringReader catAsStringReader , URI baseUri ) { } }

implementation: XMLEntityResolver resolver = new XMLEntityResolver ( false ) ; SAXBuilder builder = resolver . getSAXBuilder ( ) ; Document inDoc ; try { inDoc = builder . build ( catAsStringReader ) ; } catch ( Exception e ) { InvCatalogImpl cat = new InvCatalogImpl ( baseUri . toString ( ) , null , null ) ; cat . appendErrorMessage ( "**Fatal:  InvCatalogFactory.readXML(String catAsString, URI url) failed:" + "\n  Exception= " + e . getClass ( ) . getName ( ) + " " + e . getMessage ( ) + "\n  fatalMessages= " + fatalMessages . toString ( ) + "\n  errMessages= " + errMessages . toString ( ) + "\n  warnMessages= " + warnMessages . toString ( ) + "\n" , true ) ; return cat ; } return readXML ( inDoc , baseUri ) ;


signature:
public class InvCatalogFactory { /** * Create an InvCatalog from an InputStream .
 * Failures and exceptions are handled
 * by causing validate ( ) to fail . Therefore , be sure to call validate ( ) before trying
 * to use the InvCatalog object .
 * @ param docIs : the InputStream to read from
 * @ param uri : the URI of the document , used for resolving reletive references .
 * @ return an InvCatalogImpl object */
public InvCatalogImpl readXML ( InputStream docIs , URI uri ) { } }

implementation:
// get ready for XML parsing
warnMessages . setLength ( 0 ) ; errMessages . setLength ( 0 ) ; fatalMessages . setLength ( 0 ) ; org . jdom2 . Document jdomDoc ; try { jdomDoc = saxBuilder . build ( docIs ) ; } catch ( Exception e ) { InvCatalogImpl cat = new InvCatalogImpl ( uri . toString ( ) , null , uri ) ; cat . appendErrorMessage ( "**Fatal:  InvCatalogFactory.readXML failed" + "\n Exception= " + e . getClass ( ) . getName ( ) + " " + e . getMessage ( ) + "\n fatalMessages= " + fatalMessages . toString ( ) + "\n errMessages= " + errMessages . toString ( ) + "\n warnMessages= " + warnMessages . toString ( ) + "\n" , true ) ; return cat ; } if ( fatalMessages . length ( ) > 0 ) { InvCatalogImpl cat = new InvCatalogImpl ( uri . toString ( ) , null , uri ) ; cat . appendErrorMessage ( "**Fatal:  InvCatalogFactory.readXML XML Fatal error(s) =\n" + fatalMessages . toString ( ) + "\n" , true ) ; return cat ; } return readXML ( jdomDoc , uri ) ;


signature:
public class InvCatalogFactory { /** * Create an InvCatalog from a JDOM document .
 * Failures and exceptions are handled
 * by causing validate ( ) to fail . Therefore , be sure to call validate ( ) before trying
 * to use the InvCatalog object .
 * @ param jdomDoc a parsed JDOM Document
 * @ param uri : the URI of the document , used for resolving reletive references .
 * @ return an InvCatalogImpl object */
public InvCatalogImpl readXML ( org . jdom2 . Document jdomDoc , URI uri ) { } }

implementation:
// decide on converter based on namespace
Element root = jdomDoc . getRootElement ( ) ; if ( ! root . getName ( ) . equalsIgnoreCase ( "catalog" ) ) { throw new IllegalArgumentException ( "not a catalog" ) ; } String namespace = root . getNamespaceURI ( ) ; InvCatalogConvertIF fac = converters . get ( namespace ) ; if ( fac == null ) { fac = defaultConverter ; // LOOK
if ( debugVersion ) System . out . println ( "use default converter " + fac . getClass ( ) . getName ( ) + "; no namespace " + namespace ) ; } else if ( debugVersion ) System . out . println ( "use converter " + fac . getClass ( ) . getName ( ) + " based on namespace " + namespace ) ; InvCatalogImpl cat = fac . parseXML ( this , jdomDoc , uri ) ; cat . setCreateFrom ( uri . toString ( ) ) ; // cat . setCatalogFactory ( this ) ;
// cat . setCatalogConverter ( fac ) ;
cat . finish ( ) ; /* if ( showCatalogXML ) {
 System . out . println ( " * * * catalog / showCatalogXML " ) ;
 try {
 writeXML ( cat , System . out ) ;
 catch ( IOException ex ) {
 log . warn ( " Error writing catalog for debugging " , ex ) ; */
if ( fatalMessages . length ( ) > 0 ) cat . appendErrorMessage ( fatalMessages . toString ( ) , true ) ; // makes it invalid
if ( errMessages . length ( ) > 0 ) cat . appendErrorMessage ( errMessages . toString ( ) , false ) ; // doesnt make it invalid
if ( warnMessages . length ( ) > 0 ) cat . appendErrorMessage ( warnMessages . toString ( ) , false ) ; // doesnt make it invalid
return cat ;


signature:
public class InvCatalogFactory { /** * Write the InvCatalogImpl to the OutputStream as a InvCatalog 1.0 document .
 * @ param catalog - the catalog to be written
 * @ param os - the OutputStream to write to
 * @ param raw if true , write raw , vs converted
 * @ throws IOException when the OutputStream can ' t be written
 * @ throws IllegalStateException when the factory doesn ' t know how to write a 1.0 document . */
public void writeXML ( InvCatalogImpl catalog , OutputStream os , boolean raw ) throws IOException { } }

implementation: InvCatalogConvertIF converter = this . getCatalogConverter ( XMLEntityResolver . CATALOG_NAMESPACE_10 ) ; converter . writeXML ( catalog , os , raw ) ;


signature:
public class InvCatalogFactory { /** * Write the catalog as an XML document to the specified filename .
 * @ param catalog write this catalog
 * @ param filename write to this filename
 * @ throws IOException on an error . */
public void writeXML ( InvCatalogImpl catalog , String filename ) throws IOException { } }

implementation: BufferedOutputStream os = new BufferedOutputStream ( new FileOutputStream ( filename ) ) ; writeXML ( catalog , os , false ) ; os . close ( ) ;


signature:
public class InvCatalogFactory { /** * Write the catalog as an XML document to a String .
 * @ param catalog write this catalog
 * @ return string containing XML representation
 * @ throws IOException on write error */
public String writeXML ( InvCatalogImpl catalog ) throws IOException { } }

implementation: ByteArrayOutputStream os = new ByteArrayOutputStream ( 10000 ) ; writeXML ( catalog , os , false ) ; return new String ( os . toByteArray ( ) , CDM . utf8Charset ) ;


signature:
public class InvCatalogFactory { /** * Find the MetadataConverterIF registered for this key
 * @ param key search on this key
 * @ return MetadataConverterIF else null */
public MetadataConverterIF getMetadataConverter ( String key ) { } }

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


signature:
public class InvCatalogFactory { /** * testing */
private static InvCatalogImpl doOne ( InvCatalogFactory fac , String urlString , boolean show ) { } }

implementation:
System . out . println ( "***read " + urlString ) ; if ( show ) System . out . println ( " original catalog=\n" + IO . readURLcontents ( urlString ) ) ; try { InvCatalogImpl cat = fac . readXML ( new URI ( urlString ) ) ; StringBuilder buff = new StringBuilder ( ) ; boolean isValid = cat . check ( buff , false ) ; System . out . println ( "catalog <" + cat . getName ( ) + "> " + ( isValid ? "is" : "is not" ) + " valid" ) ; System . out . println ( " validation output=\n" + buff ) ; // if ( show ) System . out . println ( " parsed catalog = \ n " + fac . writeXML ( cat ) ) ;
// System . out . println ( " - - - - - \ n " + cat . dump ( ) ) ;
return cat ; } catch ( Exception e ) { e . printStackTrace ( ) ; return null ; }


signature:
public class DerivedUnitImpl { /** * Returns the identifiers associated with the dimensionless , derived unit .
 * @ return The identifiers of the dimensionless , derived unit . */
private static UnitName dimensionlessID ( ) { } }

implementation: UnitName id ; try { id = UnitName . newUnitName ( "1" , "1" , "1" ) ; } catch ( final NameException e ) { id = null ; } return id ;


signature:
public class DerivedUnitImpl { /** * Multiplies this derived unit by another .
 * @ param that
 * The other unit .
 * @ return The product of the two units .
 * @ throws MultiplyException
 * Can ' t multiply these units . */
@ Override protected Unit myMultiplyBy ( final Unit that ) throws MultiplyException { } }

implementation: Unit result ; if ( dimension . getRank ( ) == 0 ) { result = that ; } else { if ( ! ( that instanceof DerivedUnit ) ) { result = that . multiplyBy ( this ) ; } else { final UnitDimension thatDimension = ( ( DerivedUnit ) that ) . getDimension ( ) ; result = thatDimension . getRank ( ) == 0 ? this : new DerivedUnitImpl ( dimension . multiplyBy ( thatDimension ) ) ; } } return result ;


signature:
public class DerivedUnitImpl { /** * Divides this derived unit by another .
 * @ param that
 * The other unit .
 * @ return The quotient of the two units .
 * @ throws OperationException
 * Can ' t divide these units . */
@ Override protected Unit myDivideBy ( final Unit that ) throws OperationException { } }

implementation: Unit result ; if ( dimension . getRank ( ) == 0 ) { result = that . raiseTo ( - 1 ) ; } else { if ( ! ( that instanceof DerivedUnit ) ) { result = that . divideInto ( this ) ; } else { final UnitDimension thatDimension = ( ( DerivedUnit ) that ) . getDimension ( ) ; result = thatDimension . getRank ( ) == 0 ? this : new DerivedUnitImpl ( dimension . divideBy ( thatDimension ) ) ; } } return result ;


signature:
public class DerivedUnitImpl { /** * Converts numerical values from this unit to the derived unit . Obviously ,
 * the numerical values are unchanged .
 * @ param input
 * The numerical values in this unit .
 * @ param output
 * The numerical values in the derived unit . May be the same
 * array as < code > input < / code > .
 * @ return < code > output < / code > . */
public final float [ ] toDerivedUnit ( final float [ ] input , final float [ ] output ) { } }

implementation: if ( input != output ) { System . arraycopy ( input , 0 , output , 0 , input . length ) ; } return output ;


signature:
public class DerivedUnitImpl { /** * Indicates if values in this unit are convertible with another unit .
 * @ param that
 * The other unit .
 * @ return < code > true < / code > if and only if values in this unit are
 * convertible to values in < code >
 * that < / code > . */
@ Override public final boolean isCompatible ( final Unit that ) { } }

implementation: final DerivedUnit unit = that . getDerivedUnit ( ) ; return equals ( unit ) || isReciprocalOf ( unit ) ;


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

implementation: final BaseUnit second = BaseUnit . getOrCreate ( UnitName . newUnitName ( "second" , null , "s" ) , BaseQuantity . TIME ) ; System . out . println ( "second = \"" + second + '"' ) ; final BaseUnit meter = BaseUnit . getOrCreate ( UnitName . newUnitName ( "meter" , null , "m" ) , BaseQuantity . LENGTH ) ; System . out . println ( "meter = \"" + meter + '"' ) ; final DerivedUnitImpl meterSecond = ( DerivedUnitImpl ) meter . myMultiplyBy ( second ) ; System . out . println ( "meterSecond = \"" + meterSecond + '"' ) ; final DerivedUnitImpl meterPerSecond = ( DerivedUnitImpl ) meter . myDivideBy ( second ) ; System . out . println ( "meterPerSecond = \"" + meterPerSecond + '"' ) ; final DerivedUnitImpl secondPerMeter = ( DerivedUnitImpl ) second . myDivideBy ( meter ) ; System . out . println ( "secondPerMeter = \"" + secondPerMeter + '"' ) ; System . out . println ( "meterPerSecond.isReciprocalOf(secondPerMeter)=" + meterPerSecond . isReciprocalOf ( secondPerMeter ) ) ; System . out . println ( "meter.toDerivedUnit(1.0)=" + meter . toDerivedUnit ( 1.0 ) ) ; System . out . println ( "meter.toDerivedUnit(new double[] {1,2,3}, new double[3])[1]=" + meter . toDerivedUnit ( new double [ ] { 1 , 2 , 3 } , new double [ 3 ] ) [ 1 ] ) ; System . out . println ( "meter.fromDerivedUnit(1.0)=" + meter . fromDerivedUnit ( 1.0 ) ) ; System . out . println ( "meter.fromDerivedUnit(new double[] {1,2,3}, new double[3])[2]=" + meter . fromDerivedUnit ( new double [ ] { 1 , 2 , 3 } , new double [ 3 ] ) [ 2 ] ) ; System . out . println ( "meter.isCompatible(meter)=" + meter . isCompatible ( meter ) ) ; System . out . println ( "meter.isCompatible(second)=" + meter . isCompatible ( second ) ) ; System . out . println ( "meter.equals(meter)=" + meter . equals ( meter ) ) ; System . out . println ( "meter.equals(second)=" + meter . equals ( second ) ) ; System . out . println ( "meter.isDimensionless()=" + meter . isDimensionless ( ) ) ; final Unit sPerS = second . myDivideBy ( second ) ; System . out . println ( "sPerS = \"" + sPerS + '"' ) ; System . out . println ( "sPerS.isDimensionless()=" + sPerS . isDimensionless ( ) ) ; meterPerSecond . raiseTo ( 2 ) ; meter . myDivideBy ( meterPerSecond ) ;


signature:
public class GMLFeatureWriter { /** * Checks the type of the Simple Geom and calls the appropriate method to build the xml
 * @ param geom the Simple Geom
 * @ return the xml */
public String writeFeature ( SimpleGeometry geom ) { } }

implementation: if ( geom instanceof Point ) return writePoint ( ( Point ) geom ) ; else if ( geom instanceof Line ) return writeLine ( ( Line ) geom ) ; else if ( geom instanceof Polygon ) return writePolygon ( ( Polygon ) geom ) ; else return null ;


signature:
public class GMLFeatureWriter { /** * Takes in a point and writes its xml
 * @ param point the point
 * @ return the xml */
private String writePoint ( Point point ) { } }

implementation: String xml = "" ; xml += "<gml:Point srsName=\"http://www.opengis.net/gml/srs/epsg.xml@900913\" srsDimension=\"2\">" + "<gml:pos>" + point . getX ( ) + " " + point . getY ( ) + "</gml:pos>" + "</gml:Point>" ; return xml ;


signature:
public class GMLFeatureWriter { /** * Takes in a line and iterates through all its points , writing the posList to xml
 * @ param line the line
 * @ return the xml */
private String writeLine ( Line line ) { } }

implementation: String xml = "" ; xml += "<gml:LineString><gml:posList>" ; for ( Point point : line . getPoints ( ) ) { xml += point . getX ( ) + " " + point . getY ( ) + " " ; } xml += "</gml:posList></gml:LineString>" ; return xml ;


signature:
public class GMLFeatureWriter { /** * Takes in a polygon , checks whether it is an interior or exterior ring , and writes the corresponding xml .
 * Iterates through all linked polygons
 * @ param polygon the polygon
 * @ return the xml */
private String writePolygon ( Polygon poly ) { } }

implementation:
String xml = "" ; xml += "<gml:Polygon>" ; Polygon polygon = poly ; // while ( polygon ! = null ) {
if ( ! polygon . getInteriorRing ( ) ) { xml += "<gml:exterior><gml:LinearRing><gml:posList>" ; for ( Point point : polygon . getPoints ( ) ) { xml += point . getX ( ) + " " + point . getY ( ) + " " ; } xml += "</gml:posList></gml:LinearRing></gml:exterior>" ; } else { xml += "<gml:interior><gml:LinearRing><gml:posList>" ; for ( Point point : polygon . getPoints ( ) ) { xml += point . getX ( ) + " " + point . getY ( ) + " " ; } xml += "</gml:posList></gml:LinearRing></gml:interior>" ; } // polygon = polygon . getNext ( ) ;
xml += "</gml:Polygon>" ; return xml ;


signature:
public class DOM4Parser { /** * Parser API */
public boolean parse ( String input ) throws SAXException { } }

implementation: try { DocumentBuilderFactory domfactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder dombuilder = domfactory . newDocumentBuilder ( ) ; StringReader rdr = new StringReader ( input ) ; InputSource src = new InputSource ( rdr ) ; Document doc = dombuilder . parse ( src ) ; doc . getDocumentElement ( ) . normalize ( ) ; rdr . close ( ) ; parseresponse ( doc . getDocumentElement ( ) ) ; return true ; } catch ( ParserConfigurationException | IOException e ) { throw new SAXException ( e ) ; }


signature:
public class DOM4Parser { /** * XML Attribute utilities */
protected String pull ( Node n , String name ) { } }

implementation: NamedNodeMap map = n . getAttributes ( ) ; Node attr = map . getNamedItem ( name ) ; if ( attr == null ) return null ; return attr . getNodeValue ( ) ;


signature:
public class DOM4Parser { /** * Attribute construction */
DapAttribute makeAttribute ( DapSort sort , String name , DapType basetype , List < String > nslist ) throws ParseException { } }

implementation: DapAttribute attr = factory . newAttribute ( name , basetype ) ; if ( sort == DapSort . ATTRIBUTE ) { attr . setBaseType ( basetype ) ; } attr . setNamespaceList ( nslist ) ; return attr ;


signature:
public class DOM4Parser { /** * Return the subnodes of a node with non - element nodes suppressed
 * @ param parent
 * @ return list of element children */
List < Node > getSubnodes ( Node parent ) { } }

implementation: List < Node > subs = new ArrayList < > ( ) ; NodeList nodes = parent . getChildNodes ( ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; i ++ ) { Node n = nodes . item ( i ) ; if ( n . getNodeType ( ) == Node . ELEMENT_NODE ) subs . add ( n ) ; } return subs ;


signature:
public class DOM4Parser { /** * Recursive descent parser */
protected void parseresponse ( Node root ) throws ParseException { } }

implementation: String elemname = root . getNodeName ( ) ; if ( elemname . equalsIgnoreCase ( "Error" ) ) { parseerror ( root ) ; } else if ( elemname . equalsIgnoreCase ( "Dataset" ) ) { parsedataset ( root ) ; } else throw new ParseException ( "Unexpected response root: " + elemname ) ;


signature:
public class DOM4Parser { /** * Pass reserved xml attributes unchanged
 * @ param node
 * @ param dap
 * @ throws ParseException */
protected void passReserved ( Node node , DapNode dap ) throws ParseException { } }

implementation: try { NamedNodeMap attrs = node . getAttributes ( ) ; for ( int i = 0 ; i < attrs . getLength ( ) ; i ++ ) { Node n = attrs . item ( i ) ; String key = n . getNodeName ( ) ; String value = n . getNodeValue ( ) ; if ( isReserved ( key ) ) dap . addXMLAttribute ( key , value ) ; } } catch ( DapException de ) { throw new ParseException ( de ) ; }


signature:
public class CFSimpleGeometryHelper { /** * Gets the subset string to be used in NetCDFFile . read given a variable and some indicies .
 * useful for subsetting timeseries
 * @ param var variable to subset
 * @ param beginInd beginning index ( inclusive )
 * @ param endInd end index ( exclusive )
 * @ param id The SimpleGeometryID to index
 * @ return subset string */
public static String getSubsetString ( Variable var , int beginInd , int endInd , int id ) { } }

implementation:
if ( var == null ) return null ; String subStr = "" ; List < Dimension > dimList = var . getDimensions ( ) ; // Enforce two dimension arrays
if ( dimList . size ( ) > 2 || dimList . size ( ) < 1 ) { return null ; } for ( int i = 0 ; i < dimList . size ( ) ; i ++ ) { Dimension dim = dimList . get ( i ) ; if ( dim == null ) continue ; // If not CF Time then select only that ID
if ( ! CF . TIME . equalsIgnoreCase ( dim . getShortName ( ) ) && ! CF . TIME . equalsIgnoreCase ( dim . getFullNameEscaped ( ) ) ) { subStr += id ; } // Otherwise subset based on time
else { if ( beginInd < 0 || endInd < 0 ) subStr += ":" ; else subStr += ( beginInd + ":" + endInd ) ; } if ( i < dimList . size ( ) - 1 ) { subStr += "," ; } } return subStr ;


signature:
public class ArrayStructureMA { /** * Turn any ArrayStructure into a ArrayStructureMA
 * @ param from copy from here . If from is a ArrayStructureMA , return it .
 * @ return equivalent ArrayStructureMA
 * @ throws java . io . IOException on error reading a sequence */
static public ArrayStructureMA factoryMA ( ArrayStructure from ) throws IOException { } }

implementation:
if ( from instanceof ArrayStructureMA ) return ( ArrayStructureMA ) from ; // To create an ArrayStructureMA that we can iterate over later , we need to know the shape of " from " .
if ( from . getSize ( ) > 0 ) { ArrayStructureMA to = new ArrayStructureMA ( new StructureMembers ( from . getStructureMembers ( ) ) , from . getShape ( ) ) ; for ( StructureMembers . Member m : from . getMembers ( ) ) { to . setMemberArray ( m . getName ( ) , from . extractMemberArray ( m ) ) ; } return to ; } // from . getSize ( ) < = 0 . This usually means that " from " is an ArraySequence , and that we won ' t know its size until
// we iterate over it . extractMemberArray ( ) will do that iteration for us , and then we can use the size of the
// array it returns to determine the shape of " from " .
int numRecords = - 1 ; Map < String , Array > memberArrayMap = new LinkedHashMap < > ( ) ; for ( StructureMembers . Member m : from . getMembers ( ) ) { Array array = from . extractMemberArray ( m ) ; assert array . getSize ( ) > 0 : "array's size should have been computed in extractMemberArray()." ; int firstDimLen = array . getShape ( ) [ 0 ] ; if ( numRecords == - 1 ) { numRecords = firstDimLen ; } else { assert numRecords == firstDimLen : String . format ( "Expected all structure members to have the same first" + "dimension length, but %d != %d." , numRecords , firstDimLen ) ; } memberArrayMap . put ( m . getName ( ) , array ) ; } int [ ] shape ; if ( numRecords == - 1 ) { shape = new int [ ] { 0 } ; // " from " really was empty .
} else { shape = new int [ ] { numRecords } ; } ArrayStructureMA to = new ArrayStructureMA ( new StructureMembers ( from . getStructureMembers ( ) ) , shape ) ; for ( Map . Entry < String , Array > entry : memberArrayMap . entrySet ( ) ) { to . setMemberArray ( entry . getKey ( ) , entry . getValue ( ) ) ; } return to ;


signature:
public class ArrayStructureMA { /** * Set the data array for this member .
 * @ param memberName name of member
 * @ param data Array for this member . */
public void setMemberArray ( String memberName , Array data ) { } }

implementation: StructureMembers . Member m = members . findMember ( memberName ) ; m . setDataArray ( data ) ;


signature:
public class ArrayStructureMA { /** * Create an ArrayStructure for a Structure . Allow nested Structures .
 * Create the data arrays , and an iterator .
 * @ param from copy from here . If from is a ArrayStructureMA , return it .
 * @ param shape the shape of the ArrayStructure
 * @ return equivilent ArrayStructureMA
 * @ throws java . io . IOException on error reading a sequence */
static public ArrayStructureMA factoryMA ( Structure from , int [ ] shape ) throws IOException { } }

implementation:
StructureMembers sm = from . makeStructureMembers ( ) ; for ( Variable v : from . getVariables ( ) ) { Array data ; if ( v instanceof Sequence ) { data = Array . factory ( DataType . SEQUENCE , shape ) ; // an array sequence - one for each parent element
// Structure s = ( Structure ) v ;
// StructureMembers smn = s . makeStructureMembers ( ) ;
// data = new ArraySequenceNested ( smn , ( int ) Index . computeSize ( v . getShapeAll ( ) ) ) ; / / ? ?
} else if ( v instanceof Structure ) data = ArrayStructureMA . factoryMA ( ( Structure ) v , combine ( shape , v . getShape ( ) ) ) ; else data = Array . factory ( v . getDataType ( ) , combine ( shape , v . getShape ( ) ) ) ; StructureMembers . Member m = sm . findMember ( v . getShortName ( ) ) ; m . setDataArray ( data ) ; } return new ArrayStructureMA ( sm , shape ) ;


signature:
public class SimpleGeometryReader { /** * Returns a Polygon given a variable name and the geometric index . If the Polygon is not found it will return null . If the Polygon is a part of the Multi - Polygon , it will return the head
 * ( the first Polygon in the series which constitutes the Multi - Polygon ) .
 * @ param name of the variable which holds the Polygon
 * @ param index of the Polygon within the variable
 * @ return a new polygon with all associated information */
public Polygon readPolygon ( String name , int index ) { } }

implementation:
Variable polyvar = ds . findVariable ( name ) ; if ( polyvar == null ) return null ; Polygon poly = null ; // CFConvention
if ( ds . findGlobalAttribute ( CF . CONVENTIONS ) != null ) if ( ucar . nc2 . dataset . conv . CF1Convention . getVersion ( ds . findGlobalAttribute ( CF . CONVENTIONS ) . getStringValue ( ) ) >= 8 ) poly = new CFPolygon ( ) ; if ( poly == null ) return null ; else return poly . setupPolygon ( ds , polyvar , index ) ;


signature:
public class SimpleGeometryReader { /** * Returns a Line given a variable name and the geometric index . If the Line is not found it will return null . If the Line is a part of the Multi - Line , it will return the head
 * ( the first Line in the series which constitutes the Multi - Line ) .
 * @ param name of the variable which holds the Line
 * @ param index of the Line within the variable
 * @ return a new line with all associated information */
public Line readLine ( String name , int index ) { } }

implementation:
Variable linevar = ds . findVariable ( name ) ; if ( linevar == null ) return null ; Line line = null ; // CFConvention
if ( ds . findGlobalAttribute ( CF . CONVENTIONS ) != null ) if ( ucar . nc2 . dataset . conv . CF1Convention . getVersion ( ds . findGlobalAttribute ( CF . CONVENTIONS ) . getStringValue ( ) ) >= 8 ) line = new CFLine ( ) ; if ( line == null ) return null ; else return line . setupLine ( ds , linevar , index ) ;


signature:
public class SimpleGeometryReader { /** * Returns a Point given a variable name and the geometric index . If the Point is not found it will return null . If the Point is a part of the Multi - Point , it will return the head
 * ( the first Point in the series which constitutes the Multi - Point ) .
 * @ param name of the variable which holds the Point
 * @ param index of the Point within the variable
 * @ return a new Point with all associated information */
public Point readPoint ( String name , int index ) { } }

implementation:
Variable pointvar = ds . findVariable ( name ) ; if ( pointvar == null ) return null ; Point pt = null ; // CFConvention
if ( ds . findGlobalAttribute ( CF . CONVENTIONS ) != null ) if ( ucar . nc2 . dataset . conv . CF1Convention . getVersion ( ds . findGlobalAttribute ( CF . CONVENTIONS ) . getStringValue ( ) ) >= 8 ) pt = new CFPoint ( ) ; if ( pt == null ) return pt ; else return pt . setupPoint ( ds , pointvar , index ) ;


signature:
public class SimpleGeometryReader { /** * Given a variable name , returns the geometry type which that variable is associated with .
 * If the variable has no simple geometry information , null will be returned .
 * @ param name variable name which will have geometry type be checked
 * @ return Geometry Type if holds geometry information , null if not */
public GeometryType getGeometryType ( String name ) { } }

implementation:
Variable geometryVar = ds . findVariable ( name ) ; if ( geometryVar == null ) return null ; // CFConvention
if ( ds . findGlobalAttribute ( CF . CONVENTIONS ) != null ) if ( ucar . nc2 . dataset . conv . CF1Convention . getVersion ( ds . findGlobalAttribute ( CF . CONVENTIONS ) . getStringValue ( ) ) >= 8 ) { Attribute geometryTypeAttr = null ; String geometry_type = null ; geometryTypeAttr = geometryVar . findAttribute ( CF . GEOMETRY_TYPE ) ; if ( geometryTypeAttr == null ) return null ; geometry_type = geometryTypeAttr . getStringValue ( ) ; switch ( geometry_type ) { case CF . POLYGON : return GeometryType . POLYGON ; case CF . LINE : return GeometryType . LINE ; case CF . POINT : return GeometryType . POINT ; default : return null ; } } return null ;


signature:
public class StandardStationCollectionImpl { /** * Make a Station from the station data structure .
 * @ param stationData station data structure
 * @ param recnum station data recnum within table
 * @ return Station or null , skip this Station */
public StationTimeSeriesFeature makeStation ( StructureData stationData , int recnum ) { } }

implementation: StationFeature s = ft . makeStation ( stationData ) ; if ( s == null ) return null ; return new StandardStationFeatureImpl ( s , timeUnit , stationData , recnum ) ;


signature:
public class CECompiler { /** * Recursive AST walker ; compilation of filters is done elsewhere . */
protected void compileAST ( CEAST ast ) throws DapException { } }

implementation:
switch ( ast . sort ) { case CONSTRAINT : for ( CEAST clause : ast . clauses ) { compileAST ( clause ) ; } // invoke semantic checks
this . ce . expand ( ) ; this . ce . finish ( ) ; break ; case PROJECTION : scopestack . clear ( ) ; compileAST ( ast . tree ) ; break ; case SEGMENT : compilesegment ( ast ) ; break ; case SELECTION : scopestack . clear ( ) ; compileselection ( ast ) ; break ; case DEFINE : dimredef ( ast ) ; break ; default : assert false : "uknown CEAST node type" ; }


signature:
public class CECompiler { /** * Convert field references in a filter */
public void compilefilter ( DapVariable var , DapSequence seq , CEAST expr ) throws DapException { } }

implementation:
if ( expr == null ) return ; if ( expr . sort == CEAST . Sort . SEGMENT ) { // This must be a simple segment and it must appear in seq
if ( expr . subnodes != null ) throw new DapException ( "compilefilter: Non-simple segment:" + expr . name ) ; // Look for the name in the top - level field of seq
DapVariable field = seq . findByName ( expr . name ) ; if ( field == null ) throw new DapException ( "compilefilter: Unknown filter variable:" + expr . name ) ; expr . field = field ; } else if ( expr . sort == CEAST . Sort . EXPR ) { if ( expr . lhs != null ) compilefilter ( var , seq , expr . lhs ) ; if ( expr . rhs != null ) compilefilter ( var , seq , expr . rhs ) ; // If both lhs and rhs are non - null ,
// canonicalize any comparison so that it is var op const
if ( expr . lhs != null && expr . rhs != null ) { boolean leftvar = ( expr . lhs . sort == CEAST . Sort . SEGMENT ) ; boolean rightvar = ( expr . rhs . sort == CEAST . Sort . SEGMENT ) ; if ( rightvar && ! leftvar ) { // swap operands
CEAST tmp = expr . lhs ; expr . lhs = expr . rhs ; expr . rhs = tmp ; // fix operator
switch ( expr . op ) { case LT : // x < y - > y > x
expr . op = CEAST . Operator . GT ; break ; case LE : // x < = y - > y > = x
expr . op = CEAST . Operator . GE ; break ; case GT : // x > y - > y < x
expr . op = CEAST . Operator . LT ; break ; case GE : // x > = y - > y < = x
expr . op = CEAST . Operator . LE ; break ; default : break ; // leave as is
} } } } else if ( expr . sort == CEAST . Sort . CONSTANT ) { return ; } else throw new DapException ( "compilefilter: Unexpected node type:" + expr . sort ) ;


signature:
public class CECompiler { /** * Process a dim redefinition */
protected void dimredef ( CEAST node ) throws DapException { } }

implementation: DapDimension dim = ( DapDimension ) dataset . findByFQN ( node . name , DapSort . DIMENSION ) ; if ( dim == null ) throw new DapException ( "Constraint dim redef: no dimension name: " + node . name ) ; Slice slice = node . slice ; slice . finish ( ) ; ce . addRedef ( dim , slice ) ;


signature:
public class ArrayObject { /** * package private . use Array . factory ( ) */
static ArrayObject factory ( DataType dtype , Class elemType , boolean isVlen , Index index ) { } }

implementation: return ArrayObject . factory ( dtype , elemType , isVlen , index , null ) ;


signature:
public class ArrayObject { /** * / * Create new ArrayObject with given indexImpl and backing store .
 * Should be private .
 * @ param index use this Index
 * @ param stor . use this storage . if null , allocate .
 * @ return . new ArrayObject . D < rank > or ArrayObject object . */
static ArrayObject factory ( DataType dtype , Class elemType , boolean isVlen , Index index , Object [ ] storage ) { } }

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


signature:
public class ArrayObject { /** * create new Array with given indexImpl and the same backing store */
protected Array createView ( Index index ) { } }

implementation: return ArrayObject . factory ( dataType , elementType , isVlen , index , storage ) ;


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

implementation: Object [ ] ja = ( Object [ ] ) javaArray ; for ( Object aJa : ja ) iter . setObjectNext ( aJa ) ;


signature:
public class LatLonRect { /** * Returns { @ code true } if this rectangle is nearly equal to { @ code other } . The " near equality " of corners is
 * determined using { @ link LatLonPoint # nearlyEquals ( LatLonPoint , double ) } , with the specified maxRelDiff .
 * @ param other the other rectangle to check .
 * @ param maxRelDiff the maximum { @ link Misc # relativeDifference relative difference } that two corners may have .
 * @ return { @ code true } if this rectangle is nearly equal to { @ code other } . */
public boolean nearlyEquals ( LatLonRect other , double maxRelDiff ) { } }

implementation: return this . getLowerLeftPoint ( ) . nearlyEquals ( other . getLowerLeftPoint ( ) , maxRelDiff ) && this . getUpperRightPoint ( ) . nearlyEquals ( other . getUpperRightPoint ( ) , maxRelDiff ) ;


signature:
public class LatLonRect { /** * Determine if the given lat / lon point is contined inside this rectangle .
 * @ param lat lat of point
 * @ param lon lon of point
 * @ return true if the given lat / lon point is contined inside this rectangle */
public boolean contains ( double lat , double lon ) { } }

implementation:
// check lat first
double eps = 1.0e-9 ; if ( ( lat + eps < lowerLeft . getLatitude ( ) ) || ( lat - eps > upperRight . getLatitude ( ) ) ) { return false ; } if ( allLongitude ) return true ; if ( crossDateline ) { // bounding box crosses the + / - 180 seam
return ( ( lon >= lowerLeft . getLongitude ( ) ) || ( lon <= upperRight . getLongitude ( ) ) ) ; } else { // check " normal " lon case
return ( ( lon >= lowerLeft . getLongitude ( ) ) && ( lon <= upperRight . getLongitude ( ) ) ) ; }


signature:
public class LatLonRect { /** * Determine if this bounding box is contained in another LatLonRect .
 * @ param b the other box to see if it contains this one
 * @ return true if b contained in this bounding box */
public boolean containedIn ( LatLonRect b ) { } }

implementation: return ( b . getWidth ( ) >= width ) && b . contains ( upperRight ) && b . contains ( lowerLeft ) ;


signature:
public class LatLonRect { /** * Extend the bounding box to contain this point
 * @ param p point to include */
public void extend ( LatLonPoint p ) { } }

implementation:
if ( contains ( p ) ) return ; double lat = p . getLatitude ( ) ; double lon = p . getLongitude ( ) ; // lat is easy to deal with
if ( lat > upperRight . getLatitude ( ) ) { upperRight . setLatitude ( lat ) ; } if ( lat < lowerLeft . getLatitude ( ) ) { lowerLeft . setLatitude ( lat ) ; } // lon is uglier
if ( allLongitude ) { // do nothing
} else if ( crossDateline ) { // bounding box crosses the + / - 180 seam
double d1 = lon - upperRight . getLongitude ( ) ; double d2 = lowerLeft . getLongitude ( ) - lon ; if ( ( d1 > 0.0 ) && ( d2 > 0.0 ) ) { // needed ?
if ( d1 > d2 ) { lowerLeft . setLongitude ( lon ) ; } else { upperRight . setLongitude ( lon ) ; } } } else { // normal case
if ( lon > upperRight . getLongitude ( ) ) { if ( lon - upperRight . getLongitude ( ) > lowerLeft . getLongitude ( ) - lon + 360 ) { crossDateline = true ; lowerLeft . setLongitude ( lon ) ; } else { upperRight . setLongitude ( lon ) ; } } else if ( lon < lowerLeft . getLongitude ( ) ) { if ( lowerLeft . getLongitude ( ) - lon > lon + 360.0 - upperRight . getLongitude ( ) ) { crossDateline = true ; upperRight . setLongitude ( lon ) ; } else { lowerLeft . setLongitude ( lon ) ; } } } // recalc delta , center
width = upperRight . getLongitude ( ) - lowerLeft . getLongitude ( ) ; lon0 = ( upperRight . getLongitude ( ) + lowerLeft . getLongitude ( ) ) / 2 ; if ( crossDateline ) { width += 360 ; lon0 -= 180 ; } this . allLongitude = this . allLongitude || ( this . width >= 360.0 ) ;


signature:
public class LatLonRect { /** * Extend the bounding box to contain the given rectangle
 * @ param r rectangle to include */
public void extend ( LatLonRect r ) { } }

implementation:
Preconditions . checkNotNull ( r ) ; // lat is easy
double latMin = r . getLatMin ( ) ; double latMax = r . getLatMax ( ) ; if ( latMax > upperRight . getLatitude ( ) ) { upperRight . setLatitude ( latMax ) ; } if ( latMin < lowerLeft . getLatitude ( ) ) { lowerLeft . setLatitude ( latMin ) ; } // lon is uglier
if ( allLongitude ) return ; // everything is reletive to current LonMin
double lonMin = getLonMin ( ) ; double lonMax = getLonMax ( ) ; double nlonMin = LatLonPointImpl . lonNormal ( r . getLonMin ( ) , lonMin ) ; double nlonMax = nlonMin + r . getWidth ( ) ; lonMin = Math . min ( lonMin , nlonMin ) ; lonMax = Math . max ( lonMax , nlonMax ) ; width = lonMax - lonMin ; allLongitude = width >= 360.0 ; if ( allLongitude ) { width = 360.0 ; lonMin = - 180.0 ; } else { lonMin = LatLonPointImpl . lonNormal ( lonMin ) ; } lowerLeft . setLongitude ( lonMin ) ; upperRight . setLongitude ( lonMin + width ) ; lon0 = lonMin + width / 2 ; crossDateline = lowerLeft . getLongitude ( ) > upperRight . getLongitude ( ) ;


signature:
public class LatLonRect { /** * Create the instersection of this LatLon with the given one
 * @ param clip intersect with this
 * @ return intersection , or null if there is no intersection */
public LatLonRect intersect ( LatLonRect clip ) { } }

implementation:
double latMin = Math . max ( getLatMin ( ) , clip . getLatMin ( ) ) ; double latMax = Math . min ( getLatMax ( ) , clip . getLatMax ( ) ) ; double deltaLat = latMax - latMin ; if ( deltaLat < 0 ) return null ; // lon as always is a pain : if not intersection , try + / - 360
double lon1min = getLonMin ( ) ; double lon1max = getLonMax ( ) ; double lon2min = clip . getLonMin ( ) ; double lon2max = clip . getLonMax ( ) ; if ( ! intersect ( lon1min , lon1max , lon2min , lon2max ) ) { lon2min = clip . getLonMin ( ) + 360 ; lon2max = clip . getLonMax ( ) + 360 ; if ( ! intersect ( lon1min , lon1max , lon2min , lon2max ) ) { lon2min = clip . getLonMin ( ) - 360 ; lon2max = clip . getLonMax ( ) - 360 ; } } // we did our best to find an intersection
double lonMin = Math . max ( lon1min , lon2min ) ; double lonMax = Math . min ( lon1max , lon2max ) ; double deltaLon = lonMax - lonMin ; if ( deltaLon < 0 ) return null ; return new LatLonRect ( new LatLonPointImpl ( latMin , lonMin ) , deltaLat , deltaLon ) ;


signature:
public class LatLonRect { /** * Return a String representation of this object .
 * < pre > lat = [ - 90.00,90.00 ] lon = [ 0.00,360.00 < / pre >
 * @ return a String representation of this object . */
public String toString2 ( ) { } }

implementation: return " lat= [" + Format . dfrac ( getLatMin ( ) , 2 ) + "," + Format . dfrac ( getLatMax ( ) , 2 ) + "] lon= [" + Format . dfrac ( getLonMin ( ) , 2 ) + "," + Format . dfrac ( getLonMax ( ) , 2 ) + "]" ;